Identified constant variable (byte) ITEM_COUNT
Identified constant variable (byte) ITEM_SIZE
Culled Empty Block (label) main::@4

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte) ITEM_COUNT#0 ← (number) 3
  (byte) ITEM_SIZE#0 ← (number) 5
  (byte~) $0 ← (byte) ITEM_COUNT#0 * (byte) ITEM_SIZE#0
  (byte[$0]) items#0 ← { (number) 0, (number) 0, (number) 0, (number) 0, (number) 0, (number) 0, (number) 0, (number) 0, (number) 0, (number) 0, (number) 0, (number) 0, (number) 0, (number) 0, (number) 0 }
  to:@1
main: scope:[main]  from @1
  (byte*) main::cur_item#0 ← (byte[$0]) items#0
  (number~) main::$0 ← (byte) ITEM_COUNT#0 - (number) 1
  (byte) main::item#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@3
  (byte*) main::cur_item#4 ← phi( main/(byte*) main::cur_item#0 main::@3/(byte*) main::cur_item#1 )
  (byte) main::item#4 ← phi( main/(byte) main::item#0 main::@3/(byte) main::item#1 )
  (number~) main::$1 ← (byte) ITEM_SIZE#0 - (number) 1
  (byte) main::sub#0 ← (byte) 0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  (byte*) main::cur_item#2 ← phi( main::@1/(byte*) main::cur_item#4 main::@2/(byte*) main::cur_item#2 )
  (byte) main::sub#2 ← phi( main::@1/(byte) main::sub#0 main::@2/(byte) main::sub#1 )
  (byte) main::item#2 ← phi( main::@1/(byte) main::item#4 main::@2/(byte) main::item#2 )
  (number~) main::$2 ← (byte) main::item#2 * (number) $10
  (number~) main::$3 ← (number~) main::$2 | (byte) main::sub#2
  *((byte*) main::cur_item#2 + (byte) main::sub#2) ← (number~) main::$3
  (byte) main::sub#1 ← (byte) main::sub#2 + rangenext(0,main::$1)
  (bool~) main::$4 ← (byte) main::sub#1 != rangelast(0,main::$1)
  if((bool~) main::$4) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  (byte) main::item#3 ← phi( main::@2/(byte) main::item#2 )
  (byte*) main::cur_item#3 ← phi( main::@2/(byte*) main::cur_item#2 )
  (byte*) main::cur_item#1 ← (byte*) main::cur_item#3 + (byte) ITEM_SIZE#0
  (byte) main::item#1 ← (byte) main::item#3 + rangenext(0,main::$0)
  (bool~) main::$5 ← (byte) main::item#1 != rangelast(0,main::$0)
  if((bool~) main::$5) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(byte~) $0
(label) @1
(label) @2
(label) @begin
(label) @end
(byte) ITEM_COUNT
(byte) ITEM_COUNT#0
(byte) ITEM_SIZE
(byte) ITEM_SIZE#0
(byte[$0]) items
(byte[$0]) items#0
(void()) main()
(number~) main::$0
(number~) main::$1
(number~) main::$2
(number~) main::$3
(bool~) main::$4
(bool~) main::$5
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte*) main::cur_item
(byte*) main::cur_item#0
(byte*) main::cur_item#1
(byte*) main::cur_item#2
(byte*) main::cur_item#3
(byte*) main::cur_item#4
(byte) main::item
(byte) main::item#0
(byte) main::item#1
(byte) main::item#2
(byte) main::item#3
(byte) main::item#4
(byte) main::sub
(byte) main::sub#0
(byte) main::sub#1
(byte) main::sub#2

