
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::wp#0 = (unsigned int *)$400
  main::wp#1 = main::wp#0 + SIZEOF_UNSIGNED_INT
  main::$0 = byte0  *main::wp#1
  main::SCREEN[0] = main::$0
  main::$1 = byte1  *main::wp#1
  main::SCREEN[1] = main::$1
  main::wp#2 = main::wp#1 + SIZEOF_UNSIGNED_INT
  main::$2 = byte0  *main::wp#2
  main::SCREEN[2] = main::$2
  main::$3 = byte1  *main::wp#2
  main::SCREEN[3] = main::$3
  main::wp#3 = main::wp#2 - SIZEOF_UNSIGNED_INT
  main::$4 = byte0  *main::wp#3
  main::SCREEN[4] = main::$4
  main::$5 = byte1  *main::wp#3
  main::SCREEN[5] = main::$5
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  call main
  to:__start::@1
__start::@1: scope:[__start]  from __start
  to:__start::@return
__start::@return: scope:[__start]  from __start::@1
  return 
  to:@return

SYMBOL TABLE SSA
__constant char SIZEOF_UNSIGNED_INT = 2
void __start()
void main()
char main::$0
char main::$1
char main::$2
char main::$3
char main::$4
char main::$5
__constant char * const main::SCREEN = (char *)$400+$28*6
unsigned int *main::wp
unsigned int *main::wp#0
unsigned int *main::wp#1
unsigned int *main::wp#2
unsigned int *main::wp#3

Adding number conversion cast (unumber) $28*6 in 
Adding number conversion cast (unumber) 0 in main::SCREEN[0] = main::$0
Adding number conversion cast (unumber) 1 in main::SCREEN[1] = main::$1
Adding number conversion cast (unumber) 2 in main::SCREEN[2] = main::$2
Adding number conversion cast (unumber) 3 in main::SCREEN[3] = main::$3
Adding number conversion cast (unumber) 4 in main::SCREEN[4] = main::$4
Adding number conversion cast (unumber) 5 in main::SCREEN[5] = main::$5
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant pointer cast (unsigned int *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Simplifying constant integer cast 4
Simplifying constant integer cast 5
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) 5
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant main::wp#0 = (unsigned int *) 1024
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero main::SCREEN in [3] main::SCREEN[0] = main::$0
Successful SSA optimization PassNSimplifyExpressionWithZero
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Constant right-side identified [0] main::wp#1 = main::wp#0 + SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::wp#1 = main::wp#0+SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [4] main::wp#2 = main::wp#1 + SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::wp#2 = main::wp#1+SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [8] main::wp#3 = main::wp#2 - SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::wp#3 = main::wp#2-SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings main::wp#0
Inlining constant with different constant siblings main::wp#1
Inlining constant with different constant siblings main::wp#2
Inlining constant with different constant siblings main::wp#3
Constant inlined main::wp#0 = (unsigned int *) 1024
Constant inlined main::wp#3 = (unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT-SIZEOF_UNSIGNED_INT
Constant inlined main::wp#1 = (unsigned int *) 1024+SIZEOF_UNSIGNED_INT
Constant inlined main::wp#2 = (unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(main::SCREEN+1)
Consolidated array index constant in *(main::SCREEN+2)
Consolidated array index constant in *(main::SCREEN+3)
Consolidated array index constant in *(main::SCREEN+4)
Consolidated array index constant in *(main::SCREEN+5)
Successful SSA optimization Pass2ConstantAdditionElimination
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) 6
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying constant integer cast $28*6
Successful SSA optimization PassNCastSimplification
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] main::$0 = byte0  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT)
  [1] *main::SCREEN = main::$0
  [2] main::$1 = byte1  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT)
  [3] *(main::SCREEN+1) = main::$1
  [4] main::$2 = byte0  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT)
  [5] *(main::SCREEN+2) = main::$2
  [6] main::$3 = byte1  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT)
  [7] *(main::SCREEN+3) = main::$3
  [8] main::$4 = byte0  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT-SIZEOF_UNSIGNED_INT)
  [9] *(main::SCREEN+4) = main::$4
  [10] main::$5 = byte1  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT-SIZEOF_UNSIGNED_INT)
  [11] *(main::SCREEN+5) = main::$5
  to:main::@return
