Identified constant variable (byte*) TEXT
Identified constant variable (byte*) main::SCREEN
Culled Empty Block (label) main::@2
Culled Empty Block (label) next_char::@3

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) TEXT#0 ← (const string) $0
  to:@1
main: scope:[main]  from @2
  (byte*) nxt#15 ← phi( @2/(byte*) nxt#14 )
  (byte*) main::SCREEN#0 ← ((byte*)) (number) $400
  (byte) main::i#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@3
  (byte) main::i#3 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
  (byte*) nxt#13 ← phi( main/(byte*) nxt#15 main::@3/(byte*) nxt#0 )
  call next_char 
  (byte) next_char::return#0 ← (byte) next_char::return#2
  to:main::@3
main::@3: scope:[main]  from main::@1
  (byte) main::i#2 ← phi( main::@1/(byte) main::i#3 )
  (byte*) nxt#7 ← phi( main::@1/(byte*) nxt#5 )
  (byte) next_char::return#3 ← phi( main::@1/(byte) next_char::return#0 )
  (byte~) main::$0 ← (byte) next_char::return#3
  (byte*) nxt#0 ← (byte*) nxt#7
  *((byte*) main::SCREEN#0 + (byte) main::i#2) ← (byte~) main::$0
  (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,$ff)
  (bool~) main::$1 ← (byte) main::i#1 != rangelast(0,$ff)
  if((bool~) main::$1) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  (byte*) nxt#8 ← phi( main::@3/(byte*) nxt#0 )
  (byte*) nxt#1 ← (byte*) nxt#8
  return 
  to:@return
@1: scope:[]  from @begin
  (byte*) nxt#2 ← (byte*) TEXT#0
  to:@2
next_char: scope:[next_char]  from main::@1
  (byte*) nxt#9 ← phi( main::@1/(byte*) nxt#13 )
  (byte) next_char::c#0 ← *((byte*) nxt#9)
  (bool~) next_char::$0 ← (byte) next_char::c#0 == (byte) '@'
  (bool~) next_char::$1 ← ! (bool~) next_char::$0
  if((bool~) next_char::$1) goto next_char::@1
  to:next_char::@2
next_char::@1: scope:[next_char]  from next_char next_char::@2
  (byte) next_char::c#2 ← phi( next_char/(byte) next_char::c#0 next_char::@2/(byte) next_char::c#1 )
  (byte*) nxt#10 ← phi( next_char/(byte*) nxt#9 next_char::@2/(byte*) nxt#4 )
  (byte*) nxt#3 ← ++ (byte*) nxt#10
  (byte) next_char::return#1 ← (byte) next_char::c#2
  to:next_char::@return
next_char::@2: scope:[next_char]  from next_char
  (byte*) nxt#4 ← (byte*) TEXT#0
  (byte) next_char::c#1 ← *((byte*) nxt#4)
  to:next_char::@1
next_char::@return: scope:[next_char]  from next_char::@1
  (byte*) nxt#11 ← phi( next_char::@1/(byte*) nxt#3 )
  (byte) next_char::return#4 ← phi( next_char::@1/(byte) next_char::return#1 )
  (byte) next_char::return#2 ← (byte) next_char::return#4
  (byte*) nxt#5 ← (byte*) nxt#11
  return 
  to:@return
@2: scope:[]  from @1
  (byte*) nxt#14 ← phi( @1/(byte*) nxt#2 )
  call main 
  to:@3
@3: scope:[]  from @2
  (byte*) nxt#12 ← phi( @2/(byte*) nxt#1 )
  (byte*) nxt#6 ← (byte*) nxt#12
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(const string) $0 = (string) "cml @"
(label) @1
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) TEXT
(byte*) TEXT#0
(void()) main()
(byte~) main::$0
(bool~) main::$1
(label) main::@1
(label) main::@3
(label) main::@return
(byte*) main::SCREEN
(byte*) main::SCREEN#0
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte()) next_char()
(bool~) next_char::$0
(bool~) next_char::$1
(label) next_char::@1
(label) next_char::@2
(label) next_char::@return
(byte) next_char::c
(byte) next_char::c#0
(byte) next_char::c#1
(byte) next_char::c#2
(byte) next_char::return
(byte) next_char::return#0
(byte) next_char::return#1
(byte) next_char::return#2
(byte) next_char::return#3
(byte) next_char::return#4
(byte*) nxt
(byte*) nxt#0
(byte*) nxt#1
(byte*) nxt#10
(byte*) nxt#11
(byte*) nxt#12
(byte*) nxt#13
(byte*) nxt#14
(byte*) nxt#15
(byte*) nxt#2
(byte*) nxt#3
(byte*) nxt#4
(byte*) nxt#5
(byte*) nxt#6
(byte*) nxt#7
(byte*) nxt#8
(byte*) nxt#9

