
CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) SPRITE#0 ← ((byte*)) (number) $c00
  kickasm(location (byte*) SPRITE#0) {{ .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
    .for (var y=0; y<21; y++)
        .for (var x=0;x<3; x++)
            .byte pic.getSinglecolorByte(x,y)
 }}
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  (byte*) SPRITES_ENABLE#0 ← ((byte*)) (number) $d015
  (byte*) SPRITES_XPOS#0 ← ((byte*)) (number) $d000
  (byte*) SPRITES_YPOS#0 ← ((byte*)) (number) $d001
  to:@1
main: scope:[main]  from @1
  (byte*~) main::$0 ← (byte*) SCREEN#0 + (number) $3f8
  (word~) main::$1 ← ((word)) (byte*) SPRITE#0
  (number~) main::$2 ← (word~) main::$1 / (number) $40
  (byte~) main::$3 ← ((byte)) (number~) main::$2
  *((byte*~) main::$0) ← (byte~) main::$3
  *((byte*) SPRITES_ENABLE#0) ← (number) 1
  *((byte*) SPRITES_XPOS#0) ← (number) $64
  *((byte*) SPRITES_YPOS#0) ← (number) $64
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte*) SPRITE
(byte*) SPRITE#0
(byte*) SPRITES_ENABLE
(byte*) SPRITES_ENABLE#0
(byte*) SPRITES_XPOS
(byte*) SPRITES_XPOS#0
(byte*) SPRITES_YPOS
(byte*) SPRITES_YPOS#0
(void()) main()
(byte*~) main::$0
(word~) main::$1
(number~) main::$2
(byte~) main::$3
(label) main::@return

Adding number conversion cast (unumber) $3f8 in (byte*~) main::$0 ← (byte*) SCREEN#0 + (number) $3f8
Adding number conversion cast (unumber) $40 in (number~) main::$2 ← (word~) main::$1 / (number) $40
Adding number conversion cast (unumber) main::$2 in (number~) main::$2 ← (word~) main::$1 / (unumber)(number) $40
Adding number conversion cast (unumber) 1 in *((byte*) SPRITES_ENABLE#0) ← (number) 1
Adding number conversion cast (unumber) $64 in *((byte*) SPRITES_XPOS#0) ← (number) $64
Adding number conversion cast (unumber) $64 in *((byte*) SPRITES_YPOS#0) ← (number) $64
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SPRITE#0 ← (byte*)(number) $c00
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte*) SPRITES_ENABLE#0 ← (byte*)(number) $d015
Inlining cast (byte*) SPRITES_XPOS#0 ← (byte*)(number) $d000
Inlining cast (byte*) SPRITES_YPOS#0 ← (byte*)(number) $d001
Inlining cast (word~) main::$1 ← (word)(byte*) SPRITE#0
Inlining cast (byte~) main::$3 ← (byte)(unumber~) main::$2
Inlining cast *((byte*) SPRITES_ENABLE#0) ← (unumber)(number) 1
Inlining cast *((byte*) SPRITES_XPOS#0) ← (unumber)(number) $64
Inlining cast *((byte*) SPRITES_YPOS#0) ← (unumber)(number) $64
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 3072
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (byte*) 53269
Simplifying constant pointer cast (byte*) 53248
Simplifying constant pointer cast (byte*) 53249
Simplifying constant integer cast $3f8
Simplifying constant integer cast $40
Simplifying constant integer cast 1
Simplifying constant integer cast $64
Simplifying constant integer cast $64
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (word) $3f8
Finalized unsigned number type (byte) $40
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $64
Finalized unsigned number type (byte) $64
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to word in (unumber~) main::$2 ← (word~) main::$1 / (byte) $40
Constant (const byte*) SPRITE#0 = (byte*) 3072
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte*) SPRITES_ENABLE#0 = (byte*) 53269
Constant (const byte*) SPRITES_XPOS#0 = (byte*) 53248
Constant (const byte*) SPRITES_YPOS#0 = (byte*) 53249
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (word)SPRITE#0 in [7] (word~) main::$1 ← (word)(const byte*) SPRITE#0
Successful SSA optimization Pass2ConstantValues
Constant right-side identified [1] (byte*~) main::$0 ← (const byte*) SCREEN#0 + (word) $3f8
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::$0 = SCREEN#0+$3f8
Constant (const word) main::$1 = (word)SPRITE#0
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [1] (word~) main::$2 ← (const word) main::$1 / (byte) $40
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const word) main::$2 = main::$1/$40
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (byte)main::$2 in [2] (byte~) main::$3 ← (byte)(const word) main::$2
Successful SSA optimization Pass2ConstantValues
Constant (const byte) main::$3 = (byte)main::$2
Successful SSA optimization Pass2ConstantIdentification
Constant inlined main::$3 = (byte)(word)(const byte*) SPRITE#0/(byte) $40
Constant inlined main::$1 = (word)(const byte*) SPRITE#0
Constant inlined main::$2 = (word)(const byte*) SPRITE#0/(byte) $40
Constant inlined main::$0 = (const byte*) SCREEN#0+(word) $3f8
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  kickasm(location (const byte*) SPRITE#0) {{ .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
    .for (var y=0; y<21; y++)
        .for (var x=0;x<3; x++)
            .byte pic.getSinglecolorByte(x,y)
 }}
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()
main: scope:[main]  from @1
  [4] *((const byte*) SCREEN#0+(word) $3f8) ← (byte)(word)(const byte*) SPRITE#0/(byte) $40
  [5] *((const byte*) SPRITES_ENABLE#0) ← (byte) 1
  [6] *((const byte*) SPRITES_XPOS#0) ← (byte) $64
  [7] *((const byte*) SPRITES_YPOS#0) ← (byte) $64
  to:main::@return
main::@return: scope:[main]  from main
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte*) SPRITE
(byte*) SPRITES_ENABLE
(byte*) SPRITES_XPOS
(byte*) SPRITES_YPOS
(void()) main()

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
  // File Comments
// Example of inline kickasm resource data
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SPRITE = $c00
  .label SCREEN = $400
  .label SPRITES_ENABLE = $d015
  .label SPRITES_XPOS = $d000
  .label SPRITES_YPOS = $d001
  // @begin
bbegin:
  // kickasm(location (const byte*) SPRITE#0) {{ .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))     .for (var y=0; y<21; y++)         .for (var x=0;x<3; x++)             .byte pic.getSinglecolorByte(x,y)  }}
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    // [4] *((const byte*) SCREEN#0+(word) $3f8) ← (byte)(word)(const byte*) SPRITE#0/(byte) $40 -- _deref_pbuc1=vbuc2 
    lda #SPRITE/$40
    sta SCREEN+$3f8
    // [5] *((const byte*) SPRITES_ENABLE#0) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta SPRITES_ENABLE
    // [6] *((const byte*) SPRITES_XPOS#0) ← (byte) $64 -- _deref_pbuc1=vbuc2 
    lda #$64
    sta SPRITES_XPOS
    // [7] *((const byte*) SPRITES_YPOS#0) ← (byte) $64 -- _deref_pbuc1=vbuc2 
    lda #$64
    sta SPRITES_YPOS
    jmp breturn
    // main::@return
  breturn:
    // [8] return 
    rts
}
  // File Data
.pc = SPRITE "SPRITE"
  .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
    .for (var y=0; y<21; y++)
        .for (var x=0;x<3; x++)
            .byte pic.getSinglecolorByte(x,y)


REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) SCREEN#0+(word) $3f8) ← (byte)(word)(const byte*) SPRITE#0/(byte) $40 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] *((const byte*) SPRITES_ENABLE#0) ← (byte) 1 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) SPRITES_XPOS#0) ← (byte) $64 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] *((const byte*) SPRITES_YPOS#0) ← (byte) $64 [ ] ( main:2 [ ] ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [main] best 2605 combination 
Uplifting [] best 2605 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Example of inline kickasm resource data
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SPRITE = $c00
  .label SCREEN = $400
  .label SPRITES_ENABLE = $d015
  .label SPRITES_XPOS = $d000
  .label SPRITES_YPOS = $d001
  // @begin
bbegin:
  // kickasm(location (const byte*) SPRITE#0) {{ .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))     .for (var y=0; y<21; y++)         .for (var x=0;x<3; x++)             .byte pic.getSinglecolorByte(x,y)  }}
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    // [4] *((const byte*) SCREEN#0+(word) $3f8) ← (byte)(word)(const byte*) SPRITE#0/(byte) $40 -- _deref_pbuc1=vbuc2 
    lda #SPRITE/$40
    sta SCREEN+$3f8
    // [5] *((const byte*) SPRITES_ENABLE#0) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta SPRITES_ENABLE
    // [6] *((const byte*) SPRITES_XPOS#0) ← (byte) $64 -- _deref_pbuc1=vbuc2 
    lda #$64
    sta SPRITES_XPOS
    // [7] *((const byte*) SPRITES_YPOS#0) ← (byte) $64 -- _deref_pbuc1=vbuc2 
    lda #$64
    sta SPRITES_YPOS
    jmp breturn
    // main::@return
  breturn:
    // [8] return 
    rts
}
  // File Data
.pc = SPRITE "SPRITE"
  .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
    .for (var y=0; y<21; y++)
        .for (var x=0;x<3; x++)
            .byte pic.getSinglecolorByte(x,y)


ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #$64
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte*) SPRITE
(const byte*) SPRITE#0 SPRITE = (byte*) 3072
(byte*) SPRITES_ENABLE
(const byte*) SPRITES_ENABLE#0 SPRITES_ENABLE = (byte*) 53269
(byte*) SPRITES_XPOS
(const byte*) SPRITES_XPOS#0 SPRITES_XPOS = (byte*) 53248
(byte*) SPRITES_YPOS
(const byte*) SPRITES_YPOS#0 SPRITES_YPOS = (byte*) 53249
(void()) main()
(label) main::@return



FINAL ASSEMBLER
Score: 2588

  // File Comments
// Example of inline kickasm resource data
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label SPRITE = $c00
  .label SCREEN = $400
  .label SPRITES_ENABLE = $d015
  .label SPRITES_XPOS = $d000
  .label SPRITES_YPOS = $d001
  // @begin
  // kickasm
  // kickasm(location (const byte*) SPRITE#0) {{ .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))     .for (var y=0; y<21; y++)         .for (var x=0;x<3; x++)             .byte pic.getSinglecolorByte(x,y)  }}
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    // *(SCREEN+$3f8) = (byte)((word)SPRITE/$40)
    // [4] *((const byte*) SCREEN#0+(word) $3f8) ← (byte)(word)(const byte*) SPRITE#0/(byte) $40 -- _deref_pbuc1=vbuc2 
    lda #SPRITE/$40
    sta SCREEN+$3f8
    // *SPRITES_ENABLE = 1
    // [5] *((const byte*) SPRITES_ENABLE#0) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta SPRITES_ENABLE
    // *SPRITES_XPOS = 100
    // [6] *((const byte*) SPRITES_XPOS#0) ← (byte) $64 -- _deref_pbuc1=vbuc2 
    lda #$64
    sta SPRITES_XPOS
    // *SPRITES_YPOS = 100
    // [7] *((const byte*) SPRITES_YPOS#0) ← (byte) $64 -- _deref_pbuc1=vbuc2 
    sta SPRITES_YPOS
    // main::@return
    // }
    // [8] return 
    rts
}
  // File Data
.pc = SPRITE "SPRITE"
  .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
    .for (var y=0; y<21; y++)
        .for (var x=0;x<3; x++)
            .byte pic.getSinglecolorByte(x,y)