main::@return: scope:[main]  from main
  [12] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char main::$0 // 4.0
char main::$1 // 4.0
char main::$2 // 4.0
char main::$3 // 4.0
char main::$4 // 4.0
char main::$5 // 4.0
unsigned int *main::wp

Initial phi equivalence classes
Added variable main::$0 to live range equivalence class [ main::$0 ]
Added variable main::$1 to live range equivalence class [ main::$1 ]
Added variable main::$2 to live range equivalence class [ main::$2 ]
Added variable main::$3 to live range equivalence class [ main::$3 ]
Added variable main::$4 to live range equivalence class [ main::$4 ]
Added variable main::$5 to live range equivalence class [ main::$5 ]
Complete equivalence classes
[ main::$0 ]
[ main::$1 ]
[ main::$2 ]
[ main::$3 ]
[ main::$4 ]
[ main::$5 ]
Allocated zp[1]:2 [ main::$0 ]
Allocated zp[1]:3 [ main::$1 ]
Allocated zp[1]:4 [ main::$2 ]
Allocated zp[1]:5 [ main::$3 ]
Allocated zp[1]:6 [ main::$4 ]
Allocated zp[1]:7 [ main::$5 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp[1]:2 [ main::$0 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ main::$1 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ main::$2 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:5 [ main::$3 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:6 [ main::$4 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:7 [ main::$5 ] : zp[1]:7 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 4: zp[1]:2 [ main::$0 ] 4: zp[1]:3 [ main::$1 ] 4: zp[1]:4 [ main::$2 ] 4: zp[1]:5 [ main::$3 ] 4: zp[1]:6 [ main::$4 ] 4: zp[1]:7 [ main::$5 ] 
Uplift Scope [] 

Uplifting [main] best 69 combination reg byte a [ main::$0 ] reg byte a [ main::$1 ] reg byte a [ main::$2 ] reg byte a [ main::$3 ] zp[1]:6 [ main::$4 ] zp[1]:7 [ main::$5 ] 
Limited combination testing to 100 combinations of 4096 possible.
Uplifting [] best 69 combination 
Attempting to uplift remaining variables inzp[1]:6 [ main::$4 ]
Uplifting [main] best 63 combination reg byte a [ main::$4 ] 
Attempting to uplift remaining variables inzp[1]:7 [ main::$5 ]
Uplifting [main] best 57 combination reg byte a [ main::$5 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests simple word pointer iteration
  // Upstart
  // Commodore 64 PRG executable file
.file [name="word-pointer-iteration-0.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .const SIZEOF_UNSIGNED_INT = 2
.segment Code
  // main
main: {
    .label SCREEN = $400+$28*6
    // [0] main::$0 = byte0  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT) -- vbuaa=_byte0__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT
    // [1] *main::SCREEN = main::$0 -- _deref_pbuc1=vbuaa 
    sta SCREEN
    // [2] main::$1 = byte1  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT) -- vbuaa=_byte1__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT+1
    // [3] *(main::SCREEN+1) = main::$1 -- _deref_pbuc1=vbuaa 
    sta SCREEN+1
    // [4] main::$2 = byte0  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT) -- vbuaa=_byte0__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT
    // [5] *(main::SCREEN+2) = main::$2 -- _deref_pbuc1=vbuaa 
    sta SCREEN+2
    // [6] main::$3 = byte1  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT) -- vbuaa=_byte1__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT+1
    // [7] *(main::SCREEN+3) = main::$3 -- _deref_pbuc1=vbuaa 
    sta SCREEN+3
    // [8] main::$4 = byte0  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT-SIZEOF_UNSIGNED_INT) -- vbuaa=_byte0__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT-SIZEOF_UNSIGNED_INT
    // [9] *(main::SCREEN+4) = main::$4 -- _deref_pbuc1=vbuaa 
    sta SCREEN+4
    // [10] main::$5 = byte1  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT-SIZEOF_UNSIGNED_INT) -- vbuaa=_byte1__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT-SIZEOF_UNSIGNED_INT+1
    // [11] *(main::SCREEN+5) = main::$5 -- _deref_pbuc1=vbuaa 
    sta SCREEN+5
    jmp __breturn
    // main::@return
  __breturn:
    // [12] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char SIZEOF_UNSIGNED_INT = 2
void main()
char main::$0 // reg byte a 4.0
char main::$1 // reg byte a 4.0
char main::$2 // reg byte a 4.0
char main::$3 // reg byte a 4.0
char main::$4 // reg byte a 4.0
char main::$5 // reg byte a 4.0
__constant char * const main::SCREEN = (char *) 1024+$28*6
unsigned int *main::wp

reg byte a [ main::$0 ]
reg byte a [ main::$1 ]
reg byte a [ main::$2 ]
reg byte a [ main::$3 ]
reg byte a [ main::$4 ]
reg byte a [ main::$5 ]


FINAL ASSEMBLER
Score: 54

  // File Comments
// Tests simple word pointer iteration
  // Upstart
  // Commodore 64 PRG executable file
.file [name="word-pointer-iteration-0.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .const SIZEOF_UNSIGNED_INT = 2
.segment Code
  // main
main: {
    .label SCREEN = $400+$28*6
    // BYTE0(*wp)
    // [0] main::$0 = byte0  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT) -- vbuaa=_byte0__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT
    // SCREEN[0] = BYTE0(*wp)
    // [1] *main::SCREEN = main::$0 -- _deref_pbuc1=vbuaa 
    sta SCREEN
    // BYTE1(*wp)
    // [2] main::$1 = byte1  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT) -- vbuaa=_byte1__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT+1
    // SCREEN[1] = BYTE1(*wp)
    // [3] *(main::SCREEN+1) = main::$1 -- _deref_pbuc1=vbuaa 
    sta SCREEN+1
    // BYTE0(*wp)
    // [4] main::$2 = byte0  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT) -- vbuaa=_byte0__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT
    // SCREEN[2] = BYTE0(*wp)
    // [5] *(main::SCREEN+2) = main::$2 -- _deref_pbuc1=vbuaa 
    sta SCREEN+2
    // BYTE1(*wp)
    // [6] main::$3 = byte1  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT) -- vbuaa=_byte1__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT+1
    // SCREEN[3] = BYTE1(*wp)
    // [7] *(main::SCREEN+3) = main::$3 -- _deref_pbuc1=vbuaa 
    sta SCREEN+3
    // BYTE0(*wp)
    // [8] main::$4 = byte0  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT-SIZEOF_UNSIGNED_INT) -- vbuaa=_byte0__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT-SIZEOF_UNSIGNED_INT
    // SCREEN[4] = BYTE0(*wp)
    // [9] *(main::SCREEN+4) = main::$4 -- _deref_pbuc1=vbuaa 
    sta SCREEN+4
    // BYTE1(*wp)
    // [10] main::$5 = byte1  *((unsigned int *) 1024+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT-SIZEOF_UNSIGNED_INT) -- vbuaa=_byte1__deref_pwuc1 
    lda $400+SIZEOF_UNSIGNED_INT+SIZEOF_UNSIGNED_INT-SIZEOF_UNSIGNED_INT+1
    // SCREEN[5] = BYTE1(*wp)
    // [11] *(main::SCREEN+5) = main::$5 -- _deref_pbuc1=vbuaa 
    sta SCREEN+5
    // main::@return
    // }
    // [12] return 
    rts
}
  // File Data

