Culled Empty Block (label) @1
Culled Empty Block (label) print_cls::@4
Culled Empty Block (label) print_cls::@3
Culled Empty Block (label) print_cls::@5
Culled Empty Block (label) print_cls::@6
Culled Empty Block (label) @2
Culled Empty Block (label) mode_ctrl::@6
Culled Empty Block (label) mode_ctrl::@3
Culled Empty Block (label) mode_ctrl::@7
Culled Empty Block (label) mode_ctrl::@5
Culled Empty Block (label) mode_ctrl::@9
Culled Empty Block (label) mode_ctrl::@10

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) BORDERCOL#0 ← ((byte*)) (number) $d020
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  to:@3
main: scope:[main]  from @3
  call print_cls 
  to:main::@1
main::@1: scope:[main]  from main
  call mode_ctrl 
  to:main::@2
main::@2: scope:[main]  from main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return
print_cls: scope:[print_cls]  from main
  (byte*) print_cls::sc#0 ← (byte*) SCREEN#0
  to:print_cls::@1
print_cls::@1: scope:[print_cls]  from print_cls print_cls::@2
  (byte*) print_cls::sc#2 ← phi( print_cls/(byte*) print_cls::sc#0 print_cls::@2/(byte*) print_cls::sc#1 )
  (byte*~) print_cls::$0 ← (byte*) SCREEN#0 + (number) $3e8
  (bool~) print_cls::$1 ← (byte*) print_cls::sc#2 != (byte*~) print_cls::$0
  if((bool~) print_cls::$1) goto print_cls::@2
  to:print_cls::@return
