Warning! Adding boolean cast to non-boolean condition *((byte*) main::msg)
Identified constant variable (byte*) SCREEN
Culled Empty Block (label) main::@9
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@10
Culled Empty Block (label) main::@11
Culled Empty Block (label) main::@12
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@8

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1

(void()) main()
main: scope:[main]  from @1
  (byte*) main::line#0 ← (byte*)(number) $400
  (byte*) main::cursor#0 ← (byte*) main::line#0
  (byte*) main::msg#0 ← (const byte*) MESSAGE
  to:main::@1
main::@1: scope:[main]  from main main::@6
  (byte*) main::cursor#5 ← phi( main/(byte*) main::cursor#0 main::@6/(byte*) main::cursor#6 )
  (byte*) main::line#4 ← phi( main/(byte*) main::line#0 main::@6/(byte*) main::line#5 )
  (byte*) main::msg#2 ← phi( main/(byte*) main::msg#0 main::@6/(byte*) main::msg#1 )
  (bool~) main::$1 ← (number) 0 != *((byte*) main::msg#2)
  if((bool~) main::$1) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  (byte*) main::cursor#4 ← phi( main::@1/(byte*) main::cursor#5 )
  (byte*) main::line#3 ← phi( main::@1/(byte*) main::line#4 )
  (byte*) main::msg#3 ← phi( main::@1/(byte*) main::msg#2 )
  if(*((byte*) main::msg#3)==(byte) '
'pm) goto main::@4
  to:main::@5
main::@4: scope:[main]  from main::@2
  (byte*) main::msg#6 ← phi( main::@2/(byte*) main::msg#3 )
  (byte*) main::line#2 ← phi( main::@2/(byte*) main::line#3 )
  (byte*) main::line#1 ← (byte*) main::line#2 + (number) $28
  (byte*) main::cursor#1 ← (byte*) main::line#1
  to:main::@6
main::@5: scope:[main]  from main::@2
  (byte*) main::line#6 ← phi( main::@2/(byte*) main::line#3 )
  (byte*) main::cursor#3 ← phi( main::@2/(byte*) main::cursor#4 )
  (byte*) main::msg#4 ← phi( main::@2/(byte*) main::msg#3 )
  (number~) main::$0 ← *((byte*) main::msg#4) & (number) $3f
  *((byte*) main::cursor#3) ← (number~) main::$0
  (byte*) main::cursor#2 ← ++ (byte*) main::cursor#3
  to:main::@6
main::@6: scope:[main]  from main::@4 main::@5
  (byte*) main::cursor#6 ← phi( main::@4/(byte*) main::cursor#1 main::@5/(byte*) main::cursor#2 )
  (byte*) main::line#5 ← phi( main::@4/(byte*) main::line#1 main::@5/(byte*) main::line#6 )
  (byte*) main::msg#5 ← phi( main::@4/(byte*) main::msg#6 main::@5/(byte*) main::msg#4 )
  (byte*) main::msg#1 ← ++ (byte*) main::msg#5
  to:main::@1
main::@return: scope:[main]  from main::@1
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(const byte*) MESSAGE[]  = (byte*) "hello
world"pm
(void()) main()
(number~) main::$0
(bool~) main::$1
(label) main::@1
(label) main::@2
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return
(byte*) main::cursor
(byte*) main::cursor#0
(byte*) main::cursor#1
(byte*) main::cursor#2
(byte*) main::cursor#3
(byte*) main::cursor#4
(byte*) main::cursor#5
(byte*) main::cursor#6
(byte*) main::line
(byte*) main::line#0
(byte*) main::line#1
(byte*) main::line#2
(byte*) main::line#3
(byte*) main::line#4
(byte*) main::line#5
(byte*) main::line#6
(byte*) main::msg
(byte*) main::msg#0
(byte*) main::msg#1
(byte*) main::msg#2
(byte*) main::msg#3
(byte*) main::msg#4
(byte*) main::msg#5
(byte*) main::msg#6

Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (number) 0 != *((byte*) main::msg#2)
Adding number conversion cast (unumber) $28 in (byte*) main::line#1 ← (byte*) main::line#2 + (number) $28
Adding number conversion cast (unumber) $3f in (number~) main::$0 ← *((byte*) main::msg#4) & (number) $3f
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← *((byte*) main::msg#4) & (unumber)(number) $3f
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast $28
Simplifying constant integer cast $3f
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) $3f
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$0 ← *((byte*) main::msg#4) & (byte) $3f
Alias (byte*) main::cursor#0 = (byte*) main::line#0 
Alias (byte*) main::msg#2 = (byte*) main::msg#3 (byte*) main::msg#6 (byte*) main::msg#4 
Alias (byte*) main::line#2 = (byte*) main::line#3 (byte*) main::line#4 (byte*) main::line#6 
Alias (byte*) main::cursor#3 = (byte*) main::cursor#4 (byte*) main::cursor#5 
Alias (byte*) main::cursor#1 = (byte*) main::line#1 
Successful SSA optimization Pass2AliasElimination
Alias (byte*) main::msg#2 = (byte*) main::msg#5 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$1 [4] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) main::cursor#0 = (byte*) 1024
Constant (const byte*) main::msg#0 = MESSAGE
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte*) main::cursor#0
Inlining constant with var siblings (const byte*) main::msg#0
Constant inlined main::cursor#0 = (byte*) 1024
Constant inlined main::msg#0 = (const byte*) MESSAGE
Successful SSA optimization Pass2ConstantInlining
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 5 initial phi equivalence classes
Coalesced [13] main::line#9 ← main::line#2
Coalesced [14] main::cursor#9 ← main::cursor#2
Coalesced [17] main::msg#7 ← main::msg#1
Coalesced (already) [18] main::line#7 ← main::line#5
Coalesced [19] main::cursor#7 ← main::cursor#6
Not coalescing [21] main::line#8 ← main::cursor#1
Coalesced [22] main::cursor#8 ← main::cursor#1
Coalesced down to 3 phi equivalence classes
Culled Empty Block (label) @2
Renumbering block main::@4 to main::@3
Renumbering block main::@5 to main::@4
Renumbering block main::@6 to main::@5
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()

(void()) main()
main: scope:[main]  from @1
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@5
  [5] (byte*) main::cursor#3 ← phi( main/(byte*) 1024 main::@5/(byte*) main::cursor#6 )
  [5] (byte*) main::line#2 ← phi( main/(byte*) 1024 main::@5/(byte*) main::line#5 )
  [5] (byte*) main::msg#2 ← phi( main/(const byte*) MESSAGE main::@5/(byte*) main::msg#1 )
  [6] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@1
  [7] return 
  to:@return
main::@2: scope:[main]  from main::@1
  [8] if(*((byte*) main::msg#2)==(byte) '
'pm) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@2
  [9] (byte~) main::$0 ← *((byte*) main::msg#2) & (byte) $3f
  [10] *((byte*) main::cursor#3) ← (byte~) main::$0
  [11] (byte*) main::cursor#2 ← ++ (byte*) main::cursor#3
  to:main::@5
main::@5: scope:[main]  from main::@3 main::@4
  [12] (byte*) main::cursor#6 ← phi( main::@3/(byte*) main::cursor#1 main::@4/(byte*) main::cursor#2 )
  [12] (byte*) main::line#5 ← phi( main::@3/(byte*) main::line#8 main::@4/(byte*) main::line#2 )
  [13] (byte*) main::msg#1 ← ++ (byte*) main::msg#2
  to:main::@1
main::@3: scope:[main]  from main::@2
  [14] (byte*) main::cursor#1 ← (byte*) main::line#2 + (byte) $28
  [15] (byte*) main::line#8 ← (byte*) main::cursor#1
  to:main::@5


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte~) main::$0 22.0
(byte*) main::cursor
(byte*) main::cursor#1 16.5
(byte*) main::cursor#2 22.0
(byte*) main::cursor#3 6.6000000000000005
(byte*) main::cursor#6 16.5
(byte*) main::line
(byte*) main::line#2 5.5
(byte*) main::line#5 16.5
(byte*) main::line#8 22.0
(byte*) main::msg
(byte*) main::msg#1 22.0
(byte*) main::msg#2 6.111111111111112

Initial phi equivalence classes
[ main::msg#2 main::msg#1 ]
[ main::line#2 main::line#5 main::line#8 ]
[ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ]
Added variable main::$0 to live range equivalence class [ main::$0 ]
Complete equivalence classes
[ main::msg#2 main::msg#1 ]
[ main::line#2 main::line#5 main::line#8 ]
[ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ]
[ main::$0 ]
Allocated zp[2]:2 [ main::msg#2 main::msg#1 ]
Allocated zp[2]:4 [ main::line#2 main::line#5 main::line#8 ]
Allocated zp[2]:6 [ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ]
Allocated zp[1]:8 [ main::$0 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Test using some simple supported string escape \n in both string and char
// Uses encoding PETSCII mixed
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @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 __0 = 8
    .label cursor = 6
    .label msg = 2
    .label line = 4
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte*) main::cursor#3 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta.z cursor
    lda #>$400
    sta.z cursor+1
    // [5] phi (byte*) main::line#2 = (byte*) 1024 [phi:main->main::@1#1] -- pbuz1=pbuc1 
    lda #<$400
    sta.z line
    lda #>$400
    sta.z line+1
    // [5] phi (byte*) main::msg#2 = (const byte*) MESSAGE [phi:main->main::@1#2] -- pbuz1=pbuc1 
    lda #<MESSAGE
    sta.z msg
    lda #>MESSAGE
    sta.z msg+1
    jmp __b1
    // main::@1
  __b1:
    // [6] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 -- vbuc1_neq__deref_pbuz1_then_la1 
    ldy #0
    lda (msg),y
    cmp #0
    bne __b2
    jmp __breturn
    // main::@return
  __breturn:
    // [7] return 
    rts
    // main::@2
  __b2:
    // [8] if(*((byte*) main::msg#2)==(byte) ' 'pm) goto main::@3 -- _deref_pbuz1_eq_vbuc1_then_la1 
  .encoding "petscii_mixed"
    lda #'\n'
    ldy #0
    cmp (msg),y
    beq __b3
    jmp __b4
    // main::@4
  __b4:
    // [9] (byte~) main::$0 ← *((byte*) main::msg#2) & (byte) $3f -- vbuz1=_deref_pbuz2_band_vbuc1 
    lda #$3f
    ldy #0
    and (msg),y
    sta.z __0
    // [10] *((byte*) main::cursor#3) ← (byte~) main::$0 -- _deref_pbuz1=vbuz2 
    lda.z __0
    ldy #0
    sta (cursor),y
    // [11] (byte*) main::cursor#2 ← ++ (byte*) main::cursor#3 -- pbuz1=_inc_pbuz1 
    inc.z cursor
    bne !+
    inc.z cursor+1
  !:
    // [12] phi from main::@3 main::@4 to main::@5 [phi:main::@3/main::@4->main::@5]
  __b5_from___b3:
  __b5_from___b4:
    // [12] phi (byte*) main::cursor#6 = (byte*) main::cursor#1 [phi:main::@3/main::@4->main::@5#0] -- register_copy 
    // [12] phi (byte*) main::line#5 = (byte*) main::line#8 [phi:main::@3/main::@4->main::@5#1] -- register_copy 
    jmp __b5
    // main::@5
  __b5:
    // [13] (byte*) main::msg#1 ← ++ (byte*) main::msg#2 -- pbuz1=_inc_pbuz1 
    inc.z msg
    bne !+
    inc.z msg+1
  !:
    // [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
  __b1_from___b5:
    // [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#6 [phi:main::@5->main::@1#0] -- register_copy 
    // [5] phi (byte*) main::line#2 = (byte*) main::line#5 [phi:main::@5->main::@1#1] -- register_copy 
    // [5] phi (byte*) main::msg#2 = (byte*) main::msg#1 [phi:main::@5->main::@1#2] -- register_copy 
    jmp __b1
    // main::@3
  __b3:
    // [14] (byte*) main::cursor#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz2_plus_vbuc1 
    lda #$28
    clc
    adc.z line
    sta.z cursor
    lda #0
    adc.z line+1
    sta.z cursor+1
    // [15] (byte*) main::line#8 ← (byte*) main::cursor#1 -- pbuz1=pbuz2 
    lda.z cursor
    sta.z line
    lda.z cursor+1
    sta.z line+1
    jmp __b5_from___b3
}
  // File Data
  MESSAGE: .text @"hello\nworld"
  .byte 0

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 [ main::msg#2 main::line#2 main::cursor#3 ] ( main:2 [ main::msg#2 main::line#2 main::cursor#3 ] ) always clobbers reg byte a reg byte y 
Statement [8] if(*((byte*) main::msg#2)==(byte) '
'pm) goto main::@3 [ main::msg#2 main::line#2 main::cursor#3 ] ( main:2 [ main::msg#2 main::line#2 main::cursor#3 ] ) always clobbers reg byte a reg byte y 
Statement [9] (byte~) main::$0 ← *((byte*) main::msg#2) & (byte) $3f [ main::msg#2 main::line#2 main::cursor#3 main::$0 ] ( main:2 [ main::msg#2 main::line#2 main::cursor#3 main::$0 ] ) always clobbers reg byte a reg byte y 
Statement [10] *((byte*) main::cursor#3) ← (byte~) main::$0 [ main::msg#2 main::line#2 main::cursor#3 ] ( main:2 [ main::msg#2 main::line#2 main::cursor#3 ] ) always clobbers reg byte y 
Statement [14] (byte*) main::cursor#1 ← (byte*) main::line#2 + (byte) $28 [ main::msg#2 main::cursor#1 ] ( main:2 [ main::msg#2 main::cursor#1 ] ) always clobbers reg byte a 
Statement [15] (byte*) main::line#8 ← (byte*) main::cursor#1 [ main::msg#2 main::line#8 main::cursor#1 ] ( main:2 [ main::msg#2 main::line#8 main::cursor#1 ] ) always clobbers reg byte a 
Potential registers zp[2]:2 [ main::msg#2 main::msg#1 ] : zp[2]:2 , 
Potential registers zp[2]:4 [ main::line#2 main::line#5 main::line#8 ] : zp[2]:4 , 
Potential registers zp[2]:6 [ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ] : zp[2]:6 , 
Potential registers zp[1]:8 [ main::$0 ] : zp[1]:8 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 61.6: zp[2]:6 [ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ] 44: zp[2]:4 [ main::line#2 main::line#5 main::line#8 ] 28.11: zp[2]:2 [ main::msg#2 main::msg#1 ] 22: zp[1]:8 [ main::$0 ] 
Uplift Scope [] 

Uplifting [main] best 1463 combination zp[2]:6 [ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ] zp[2]:4 [ main::line#2 main::line#5 main::line#8 ] zp[2]:2 [ main::msg#2 main::msg#1 ] reg byte a [ main::$0 ] 
Uplifting [] best 1463 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test using some simple supported string escape \n in both string and char
// Uses encoding PETSCII mixed
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @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 cursor = 6
    .label msg = 2
    .label line = 4
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte*) main::cursor#3 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta.z cursor
    lda #>$400
    sta.z cursor+1
    // [5] phi (byte*) main::line#2 = (byte*) 1024 [phi:main->main::@1#1] -- pbuz1=pbuc1 
    lda #<$400
    sta.z line
    lda #>$400
    sta.z line+1
    // [5] phi (byte*) main::msg#2 = (const byte*) MESSAGE [phi:main->main::@1#2] -- pbuz1=pbuc1 
    lda #<MESSAGE
    sta.z msg
    lda #>MESSAGE
    sta.z msg+1
    jmp __b1
    // main::@1
  __b1:
    // [6] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 -- vbuc1_neq__deref_pbuz1_then_la1 
    ldy #0
    lda (msg),y
    cmp #0
    bne __b2
    jmp __breturn
    // main::@return
  __breturn:
    // [7] return 
    rts
    // main::@2
  __b2:
    // [8] if(*((byte*) main::msg#2)==(byte) ' 'pm) goto main::@3 -- _deref_pbuz1_eq_vbuc1_then_la1 
  .encoding "petscii_mixed"
    lda #'\n'
    ldy #0
    cmp (msg),y
    beq __b3
    jmp __b4
    // main::@4
  __b4:
    // [9] (byte~) main::$0 ← *((byte*) main::msg#2) & (byte) $3f -- vbuaa=_deref_pbuz1_band_vbuc1 
    lda #$3f
    ldy #0
    and (msg),y
    // [10] *((byte*) main::cursor#3) ← (byte~) main::$0 -- _deref_pbuz1=vbuaa 
    ldy #0
    sta (cursor),y
    // [11] (byte*) main::cursor#2 ← ++ (byte*) main::cursor#3 -- pbuz1=_inc_pbuz1 
    inc.z cursor
    bne !+
    inc.z cursor+1
  !:
    // [12] phi from main::@3 main::@4 to main::@5 [phi:main::@3/main::@4->main::@5]
  __b5_from___b3:
  __b5_from___b4:
    // [12] phi (byte*) main::cursor#6 = (byte*) main::cursor#1 [phi:main::@3/main::@4->main::@5#0] -- register_copy 
    // [12] phi (byte*) main::line#5 = (byte*) main::line#8 [phi:main::@3/main::@4->main::@5#1] -- register_copy 
    jmp __b5
    // main::@5
  __b5:
    // [13] (byte*) main::msg#1 ← ++ (byte*) main::msg#2 -- pbuz1=_inc_pbuz1 
    inc.z msg
    bne !+
    inc.z msg+1
  !:
    // [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
  __b1_from___b5:
    // [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#6 [phi:main::@5->main::@1#0] -- register_copy 
    // [5] phi (byte*) main::line#2 = (byte*) main::line#5 [phi:main::@5->main::@1#1] -- register_copy 
    // [5] phi (byte*) main::msg#2 = (byte*) main::msg#1 [phi:main::@5->main::@1#2] -- register_copy 
    jmp __b1
    // main::@3
  __b3:
    // [14] (byte*) main::cursor#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz2_plus_vbuc1 
    lda #$28
    clc
    adc.z line
    sta.z cursor
    lda #0
    adc.z line+1
    sta.z cursor+1
    // [15] (byte*) main::line#8 ← (byte*) main::cursor#1 -- pbuz1=pbuz2 
    lda.z cursor
    sta.z line
    lda.z cursor+1
    sta.z line+1
    jmp __b5_from___b3
}
  // File Data
  MESSAGE: .text @"hello\nworld"
  .byte 0

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b4
Removing instruction jmp __b5
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction ldy #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label __bbegin with __b1
Replacing label __b5_from___b3 with __b5
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b5_from___b3:
Removing instruction __b5_from___b4:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b4:
Removing instruction __b1_from___b5:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction ldy #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) MESSAGE[]  = (byte*) "hello
world"pm
(void()) main()
(byte~) main::$0 reg byte a 22.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@return
(byte*) main::cursor
(byte*) main::cursor#1 cursor zp[2]:6 16.5
(byte*) main::cursor#2 cursor zp[2]:6 22.0
(byte*) main::cursor#3 cursor zp[2]:6 6.6000000000000005
(byte*) main::cursor#6 cursor zp[2]:6 16.5
(byte*) main::line
(byte*) main::line#2 line zp[2]:4 5.5
(byte*) main::line#5 line zp[2]:4 16.5
(byte*) main::line#8 line zp[2]:4 22.0
(byte*) main::msg
(byte*) main::msg#1 msg zp[2]:2 22.0
(byte*) main::msg#2 msg zp[2]:2 6.111111111111112

zp[2]:2 [ main::msg#2 main::msg#1 ]
zp[2]:4 [ main::line#2 main::line#5 main::line#8 ]
zp[2]:6 [ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ]
reg byte a [ main::$0 ]


FINAL ASSEMBLER
Score: 1291

  // File Comments
// Test using some simple supported string escape \n in both string and char
// Uses encoding PETSCII mixed
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  // @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 cursor = 6
    .label msg = 2
    .label line = 4
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte*) main::cursor#3 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta.z cursor
    lda #>$400
    sta.z cursor+1
    // [5] phi (byte*) main::line#2 = (byte*) 1024 [phi:main->main::@1#1] -- pbuz1=pbuc1 
    lda #<$400
    sta.z line
    lda #>$400
    sta.z line+1
    // [5] phi (byte*) main::msg#2 = (const byte*) MESSAGE [phi:main->main::@1#2] -- pbuz1=pbuc1 
    lda #<MESSAGE
    sta.z msg
    lda #>MESSAGE
    sta.z msg+1
    // main::@1
  __b1:
    // while(*msg)
    // [6] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 -- vbuc1_neq__deref_pbuz1_then_la1 
    ldy #0
    lda (msg),y
    cmp #0
    bne __b2
    // main::@return
    // }
    // [7] return 
    rts
    // main::@2
  __b2:
    // case '\n':
    //                 line += 0x28;
    //                 cursor = line;
    //                 break;
    // [8] if(*((byte*) main::msg#2)==(byte) ' 'pm) goto main::@3 -- _deref_pbuz1_eq_vbuc1_then_la1 
  .encoding "petscii_mixed"
    lda #'\n'
    ldy #0
    cmp (msg),y
    beq __b3
    // main::@4
    // *msg & 0x3f
    // [9] (byte~) main::$0 ← *((byte*) main::msg#2) & (byte) $3f -- vbuaa=_deref_pbuz1_band_vbuc1 
    lda #$3f
    and (msg),y
    // *cursor++ = *msg & 0x3f
    // [10] *((byte*) main::cursor#3) ← (byte~) main::$0 -- _deref_pbuz1=vbuaa 
    sta (cursor),y
    // *cursor++ = *msg & 0x3f;
    // [11] (byte*) main::cursor#2 ← ++ (byte*) main::cursor#3 -- pbuz1=_inc_pbuz1 
    inc.z cursor
    bne !+
    inc.z cursor+1
  !:
    // [12] phi from main::@3 main::@4 to main::@5 [phi:main::@3/main::@4->main::@5]
    // [12] phi (byte*) main::cursor#6 = (byte*) main::cursor#1 [phi:main::@3/main::@4->main::@5#0] -- register_copy 
    // [12] phi (byte*) main::line#5 = (byte*) main::line#8 [phi:main::@3/main::@4->main::@5#1] -- register_copy 
    // main::@5
  __b5:
    // msg++;
    // [13] (byte*) main::msg#1 ← ++ (byte*) main::msg#2 -- pbuz1=_inc_pbuz1 
    inc.z msg
    bne !+
    inc.z msg+1
  !:
    // [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
    // [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#6 [phi:main::@5->main::@1#0] -- register_copy 
    // [5] phi (byte*) main::line#2 = (byte*) main::line#5 [phi:main::@5->main::@1#1] -- register_copy 
    // [5] phi (byte*) main::msg#2 = (byte*) main::msg#1 [phi:main::@5->main::@1#2] -- register_copy 
    jmp __b1
    // main::@3
  __b3:
    // line += 0x28
    // [14] (byte*) main::cursor#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz2_plus_vbuc1 
    lda #$28
    clc
    adc.z line
    sta.z cursor
    lda #0
    adc.z line+1
    sta.z cursor+1
    // [15] (byte*) main::line#8 ← (byte*) main::cursor#1 -- pbuz1=pbuz2 
    lda.z cursor
    sta.z line
    lda.z cursor+1
    sta.z line+1
    jmp __b5
}
  // File Data
  MESSAGE: .text @"hello\nworld"
  .byte 0

