
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::line#0 = 0
  main::line#1 = 0
  to:main::@1
main::@1: scope:[main]  from main main::@6
  main::line#3 = phi( main/main::line#1, main::@6/main::line#2 )
  main::$0 = main::line#3 < $28*$18
  if(main::$0) goto main::@2
  to:main::@3
main::@2: scope:[main]  from main::@1
  main::line#9 = phi( main::@1/main::line#3 )
  main::c#0 = 0
  to:main::@4
main::@3: scope:[main]  from main::@1
  main::line#10 = phi( main::@1/main::line#3 )
  main::c1#0 = 0
  to:main::@7
main::@4: scope:[main]  from main::@2 main::@5
  main::line#7 = phi( main::@2/main::line#9, main::@5/main::line#4 )
  main::c#2 = phi( main::@2/main::c#0, main::@5/main::c#1 )
  main::$1 = main::c#2 < $28
  if(main::$1) goto main::@5
  to:main::@6
main::@5: scope:[main]  from main::@4
  main::c#3 = phi( main::@4/main::c#2 )
  main::line#4 = phi( main::@4/main::line#7 )
  main::$2 = main::line#4 + main::c#3
  main::$3 = main::line#4 + main::c#3
  main::$4 = main::$3 + $28
  main::screen[main::$2] = main::screen[main::$4]
  main::c#1 = ++ main::c#3
  to:main::@4
main::@6: scope:[main]  from main::@4
  main::line#5 = phi( main::@4/main::line#7 )
  main::line#2 = main::line#5 + $28
  to:main::@1
main::@7: scope:[main]  from main::@3 main::@8
  main::line#8 = phi( main::@3/main::line#10, main::@8/main::line#6 )
  main::c1#2 = phi( main::@3/main::c1#0, main::@8/main::c1#1 )
  main::$5 = main::c1#2 < $28
  if(main::$5) goto main::@8
  to:main::@return
main::@8: scope:[main]  from main::@7
  main::c1#3 = phi( main::@7/main::c1#2 )
  main::line#6 = phi( main::@7/main::line#8 )
  main::$6 = main::line#6 + main::c1#3
  main::screen[main::$6] = ' '
  main::c1#1 = ++ main::c1#3
  to:main::@7
main::@return: scope:[main]  from main::@7
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  call main
  to:__start::@1
__start::@1: scope:[__start]  from __start
  to:__start::@return
__start::@return: scope:[__start]  from __start::@1
  return 
  to:@return

SYMBOL TABLE SSA
void __start()
void main()
bool main::$0
bool main::$1
unsigned int main::$2
unsigned int main::$3
number main::$4
bool main::$5
unsigned int main::$6
char main::c
char main::c#0
char main::c#1
char main::c#2
char main::c#3
char main::c1
char main::c1#0
char main::c1#1
char main::c1#2
char main::c1#3
unsigned int main::line
unsigned int main::line#0
unsigned int main::line#1
unsigned int main::line#10
unsigned int main::line#2
unsigned int main::line#3
unsigned int main::line#4
unsigned int main::line#5
unsigned int main::line#6
unsigned int main::line#7
unsigned int main::line#8
unsigned int main::line#9
__constant char *main::screen = (char *)$400

