
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::idx#0 = 0
  main::$0 = sizeof  main::ba
  main::$1 = main::$0 / SIZEOF_CHAR
  main::$18 = (char)main::$1
  main::$2 = '0' + main::$18
  SCREEN[main::idx#0] = main::$2
  main::idx#1 = ++ main::idx#0
  main::$3 = sizeof  main::wa
  main::$4 = main::$3 / SIZEOF_UNSIGNED_INT
  main::$19 = (char)main::$4
  main::$5 = '0' + main::$19
  SCREEN[main::idx#1] = main::$5
  main::idx#2 = ++ main::idx#1
  main::$6 = sizeof  main::bb
  main::$7 = main::$6 / SIZEOF_CHAR
  main::$20 = (char)main::$7
  main::$8 = '0' + main::$20
  SCREEN[main::idx#2] = main::$8
  main::idx#3 = ++ main::idx#2
  main::$9 = sizeof  main::wb
  main::$10 = main::$9 / SIZEOF_UNSIGNED_INT
  main::$21 = (char)main::$10
  main::$11 = '0' + main::$21
  SCREEN[main::idx#3] = main::$11
  main::idx#4 = ++ main::idx#3
  main::$12 = sizeof  main::sa
  main::$13 = main::$12 / SIZEOF_CHAR
  main::$22 = (char)main::$13
  main::$14 = '0' + main::$22
  SCREEN[main::idx#4] = main::$14
  main::idx#5 = ++ main::idx#4
  main::$15 = sizeof  main::sb
  main::$16 = main::$15 / SIZEOF_CHAR
  main::$23 = (char)main::$16
  main::$17 = '0' + main::$23
  SCREEN[main::idx#5] = main::$17
  main::idx#6 = ++ main::idx#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 * const SCREEN = (char *)$400
__constant char SIZEOF_CHAR = 1
__constant char SIZEOF_UNSIGNED_INT = 2
void __start()
void main()
unsigned int main::$0
unsigned int main::$1
unsigned int main::$10
char main::$11
unsigned int main::$12
unsigned int main::$13
char main::$14
unsigned int main::$15
unsigned int main::$16
char main::$17
char main::$18
char main::$19
char main::$2
char main::$20
char main::$21
char main::$22
char main::$23
unsigned int main::$3
unsigned int main::$4
char main::$5
unsigned int main::$6
unsigned int main::$7
char main::$8
unsigned int main::$9
__constant char main::ba[3] = { fill( 3, 0) }
__constant char main::bb[main::sz+2] = { fill( main::sz+2, 0) }
char main::idx
char main::idx#0
char main::idx#1
char main::idx#2
char main::idx#3
char main::idx#4
char main::idx#5
char main::idx#6
__constant char main::sa[] = "camelot"
__constant char main::sb[] = { 'a', 'b', 'c', 0 }
__constant const char main::sz = 7
__constant unsigned int main::wa[3] = { fill( 3, 0) }
__constant unsigned int main::wb[] = { 1, 2, 3, 4 }

Adding number conversion cast (unumber) 2 in 
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [1] main::$0 = sizeof  main::ba
Constant right-side identified [7] main::$3 = sizeof  main::wa
Constant right-side identified [13] main::$6 = sizeof  main::bb
Constant right-side identified [19] main::$9 = sizeof  main::wb
Constant right-side identified [25] main::$12 = sizeof  main::sa
Constant right-side identified [31] main::$15 = sizeof  main::sb
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::idx#0 = 0
Constant main::$0 = sizeof main::ba
Constant main::$3 = sizeof main::wa
Constant main::$6 = sizeof main::bb
Constant main::$9 = sizeof main::wb
Constant main::$12 = sizeof main::sa
Constant main::$15 = sizeof main::sb
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero SCREEN in [5] SCREEN[main::idx#0] = main::$2
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable main::idx#6 and assignment [29] main::idx#6 = ++ main::idx#5
Successful SSA optimization PassNEliminateUnusedVars
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
Resolving array sizeof() sizeof main::ba
Resolving array sizeof() sizeof main::wa
Resolving array sizeof() sizeof main::bb
Resolving array sizeof() sizeof main::wb
Resolving string sizeof() sizeof main::sa
Resolving array sizeof() sizeof main::sb
Successful SSA optimization PassNSizeOfSimplification
Constant right-side identified [0] main::$1 = main::$0 / SIZEOF_CHAR
Constant right-side identified [4] main::idx#1 = ++ main::idx#0
Constant right-side identified [5] main::$4 = main::$3 / SIZEOF_UNSIGNED_INT
Constant right-side identified [10] main::$7 = main::$6 / SIZEOF_CHAR
Constant right-side identified [15] main::$10 = main::$9 / SIZEOF_UNSIGNED_INT
Constant right-side identified [20] main::$13 = main::$12 / SIZEOF_CHAR
Constant right-side identified [25] main::$16 = main::$15 / SIZEOF_CHAR
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$1 = main::$0/SIZEOF_CHAR
Constant main::idx#1 = ++main::idx#0
Constant main::$4 = main::$3/SIZEOF_UNSIGNED_INT
Constant main::$7 = main::$6/SIZEOF_CHAR
Constant main::$10 = main::$9/SIZEOF_UNSIGNED_INT
Constant main::$13 = main::$12/SIZEOF_CHAR
Constant main::$16 = main::$15/SIZEOF_CHAR
Successful SSA optimization Pass2ConstantIdentification
Constant main::$18 = (char)main::$1
Constant main::$19 = (char)main::$4
Constant main::$20 = (char)main::$7
Constant main::$21 = (char)main::$10
Constant main::$22 = (char)main::$13
Constant main::$23 = (char)main::$16
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant main::ba
Eliminating unused constant main::wa
Eliminating unused constant main::bb
Eliminating unused constant main::wb
Eliminating unused constant main::sa
Eliminating unused constant main::sb
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) 3 in 
Adding number conversion cast (unumber) 3 in 
Adding number conversion cast (unumber) 4 in 
Adding number conversion cast (unumber) 8 in 
Adding number conversion cast (unumber) 4 in 
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 3
Simplifying constant integer cast 3
Simplifying constant integer cast 4
Simplifying constant integer cast 8
Simplifying constant integer cast 4
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) 8
Finalized unsigned number type (char) 4
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [0] main::$2 = '0' + main::$18
Constant right-side identified [2] main::$5 = '0' + main::$19
Constant right-side identified [4] main::idx#2 = ++ main::idx#1
Constant right-side identified [5] main::$8 = '0' + main::$20
Constant right-side identified [8] main::$11 = '0' + main::$21
Constant right-side identified [11] main::$14 = '0' + main::$22
Constant right-side identified [14] main::$17 = '0' + main::$23
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$2 = '0'+main::$18
Constant main::$5 = '0'+main::$19
Constant main::idx#2 = ++main::idx#1
Constant main::$8 = '0'+main::$20
Constant main::$11 = '0'+main::$21
Constant main::$14 = '0'+main::$22
Constant main::$17 = '0'+main::$23
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [3] main::idx#3 = ++ main::idx#2
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::idx#3 = ++main::idx#2
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [4] main::idx#4 = ++ main::idx#3
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::idx#4 = ++main::idx#3
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [5] main::idx#5 = ++ main::idx#4
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::idx#5 = ++main::idx#4
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings main::idx#0
Inlining constant with different constant siblings main::idx#1
Inlining constant with different constant siblings main::idx#2
Inlining constant with different constant siblings main::idx#3
Inlining constant with different constant siblings main::idx#4
Inlining constant with different constant siblings main::idx#5
Constant inlined main::$12 = 8*SIZEOF_CHAR
Constant inlined main::$13 = 8*SIZEOF_CHAR/SIZEOF_CHAR
Constant inlined main::$14 = '0'+(char)8*SIZEOF_CHAR/SIZEOF_CHAR
Constant inlined main::$15 = 4*SIZEOF_CHAR
Constant inlined main::$10 = 4*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
Constant inlined main::$11 = '0'+(char)4*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
Constant inlined main::$16 = 4*SIZEOF_CHAR/SIZEOF_CHAR
Constant inlined main::$17 = '0'+(char)4*SIZEOF_CHAR/SIZEOF_CHAR
Constant inlined main::$18 = (char)3*SIZEOF_CHAR/SIZEOF_CHAR
Constant inlined main::$19 = (char)3*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
Constant inlined main::$23 = (char)4*SIZEOF_CHAR/SIZEOF_CHAR
Constant inlined main::$20 = (char)main::sz+2*SIZEOF_CHAR/SIZEOF_CHAR
Constant inlined main::$21 = (char)4*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
Constant inlined main::$22 = (char)8*SIZEOF_CHAR/SIZEOF_CHAR
Constant inlined main::idx#0 = 0
Constant inlined main::idx#1 = ++0
Constant inlined main::idx#2 = ++++0
Constant inlined main::$1 = 3*SIZEOF_CHAR/SIZEOF_CHAR
Constant inlined main::idx#3 = ++++++0
Constant inlined main::$2 = '0'+(char)3*SIZEOF_CHAR/SIZEOF_CHAR
Constant inlined main::idx#4 = ++++++++0
Constant inlined main::idx#5 = ++++++++++0
Constant inlined main::$0 = 3*SIZEOF_CHAR
Constant inlined main::$5 = '0'+(char)3*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
Constant inlined main::$6 = main::sz+2*SIZEOF_CHAR
Constant inlined main::$3 = 3*SIZEOF_UNSIGNED_INT
Constant inlined main::$4 = 3*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
Constant inlined main::$9 = 4*SIZEOF_UNSIGNED_INT
Constant inlined main::$7 = main::sz+2*SIZEOF_CHAR/SIZEOF_CHAR
Constant inlined main::$8 = '0'+(char)main::sz+2*SIZEOF_CHAR/SIZEOF_CHAR
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN+++0)
Consolidated array index constant in *(SCREEN+++++0)
Consolidated array index constant in *(SCREEN+++++++0)
Consolidated array index constant in *(SCREEN+++++++++0)
Consolidated array index constant in *(SCREEN+++++++++++0)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++0
Simplifying constant integer increment ++0
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++3
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++3
Simplifying constant integer increment ++4
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer cast 3*SIZEOF_CHAR/SIZEOF_CHAR
Simplifying constant integer cast 3*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
Simplifying constant integer cast main::sz+2*SIZEOF_CHAR/SIZEOF_CHAR
Simplifying constant integer cast 4*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
Simplifying constant integer cast 8*SIZEOF_CHAR/SIZEOF_CHAR
Simplifying constant integer cast 4*SIZEOF_CHAR/SIZEOF_CHAR
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] *SCREEN = '0'+3*SIZEOF_CHAR/SIZEOF_CHAR
  [1] *(SCREEN+1) = '0'+3*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
  [2] *(SCREEN+2) = '0'+main::sz+2*SIZEOF_CHAR/SIZEOF_CHAR
  [3] *(SCREEN+3) = '0'+4*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
  [4] *(SCREEN+4) = '0'+8*SIZEOF_CHAR/SIZEOF_CHAR
  [5] *(SCREEN+5) = '0'+4*SIZEOF_CHAR/SIZEOF_CHAR
  to:main::@return
main::@return: scope:[main]  from main
  [6] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char main::idx

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *SCREEN = '0'+3*SIZEOF_CHAR/SIZEOF_CHAR [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] *(SCREEN+1) = '0'+3*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [2] *(SCREEN+2) = '0'+main::sz+2*SIZEOF_CHAR/SIZEOF_CHAR [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [3] *(SCREEN+3) = '0'+4*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [4] *(SCREEN+4) = '0'+8*SIZEOF_CHAR/SIZEOF_CHAR [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [5] *(SCREEN+5) = '0'+4*SIZEOF_CHAR/SIZEOF_CHAR [ ] (  [ ] { }  ) always clobbers reg byte a 

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

Uplifting [main] best 45 combination 
Uplifting [] best 45 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests the sizeof() operator on arrays
  // Upstart
  // Commodore 64 PRG executable file
.file [name="sizeof-arrays.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_CHAR = 1
  .const SIZEOF_UNSIGNED_INT = 2
  .label SCREEN = $400
.segment Code
  // main
main: {
    .const sz = 7
    // [0] *SCREEN = '0'+3*SIZEOF_CHAR/SIZEOF_CHAR -- _deref_pbuc1=vbuc2 
    lda #'0'+3*SIZEOF_CHAR/SIZEOF_CHAR
    sta SCREEN
    // [1] *(SCREEN+1) = '0'+3*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT -- _deref_pbuc1=vbuc2 
    lda #'0'+3*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
    sta SCREEN+1
    // [2] *(SCREEN+2) = '0'+main::sz+2*SIZEOF_CHAR/SIZEOF_CHAR -- _deref_pbuc1=vbuc2 
    lda #'0'+(sz+2)*SIZEOF_CHAR/SIZEOF_CHAR
    sta SCREEN+2
    // [3] *(SCREEN+3) = '0'+4*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT -- _deref_pbuc1=vbuc2 
    lda #'0'+4*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
    sta SCREEN+3
    // [4] *(SCREEN+4) = '0'+8*SIZEOF_CHAR/SIZEOF_CHAR -- _deref_pbuc1=vbuc2 
    lda #'0'+8*SIZEOF_CHAR/SIZEOF_CHAR
    sta SCREEN+4
    // [5] *(SCREEN+5) = '0'+4*SIZEOF_CHAR/SIZEOF_CHAR -- _deref_pbuc1=vbuc2 
    lda #'0'+4*SIZEOF_CHAR/SIZEOF_CHAR
    sta SCREEN+5
    jmp __breturn
    // main::@return
  __breturn:
    // [6] 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 * const SCREEN = (char *) 1024
__constant char SIZEOF_CHAR = 1
__constant char SIZEOF_UNSIGNED_INT = 2
void main()
char main::idx
__constant const char main::sz = 7



FINAL ASSEMBLER
Score: 42

  // File Comments
// Tests the sizeof() operator on arrays
  // Upstart
  // Commodore 64 PRG executable file
.file [name="sizeof-arrays.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_CHAR = 1
  .const SIZEOF_UNSIGNED_INT = 2
  .label SCREEN = $400
.segment Code
  // main
main: {
    .const sz = 7
    // SCREEN[idx++] = '0'+(char)(sizeof(ba)/sizeof(byte))
    // [0] *SCREEN = '0'+3*SIZEOF_CHAR/SIZEOF_CHAR -- _deref_pbuc1=vbuc2 
    lda #'0'+3*SIZEOF_CHAR/SIZEOF_CHAR
    sta SCREEN
    // SCREEN[idx++] = '0'+(char)(sizeof(wa)/sizeof(word))
    // [1] *(SCREEN+1) = '0'+3*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT -- _deref_pbuc1=vbuc2 
    lda #'0'+3*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
    sta SCREEN+1
    // SCREEN[idx++] = '0'+(char)(sizeof(bb)/sizeof(byte))
    // [2] *(SCREEN+2) = '0'+main::sz+2*SIZEOF_CHAR/SIZEOF_CHAR -- _deref_pbuc1=vbuc2 
    lda #'0'+(sz+2)*SIZEOF_CHAR/SIZEOF_CHAR
    sta SCREEN+2
    // SCREEN[idx++] = '0'+(char)(sizeof(wb)/sizeof(word))
    // [3] *(SCREEN+3) = '0'+4*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT -- _deref_pbuc1=vbuc2 
    lda #'0'+4*SIZEOF_UNSIGNED_INT/SIZEOF_UNSIGNED_INT
    sta SCREEN+3
    // SCREEN[idx++] = '0'+(char)(sizeof(sa)/sizeof(byte))
    // [4] *(SCREEN+4) = '0'+8*SIZEOF_CHAR/SIZEOF_CHAR -- _deref_pbuc1=vbuc2 
    lda #'0'+8*SIZEOF_CHAR/SIZEOF_CHAR
    sta SCREEN+4
    // SCREEN[idx++] = '0'+(char)(sizeof(sb)/sizeof(byte))
    // [5] *(SCREEN+5) = '0'+4*SIZEOF_CHAR/SIZEOF_CHAR -- _deref_pbuc1=vbuc2 
    lda #'0'+4*SIZEOF_CHAR/SIZEOF_CHAR
    sta SCREEN+5
    // main::@return
    // }
    // [6] return 
    rts
}
  // File Data