print_cls::@2: scope:[print_cls]  from print_cls::@1
  (byte*) print_cls::sc#3 ← phi( print_cls::@1/(byte*) print_cls::sc#2 )
  *((byte*) print_cls::sc#3) ← (byte) ' '
  (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#3
  to:print_cls::@1
print_cls::@return: scope:[print_cls]  from print_cls::@1
  return 
  to:@return
mode_ctrl: scope:[mode_ctrl]  from main::@1
  to:mode_ctrl::@1
mode_ctrl::@1: scope:[mode_ctrl]  from mode_ctrl mode_ctrl::@4 mode_ctrl::@8
  if(true) goto mode_ctrl::@2
  to:mode_ctrl::@return
mode_ctrl::@2: scope:[mode_ctrl]  from mode_ctrl::@1
  (byte) mode_ctrl::before#0 ← *((byte*) BORDERCOL#0)
  (bool~) mode_ctrl::$0 ← (byte) mode_ctrl::before#0 == (number) $ff
  if((bool~) mode_ctrl::$0) goto mode_ctrl::@4
  to:mode_ctrl::@8
mode_ctrl::@4: scope:[mode_ctrl]  from mode_ctrl::@2
  *((byte*) BORDERCOL#0) ← (number) 2
  to:mode_ctrl::@1
mode_ctrl::@8: scope:[mode_ctrl]  from mode_ctrl::@2
  *((byte*) BORDERCOL#0) ← (number) 3
  to:mode_ctrl::@1
mode_ctrl::@return: scope:[mode_ctrl]  from mode_ctrl::@1
  return 
  to:@return
@3: scope:[]  from @begin
  call main 
  to:@4
@4: scope:[]  from @3
  to:@end
@end: scope:[]  from @4

SYMBOL TABLE SSA
(label) @3
(label) @4
(label) @begin
(label) @end
(byte*) BORDERCOL
(byte*) BORDERCOL#0
(byte*) SCREEN
(byte*) SCREEN#0
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(void()) mode_ctrl()
(bool~) mode_ctrl::$0
(label) mode_ctrl::@1
(label) mode_ctrl::@2
(label) mode_ctrl::@4
(label) mode_ctrl::@8
(label) mode_ctrl::@return
(byte) mode_ctrl::before
(byte) mode_ctrl::before#0
(void()) print_cls()
(byte*~) print_cls::$0
(bool~) print_cls::$1
(label) print_cls::@1
(label) print_cls::@2
(label) print_cls::@return
(byte*) print_cls::sc
(byte*) print_cls::sc#0
(byte*) print_cls::sc#1
(byte*) print_cls::sc#2
(byte*) print_cls::sc#3

Adding number conversion cast (unumber) $3e8 in (byte*~) print_cls::$0 ← (byte*) SCREEN#0 + (number) $3e8
Adding number conversion cast (unumber) $ff in (bool~) mode_ctrl::$0 ← (byte) mode_ctrl::before#0 == (number) $ff
Adding number conversion cast (unumber) 2 in *((byte*) BORDERCOL#0) ← (number) 2
Adding number conversion cast (unumber) 3 in *((byte*) BORDERCOL#0) ← (number) 3
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) BORDERCOL#0 ← (byte*)(number) $d020
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast *((byte*) BORDERCOL#0) ← (unumber)(number) 2
Inlining cast *((byte*) BORDERCOL#0) ← (unumber)(number) 3
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $3e8
Simplifying constant integer cast $ff
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (word) $3e8
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte*) print_cls::sc#2 = (byte*) print_cls::sc#3 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) print_cls::$1 [9] if((byte*) print_cls::sc#2!=(byte*~) print_cls::$0) goto print_cls::@2
Simple Condition (bool~) mode_ctrl::$0 [17] if((byte) mode_ctrl::before#0==(byte) $ff) goto mode_ctrl::@4
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) BORDERCOL#0 = (byte*) 53280
Constant (const byte*) SCREEN#0 = (byte*) 1024
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) print_cls::sc#0 = SCREEN#0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [14] if(true) goto mode_ctrl::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block mode_ctrl::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Constant right-side identified [4] (byte*~) print_cls::$0 ← (const byte*) SCREEN#0 + (word) $3e8
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) print_cls::$0 = SCREEN#0+$3e8
Successful SSA optimization Pass2ConstantIdentification
Successful SSA optimization Pass2LoopHeadConstantIdentification
Alias (byte*) print_cls::sc#1 = (byte*) print_cls::sc#2 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte*) print_cls::sc#5 (const byte*) print_cls::sc#0
Successful SSA optimization Pass2IdenticalPhiElimination
if() condition always true - replacing block destination [16] if((const byte*) print_cls::sc#0!=(const byte*) print_cls::$0) goto print_cls::@2
Successful SSA optimization Pass2ConstantIfs
Inlining constant with var siblings (const byte*) print_cls::sc#0
Constant inlined print_cls::sc#0 = (const byte*) SCREEN#0
Constant inlined print_cls::$0 = (const byte*) SCREEN#0+(word) $3e8
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting print_cls::@7(between print_cls::@1 and print_cls::@2)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @3
Adding NOP phi() at start of @4
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of mode_ctrl
Adding NOP phi() at start of mode_ctrl::@1
Adding NOP phi() at start of print_cls
Adding NOP phi() at start of print_cls::@1_1
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to print_cls:6 mode_ctrl:8 

Created 1 initial phi equivalence classes
Coalesced [24] print_cls::sc#6 ← print_cls::sc#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @4
Culled Empty Block (label) main::@2
Culled Empty Block (label) mode_ctrl::@1
Culled Empty Block (label) print_cls::@1_1
Culled Empty Block (label) print_cls::@7
Renumbering block @3 to @1
Renumbering block mode_ctrl::@2 to mode_ctrl::@1
Renumbering block mode_ctrl::@4 to mode_ctrl::@2
Renumbering block mode_ctrl::@8 to mode_ctrl::@3
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
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of mode_ctrl
Adding NOP phi() at start of print_cls

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()
  [5] call print_cls 
  to:main::@1
main::@1: scope:[main]  from main
  [6] phi()
  [7] call mode_ctrl 
  to:main::@return
main::@return: scope:[main]  from main::@1
  [8] return 
  to:@return
mode_ctrl: scope:[mode_ctrl]  from main::@1
  [9] phi()
  to:mode_ctrl::@1
mode_ctrl::@1: scope:[mode_ctrl]  from mode_ctrl mode_ctrl::@2 mode_ctrl::@3
  [10] (byte) mode_ctrl::before#0 ← *((const byte*) BORDERCOL#0)
  [11] if((byte) mode_ctrl::before#0==(byte) $ff) goto mode_ctrl::@2
  to:mode_ctrl::@3
mode_ctrl::@3: scope:[mode_ctrl]  from mode_ctrl::@1
  [12] *((const byte*) BORDERCOL#0) ← (byte) 3
  to:mode_ctrl::@1
mode_ctrl::@2: scope:[mode_ctrl]  from mode_ctrl::@1
  [13] *((const byte*) BORDERCOL#0) ← (byte) 2
  to:mode_ctrl::@1
print_cls: scope:[print_cls]  from main
  [14] phi()
  to:print_cls::@2
print_cls::@2: scope:[print_cls]  from print_cls print_cls::@1
  [15] (byte*) print_cls::sc#4 ← phi( print_cls::@1/(byte*) print_cls::sc#1 print_cls/(const byte*) SCREEN#0 )
  [16] *((byte*) print_cls::sc#4) ← (byte) ' '
  [17] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#4
  to:print_cls::@1
print_cls::@1: scope:[print_cls]  from print_cls::@2
  [18] if((byte*) print_cls::sc#1!=(const byte*) SCREEN#0+(word) $3e8) goto print_cls::@2
  to:print_cls::@return
print_cls::@return: scope:[print_cls]  from print_cls::@1
  [19] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) BORDERCOL
(byte*) SCREEN
(void()) main()
(void()) mode_ctrl()
(byte) mode_ctrl::before
(byte) mode_ctrl::before#0 22.0
(void()) print_cls()
(byte*) print_cls::sc
(byte*) print_cls::sc#1 16.5
(byte*) print_cls::sc#4 16.5

Initial phi equivalence classes
[ print_cls::sc#4 print_cls::sc#1 ]
Added variable mode_ctrl::before#0 to zero page equivalence class [ mode_ctrl::before#0 ]
Complete equivalence classes
[ print_cls::sc#4 print_cls::sc#1 ]
[ mode_ctrl::before#0 ]
Allocated zp ZP_WORD:2 [ print_cls::sc#4 print_cls::sc#1 ]
Allocated zp ZP_BYTE:4 [ mode_ctrl::before#0 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label BORDERCOL = $d020
  .label SCREEN = $400
  // @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: {
    // [5] call print_cls 
    // [14] phi from main to print_cls [phi:main->print_cls]
  print_cls_from_main:
    jsr print_cls
    // [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    jmp b1
    // main::@1
  b1:
    // [7] call mode_ctrl 
    // [9] phi from main::@1 to mode_ctrl [phi:main::@1->mode_ctrl]
  mode_ctrl_from_b1:
    jsr mode_ctrl
    jmp breturn
    // main::@return
  breturn:
    // [8] return 
    rts
}
  // mode_ctrl
mode_ctrl: {
    .label before = 4
    jmp b1
    // mode_ctrl::@1
  b1:
    // [10] (byte) mode_ctrl::before#0 ← *((const byte*) BORDERCOL#0) -- vbuz1=_deref_pbuc1 
    lda BORDERCOL
    sta.z before
    // [11] if((byte) mode_ctrl::before#0==(byte) $ff) goto mode_ctrl::@2 -- vbuz1_eq_vbuc1_then_la1 
    lda #$ff
    cmp.z before
    beq b2
    jmp b3
    // mode_ctrl::@3
  b3:
    // [12] *((const byte*) BORDERCOL#0) ← (byte) 3 -- _deref_pbuc1=vbuc2 
    lda #3
    sta BORDERCOL
    jmp b1
    // mode_ctrl::@2
  b2:
    // [13] *((const byte*) BORDERCOL#0) ← (byte) 2 -- _deref_pbuc1=vbuc2 
    lda #2
    sta BORDERCOL
    jmp b1
}
  // print_cls
print_cls: {
    .label sc = 2
    // [15] phi from print_cls to print_cls::@2 [phi:print_cls->print_cls::@2]
  b2_from_print_cls:
    // [15] phi (byte*) print_cls::sc#4 = (const byte*) SCREEN#0 [phi:print_cls->print_cls::@2#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta.z sc
    lda #>SCREEN
    sta.z sc+1
    jmp b2
    // [15] phi from print_cls::@1 to print_cls::@2 [phi:print_cls::@1->print_cls::@2]
  b2_from_b1:
    // [15] phi (byte*) print_cls::sc#4 = (byte*) print_cls::sc#1 [phi:print_cls::@1->print_cls::@2#0] -- register_copy 
    jmp b2
    // print_cls::@2
  b2:
    // [16] *((byte*) print_cls::sc#4) ← (byte) ' ' -- _deref_pbuz1=vbuc1 
    lda #' '
    ldy #0
    sta (sc),y
    // [17] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#4 -- pbuz1=_inc_pbuz1 
    inc.z sc
    bne !+
    inc.z sc+1
  !:
    jmp b1
    // print_cls::@1
  b1:
    // [18] if((byte*) print_cls::sc#1!=(const byte*) SCREEN#0+(word) $3e8) goto print_cls::@2 -- pbuz1_neq_pbuc1_then_la1 
    lda.z sc+1
    cmp #>SCREEN+$3e8
    bne b2_from_b1
    lda.z sc
    cmp #<SCREEN+$3e8
    bne b2_from_b1
    jmp breturn
    // print_cls::@return
  breturn:
    // [19] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [12] *((const byte*) BORDERCOL#0) ← (byte) 3 [ ] ( main:2::mode_ctrl:7 [ ] ) always clobbers reg byte a 
Statement [13] *((const byte*) BORDERCOL#0) ← (byte) 2 [ ] ( main:2::mode_ctrl:7 [ ] ) always clobbers reg byte a 
Statement [16] *((byte*) print_cls::sc#4) ← (byte) ' ' [ print_cls::sc#4 ] ( main:2::print_cls:5 [ print_cls::sc#4 ] ) always clobbers reg byte a reg byte y 
Statement [18] if((byte*) print_cls::sc#1!=(const byte*) SCREEN#0+(word) $3e8) goto print_cls::@2 [ print_cls::sc#1 ] ( main:2::print_cls:5 [ print_cls::sc#1 ] ) always clobbers reg byte a 
Potential registers zp ZP_WORD:2 [ print_cls::sc#4 print_cls::sc#1 ] : zp ZP_WORD:2 , 
Potential registers zp ZP_BYTE:4 [ mode_ctrl::before#0 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [print_cls] 33: zp ZP_WORD:2 [ print_cls::sc#4 print_cls::sc#1 ] 
Uplift Scope [mode_ctrl] 22: zp ZP_BYTE:4 [ mode_ctrl::before#0 ] 
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [print_cls] best 1022 combination zp ZP_WORD:2 [ print_cls::sc#4 print_cls::sc#1 ] 
Uplifting [mode_ctrl] best 962 combination reg byte a [ mode_ctrl::before#0 ] 
Uplifting [main] best 962 combination 
Uplifting [] best 962 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label BORDERCOL = $d020
  .label SCREEN = $400
  // @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: {
    // [5] call print_cls 
    // [14] phi from main to print_cls [phi:main->print_cls]
  print_cls_from_main:
    jsr print_cls
    // [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    jmp b1
    // main::@1
  b1:
    // [7] call mode_ctrl 
    // [9] phi from main::@1 to mode_ctrl [phi:main::@1->mode_ctrl]
  mode_ctrl_from_b1:
    jsr mode_ctrl
    jmp breturn
    // main::@return
  breturn:
    // [8] return 
    rts
}
  // mode_ctrl
mode_ctrl: {
    jmp b1
    // mode_ctrl::@1
  b1:
    // [10] (byte) mode_ctrl::before#0 ← *((const byte*) BORDERCOL#0) -- vbuaa=_deref_pbuc1 
    lda BORDERCOL
    // [11] if((byte) mode_ctrl::before#0==(byte) $ff) goto mode_ctrl::@2 -- vbuaa_eq_vbuc1_then_la1 
    cmp #$ff
    beq b2
    jmp b3
    // mode_ctrl::@3
  b3:
    // [12] *((const byte*) BORDERCOL#0) ← (byte) 3 -- _deref_pbuc1=vbuc2 
    lda #3
    sta BORDERCOL
    jmp b1
    // mode_ctrl::@2
  b2:
    // [13] *((const byte*) BORDERCOL#0) ← (byte) 2 -- _deref_pbuc1=vbuc2 
    lda #2
    sta BORDERCOL
    jmp b1
}
  // print_cls
print_cls: {
    .label sc = 2
    // [15] phi from print_cls to print_cls::@2 [phi:print_cls->print_cls::@2]
  b2_from_print_cls:
    // [15] phi (byte*) print_cls::sc#4 = (const byte*) SCREEN#0 [phi:print_cls->print_cls::@2#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta.z sc
    lda #>SCREEN
    sta.z sc+1
    jmp b2
    // [15] phi from print_cls::@1 to print_cls::@2 [phi:print_cls::@1->print_cls::@2]
  b2_from_b1:
    // [15] phi (byte*) print_cls::sc#4 = (byte*) print_cls::sc#1 [phi:print_cls::@1->print_cls::@2#0] -- register_copy 
    jmp b2
    // print_cls::@2
  b2:
    // [16] *((byte*) print_cls::sc#4) ← (byte) ' ' -- _deref_pbuz1=vbuc1 
    lda #' '
    ldy #0
    sta (sc),y
    // [17] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#4 -- pbuz1=_inc_pbuz1 
    inc.z sc
    bne !+
    inc.z sc+1
  !:
    jmp b1
    // print_cls::@1
  b1:
    // [18] if((byte*) print_cls::sc#1!=(const byte*) SCREEN#0+(word) $3e8) goto print_cls::@2 -- pbuz1_neq_pbuc1_then_la1 
    lda.z sc+1
    cmp #>SCREEN+$3e8
    bne b2_from_b1
    lda.z sc
    cmp #<SCREEN+$3e8
    bne b2_from_b1
    jmp breturn
    // print_cls::@return
  breturn:
    // [19] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp breturn
Removing instruction jmp b1
Removing instruction jmp b3
Removing instruction jmp b2
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b2_from_b1 with b2
Replacing label b2_from_b1 with b2
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_main:
Removing instruction mode_ctrl_from_b1:
Removing instruction b2_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction print_cls_from_main:
Removing instruction b1:
Removing instruction breturn:
Removing instruction b3:
Removing instruction b2_from_print_cls:
Removing instruction b1:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
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*) BORDERCOL
(const byte*) BORDERCOL#0 BORDERCOL = (byte*) 53280
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(void()) main()
(label) main::@1
(label) main::@return
(void()) mode_ctrl()
(label) mode_ctrl::@1
(label) mode_ctrl::@2
(label) mode_ctrl::@3
(byte) mode_ctrl::before
(byte) mode_ctrl::before#0 reg byte a 22.0
(void()) print_cls()
(label) print_cls::@1
(label) print_cls::@2
(label) print_cls::@return
(byte*) print_cls::sc
(byte*) print_cls::sc#1 sc zp ZP_WORD:2 16.5
(byte*) print_cls::sc#4 sc zp ZP_WORD:2 16.5

zp ZP_WORD:2 [ print_cls::sc#4 print_cls::sc#1 ]
reg byte a [ mode_ctrl::before#0 ]


FINAL ASSEMBLER
Score: 764

  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label BORDERCOL = $d020
  .label SCREEN = $400
  // @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: {
    // print_cls()
    // [5] call print_cls 
    // [14] phi from main to print_cls [phi:main->print_cls]
    jsr print_cls
    // [6] phi from main to main::@1 [phi:main->main::@1]
    // main::@1
    // mode_ctrl()
    // [7] call mode_ctrl 
    // [9] phi from main::@1 to mode_ctrl [phi:main::@1->mode_ctrl]
    jsr mode_ctrl
    // main::@return
    // }
    // [8] return 
    rts
}
  // mode_ctrl
mode_ctrl: {
    // mode_ctrl::@1
  b1:
    // before = *BORDERCOL
    // [10] (byte) mode_ctrl::before#0 ← *((const byte*) BORDERCOL#0) -- vbuaa=_deref_pbuc1 
    lda BORDERCOL
    // if(before==$ff)
    // [11] if((byte) mode_ctrl::before#0==(byte) $ff) goto mode_ctrl::@2 -- vbuaa_eq_vbuc1_then_la1 
    cmp #$ff
    beq b2
    // mode_ctrl::@3
    // *BORDERCOL = 3
    // [12] *((const byte*) BORDERCOL#0) ← (byte) 3 -- _deref_pbuc1=vbuc2 
    lda #3
    sta BORDERCOL
    jmp b1
    // mode_ctrl::@2
  b2:
    // *BORDERCOL = 2
    // [13] *((const byte*) BORDERCOL#0) ← (byte) 2 -- _deref_pbuc1=vbuc2 
    lda #2
    sta BORDERCOL
    jmp b1
}
  // print_cls
print_cls: {
    .label sc = 2
    // [15] phi from print_cls to print_cls::@2 [phi:print_cls->print_cls::@2]
    // [15] phi (byte*) print_cls::sc#4 = (const byte*) SCREEN#0 [phi:print_cls->print_cls::@2#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta.z sc
    lda #>SCREEN
    sta.z sc+1
    // [15] phi from print_cls::@1 to print_cls::@2 [phi:print_cls::@1->print_cls::@2]
    // [15] phi (byte*) print_cls::sc#4 = (byte*) print_cls::sc#1 [phi:print_cls::@1->print_cls::@2#0] -- register_copy 
    // print_cls::@2
  b2:
    // *sc = ' '
    // [16] *((byte*) print_cls::sc#4) ← (byte) ' ' -- _deref_pbuz1=vbuc1 
    lda #' '
    ldy #0
    sta (sc),y
    // for(byte* sc=SCREEN; sc!=SCREEN+1000; sc++)
    // [17] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#4 -- pbuz1=_inc_pbuz1 
    inc.z sc
    bne !+
    inc.z sc+1
  !:
    // print_cls::@1
    // [18] if((byte*) print_cls::sc#1!=(const byte*) SCREEN#0+(word) $3e8) goto print_cls::@2 -- pbuz1_neq_pbuc1_then_la1 
    lda.z sc+1
    cmp #>SCREEN+$3e8
    bne b2
    lda.z sc
    cmp #<SCREEN+$3e8
    bne b2
    // print_cls::@return
    // }
    // [19] return 
    rts
}
  // File Data