Inlining cast (byte*) main::SCREEN#0 ← (byte*)(number) $400
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Successful SSA optimization PassNCastSimplification
Inversing boolean not [21] (bool~) next_char::$1 ← (byte) next_char::c#0 != (byte) '@' from [20] (bool~) next_char::$0 ← (byte) next_char::c#0 == (byte) '@'
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte) next_char::return#0 = (byte) next_char::return#3 
Alias (byte) main::i#2 = (byte) main::i#3 
Alias (byte*) nxt#0 = (byte*) nxt#7 (byte*) nxt#8 (byte*) nxt#1 
Alias (byte*) TEXT#0 = (byte*) nxt#2 (byte*) nxt#14 
Alias (byte) next_char::return#1 = (byte) next_char::c#2 (byte) next_char::return#4 (byte) next_char::return#2 
Alias (byte*) nxt#11 = (byte*) nxt#3 (byte*) nxt#5 
Alias (byte*) nxt#12 = (byte*) nxt#6 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte*) nxt#15 (byte*) TEXT#0
Identical Phi Values (byte*) nxt#0 (byte*) nxt#11
Identical Phi Values (byte*) nxt#9 (byte*) nxt#13
Identical Phi Values (byte*) nxt#12 (byte*) nxt#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$1 [13] if((byte) main::i#1!=rangelast(0,$ff)) goto main::@1
Simple Condition (bool~) next_char::$1 [22] if((byte) next_char::c#0!=(byte) '@') goto next_char::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) TEXT#0 = $0
Constant (const byte*) main::SCREEN#0 = (byte*) 1024
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) nxt#4 = TEXT#0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [11] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [13] if(main::i#1!=rangelast(0,$ff)) goto main::@1 to (number) 0
Adding number conversion cast (unumber) 0 in if((byte) main::i#1!=(number) 0) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte*) nxt#4
Constant inlined $0 = (const byte*) TEXT#0
Constant inlined main::i#0 = (byte) 0
Constant inlined nxt#4 = (const byte*) TEXT#0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@4(between main::@3 and main::@1)
Added new block during phi lifting next_char::@4(between next_char and next_char::@1)
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 @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:3 
Calls in [main] to next_char:8 

Created 4 initial phi equivalence classes
Coalesced [15] nxt#16 ← nxt#11
Coalesced [16] main::i#4 ← main::i#1
Coalesced [20] next_char::return#6 ← next_char::c#1
Coalesced [24] nxt#17 ← nxt#13
Coalesced [25] next_char::return#5 ← next_char::c#0
Coalesced down to 3 phi equivalence classes
Culled Empty Block (label) @1
Culled Empty Block (label) @3
Culled Empty Block (label) main::@4
Culled Empty Block (label) next_char::@4
Renumbering block @2 to @1
Renumbering block main::@3 to main::@2
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::@2
  [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
  [5] (byte*) nxt#13 ← phi( main/(const byte*) TEXT#0 main::@2/(byte*) nxt#11 )
  [6] call next_char 
  [7] (byte) next_char::return#0 ← (byte) next_char::return#1
  to:main::@2
main::@2: scope:[main]  from main::@1
  [8] (byte~) main::$0 ← (byte) next_char::return#0
  [9] *((const byte*) main::SCREEN#0 + (byte) main::i#2) ← (byte~) main::$0
  [10] (byte) main::i#1 ← ++ (byte) main::i#2
  [11] if((byte) main::i#1!=(byte) 0) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  [12] return 
  to:@return
next_char: scope:[next_char]  from main::@1
  [13] (byte) next_char::c#0 ← *((byte*) nxt#13)
  [14] if((byte) next_char::c#0!=(byte) '@') goto next_char::@1
  to:next_char::@2
next_char::@2: scope:[next_char]  from next_char
  [15] (byte) next_char::c#1 ← *((const byte*) TEXT#0)
  to:next_char::@1
next_char::@1: scope:[next_char]  from next_char next_char::@2
  [16] (byte) next_char::return#1 ← phi( next_char/(byte) next_char::c#0 next_char::@2/(byte) next_char::c#1 )
  [16] (byte*) nxt#10 ← phi( next_char/(byte*) nxt#13 next_char::@2/(const byte*) TEXT#0 )
  [17] (byte*) nxt#11 ← ++ (byte*) nxt#10
  to:next_char::@return
next_char::@return: scope:[next_char]  from next_char::@1
  [18] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) TEXT
(void()) main()
(byte~) main::$0 22.0
(byte*) main::SCREEN
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 6.6000000000000005
(byte()) next_char()
(byte) next_char::c
(byte) next_char::c#0 3.0
(byte) next_char::c#1 4.0
(byte) next_char::return
(byte) next_char::return#0 22.0
(byte) next_char::return#1 3.75
(byte*) nxt
(byte*) nxt#10 4.0
(byte*) nxt#11 1.625
(byte*) nxt#13 5.0

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ nxt#10 nxt#13 nxt#11 ]
[ next_char::return#1 next_char::c#0 next_char::c#1 ]
Added variable next_char::return#0 to zero page equivalence class [ next_char::return#0 ]
Added variable main::$0 to zero page equivalence class [ main::$0 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ nxt#10 nxt#13 nxt#11 ]
[ next_char::return#1 next_char::c#0 next_char::c#1 ]
[ next_char::return#0 ]
[ main::$0 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_WORD:3 [ nxt#10 nxt#13 nxt#11 ]
Allocated zp ZP_BYTE:5 [ next_char::return#1 next_char::c#0 next_char::c#1 ]
Allocated zp ZP_BYTE:6 [ next_char::return#0 ]
Allocated zp ZP_BYTE:7 [ main::$0 ]

INITIAL ASM
  // File Comments
// Clobber problem in next_char return value
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label nxt = 3
  // @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
main: {
    .label SCREEN = $400
    .label _0 = 7
    .label i = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    // [5] phi (byte*) nxt#13 = (const byte*) TEXT#0 [phi:main->main::@1#1] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    jmp b1
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  b1_from_b2:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy 
    // [5] phi (byte*) nxt#13 = (byte*) nxt#11 [phi:main::@2->main::@1#1] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] call next_char 
    jsr next_char
    // [7] (byte) next_char::return#0 ← (byte) next_char::return#1 -- vbuz1=vbuz2 
    lda next_char.return_1
    sta next_char.return
    jmp b2
    // main::@2
  b2:
    // [8] (byte~) main::$0 ← (byte) next_char::return#0 -- vbuz1=vbuz2 
    lda next_char.return
    sta _0
    // [9] *((const byte*) main::SCREEN#0 + (byte) main::i#2) ← (byte~) main::$0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda _0
    ldy i
    sta SCREEN,y
    // [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc i
    // [11] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuz1_neq_0_then_la1 
    lda i
    cmp #0
    bne b1_from_b2
    jmp breturn
    // main::@return
  breturn:
    // [12] return 
    rts
}
  // next_char
// Find the next char of the text
next_char: {
    .label return = 6
    .label c = 5
    .label return_1 = 5
    // [13] (byte) next_char::c#0 ← *((byte*) nxt#13) -- vbuz1=_deref_pbuz2 
    ldy #0
    lda (nxt),y
    sta c
    // [14] if((byte) next_char::c#0!=(byte) '@') goto next_char::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #'@'
    cmp c
    bne b1_from_next_char
    jmp b2
    // next_char::@2
  b2:
    // [15] (byte) next_char::c#1 ← *((const byte*) TEXT#0) -- vbuz1=_deref_pbuc1 
    lda TEXT
    sta c
    // [16] phi from next_char::@2 to next_char::@1 [phi:next_char::@2->next_char::@1]
  b1_from_b2:
    // [16] phi (byte) next_char::return#1 = (byte) next_char::c#1 [phi:next_char::@2->next_char::@1#0] -- register_copy 
    // [16] phi (byte*) nxt#10 = (const byte*) TEXT#0 [phi:next_char::@2->next_char::@1#1] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    jmp b1
    // [16] phi from next_char to next_char::@1 [phi:next_char->next_char::@1]
  b1_from_next_char:
    // [16] phi (byte) next_char::return#1 = (byte) next_char::c#0 [phi:next_char->next_char::@1#0] -- register_copy 
    // [16] phi (byte*) nxt#10 = (byte*) nxt#13 [phi:next_char->next_char::@1#1] -- register_copy 
    jmp b1
    // next_char::@1
  b1:
    // [17] (byte*) nxt#11 ← ++ (byte*) nxt#10 -- pbuz1=_inc_pbuz1 
    inc nxt
    bne !+
    inc nxt+1
  !:
    jmp breturn
    // next_char::@return
  breturn:
    // [18] return 
    rts
}
  // File Data
  TEXT: .text "cml @"

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [13] (byte) next_char::c#0 ← *((byte*) nxt#13) [ nxt#13 next_char::c#0 ] ( main:2::next_char:6 [ main::i#2 nxt#13 next_char::c#0 ] ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Statement [13] (byte) next_char::c#0 ← *((byte*) nxt#13) [ nxt#13 next_char::c#0 ] ( main:2::next_char:6 [ main::i#2 nxt#13 next_char::c#0 ] ) always clobbers reg byte a reg byte y 
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , 
Potential registers zp ZP_WORD:3 [ nxt#10 nxt#13 nxt#11 ] : zp ZP_WORD:3 , 
Potential registers zp ZP_BYTE:5 [ next_char::return#1 next_char::c#0 next_char::c#1 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:6 [ next_char::return#0 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:7 [ main::$0 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 23.1: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 22: zp ZP_BYTE:7 [ main::$0 ] 
Uplift Scope [next_char] 22: zp ZP_BYTE:6 [ next_char::return#0 ] 10.75: zp ZP_BYTE:5 [ next_char::return#1 next_char::c#0 next_char::c#1 ] 
Uplift Scope [] 10.62: zp ZP_WORD:3 [ nxt#10 nxt#13 nxt#11 ] 

Uplifting [main] best 587 combination reg byte x [ main::i#2 main::i#1 ] reg byte a [ main::$0 ] 
Uplifting [next_char] best 510 combination reg byte a [ next_char::return#0 ] reg byte y [ next_char::return#1 next_char::c#0 next_char::c#1 ] 
Uplifting [] best 510 combination zp ZP_WORD:3 [ nxt#10 nxt#13 nxt#11 ] 
Allocated (was zp ZP_WORD:3) zp ZP_WORD:2 [ nxt#10 nxt#13 nxt#11 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Clobber problem in next_char return value
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label nxt = 2
  // @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
main: {
    .label SCREEN = $400
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi (byte*) nxt#13 = (const byte*) TEXT#0 [phi:main->main::@1#1] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    jmp b1
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  b1_from_b2:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy 
    // [5] phi (byte*) nxt#13 = (byte*) nxt#11 [phi:main::@2->main::@1#1] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] call next_char 
    jsr next_char
    // [7] (byte) next_char::return#0 ← (byte) next_char::return#1 -- vbuaa=vbuyy 
    tya
    jmp b2
    // main::@2
  b2:
    // [8] (byte~) main::$0 ← (byte) next_char::return#0
    // [9] *((const byte*) main::SCREEN#0 + (byte) main::i#2) ← (byte~) main::$0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [11] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuxx_neq_0_then_la1 
    cpx #0
    bne b1_from_b2
    jmp breturn
    // main::@return
  breturn:
    // [12] return 
    rts
}
  // next_char
// Find the next char of the text
next_char: {
    // [13] (byte) next_char::c#0 ← *((byte*) nxt#13) -- vbuyy=_deref_pbuz1 
    ldy #0
    lda (nxt),y
    tay
    // [14] if((byte) next_char::c#0!=(byte) '@') goto next_char::@1 -- vbuyy_neq_vbuc1_then_la1 
    cpy #'@'
    bne b1_from_next_char
    jmp b2
    // next_char::@2
  b2:
    // [15] (byte) next_char::c#1 ← *((const byte*) TEXT#0) -- vbuyy=_deref_pbuc1 
    ldy TEXT
    // [16] phi from next_char::@2 to next_char::@1 [phi:next_char::@2->next_char::@1]
  b1_from_b2:
    // [16] phi (byte) next_char::return#1 = (byte) next_char::c#1 [phi:next_char::@2->next_char::@1#0] -- register_copy 
    // [16] phi (byte*) nxt#10 = (const byte*) TEXT#0 [phi:next_char::@2->next_char::@1#1] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    jmp b1
    // [16] phi from next_char to next_char::@1 [phi:next_char->next_char::@1]
  b1_from_next_char:
    // [16] phi (byte) next_char::return#1 = (byte) next_char::c#0 [phi:next_char->next_char::@1#0] -- register_copy 
    // [16] phi (byte*) nxt#10 = (byte*) nxt#13 [phi:next_char->next_char::@1#1] -- register_copy 
    jmp b1
    // next_char::@1
  b1:
    // [17] (byte*) nxt#11 ← ++ (byte*) nxt#10 -- pbuz1=_inc_pbuz1 
    inc nxt
    bne !+
    inc nxt+1
  !:
    jmp breturn
    // next_char::@return
  breturn:
    // [18] return 
    rts
}
  // File Data
  TEXT: .text "cml @"

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp breturn
Removing instruction jmp b2
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b2 with b1
Replacing label b1_from_next_char with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b2:
Removing instruction b1_from_next_char:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b2:
Removing instruction breturn:
Removing instruction b2:
Removing instruction b1_from_b2:
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 b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) TEXT
(const byte*) TEXT#0 TEXT = (string) "cml @"
(void()) main()
(byte~) main::$0 reg byte a 22.0
(label) main::@1
(label) main::@2
(label) main::@return
(byte*) main::SCREEN
(const byte*) main::SCREEN#0 SCREEN = (byte*) 1024
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 6.6000000000000005
(byte()) next_char()
(label) next_char::@1
(label) next_char::@2
(label) next_char::@return
(byte) next_char::c
(byte) next_char::c#0 reg byte y 3.0
(byte) next_char::c#1 reg byte y 4.0
(byte) next_char::return
(byte) next_char::return#0 reg byte a 22.0
(byte) next_char::return#1 reg byte y 3.75
(byte*) nxt
(byte*) nxt#10 nxt zp ZP_WORD:2 4.0
(byte*) nxt#11 nxt zp ZP_WORD:2 1.625
(byte*) nxt#13 nxt zp ZP_WORD:2 5.0

reg byte x [ main::i#2 main::i#1 ]
zp ZP_WORD:2 [ nxt#10 nxt#13 nxt#11 ]
reg byte y [ next_char::return#1 next_char::c#0 next_char::c#1 ]
reg byte a [ next_char::return#0 ]
reg byte a [ main::$0 ]


FINAL ASSEMBLER
Score: 366

  // File Comments
// Clobber problem in next_char return value
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label nxt = 2
  // @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
main: {
    .label SCREEN = $400
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi (byte*) nxt#13 = (const byte*) TEXT#0 [phi:main->main::@1#1] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy 
    // [5] phi (byte*) nxt#13 = (byte*) nxt#11 [phi:main::@2->main::@1#1] -- register_copy 
    // main::@1
  b1:
    // next_char()
    // [6] call next_char 
    jsr next_char
    // [7] (byte) next_char::return#0 ← (byte) next_char::return#1 -- vbuaa=vbuyy 
    tya
    // main::@2
    // [8] (byte~) main::$0 ← (byte) next_char::return#0
    // SCREEN[i] = next_char()
    // [9] *((const byte*) main::SCREEN#0 + (byte) main::i#2) ← (byte~) main::$0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // for( byte i: 0..255)
    // [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [11] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuxx_neq_0_then_la1 
    cpx #0
    bne b1
    // main::@return
    // }
    // [12] return 
    rts
}
  // next_char
// Find the next char of the text
next_char: {
    // c = *nxt
    // [13] (byte) next_char::c#0 ← *((byte*) nxt#13) -- vbuyy=_deref_pbuz1 
    ldy #0
    lda (nxt),y
    tay
    // if(c=='@')
    // [14] if((byte) next_char::c#0!=(byte) '@') goto next_char::@1 -- vbuyy_neq_vbuc1_then_la1 
    cpy #'@'
    bne b1
    // next_char::@2
    // c = *nxt
    // [15] (byte) next_char::c#1 ← *((const byte*) TEXT#0) -- vbuyy=_deref_pbuc1 
    ldy TEXT
    // [16] phi from next_char::@2 to next_char::@1 [phi:next_char::@2->next_char::@1]
    // [16] phi (byte) next_char::return#1 = (byte) next_char::c#1 [phi:next_char::@2->next_char::@1#0] -- register_copy 
    // [16] phi (byte*) nxt#10 = (const byte*) TEXT#0 [phi:next_char::@2->next_char::@1#1] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    // [16] phi from next_char to next_char::@1 [phi:next_char->next_char::@1]
    // [16] phi (byte) next_char::return#1 = (byte) next_char::c#0 [phi:next_char->next_char::@1#0] -- register_copy 
    // [16] phi (byte*) nxt#10 = (byte*) nxt#13 [phi:next_char->next_char::@1#1] -- register_copy 
    // next_char::@1
  b1:
    // nxt++;
    // [17] (byte*) nxt#11 ← ++ (byte*) nxt#10 -- pbuz1=_inc_pbuz1 
    inc nxt
    bne !+
    inc nxt+1
  !:
    // next_char::@return
    // }
    // [18] return 
    rts
}
  // File Data
  TEXT: .text "cml @"

