
CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  kickasm(location (const byte*) 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)
 }}
  to:@1

(void()) main()
main: scope:[main]  from @1
  *((const byte*) SCREEN+(number) $3f8) ← (byte)(word)(const byte*) SPRITE/(number) $40
  *((const byte*) SPRITES_ENABLE) ← (number) 1
  *((const byte*) SPRITES_XPOS) ← (number) $64
  *((const byte*) SPRITES_YPOS) ← (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
(const byte*) SCREEN = (byte*)(number) $400
(const byte*) SPRITE = (byte*)(number) $c00
(const byte*) SPRITES_ENABLE = (byte*)(number) $d015
(const byte*) SPRITES_XPOS = (byte*)(number) $d000
(const byte*) SPRITES_YPOS = (byte*)(number) $d001
(void()) main()
(label) main::@return

Adding number conversion cast (unumber) $40 in *((const byte*) SCREEN+(number) $3f8) ← (byte)(word)(const byte*) SPRITE/(number) $40
Adding number conversion cast (unumber) $3f8 in *((const byte*) SCREEN+(number) $3f8) ← (byte)(word)(const byte*) SPRITE/(unumber)(number) $40
Adding number conversion cast (unumber) 1 in *((const byte*) SPRITES_ENABLE) ← (number) 1
Adding number conversion cast (unumber) $64 in *((const byte*) SPRITES_XPOS) ← (number) $64
Adding number conversion cast (unumber) $64 in *((const byte*) SPRITES_YPOS) ← (number) $64
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((const byte*) SPRITES_ENABLE) ← (unumber)(number) 1
Inlining cast *((const byte*) SPRITES_XPOS) ← (unumber)(number) $64
Inlining cast *((const byte*) SPRITES_YPOS) ← (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 $40
Simplifying constant integer cast $3f8
Simplifying constant integer cast 1
Simplifying constant integer cast $64
Simplifying constant integer cast $64
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $40
Finalized unsigned number type (word) $3f8
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $64
Finalized unsigned number type (byte) $64
Successful SSA optimization PassNFinalizeNumberTypeConversions
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) {{ .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()

(void()) main()
main: scope:[main]  from @1
  [4] *((const byte*) SCREEN+(word) $3f8) ← (byte)(word)(const byte*) SPRITE/(byte) $40
  [5] *((const byte*) SPRITES_ENABLE) ← (byte) 1
  [6] *((const byte*) SPRITES_XPOS) ← (byte) $64
  [7] *((const byte*) SPRITES_YPOS) ← (byte) $64
  to:main::@return
main::@return: scope:[main]  from main
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Example of inline kickasm resource data
  // 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) {{ .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+(word) $3f8) ← (byte)(word)(const byte*) SPRITE/(byte) $40 -- _deref_pbuc1=vbuc2 
    lda #SPRITE/$40
    sta SCREEN+$3f8
    // [5] *((const byte*) SPRITES_ENABLE) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta SPRITES_ENABLE
    // [6] *((const byte*) SPRITES_XPOS) ← (byte) $64 -- _deref_pbuc1=vbuc2 
    lda #$64
    sta SPRITES_XPOS
    // [7] *((const byte*) SPRITES_YPOS) ← (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+(word) $3f8) ← (byte)(word)(const byte*) SPRITE/(byte) $40 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] *((const byte*) SPRITES_ENABLE) ← (byte) 1 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) SPRITES_XPOS) ← (byte) $64 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] *((const byte*) SPRITES_YPOS) ← (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
  // 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) {{ .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+(word) $3f8) ← (byte)(word)(const byte*) SPRITE/(byte) $40 -- _deref_pbuc1=vbuc2 
    lda #SPRITE/$40
    sta SCREEN+$3f8
    // [5] *((const byte*) SPRITES_ENABLE) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta SPRITES_ENABLE
    // [6] *((const byte*) SPRITES_XPOS) ← (byte) $64 -- _deref_pbuc1=vbuc2 
    lda #$64
    sta SPRITES_XPOS
    // [7] *((const byte*) SPRITES_YPOS) ← (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
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
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 __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

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



FINAL ASSEMBLER
Score: 2588

  // File Comments
// Example of inline kickasm resource data
  // 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) {{ .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+(word) $3f8) ← (byte)(word)(const byte*) SPRITE/(byte) $40 -- _deref_pbuc1=vbuc2 
    lda #SPRITE/$40
    sta SCREEN+$3f8
    // *SPRITES_ENABLE = 1
    // [5] *((const byte*) SPRITES_ENABLE) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta SPRITES_ENABLE
    // *SPRITES_XPOS = 100
    // [6] *((const byte*) SPRITES_XPOS) ← (byte) $64 -- _deref_pbuc1=vbuc2 
    lda #$64
    sta SPRITES_XPOS
    // *SPRITES_YPOS = 100
    // [7] *((const byte*) SPRITES_YPOS) ← (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)


