
CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte) cnt#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  (byte) cnt2#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  (byte) cnt3#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  (byte[256]) SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@2
main: scope:[main]  from @2
  (byte) cnt3#13 ← phi( @2/(byte) cnt3#14 )
  (byte) cnt2#13 ← phi( @2/(byte) cnt2#14 )
  (byte) cnt#14 ← phi( @2/(byte) cnt#15 )
  call inccnt 
  (byte) inccnt::return#0 ← (byte) inccnt::return#3
  to:main::@1
main::@1: scope:[main]  from main
  (byte) cnt3#7 ← phi( main/(byte) cnt3#5 )
  (byte) cnt2#7 ← phi( main/(byte) cnt2#5 )
  (byte) cnt#8 ← phi( main/(byte) cnt#6 )
  (byte) inccnt::return#4 ← phi( main/(byte) inccnt::return#0 )
  (byte~) main::$0 ← (byte) inccnt::return#4
  (byte) cnt#1 ← (byte) cnt#8
  (byte) cnt2#1 ← (byte) cnt2#7
  (byte) cnt3#1 ← (byte) cnt3#7
  *((byte[256]) SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 0) ← (byte~) main::$0
  (byte) cnt#2 ← ++ (byte) cnt#1
  call inccnt 
  (byte) inccnt::return#1 ← (byte) inccnt::return#3
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte) cnt3#8 ← phi( main::@1/(byte) cnt3#5 )
  (byte) cnt2#8 ← phi( main::@1/(byte) cnt2#5 )
  (byte) cnt#9 ← phi( main::@1/(byte) cnt#6 )
  (byte) inccnt::return#5 ← phi( main::@1/(byte) inccnt::return#1 )
  (byte~) main::$1 ← (byte) inccnt::return#5
  (byte) cnt#3 ← (byte) cnt#9
  (byte) cnt2#2 ← (byte) cnt2#8
  (byte) cnt3#2 ← (byte) cnt3#8
  *((byte[256]) SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$1
  to:main::@return
main::@return: scope:[main]  from main::@2
  (byte) cnt3#9 ← phi( main::@2/(byte) cnt3#2 )
  (byte) cnt2#9 ← phi( main::@2/(byte) cnt2#2 )
  (byte) cnt#10 ← phi( main::@2/(byte) cnt#3 )
  (byte) cnt#4 ← (byte) cnt#10
  (byte) cnt2#3 ← (byte) cnt2#9
  (byte) cnt3#3 ← (byte) cnt3#9
  return 
  to:@return
inccnt: scope:[inccnt]  from main main::@1
  (byte) cnt3#10 ← phi( main/(byte) cnt3#13 main::@1/(byte) cnt3#1 )
  (byte) cnt2#10 ← phi( main/(byte) cnt2#13 main::@1/(byte) cnt2#1 )
  (byte) cnt#11 ← phi( main/(byte) cnt#14 main::@1/(byte) cnt#2 )
  (byte) cnt#5 ← ++ (byte) cnt#11
  (byte) cnt2#4 ← ++ (byte) cnt2#10
  (byte) cnt3#4 ← ++ (byte) cnt3#10
  (byte) inccnt::return#2 ← (byte) cnt#5
  to:inccnt::@return
inccnt::@return: scope:[inccnt]  from inccnt
  (byte) cnt3#11 ← phi( inccnt/(byte) cnt3#4 )
  (byte) cnt2#11 ← phi( inccnt/(byte) cnt2#4 )
  (byte) cnt#12 ← phi( inccnt/(byte) cnt#5 )
  (byte) inccnt::return#6 ← phi( inccnt/(byte) inccnt::return#2 )
  (byte) inccnt::return#3 ← (byte) inccnt::return#6
  (byte) cnt#6 ← (byte) cnt#12
  (byte) cnt2#5 ← (byte) cnt2#11
  (byte) cnt3#5 ← (byte) cnt3#11
  return 
  to:@return
@2: scope:[]  from @begin
  (byte) cnt3#14 ← phi( @begin/(byte) cnt3#0 )
  (byte) cnt2#14 ← phi( @begin/(byte) cnt2#0 )
  (byte) cnt#15 ← phi( @begin/(byte) cnt#0 )
  call main 
  to:@3
@3: scope:[]  from @2
  (byte) cnt3#12 ← phi( @2/(byte) cnt3#3 )
  (byte) cnt2#12 ← phi( @2/(byte) cnt2#3 )
  (byte) cnt#13 ← phi( @2/(byte) cnt#4 )
  (byte) cnt#7 ← (byte) cnt#13
  (byte) cnt2#6 ← (byte) cnt2#12
  (byte) cnt3#6 ← (byte) cnt3#12
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(byte[256]) SCREEN
(byte[256]) SCREEN#0
(byte) cnt
(byte) cnt#0
(byte) cnt#1
(byte) cnt#10
(byte) cnt#11
(byte) cnt#12
(byte) cnt#13
(byte) cnt#14
(byte) cnt#15
(byte) cnt#2
(byte) cnt#3
(byte) cnt#4
(byte) cnt#5
(byte) cnt#6
(byte) cnt#7
(byte) cnt#8
(byte) cnt#9
(byte) cnt2
(byte) cnt2#0
(byte) cnt2#1
(byte) cnt2#10
(byte) cnt2#11
(byte) cnt2#12
(byte) cnt2#13
(byte) cnt2#14
(byte) cnt2#2
(byte) cnt2#3
(byte) cnt2#4
(byte) cnt2#5
(byte) cnt2#6
(byte) cnt2#7
(byte) cnt2#8
(byte) cnt2#9
(byte) cnt3
(byte) cnt3#0
(byte) cnt3#1
(byte) cnt3#10
(byte) cnt3#11
(byte) cnt3#12
(byte) cnt3#13
(byte) cnt3#14
(byte) cnt3#2
(byte) cnt3#3
(byte) cnt3#4
(byte) cnt3#5
(byte) cnt3#6
(byte) cnt3#7
(byte) cnt3#8
(byte) cnt3#9
(byte()) inccnt()
(label) inccnt::@return
(byte) inccnt::return
(byte) inccnt::return#0
(byte) inccnt::return#1
(byte) inccnt::return#2
(byte) inccnt::return#3
(byte) inccnt::return#4
(byte) inccnt::return#5
(byte) inccnt::return#6
(void()) main()
(byte~) main::$0
(byte~) main::$1
(label) main::@1
(label) main::@2
(label) main::@return

Alias (byte) inccnt::return#0 = (byte) inccnt::return#4 
Alias (byte) cnt#1 = (byte) cnt#8 
Alias (byte) cnt2#1 = (byte) cnt2#7 
Alias (byte) cnt3#1 = (byte) cnt3#7 
Alias (byte) inccnt::return#1 = (byte) inccnt::return#5 
Alias (byte) cnt#10 = (byte) cnt#3 (byte) cnt#9 (byte) cnt#4 
Alias (byte) cnt2#2 = (byte) cnt2#8 (byte) cnt2#9 (byte) cnt2#3 
Alias (byte) cnt3#2 = (byte) cnt3#8 (byte) cnt3#9 (byte) cnt3#3 
Alias (byte) inccnt::return#2 = (byte) inccnt::return#6 (byte) inccnt::return#3 
Alias (byte) cnt#12 = (byte) cnt#5 (byte) cnt#6 
Alias (byte) cnt2#11 = (byte) cnt2#4 (byte) cnt2#5 
Alias (byte) cnt3#11 = (byte) cnt3#4 (byte) cnt3#5 
Alias (byte) cnt#0 = (byte) cnt#15 
Alias (byte) cnt2#0 = (byte) cnt2#14 
Alias (byte) cnt3#0 = (byte) cnt3#14 
Alias (byte) cnt#13 = (byte) cnt#7 
Alias (byte) cnt2#12 = (byte) cnt2#6 
Alias (byte) cnt3#12 = (byte) cnt3#6 
Successful SSA optimization Pass2AliasElimination
Redundant Phi (byte) cnt#14 (byte) cnt#0
Redundant Phi (byte) cnt2#13 (byte) cnt2#0
Redundant Phi (byte) cnt3#13 (byte) cnt3#0
Redundant Phi (byte) cnt#1 (byte) cnt#12
Redundant Phi (byte) cnt2#1 (byte) cnt2#11
Redundant Phi (byte) cnt3#1 (byte) cnt3#11
Redundant Phi (byte) cnt#10 (byte) cnt#12
Redundant Phi (byte) cnt2#2 (byte) cnt2#11
Redundant Phi (byte) cnt3#2 (byte) cnt3#11
Redundant Phi (byte) cnt#13 (byte) cnt#10
Redundant Phi (byte) cnt2#12 (byte) cnt2#2
Redundant Phi (byte) cnt3#12 (byte) cnt3#2
Successful SSA optimization Pass2RedundantPhiElimination
Constant (const byte) cnt#0 = 0
Constant (const byte) cnt2#0 = 0
Constant (const byte) cnt3#0 = 0
Constant (const byte[256]) SCREEN#0 = ((byte*))1024
Successful SSA optimization Pass2ConstantIdentification
Consolidated array index constant in *(SCREEN#0+0)
Consolidated array index constant in *(SCREEN#0+1)
Successful SSA optimization Pass2ConstantAdditionElimination
Culled Empty Block (label) @3
Successful SSA optimization Pass2CullEmptyBlocks
Inlining constant with var siblings (const byte) cnt#0
Inlining constant with var siblings (const byte) cnt2#0
Inlining constant with var siblings (const byte) cnt3#0
Constant inlined cnt#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined cnt3#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined cnt2#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Successful SSA optimization Pass2ConstantInlining
Simplifying constant plus zero SCREEN#0+0
Adding NOP phi() at start of @begin
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 
Calls in [main] to inccnt:5 inccnt:13 

Created 3 initial phi equivalence classes
Coalesced [10] cnt#16 ← cnt#2
Coalesced [11] cnt2#15 ← cnt2#11
Coalesced [12] cnt3#15 ← cnt3#11
Coalesced down to 3 phi equivalence classes
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@2
@2: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @2
  [3] phi()
main: scope:[main]  from @2
  [4] phi()
  [5] call inccnt 
  [6] (byte) inccnt::return#0 ← (byte) inccnt::return#2
  to:main::@1
main::@1: scope:[main]  from main
  [7] (byte~) main::$0 ← (byte) inccnt::return#0
  [8] *((const byte[256]) SCREEN#0) ← (byte~) main::$0
  [9] (byte) cnt#2 ← ++ (byte) cnt#12
  [10] call inccnt 
  [11] (byte) inccnt::return#1 ← (byte) inccnt::return#2
  to:main::@2
main::@2: scope:[main]  from main::@1
  [12] (byte~) main::$1 ← (byte) inccnt::return#1
  [13] *((const byte[256]) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$1
  to:main::@return
main::@return: scope:[main]  from main::@2
  [14] return 
  to:@return
inccnt: scope:[inccnt]  from main main::@1
  [15] (byte) cnt3#10 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) cnt3#11 )
  [15] (byte) cnt2#10 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) cnt2#11 )
  [15] (byte) cnt#11 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) cnt#2 )
  [16] (byte) cnt#12 ← ++ (byte) cnt#11
  [17] (byte) cnt2#11 ← ++ (byte) cnt2#10
  [18] (byte) cnt3#11 ← ++ (byte) cnt3#10
  [19] (byte) inccnt::return#2 ← (byte) cnt#12
  to:inccnt::@return
inccnt::@return: scope:[inccnt]  from inccnt
  [20] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte[256]) SCREEN
(byte) cnt
(byte) cnt#11 4.0
(byte) cnt#12 0.6666666666666666
(byte) cnt#2 4.0
(byte) cnt2
(byte) cnt2#10 2.0
(byte) cnt2#11 0.4444444444444444
(byte) cnt3
(byte) cnt3#10 1.3333333333333333
(byte) cnt3#11 0.5
(byte()) inccnt()
(byte) inccnt::return
(byte) inccnt::return#0 4.0
(byte) inccnt::return#1 4.0
(byte) inccnt::return#2 1.5
(void()) main()
(byte~) main::$0 4.0
(byte~) main::$1 4.0

Initial phi equivalence classes
[ cnt#11 cnt#2 ]
[ cnt2#10 cnt2#11 ]
[ cnt3#10 cnt3#11 ]
Added variable inccnt::return#0 to zero page equivalence class [ inccnt::return#0 ]
Added variable main::$0 to zero page equivalence class [ main::$0 ]
Added variable inccnt::return#1 to zero page equivalence class [ inccnt::return#1 ]
Added variable main::$1 to zero page equivalence class [ main::$1 ]
Added variable cnt#12 to zero page equivalence class [ cnt#12 ]
Added variable inccnt::return#2 to zero page equivalence class [ inccnt::return#2 ]
Complete equivalence classes
[ cnt#11 cnt#2 ]
[ cnt2#10 cnt2#11 ]
[ cnt3#10 cnt3#11 ]
[ inccnt::return#0 ]
[ main::$0 ]
[ inccnt::return#1 ]
[ main::$1 ]
[ cnt#12 ]
[ inccnt::return#2 ]
Allocated zp ZP_BYTE:2 [ cnt#11 cnt#2 ]
Allocated zp ZP_BYTE:3 [ cnt2#10 cnt2#11 ]
Allocated zp ZP_BYTE:4 [ cnt3#10 cnt3#11 ]
Allocated zp ZP_BYTE:5 [ inccnt::return#0 ]
Allocated zp ZP_BYTE:6 [ main::$0 ]
Allocated zp ZP_BYTE:7 [ inccnt::return#1 ]
Allocated zp ZP_BYTE:8 [ main::$1 ]
Allocated zp ZP_BYTE:9 [ cnt#12 ]
Allocated zp ZP_BYTE:10 [ inccnt::return#2 ]

INITIAL ASM
//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label SCREEN = $400
  .label cnt = 2
  .label cnt2 = 3
  .label cnt3 = 4
  .label cnt_12 = 9
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG5 @2
b2:
//SEG6 [2] call main 
//SEG7 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
  jsr main
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
    .label _0 = 6
    .label _1 = 8
  //SEG11 [5] call inccnt 
  //SEG12 [15] phi from main to inccnt [phi:main->inccnt]
  inccnt_from_main:
  //SEG13 [15] phi (byte) cnt3#10 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->inccnt#0] -- vbuz1=vbuc1 
    lda #0
    sta cnt3
  //SEG14 [15] phi (byte) cnt2#10 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->inccnt#1] -- vbuz1=vbuc1 
    lda #0
    sta cnt2
  //SEG15 [15] phi (byte) cnt#11 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->inccnt#2] -- vbuz1=vbuc1 
    lda #0
    sta cnt
    jsr inccnt
  //SEG16 [6] (byte) inccnt::return#0 ← (byte) inccnt::return#2 -- vbuz1=vbuz2 
    lda inccnt.return_2
    sta inccnt.return
    jmp b1
  //SEG17 main::@1
  b1:
  //SEG18 [7] (byte~) main::$0 ← (byte) inccnt::return#0 -- vbuz1=vbuz2 
    lda inccnt.return
    sta _0
  //SEG19 [8] *((const byte[256]) SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuz1 
    lda _0
    sta SCREEN
  //SEG20 [9] (byte) cnt#2 ← ++ (byte) cnt#12 -- vbuz1=_inc_vbuz2 
    ldy cnt_12
    iny
    sty cnt
  //SEG21 [10] call inccnt 
  //SEG22 [15] phi from main::@1 to inccnt [phi:main::@1->inccnt]
  inccnt_from_b1:
  //SEG23 [15] phi (byte) cnt3#10 = (byte) cnt3#11 [phi:main::@1->inccnt#0] -- register_copy 
  //SEG24 [15] phi (byte) cnt2#10 = (byte) cnt2#11 [phi:main::@1->inccnt#1] -- register_copy 
  //SEG25 [15] phi (byte) cnt#11 = (byte) cnt#2 [phi:main::@1->inccnt#2] -- register_copy 
    jsr inccnt
  //SEG26 [11] (byte) inccnt::return#1 ← (byte) inccnt::return#2 -- vbuz1=vbuz2 
    lda inccnt.return_2
    sta inccnt.return_1
    jmp b2
  //SEG27 main::@2
  b2:
  //SEG28 [12] (byte~) main::$1 ← (byte) inccnt::return#1 -- vbuz1=vbuz2 
    lda inccnt.return_1
    sta _1
  //SEG29 [13] *((const byte[256]) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$1 -- _deref_pbuc1=vbuz1 
    lda _1
    sta SCREEN+1
    jmp breturn
  //SEG30 main::@return
  breturn:
  //SEG31 [14] return 
    rts
}
//SEG32 inccnt
inccnt: {
    .label return = 5
    .label return_1 = 7
    .label return_2 = $a
  //SEG33 [16] (byte) cnt#12 ← ++ (byte) cnt#11 -- vbuz1=_inc_vbuz2 
    ldy cnt
    iny
    sty cnt_12
  //SEG34 [17] (byte) cnt2#11 ← ++ (byte) cnt2#10 -- vbuz1=_inc_vbuz1 
    inc cnt2
  //SEG35 [18] (byte) cnt3#11 ← ++ (byte) cnt3#10 -- vbuz1=_inc_vbuz1 
    inc cnt3
  //SEG36 [19] (byte) inccnt::return#2 ← (byte) cnt#12 -- vbuz1=vbuz2 
    lda cnt_12
    sta return_2
    jmp breturn
  //SEG37 inccnt::@return
  breturn:
  //SEG38 [20] return 
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp ZP_BYTE:2 [ cnt#11 cnt#2 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ cnt2#10 cnt2#11 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ cnt3#10 cnt3#11 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ inccnt::return#0 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:6 [ main::$0 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:7 [ inccnt::return#1 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:8 [ main::$1 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:9 [ cnt#12 ] : zp ZP_BYTE:9 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:10 [ inccnt::return#2 ] : zp ZP_BYTE:10 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 8: zp ZP_BYTE:2 [ cnt#11 cnt#2 ] 2.44: zp ZP_BYTE:3 [ cnt2#10 cnt2#11 ] 1.83: zp ZP_BYTE:4 [ cnt3#10 cnt3#11 ] 0.67: zp ZP_BYTE:9 [ cnt#12 ] 
Uplift Scope [inccnt] 4: zp ZP_BYTE:5 [ inccnt::return#0 ] 4: zp ZP_BYTE:7 [ inccnt::return#1 ] 1.5: zp ZP_BYTE:10 [ inccnt::return#2 ] 
Uplift Scope [main] 4: zp ZP_BYTE:6 [ main::$0 ] 4: zp ZP_BYTE:8 [ main::$1 ] 

Uplifting [] best 116 combination reg byte a [ cnt#11 cnt#2 ] reg byte y [ cnt2#10 cnt2#11 ] reg byte x [ cnt3#10 cnt3#11 ] zp ZP_BYTE:9 [ cnt#12 ] 
Limited combination testing to 100 combinations of 256 possible.
Uplifting [inccnt] best 95 combination reg byte a [ inccnt::return#0 ] reg byte a [ inccnt::return#1 ] reg byte a [ inccnt::return#2 ] 
Uplifting [main] best 83 combination reg byte a [ main::$0 ] reg byte a [ main::$1 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:9 [ cnt#12 ]
Uplifting [] best 83 combination zp ZP_BYTE:9 [ cnt#12 ] 
Allocated (was zp ZP_BYTE:9) zp ZP_BYTE:2 [ cnt#12 ]

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label SCREEN = $400
  .label cnt = 2
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG5 @2
b2:
//SEG6 [2] call main 
//SEG7 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
  jsr main
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
  //SEG11 [5] call inccnt 
  //SEG12 [15] phi from main to inccnt [phi:main->inccnt]
  inccnt_from_main:
  //SEG13 [15] phi (byte) cnt3#10 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->inccnt#0] -- vbuxx=vbuc1 
    ldx #0
  //SEG14 [15] phi (byte) cnt2#10 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->inccnt#1] -- vbuyy=vbuc1 
    ldy #0
  //SEG15 [15] phi (byte) cnt#11 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->inccnt#2] -- vbuaa=vbuc1 
    lda #0
    jsr inccnt
  //SEG16 [6] (byte) inccnt::return#0 ← (byte) inccnt::return#2
    jmp b1
  //SEG17 main::@1
  b1:
  //SEG18 [7] (byte~) main::$0 ← (byte) inccnt::return#0
  //SEG19 [8] *((const byte[256]) SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuaa 
    sta SCREEN
  //SEG20 [9] (byte) cnt#2 ← ++ (byte) cnt#12 -- vbuaa=_inc_vbuz1 
    lda cnt
    clc
    adc #1
  //SEG21 [10] call inccnt 
  //SEG22 [15] phi from main::@1 to inccnt [phi:main::@1->inccnt]
  inccnt_from_b1:
  //SEG23 [15] phi (byte) cnt3#10 = (byte) cnt3#11 [phi:main::@1->inccnt#0] -- register_copy 
  //SEG24 [15] phi (byte) cnt2#10 = (byte) cnt2#11 [phi:main::@1->inccnt#1] -- register_copy 
  //SEG25 [15] phi (byte) cnt#11 = (byte) cnt#2 [phi:main::@1->inccnt#2] -- register_copy 
    jsr inccnt
  //SEG26 [11] (byte) inccnt::return#1 ← (byte) inccnt::return#2
    jmp b2
  //SEG27 main::@2
  b2:
  //SEG28 [12] (byte~) main::$1 ← (byte) inccnt::return#1
  //SEG29 [13] *((const byte[256]) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$1 -- _deref_pbuc1=vbuaa 
    sta SCREEN+1
    jmp breturn
  //SEG30 main::@return
  breturn:
  //SEG31 [14] return 
    rts
}
//SEG32 inccnt
inccnt: {
  //SEG33 [16] (byte) cnt#12 ← ++ (byte) cnt#11 -- vbuz1=_inc_vbuaa 
    clc
    adc #1
    sta cnt
  //SEG34 [17] (byte) cnt2#11 ← ++ (byte) cnt2#10 -- vbuyy=_inc_vbuyy 
    iny
  //SEG35 [18] (byte) cnt3#11 ← ++ (byte) cnt3#10 -- vbuxx=_inc_vbuxx 
    inx
  //SEG36 [19] (byte) inccnt::return#2 ← (byte) cnt#12 -- vbuaa=vbuz1 
    lda cnt
    jmp breturn
  //SEG37 inccnt::@return
  breturn:
  //SEG38 [20] return 
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b2
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing instruction lda #0 with TXA
Removing instruction lda cnt
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction b2_from_bbegin:
Removing instruction b2:
Removing instruction main_from_b2:
Removing instruction bend_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction inccnt_from_main:
Removing instruction b1:
Removing instruction inccnt_from_b1:
Removing instruction b2:
Removing instruction breturn:
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) @2
(label) @begin
(label) @end
(byte[256]) SCREEN
(const byte[256]) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(byte) cnt
(byte) cnt#11 reg byte a 4.0
(byte) cnt#12 cnt zp ZP_BYTE:2 0.6666666666666666
(byte) cnt#2 reg byte a 4.0
(byte) cnt2
(byte) cnt2#10 reg byte y 2.0
(byte) cnt2#11 reg byte y 0.4444444444444444
(byte) cnt3
(byte) cnt3#10 reg byte x 1.3333333333333333
(byte) cnt3#11 reg byte x 0.5
(byte()) inccnt()
(label) inccnt::@return
(byte) inccnt::return
(byte) inccnt::return#0 reg byte a 4.0
(byte) inccnt::return#1 reg byte a 4.0
(byte) inccnt::return#2 reg byte a 1.5
(void()) main()
(byte~) main::$0 reg byte a 4.0
(byte~) main::$1 reg byte a 4.0
(label) main::@1
(label) main::@2
(label) main::@return

reg byte a [ cnt#11 cnt#2 ]
reg byte y [ cnt2#10 cnt2#11 ]
reg byte x [ cnt3#10 cnt3#11 ]
reg byte a [ inccnt::return#0 ]
reg byte a [ main::$0 ]
reg byte a [ inccnt::return#1 ]
reg byte a [ main::$1 ]
zp ZP_BYTE:2 [ cnt#12 ]
reg byte a [ inccnt::return#2 ]


FINAL ASSEMBLER
Score: 56

//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label SCREEN = $400
  .label cnt = 2
//SEG3 @begin
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG5 @2
//SEG6 [2] call main 
//SEG7 [4] phi from @2 to main [phi:@2->main]
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
//SEG9 @end
//SEG10 main
main: {
  //SEG11 [5] call inccnt 
  //SEG12 [15] phi from main to inccnt [phi:main->inccnt]
  //SEG13 [15] phi (byte) cnt3#10 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->inccnt#0] -- vbuxx=vbuc1 
    ldx #0
  //SEG14 [15] phi (byte) cnt2#10 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->inccnt#1] -- vbuyy=vbuc1 
    ldy #0
  //SEG15 [15] phi (byte) cnt#11 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->inccnt#2] -- vbuaa=vbuc1 
    txa
    jsr inccnt
  //SEG16 [6] (byte) inccnt::return#0 ← (byte) inccnt::return#2
  //SEG17 main::@1
  //SEG18 [7] (byte~) main::$0 ← (byte) inccnt::return#0
  //SEG19 [8] *((const byte[256]) SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuaa 
    sta SCREEN
  //SEG20 [9] (byte) cnt#2 ← ++ (byte) cnt#12 -- vbuaa=_inc_vbuz1 
    lda cnt
    clc
    adc #1
  //SEG21 [10] call inccnt 
  //SEG22 [15] phi from main::@1 to inccnt [phi:main::@1->inccnt]
  //SEG23 [15] phi (byte) cnt3#10 = (byte) cnt3#11 [phi:main::@1->inccnt#0] -- register_copy 
  //SEG24 [15] phi (byte) cnt2#10 = (byte) cnt2#11 [phi:main::@1->inccnt#1] -- register_copy 
  //SEG25 [15] phi (byte) cnt#11 = (byte) cnt#2 [phi:main::@1->inccnt#2] -- register_copy 
    jsr inccnt
  //SEG26 [11] (byte) inccnt::return#1 ← (byte) inccnt::return#2
  //SEG27 main::@2
  //SEG28 [12] (byte~) main::$1 ← (byte) inccnt::return#1
  //SEG29 [13] *((const byte[256]) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$1 -- _deref_pbuc1=vbuaa 
    sta SCREEN+1
  //SEG30 main::@return
  //SEG31 [14] return 
    rts
}
//SEG32 inccnt
inccnt: {
  //SEG33 [16] (byte) cnt#12 ← ++ (byte) cnt#11 -- vbuz1=_inc_vbuaa 
    clc
    adc #1
    sta cnt
  //SEG34 [17] (byte) cnt2#11 ← ++ (byte) cnt2#10 -- vbuyy=_inc_vbuyy 
    iny
  //SEG35 [18] (byte) cnt3#11 ← ++ (byte) cnt3#10 -- vbuxx=_inc_vbuxx 
    inx
  //SEG36 [19] (byte) inccnt::return#2 ← (byte) cnt#12 -- vbuaa=vbuz1 
  //SEG37 inccnt::@return
  //SEG38 [20] return 
    rts
}