Adding number conversion cast (unumber) 3 in (byte) ITEM_COUNT#0 ← (number) 3
Adding number conversion cast (unumber) 5 in (byte) ITEM_SIZE#0 ← (number) 5
Adding number conversion cast (unumber) 1 in (number~) main::$0 ← (byte) ITEM_COUNT#0 - (number) 1
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (byte) ITEM_COUNT#0 - (unumber)(number) 1
Adding number conversion cast (unumber) 1 in (number~) main::$1 ← (byte) ITEM_SIZE#0 - (number) 1
Adding number conversion cast (unumber) main::$1 in (number~) main::$1 ← (byte) ITEM_SIZE#0 - (unumber)(number) 1
Adding number conversion cast (unumber) $10 in (number~) main::$2 ← (byte) main::item#2 * (number) $10
Adding number conversion cast (unumber) main::$2 in (number~) main::$2 ← (byte) main::item#2 * (unumber)(number) $10
Adding number conversion cast (unumber) main::$3 in (number~) main::$3 ← (unumber~) main::$2 | (byte) main::sub#2
Successful SSA optimization PassNAddNumberTypeConversions
Adding number conversion cast (byte) to elements in (byte[$0]) items#0 ← { (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0, (byte)(number) 0 }
Successful SSA optimization PassNAddArrayNumberTypeConversions
Inlining cast (byte) ITEM_COUNT#0 ← (unumber)(number) 3
Inlining cast (byte) ITEM_SIZE#0 ← (unumber)(number) 5
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 3
Simplifying constant integer cast 5
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Simplifying constant integer cast $10
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 5
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $10
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$0 ← (byte) ITEM_COUNT#0 - (byte) 1
Inferred type updated to byte in (unumber~) main::$1 ← (byte) ITEM_SIZE#0 - (byte) 1
Inferred type updated to byte in (unumber~) main::$2 ← (byte) main::item#2 * (byte) $10
Inferred type updated to byte in (unumber~) main::$3 ← (byte~) main::$2 | (byte) main::sub#2
Alias (byte*) main::cur_item#2 = (byte*) main::cur_item#3 
Alias (byte) main::item#2 = (byte) main::item#3 
Successful SSA optimization Pass2AliasElimination
Self Phi Eliminated (byte) main::item#2
Self Phi Eliminated (byte*) main::cur_item#2
Successful SSA optimization Pass2SelfPhiElimination
Identical Phi Values (byte) main::item#2 (byte) main::item#4
Identical Phi Values (byte*) main::cur_item#2 (byte*) main::cur_item#4
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$4 [16] if((byte) main::sub#1!=rangelast(0,main::$1)) goto main::@2
Simple Condition (bool~) main::$5 [21] if((byte) main::item#1!=rangelast(0,main::$0)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [3] (byte[$0]) items#0 ← { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 }
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) ITEM_COUNT#0 = 3
Constant (const byte) ITEM_SIZE#0 = 5
Constant (const byte[$0]) items#0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
Constant (const byte) main::item#0 = 0
Constant (const byte) main::sub#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) main::cur_item#0 = items#0
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [0] (byte~) $0 ← (const byte) ITEM_COUNT#0 * (const byte) ITEM_SIZE#0
Constant right-side identified [1] (byte~) main::$0 ← (const byte) ITEM_COUNT#0 - (byte) 1
Constant right-side identified [3] (byte~) main::$1 ← (const byte) ITEM_SIZE#0 - (byte) 1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) $0 = ITEM_COUNT#0*ITEM_SIZE#0
Constant (const byte) main::$0 = ITEM_COUNT#0-1
Constant (const byte) main::$1 = ITEM_SIZE#0-1
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [8] main::sub#1 ← ++ main::sub#2 to ++
Resolved ranged comparison value [9] if(main::sub#1!=rangelast(0,main::$1)) goto main::@2 to (const byte) main::$1+(number) 1
Resolved ranged next value [11] main::item#1 ← ++ main::item#4 to ++
Resolved ranged comparison value [12] if(main::item#1!=rangelast(0,main::$0)) goto main::@1 to (const byte) main::$0+(number) 1
Adding number conversion cast (unumber) main::$1+1 in if((byte) main::sub#1!=(const byte) main::$1+(number) 1) goto main::@2
Adding number conversion cast (unumber) 1 in if((byte) main::sub#1!=(unumber)(const byte) main::$1+(number) 1) goto main::@2
Adding number conversion cast (unumber) main::$0+1 in if((byte) main::item#1!=(const byte) main::$0+(number) 1) goto main::@1
Adding number conversion cast (unumber) 1 in if((byte) main::item#1!=(unumber)(const byte) main::$0+(number) 1) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast (const byte) main::$1+(unumber)(number) 1
Simplifying constant integer cast 1
Simplifying constant integer cast (const byte) main::$0+(unumber)(number) 1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift [2] (byte~) main::$2 ← (byte) main::item#4 * (byte) $10
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings (const byte) main::item#0
Inlining constant with var siblings (const byte) main::sub#0
Inlining constant with var siblings (const byte*) main::cur_item#0
Constant inlined main::sub#0 = (byte) 0
Constant inlined main::$1 = (const byte) ITEM_SIZE#0-(byte) 1
Constant inlined $0 = (const byte) ITEM_COUNT#0*(const byte) ITEM_SIZE#0
Constant inlined main::cur_item#0 = (const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0
Constant inlined main::$0 = (const byte) ITEM_COUNT#0-(byte) 1
Constant inlined main::item#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@5(between main::@3 and main::@1)
Added new block during phi lifting main::@6(between main::@2 and main::@2)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2 

Created 3 initial phi equivalence classes
Coalesced [17] main::item#5 ← main::item#1
Coalesced [18] main::cur_item#5 ← main::cur_item#1
Coalesced [19] main::sub#3 ← main::sub#1
Coalesced down to 3 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  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] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@3
  [5] (byte*) main::cur_item#4 ← phi( main/(const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 main::@3/(byte*) main::cur_item#1 )
  [5] (byte) main::item#4 ← phi( main/(byte) 0 main::@3/(byte) main::item#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [6] (byte) main::sub#2 ← phi( main::@1/(byte) 0 main::@2/(byte) main::sub#1 )
  [7] (byte~) main::$2 ← (byte) main::item#4 << (byte) 4
  [8] (byte~) main::$3 ← (byte~) main::$2 | (byte) main::sub#2
  [9] *((byte*) main::cur_item#4 + (byte) main::sub#2) ← (byte~) main::$3
  [10] (byte) main::sub#1 ← ++ (byte) main::sub#2
  [11] if((byte) main::sub#1!=(const byte) ITEM_SIZE#0-(byte) 1+(byte) 1) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  [12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const byte) ITEM_SIZE#0
  [13] (byte) main::item#1 ← ++ (byte) main::item#4
  [14] if((byte) main::item#1!=(const byte) ITEM_COUNT#0-(byte) 1+(byte) 1) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  [15] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte) ITEM_COUNT
(byte) ITEM_SIZE
(byte[ITEM_COUNT#0*ITEM_SIZE#0]) items
(void()) main()
(byte~) main::$2 202.0
(byte~) main::$3 202.0
(byte*) main::cur_item
(byte*) main::cur_item#1 7.333333333333333
(byte*) main::cur_item#4 17.571428571428573
(byte) main::item
(byte) main::item#1 16.5
(byte) main::item#4 15.375
(byte) main::sub
(byte) main::sub#1 151.5
(byte) main::sub#2 101.0

Initial phi equivalence classes
[ main::item#4 main::item#1 ]
[ main::cur_item#4 main::cur_item#1 ]
[ main::sub#2 main::sub#1 ]
Added variable main::$2 to zero page equivalence class [ main::$2 ]
Added variable main::$3 to zero page equivalence class [ main::$3 ]
Complete equivalence classes
[ main::item#4 main::item#1 ]
[ main::cur_item#4 main::cur_item#1 ]
[ main::sub#2 main::sub#1 ]
[ main::$2 ]
[ main::$3 ]
Allocated zp ZP_BYTE:2 [ main::item#4 main::item#1 ]
Allocated zp ZP_WORD:3 [ main::cur_item#4 main::cur_item#1 ]
Allocated zp ZP_BYTE:5 [ main::sub#2 main::sub#1 ]
Allocated zp ZP_BYTE:6 [ main::$2 ]
Allocated zp ZP_BYTE:7 [ main::$3 ]

INITIAL ASM
  // File Comments
// Illustrates symbolic array lengths
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const ITEM_COUNT = 3
  .const ITEM_SIZE = 5
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
// Fills the array item by item with $is, where i is the item# and s is the sub#
main: {
    .label _2 = 6
    .label _3 = 7
    .label sub = 5
    .label cur_item = 3
    .label item = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte*) main::cur_item#4 = (const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<items
    sta cur_item
    lda #>items
    sta cur_item+1
    // [5] phi (byte) main::item#4 = (byte) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta item
    jmp b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  b1_from_b3:
    // [5] phi (byte*) main::cur_item#4 = (byte*) main::cur_item#1 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte) main::item#4 = (byte) main::item#1 [phi:main::@3->main::@1#1] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [6] phi (byte) main::sub#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta sub
    jmp b2
    // [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
    // [6] phi (byte) main::sub#2 = (byte) main::sub#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [7] (byte~) main::$2 ← (byte) main::item#4 << (byte) 4 -- vbuz1=vbuz2_rol_4 
    lda item
    asl
    asl
    asl
    asl
    sta _2
    // [8] (byte~) main::$3 ← (byte~) main::$2 | (byte) main::sub#2 -- vbuz1=vbuz2_bor_vbuz3 
    lda _2
    ora sub
    sta _3
    // [9] *((byte*) main::cur_item#4 + (byte) main::sub#2) ← (byte~) main::$3 -- pbuz1_derefidx_vbuz2=vbuz3 
    lda _3
    ldy sub
    sta (cur_item),y
    // [10] (byte) main::sub#1 ← ++ (byte) main::sub#2 -- vbuz1=_inc_vbuz1 
    inc sub
    // [11] if((byte) main::sub#1!=(const byte) ITEM_SIZE#0-(byte) 1+(byte) 1) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #ITEM_SIZE-1+1
    cmp sub
    bne b2_from_b2
    jmp b3
    // main::@3
  b3:
    // [12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const byte) ITEM_SIZE#0 -- pbuz1=pbuz1_plus_vbuc1 
    lda #ITEM_SIZE
    clc
    adc cur_item
    sta cur_item
    bcc !+
    inc cur_item+1
  !:
    // [13] (byte) main::item#1 ← ++ (byte) main::item#4 -- vbuz1=_inc_vbuz1 
    inc item
    // [14] if((byte) main::item#1!=(const byte) ITEM_COUNT#0-(byte) 1+(byte) 1) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #ITEM_COUNT-1+1
    cmp item
    bne b1_from_b3
    jmp breturn
    // main::@return
  breturn:
    // [15] return 
    rts
}
  // File Data
  items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] (byte~) main::$2 ← (byte) main::item#4 << (byte) 4 [ main::item#4 main::cur_item#4 main::sub#2 main::$2 ] ( main:2 [ main::item#4 main::cur_item#4 main::sub#2 main::$2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::item#4 main::item#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:5 [ main::sub#2 main::sub#1 ]
Statement [12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const byte) ITEM_SIZE#0 [ main::item#4 main::cur_item#1 ] ( main:2 [ main::item#4 main::cur_item#1 ] ) always clobbers reg byte a 
Statement [7] (byte~) main::$2 ← (byte) main::item#4 << (byte) 4 [ main::item#4 main::cur_item#4 main::sub#2 main::$2 ] ( main:2 [ main::item#4 main::cur_item#4 main::sub#2 main::$2 ] ) always clobbers reg byte a 
Statement [12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const byte) ITEM_SIZE#0 [ main::item#4 main::cur_item#1 ] ( main:2 [ main::item#4 main::cur_item#1 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::item#4 main::item#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , 
Potential registers zp ZP_WORD:3 [ main::cur_item#4 main::cur_item#1 ] : zp ZP_WORD:3 , 
Potential registers zp ZP_BYTE:5 [ main::sub#2 main::sub#1 ] : zp ZP_BYTE:5 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:6 [ main::$2 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:7 [ main::$3 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 252.5: zp ZP_BYTE:5 [ main::sub#2 main::sub#1 ] 202: zp ZP_BYTE:6 [ main::$2 ] 202: zp ZP_BYTE:7 [ main::$3 ] 31.88: zp ZP_BYTE:2 [ main::item#4 main::item#1 ] 24.9: zp ZP_WORD:3 [ main::cur_item#4 main::cur_item#1 ] 
Uplift Scope [] 

Uplifting [main] best 4418 combination reg byte y [ main::sub#2 main::sub#1 ] reg byte a [ main::$2 ] reg byte a [ main::$3 ] reg byte x [ main::item#4 main::item#1 ] zp ZP_WORD:3 [ main::cur_item#4 main::cur_item#1 ] 
Limited combination testing to 100 combinations of 144 possible.
Uplifting [] best 4418 combination 
Allocated (was zp ZP_WORD:3) zp ZP_WORD:2 [ main::cur_item#4 main::cur_item#1 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Illustrates symbolic array lengths
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const ITEM_COUNT = 3
  .const ITEM_SIZE = 5
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
// Fills the array item by item with $is, where i is the item# and s is the sub#
main: {
    .label cur_item = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte*) main::cur_item#4 = (const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<items
    sta cur_item
    lda #>items
    sta cur_item+1
    // [5] phi (byte) main::item#4 = (byte) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #0
    jmp b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  b1_from_b3:
    // [5] phi (byte*) main::cur_item#4 = (byte*) main::cur_item#1 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte) main::item#4 = (byte) main::item#1 [phi:main::@3->main::@1#1] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [6] phi (byte) main::sub#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuyy=vbuc1 
    ldy #0
    jmp b2
    // [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
    // [6] phi (byte) main::sub#2 = (byte) main::sub#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [7] (byte~) main::$2 ← (byte) main::item#4 << (byte) 4 -- vbuaa=vbuxx_rol_4 
    txa
    asl
    asl
    asl
    asl
    // [8] (byte~) main::$3 ← (byte~) main::$2 | (byte) main::sub#2 -- vbuaa=vbuaa_bor_vbuyy 
    sty $ff
    ora $ff
    // [9] *((byte*) main::cur_item#4 + (byte) main::sub#2) ← (byte~) main::$3 -- pbuz1_derefidx_vbuyy=vbuaa 
    sta (cur_item),y
    // [10] (byte) main::sub#1 ← ++ (byte) main::sub#2 -- vbuyy=_inc_vbuyy 
    iny
    // [11] if((byte) main::sub#1!=(const byte) ITEM_SIZE#0-(byte) 1+(byte) 1) goto main::@2 -- vbuyy_neq_vbuc1_then_la1 
    cpy #ITEM_SIZE-1+1
    bne b2_from_b2
    jmp b3
    // main::@3
  b3:
    // [12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const byte) ITEM_SIZE#0 -- pbuz1=pbuz1_plus_vbuc1 
    lda #ITEM_SIZE
    clc
    adc cur_item
    sta cur_item
    bcc !+
    inc cur_item+1
  !:
    // [13] (byte) main::item#1 ← ++ (byte) main::item#4 -- vbuxx=_inc_vbuxx 
    inx
    // [14] if((byte) main::item#1!=(const byte) ITEM_COUNT#0-(byte) 1+(byte) 1) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #ITEM_COUNT-1+1
    bne b1_from_b3
    jmp breturn
    // main::@return
  breturn:
    // [15] return 
    rts
}
  // File Data
  items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b3
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b2_from_b2 with b2
Replacing label b1_from_b3 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b3:
Removing instruction b2_from_b1:
Removing instruction b2_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b3:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte) ITEM_COUNT
(const byte) ITEM_COUNT#0 ITEM_COUNT = (byte) 3
(byte) ITEM_SIZE
(const byte) ITEM_SIZE#0 ITEM_SIZE = (byte) 5
(byte[ITEM_COUNT#0*ITEM_SIZE#0]) items
(const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 items = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 }
(void()) main()
(byte~) main::$2 reg byte a 202.0
(byte~) main::$3 reg byte a 202.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte*) main::cur_item
(byte*) main::cur_item#1 cur_item zp ZP_WORD:2 7.333333333333333
(byte*) main::cur_item#4 cur_item zp ZP_WORD:2 17.571428571428573
(byte) main::item
(byte) main::item#1 reg byte x 16.5
(byte) main::item#4 reg byte x 15.375
(byte) main::sub
(byte) main::sub#1 reg byte y 151.5
(byte) main::sub#2 reg byte y 101.0

reg byte x [ main::item#4 main::item#1 ]
zp ZP_WORD:2 [ main::cur_item#4 main::cur_item#1 ]
reg byte y [ main::sub#2 main::sub#1 ]
reg byte a [ main::$2 ]
reg byte a [ main::$3 ]


FINAL ASSEMBLER
Score: 3416

  // File Comments
// Illustrates symbolic array lengths
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .const ITEM_COUNT = 3
  .const ITEM_SIZE = 5
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
// Fills the array item by item with $is, where i is the item# and s is the sub#
main: {
    .label cur_item = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte*) main::cur_item#4 = (const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<items
    sta cur_item
    lda #>items
    sta cur_item+1
    // [5] phi (byte) main::item#4 = (byte) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [5] phi (byte*) main::cur_item#4 = (byte*) main::cur_item#1 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte) main::item#4 = (byte) main::item#1 [phi:main::@3->main::@1#1] -- register_copy 
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [6] phi (byte) main::sub#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuyy=vbuc1 
    ldy #0
    // [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
    // [6] phi (byte) main::sub#2 = (byte) main::sub#1 [phi:main::@2->main::@2#0] -- register_copy 
    // main::@2
  b2:
    // item*$10
    // [7] (byte~) main::$2 ← (byte) main::item#4 << (byte) 4 -- vbuaa=vbuxx_rol_4 
    txa
    asl
    asl
    asl
    asl
    // item*$10|sub
    // [8] (byte~) main::$3 ← (byte~) main::$2 | (byte) main::sub#2 -- vbuaa=vbuaa_bor_vbuyy 
    sty $ff
    ora $ff
    // cur_item[sub] = item*$10|sub
    // [9] *((byte*) main::cur_item#4 + (byte) main::sub#2) ← (byte~) main::$3 -- pbuz1_derefidx_vbuyy=vbuaa 
    sta (cur_item),y
    // for( byte sub: 0..ITEM_SIZE-1)
    // [10] (byte) main::sub#1 ← ++ (byte) main::sub#2 -- vbuyy=_inc_vbuyy 
    iny
    // [11] if((byte) main::sub#1!=(const byte) ITEM_SIZE#0-(byte) 1+(byte) 1) goto main::@2 -- vbuyy_neq_vbuc1_then_la1 
    cpy #ITEM_SIZE-1+1
    bne b2
    // main::@3
    // cur_item += ITEM_SIZE
    // [12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const byte) ITEM_SIZE#0 -- pbuz1=pbuz1_plus_vbuc1 
    lda #ITEM_SIZE
    clc
    adc cur_item
    sta cur_item
    bcc !+
    inc cur_item+1
  !:
    // for( byte item: 0..ITEM_COUNT-1)
    // [13] (byte) main::item#1 ← ++ (byte) main::item#4 -- vbuxx=_inc_vbuxx 
    inx
    // [14] if((byte) main::item#1!=(const byte) ITEM_COUNT#0-(byte) 1+(byte) 1) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #ITEM_COUNT-1+1
    bne b1
    // main::@return
    // }
    // [15] return 
    rts
}
  // File Data
  items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