Adding number conversion cast (unumber) 0 in main::line#1 = 0
Adding number conversion cast (unumber) $28*$18 in main::$0 = main::line#3 < $28*$18
Adding number conversion cast (unumber) $28 in main::$1 = main::c#2 < $28
Adding number conversion cast (unumber) $28 in main::$4 = main::$3 + $28
Adding number conversion cast (unumber) main::$4 in main::$4 = main::$3 + (unumber)$28
Adding number conversion cast (unumber) $28 in main::line#2 = main::line#5 + $28
Adding number conversion cast (unumber) $28 in main::$5 = main::c1#2 < $28
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast main::line#1 = (unumber)0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast $28
Simplifying constant integer cast $28
Simplifying constant integer cast $28
Simplifying constant integer cast $28
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) $28
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to unsigned int in main::$4 = main::$3 + $28
Alias main::line#10 = main::line#9 main::line#3 
Alias main::line#4 = main::line#7 main::line#5 
Alias main::c#2 = main::c#3 
Alias main::line#6 = main::line#8 
Alias main::c1#2 = main::c1#3 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values main::line#4 main::line#10
Identical Phi Values main::line#6 main::line#10
Successful SSA optimization Pass2IdenticalPhiElimination
Identified duplicate assignment right side [14] main::$3 = main::line#10 + main::c#2
Successful SSA optimization Pass2DuplicateRValueIdentification
Simple Condition main::$0 [4] if(main::line#10<(unsigned int)$28*$18) goto main::@2
Simple Condition main::$1 [9] if(main::c#2<$28) goto main::@5
Simple Condition main::$5 [18] if(main::c1#2<$28) goto main::@8
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::line#0 = 0
Constant main::line#1 = 0
Constant main::c#0 = 0
Constant main::c1#0 = 0
Successful SSA optimization Pass2ConstantIdentification
De-inlining pointer[w] to *(pointer+w)   [13] main::screen[main::$2] = main::screen[main::$4]
De-inlining pointer[w] to *(pointer+w)   [13] main::screen[main::$2] = *main::$7
De-inlining pointer[w] to *(pointer+w)   [20] main::screen[main::$6] = ' '
Successful SSA optimization Pass2DeInlineWordDerefIdx
Eliminating unused constant main::line#0
Successful SSA optimization PassNEliminateUnusedVars
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Alias main::$3 = main::$2 
Successful SSA optimization Pass2AliasElimination
Inlining constant with var siblings main::line#1
Inlining constant with var siblings main::c#0
Inlining constant with var siblings main::c1#0
Constant inlined main::c1#0 = 0
Constant inlined main::c#0 = 0
Constant inlined main::line#1 = 0
Successful SSA optimization Pass2ConstantInlining
Consolidated constant in assignment main::$7
Successful SSA optimization Pass2ConstantAdditionElimination
Alias main::$4 = main::$3 
Successful SSA optimization Pass2AliasElimination
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) $18
Successful SSA optimization PassNFinalizeNumberTypeConversions
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of main::@2
CALL GRAPH

Created 3 initial phi equivalence classes
Coalesced [11] main::c1#4 = main::c1#1
Coalesced [16] main::line#11 = main::line#2
Coalesced [22] main::c#4 = main::c#1
Coalesced down to 3 phi equivalence classes
Culled Empty Block label main::@3
Culled Empty Block label main::@2
Renumbering block main::@4 to main::@2
Renumbering block main::@5 to main::@3
Renumbering block main::@6 to main::@4
Renumbering block main::@7 to main::@5
Renumbering block main::@8 to main::@6
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@4
  [1] main::line#10 = phi( main/0, main::@4/main::line#2 )
  [2] if(main::line#10<(unsigned int)$28*$18) goto main::@2
  to:main::@5
main::@5: scope:[main]  from main::@1 main::@6
  [3] main::c1#2 = phi( main::@1/0, main::@6/main::c1#1 )
  [4] if(main::c1#2<$28) goto main::@6
  to:main::@return
main::@return: scope:[main]  from main::@5
  [5] return 
  to:@return
main::@6: scope:[main]  from main::@5
  [6] main::$6 = main::line#10 + main::c1#2
  [7] main::$9 = main::screen + main::$6
  [8] *main::$9 = ' '
  [9] main::c1#1 = ++ main::c1#2
  to:main::@5
main::@2: scope:[main]  from main::@1 main::@3
  [10] main::c#2 = phi( main::@1/0, main::@3/main::c#1 )
  [11] if(main::c#2<$28) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@2
  [12] main::line#2 = main::line#10 + $28
  to:main::@1
main::@3: scope:[main]  from main::@2
  [13] main::$4 = main::line#10 + main::c#2
  [14] main::$7 = main::screen+$28 + main::$4
  [15] main::$8 = main::screen + main::$4
  [16] *main::$8 = *main::$7
  [17] main::c#1 = ++ main::c#2
  to:main::@2


VARIABLE REGISTER WEIGHTS
void main()
unsigned int main::$4 // 151.5
unsigned int main::$6 // 22.0
char *main::$7 // 101.0
char *main::$8 // 202.0
char *main::$9 // 22.0
char main::c
char main::c#1 // 202.0
char main::c#2 // 67.33333333333333
char main::c1
char main::c1#1 // 22.0
char main::c1#2 // 8.8
unsigned int main::line
unsigned int main::line#10 // 9.666666666666666
unsigned int main::line#2 // 22.0

Initial phi equivalence classes
[ main::line#10 main::line#2 ]
[ main::c1#2 main::c1#1 ]
[ main::c#2 main::c#1 ]
Added variable main::$6 to live range equivalence class [ main::$6 ]
Added variable main::$9 to live range equivalence class [ main::$9 ]
Added variable main::$4 to live range equivalence class [ main::$4 ]
Added variable main::$7 to live range equivalence class [ main::$7 ]
Added variable main::$8 to live range equivalence class [ main::$8 ]
Complete equivalence classes
[ main::line#10 main::line#2 ]
[ main::c1#2 main::c1#1 ]
[ main::c#2 main::c#1 ]
[ main::$6 ]
[ main::$9 ]
[ main::$4 ]
[ main::$7 ]
[ main::$8 ]
Allocated zp[1]:2 [ main::c#2 main::c#1 ]
Allocated zp[2]:3 [ main::$8 ]
Allocated zp[2]:5 [ main::$4 ]
Allocated zp[2]:7 [ main::$7 ]
Allocated zp[2]:9 [ main::line#10 main::line#2 ]
Allocated zp[1]:11 [ main::c1#2 main::c1#1 ]
Allocated zp[2]:12 [ main::$6 ]
Allocated zp[2]:14 [ main::$9 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [2] if(main::line#10<(unsigned int)$28*$18) goto main::@2 [ main::line#10 ] (  [ main::line#10 ] { }  ) always clobbers reg byte a 
Statement [6] main::$6 = main::line#10 + main::c1#2 [ main::line#10 main::c1#2 main::$6 ] (  [ main::line#10 main::c1#2 main::$6 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:11 [ main::c1#2 main::c1#1 ]
Statement [7] main::$9 = main::screen + main::$6 [ main::line#10 main::c1#2 main::$9 ] (  [ main::line#10 main::c1#2 main::$9 ] { }  ) always clobbers reg byte a 
Statement [8] *main::$9 = ' ' [ main::line#10 main::c1#2 ] (  [ main::line#10 main::c1#2 ] { }  ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte y as potential for zp[1]:11 [ main::c1#2 main::c1#1 ]
Statement [12] main::line#2 = main::line#10 + $28 [ main::line#2 ] (  [ main::line#2 ] { }  ) always clobbers reg byte a 
Statement [13] main::$4 = main::line#10 + main::c#2 [ main::line#10 main::c#2 main::$4 ] (  [ main::line#10 main::c#2 main::$4 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::c#2 main::c#1 ]
Statement [14] main::$7 = main::screen+$28 + main::$4 [ main::line#10 main::c#2 main::$4 main::$7 ] (  [ main::line#10 main::c#2 main::$4 main::$7 ] { }  ) always clobbers reg byte a 
Statement [15] main::$8 = main::screen + main::$4 [ main::line#10 main::c#2 main::$7 main::$8 ] (  [ main::line#10 main::c#2 main::$7 main::$8 ] { }  ) always clobbers reg byte a 
Statement [16] *main::$8 = *main::$7 [ main::line#10 main::c#2 ] (  [ main::line#10 main::c#2 ] { }  ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte y as potential for zp[1]:2 [ main::c#2 main::c#1 ]
Statement [2] if(main::line#10<(unsigned int)$28*$18) goto main::@2 [ main::line#10 ] (  [ main::line#10 ] { }  ) always clobbers reg byte a 
Statement [6] main::$6 = main::line#10 + main::c1#2 [ main::line#10 main::c1#2 main::$6 ] (  [ main::line#10 main::c1#2 main::$6 ] { }  ) always clobbers reg byte a 
Statement [7] main::$9 = main::screen + main::$6 [ main::line#10 main::c1#2 main::$9 ] (  [ main::line#10 main::c1#2 main::$9 ] { }  ) always clobbers reg byte a 
Statement [8] *main::$9 = ' ' [ main::line#10 main::c1#2 ] (  [ main::line#10 main::c1#2 ] { }  ) always clobbers reg byte a reg byte y 
Statement [12] main::line#2 = main::line#10 + $28 [ main::line#2 ] (  [ main::line#2 ] { }  ) always clobbers reg byte a 
Statement [13] main::$4 = main::line#10 + main::c#2 [ main::line#10 main::c#2 main::$4 ] (  [ main::line#10 main::c#2 main::$4 ] { }  ) always clobbers reg byte a 
Statement [14] main::$7 = main::screen+$28 + main::$4 [ main::line#10 main::c#2 main::$4 main::$7 ] (  [ main::line#10 main::c#2 main::$4 main::$7 ] { }  ) always clobbers reg byte a 
Statement [15] main::$8 = main::screen + main::$4 [ main::line#10 main::c#2 main::$7 main::$8 ] (  [ main::line#10 main::c#2 main::$7 main::$8 ] { }  ) always clobbers reg byte a 
Statement [16] *main::$8 = *main::$7 [ main::line#10 main::c#2 ] (  [ main::line#10 main::c#2 ] { }  ) always clobbers reg byte a reg byte y 
Potential registers zp[2]:9 [ main::line#10 main::line#2 ] : zp[2]:9 , 
Potential registers zp[1]:11 [ main::c1#2 main::c1#1 ] : zp[1]:11 , reg byte x , 
Potential registers zp[1]:2 [ main::c#2 main::c#1 ] : zp[1]:2 , reg byte x , 
Potential registers zp[2]:12 [ main::$6 ] : zp[2]:12 , 
Potential registers zp[2]:14 [ main::$9 ] : zp[2]:14 , 
Potential registers zp[2]:5 [ main::$4 ] : zp[2]:5 , 
Potential registers zp[2]:7 [ main::$7 ] : zp[2]:7 , 
Potential registers zp[2]:3 [ main::$8 ] : zp[2]:3 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 269.33: zp[1]:2 [ main::c#2 main::c#1 ] 202: zp[2]:3 [ main::$8 ] 151.5: zp[2]:5 [ main::$4 ] 101: zp[2]:7 [ main::$7 ] 31.67: zp[2]:9 [ main::line#10 main::line#2 ] 30.8: zp[1]:11 [ main::c1#2 main::c1#1 ] 22: zp[2]:12 [ main::$6 ] 22: zp[2]:14 [ main::$9 ] 
Uplift Scope [] 

Uplifting [main] best 9851 combination reg byte x [ main::c#2 main::c#1 ] zp[2]:3 [ main::$8 ] zp[2]:5 [ main::$4 ] zp[2]:7 [ main::$7 ] zp[2]:9 [ main::line#10 main::line#2 ] reg byte x [ main::c1#2 main::c1#1 ] zp[2]:12 [ main::$6 ] zp[2]:14 [ main::$9 ] 
Uplifting [] best 9851 combination 
Coalescing zero page register [ zp[2]:12 [ main::$6 ] ] with [ zp[2]:14 [ main::$9 ] ] - score: 1
Coalescing zero page register [ zp[2]:5 [ main::$4 ] ] with [ zp[2]:3 [ main::$8 ] ] - score: 1
Allocated (was zp[2]:5) zp[2]:2 [ main::$4 main::$8 ]
Allocated (was zp[2]:7) zp[2]:4 [ main::$7 ]
Allocated (was zp[2]:12) zp[2]:6 [ main::$6 main::$9 ]
Allocated (was zp[2]:9) zp[2]:8 [ main::line#10 main::line#2 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="test-word-size-arrays.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
.segment Code
  // main
main: {
    .label screen = $400
    .label __4 = 2
    .label __6 = 6
    .label line = 8
    .label __7 = 4
    .label __8 = 2
    .label __9 = 6
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi main::line#10 = 0 [phi:main->main::@1#0] -- vwuz1=vbuc1 
    lda #<0
    sta.z line
    lda #>0
    sta.z line+1
    jmp __b1
    // main::@1
  __b1:
    // [2] if(main::line#10<(unsigned int)$28*$18) goto main::@2 -- vwuz1_lt_vwuc1_then_la1 
    lda.z line+1
    cmp #>$28*$18
    bcc __b2_from___b1
    bne !+
    lda.z line
    cmp #<$28*$18
    bcc __b2_from___b1
  !:
    // [3] phi from main::@1 to main::@5 [phi:main::@1->main::@5]
  __b5_from___b1:
    // [3] phi main::c1#2 = 0 [phi:main::@1->main::@5#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b5
  // Cleare the bottom line
    // main::@5
  __b5:
    // [4] if(main::c1#2<$28) goto main::@6 -- vbuxx_lt_vbuc1_then_la1 
    cpx #$28
    bcc __b6
    jmp __breturn
    // main::@return
  __breturn:
    // [5] return 
    rts
    // main::@6
  __b6:
    // [6] main::$6 = main::line#10 + main::c1#2 -- vwuz1=vwuz2_plus_vbuxx 
    txa
    clc
    adc.z line
    sta.z __6
    lda #0
    adc.z line+1
    sta.z __6+1
    // [7] main::$9 = main::screen + main::$6 -- pbuz1=pbuc1_plus_vwuz1 
    lda.z __9
    clc
    adc #<screen
    sta.z __9
    lda.z __9+1
    adc #>screen
    sta.z __9+1
    // [8] *main::$9 = ' ' -- _deref_pbuz1=vbuc1 
    lda #' '
    ldy #0
    sta (__9),y
    // [9] main::c1#1 = ++ main::c1#2 -- vbuxx=_inc_vbuxx 
    inx
    // [3] phi from main::@6 to main::@5 [phi:main::@6->main::@5]
  __b5_from___b6:
    // [3] phi main::c1#2 = main::c1#1 [phi:main::@6->main::@5#0] -- register_copy 
    jmp __b5
    // [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    // [10] phi main::c#2 = 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b2
    // main::@2
  __b2:
    // [11] if(main::c#2<$28) goto main::@3 -- vbuxx_lt_vbuc1_then_la1 
    cpx #$28
    bcc __b3
    jmp __b4
    // main::@4
  __b4:
    // [12] main::line#2 = main::line#10 + $28 -- vwuz1=vwuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z line
    sta.z line
    bcc !+
    inc.z line+1
  !:
    // [1] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  __b1_from___b4:
    // [1] phi main::line#10 = main::line#2 [phi:main::@4->main::@1#0] -- register_copy 
    jmp __b1
    // main::@3
  __b3:
    // [13] main::$4 = main::line#10 + main::c#2 -- vwuz1=vwuz2_plus_vbuxx 
    txa
    clc
    adc.z line
    sta.z __4
    lda #0
    adc.z line+1
    sta.z __4+1
    // [14] main::$7 = main::screen+$28 + main::$4 -- pbuz1=pbuc1_plus_vwuz2 
    lda.z __4
    clc
    adc #<screen+$28
    sta.z __7
    lda.z __4+1
    adc #>screen+$28
    sta.z __7+1
    // [15] main::$8 = main::screen + main::$4 -- pbuz1=pbuc1_plus_vwuz1 
    lda.z __8
    clc
    adc #<screen
    sta.z __8
    lda.z __8+1
    adc #>screen
    sta.z __8+1
    // [16] *main::$8 = *main::$7 -- _deref_pbuz1=_deref_pbuz2 
    ldy #0
    lda (__7),y
    ldy #0
    sta (__8),y
    // [17] main::c#1 = ++ main::c#2 -- vbuxx=_inc_vbuxx 
    inx
    // [10] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
  __b2_from___b3:
    // [10] phi main::c#2 = main::c#1 [phi:main::@3->main::@2#0] -- register_copy 
    jmp __b2
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b5
Removing instruction jmp __breturn
Removing instruction jmp __b2
Removing instruction jmp __b4
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #>0
Removing instruction ldy #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction __b1_from_main:
Removing instruction __b5_from___b1:
Removing instruction __breturn:
Removing instruction __b5_from___b6:
Removing instruction __b4:
Removing instruction __b1_from___b4:
Removing instruction __b2_from___b3:
Succesful ASM optimization Pass5UnusedLabelElimination
Relabelling long label __b2_from___b1 to __b4
Succesful ASM optimization Pass5RelabelLongLabels

FINAL SYMBOL TABLE
void main()
unsigned int main::$4 // zp[2]:2 151.5
unsigned int main::$6 // zp[2]:6 22.0
char *main::$7 // zp[2]:4 101.0
char *main::$8 // zp[2]:2 202.0
char *main::$9 // zp[2]:6 22.0
char main::c
char main::c#1 // reg byte x 202.0
char main::c#2 // reg byte x 67.33333333333333
char main::c1
char main::c1#1 // reg byte x 22.0
char main::c1#2 // reg byte x 8.8
unsigned int main::line
unsigned int main::line#10 // line zp[2]:8 9.666666666666666
unsigned int main::line#2 // line zp[2]:8 22.0
__constant char *main::screen = (char *) 1024

zp[2]:8 [ main::line#10 main::line#2 ]
reg byte x [ main::c1#2 main::c1#1 ]
reg byte x [ main::c#2 main::c#1 ]
zp[2]:6 [ main::$6 main::$9 ]
zp[2]:2 [ main::$4 main::$8 ]
zp[2]:4 [ main::$7 ]


FINAL ASSEMBLER
Score: 8941

  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="test-word-size-arrays.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
.segment Code
  // main
main: {
    .label screen = $400
    .label __4 = 2
    .label __6 = 6
    .label line = 8
    .label __7 = 4
    .label __8 = 2
    .label __9 = 6
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi main::line#10 = 0 [phi:main->main::@1#0] -- vwuz1=vbuc1 
    lda #<0
    sta.z line
    sta.z line+1
    // main::@1
  __b1:
    // for (line = 0; line < 40*24; line += 40)
    // [2] if(main::line#10<(unsigned int)$28*$18) goto main::@2 -- vwuz1_lt_vwuc1_then_la1 
    lda.z line+1
    cmp #>$28*$18
    bcc __b4
    bne !+
    lda.z line
    cmp #<$28*$18
    bcc __b4
  !:
    // [3] phi from main::@1 to main::@5 [phi:main::@1->main::@5]
    // [3] phi main::c1#2 = 0 [phi:main::@1->main::@5#0] -- vbuxx=vbuc1 
    ldx #0
  // Cleare the bottom line
    // main::@5
  __b5:
    // for (byte c=0; c<40; ++c)
    // [4] if(main::c1#2<$28) goto main::@6 -- vbuxx_lt_vbuc1_then_la1 
    cpx #$28
    bcc __b6
    // main::@return
    // }
    // [5] return 
    rts
    // main::@6
  __b6:
    // line+c
    // [6] main::$6 = main::line#10 + main::c1#2 -- vwuz1=vwuz2_plus_vbuxx 
    txa
    clc
    adc.z line
    sta.z __6
    lda #0
    adc.z line+1
    sta.z __6+1
    // screen[line+c] = ' '
    // [7] main::$9 = main::screen + main::$6 -- pbuz1=pbuc1_plus_vwuz1 
    lda.z __9
    clc
    adc #<screen
    sta.z __9
    lda.z __9+1
    adc #>screen
    sta.z __9+1
    // [8] *main::$9 = ' ' -- _deref_pbuz1=vbuc1 
    lda #' '
    ldy #0
    sta (__9),y
    // for (byte c=0; c<40; ++c)
    // [9] main::c1#1 = ++ main::c1#2 -- vbuxx=_inc_vbuxx 
    inx
    // [3] phi from main::@6 to main::@5 [phi:main::@6->main::@5]
    // [3] phi main::c1#2 = main::c1#1 [phi:main::@6->main::@5#0] -- register_copy 
    jmp __b5
    // [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b4:
    // [10] phi main::c#2 = 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    // main::@2
  __b2:
    // for (byte c=0; c<40; ++c)
    // [11] if(main::c#2<$28) goto main::@3 -- vbuxx_lt_vbuc1_then_la1 
    cpx #$28
    bcc __b3
    // main::@4
    // line += 40
    // [12] main::line#2 = main::line#10 + $28 -- vwuz1=vwuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z line
    sta.z line
    bcc !+
    inc.z line+1
  !:
    // [1] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
    // [1] phi main::line#10 = main::line#2 [phi:main::@4->main::@1#0] -- register_copy 
    jmp __b1
    // main::@3
  __b3:
    // line+c
    // [13] main::$4 = main::line#10 + main::c#2 -- vwuz1=vwuz2_plus_vbuxx 
    txa
    clc
    adc.z line
    sta.z __4
    lda #0
    adc.z line+1
    sta.z __4+1
    // screen[line+c] = screen[line+c+40]
    // [14] main::$7 = main::screen+$28 + main::$4 -- pbuz1=pbuc1_plus_vwuz2 
    lda.z __4
    clc
    adc #<screen+$28
    sta.z __7
    lda.z __4+1
    adc #>screen+$28
    sta.z __7+1
    // [15] main::$8 = main::screen + main::$4 -- pbuz1=pbuc1_plus_vwuz1 
    lda.z __8
    clc
    adc #<screen
    sta.z __8
    lda.z __8+1
    adc #>screen
    sta.z __8+1
    // [16] *main::$8 = *main::$7 -- _deref_pbuz1=_deref_pbuz2 
    ldy #0
    lda (__7),y
    sta (__8),y
    // for (byte c=0; c<40; ++c)
    // [17] main::c#1 = ++ main::c#2 -- vbuxx=_inc_vbuxx 
    inx
    // [10] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
    // [10] phi main::c#2 = main::c#1 [phi:main::@3->main::@2#0] -- register_copy 
    jmp __b2
}
  // File Data

