PARSING src/test/java/dk/camelot64/kickc/test/kc/forrangemin.kc

// Minimal range based for() loop

byte* SCREEN1 = $0400;
byte* SCREEN2 = $0500;

void main() {
    for(byte i : 0..255) {
      SCREEN1[i] = i;
    }
    byte j;
    for(j : 100..0) {
      SCREEN2[j] = j;
    }
}


STATEMENTS
  (byte*) SCREEN1 ← (word/signed word/dword/signed dword) 1024
  (byte*) SCREEN2 ← (word/signed word/dword/signed dword) 1280
proc (void()) main()
  (byte) main::i ← (byte/signed byte/word/signed word/dword/signed dword) 0
main::@1:
  *((byte*) SCREEN1 + (byte) main::i) ← (byte) main::i
  (byte) main::i ← ++ (byte) main::i
  (boolean~) main::$0 ← (byte) main::i != (byte/signed byte/word/signed word/dword/signed dword) 0
  if((boolean~) main::$0) goto main::@1
  (byte) main::j ← (byte/signed byte/word/signed word/dword/signed dword) 100
main::@2:
  *((byte*) SCREEN2 + (byte) main::j) ← (byte) main::j
  (byte) main::j ← -- (byte) main::j
  (boolean~) main::$1 ← (byte) main::j != (byte/word/signed word/dword/signed dword) 255
  if((boolean~) main::$1) goto main::@2
main::@return:
  return 
endproc // main()
  call main 

SYMBOLS
(byte*) SCREEN1
(byte*) SCREEN2
(void()) main()
(boolean~) main::$0
(boolean~) main::$1
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::i
(byte) main::j

Promoting word/signed word/dword/signed dword to byte* in SCREEN1 ← ((byte*)) 1024
Promoting word/signed word/dword/signed dword to byte* in SCREEN2 ← ((byte*)) 1280
INITIAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  (byte*) SCREEN1 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  (byte*) SCREEN2 ← ((byte*)) (word/signed word/dword/signed dword) 1280
  to:@1
main: scope:[main]  from
  (byte) main::i ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  *((byte*) SCREEN1 + (byte) main::i) ← (byte) main::i
  (byte) main::i ← ++ (byte) main::i
  (boolean~) main::$0 ← (byte) main::i != (byte/signed byte/word/signed word/dword/signed dword) 0
  if((boolean~) main::$0) goto main::@1
  to:main::@3
main::@3: scope:[main]  from main::@1
  (byte) main::j ← (byte/signed byte/word/signed word/dword/signed dword) 100
  to:main::@2
main::@2: scope:[main]  from main::@2 main::@3
  *((byte*) SCREEN2 + (byte) main::j) ← (byte) main::j
  (byte) main::j ← -- (byte) main::j
  (boolean~) main::$1 ← (byte) main::j != (byte/word/signed word/dword/signed dword) 255
  if((boolean~) main::$1) goto main::@2
  to:main::@4
main::@4: scope:[main]  from main::@2
  to:main::@return
main::@return: scope:[main]  from main::@4
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@end
@end: scope:[]  from @1

Removing empty block main::@4
PROCEDURE MODIFY VARIABLE ANALYSIS

Completing Phi functions...
Completing Phi functions...
Completing Phi functions...
Completing Phi functions...
Completing Phi functions...

CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN
@begin: scope:[]  from
  (byte*) SCREEN1#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  (byte*) SCREEN2#0 ← ((byte*)) (word/signed word/dword/signed dword) 1280
  to:@1
main: scope:[main]  from @1
  (byte*) SCREEN2#4 ← phi( @1/(byte*) SCREEN2#5 )
  (byte*) SCREEN1#2 ← phi( @1/(byte*) SCREEN1#3 )
  (byte) main::i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  (byte*) SCREEN2#3 ← phi( main/(byte*) SCREEN2#4 main::@1/(byte*) SCREEN2#3 )
  (byte*) SCREEN1#1 ← phi( main/(byte*) SCREEN1#2 main::@1/(byte*) SCREEN1#1 )
  (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
  *((byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
  (byte) main::i#1 ← ++ (byte) main::i#2
  (boolean~) main::$0 ← (byte) main::i#1 != (byte/signed byte/word/signed word/dword/signed dword) 0
  if((boolean~) main::$0) goto main::@1
  to:main::@3
main::@3: scope:[main]  from main::@1
  (byte*) SCREEN2#2 ← phi( main::@1/(byte*) SCREEN2#3 )
  (byte) main::j#0 ← (byte/signed byte/word/signed word/dword/signed dword) 100
  to:main::@2
main::@2: scope:[main]  from main::@2 main::@3
  (byte*) SCREEN2#1 ← phi( main::@2/(byte*) SCREEN2#1 main::@3/(byte*) SCREEN2#2 )
  (byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(byte) main::j#0 )
  *((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
  (byte) main::j#1 ← -- (byte) main::j#2
  (boolean~) main::$1 ← (byte) main::j#1 != (byte/word/signed word/dword/signed dword) 255
  if((boolean~) main::$1) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return
@1: scope:[]  from @begin
  (byte*) SCREEN2#5 ← phi( @begin/(byte*) SCREEN2#0 )
  (byte*) SCREEN1#3 ← phi( @begin/(byte*) SCREEN1#0 )
  call main param-assignment
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(byte*) SCREEN1
(byte*) SCREEN1#0
(byte*) SCREEN1#1
(byte*) SCREEN1#2
(byte*) SCREEN1#3
(byte*) SCREEN2
(byte*) SCREEN2#0
(byte*) SCREEN2#1
(byte*) SCREEN2#2
(byte*) SCREEN2#3
(byte*) SCREEN2#4
(byte*) SCREEN2#5
(void()) main()
(boolean~) main::$0
(boolean~) main::$1
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::j
(byte) main::j#0
(byte) main::j#1
(byte) main::j#2

OPTIMIZING CONTROL FLOW GRAPH
Culled Empty Block (label) @2
Succesful SSA optimization Pass2CullEmptyBlocks
Not aliassing across scopes: SCREEN1#2 SCREEN1#3
Not aliassing across scopes: SCREEN2#4 SCREEN2#5
Not aliassing identity: SCREEN2#1 SCREEN2#1
Alias (byte*) SCREEN2#2 = (byte*) SCREEN2#3 
Alias (byte*) SCREEN1#0 = (byte*) SCREEN1#3 
Alias (byte*) SCREEN2#0 = (byte*) SCREEN2#5 
Succesful SSA optimization Pass2AliasElimination
Not aliassing across scopes: SCREEN1#2 SCREEN1#0
Not aliassing across scopes: SCREEN2#4 SCREEN2#0
Not aliassing identity: SCREEN2#1 SCREEN2#1
Self Phi Eliminated (byte*) SCREEN1#1
Self Phi Eliminated (byte*) SCREEN2#2
Self Phi Eliminated (byte*) SCREEN2#1
Succesful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte*) SCREEN1#2 (byte*) SCREEN1#0
Redundant Phi (byte*) SCREEN2#4 (byte*) SCREEN2#0
Redundant Phi (byte*) SCREEN1#1 (byte*) SCREEN1#2
Redundant Phi (byte*) SCREEN2#2 (byte*) SCREEN2#4
Redundant Phi (byte*) SCREEN2#1 (byte*) SCREEN2#2
Succesful SSA optimization Pass2RedundantPhiElimination
Simple Condition (boolean~) main::$0 if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@1
Simple Condition (boolean~) main::$1 if((byte) main::j#1!=(byte/word/signed word/dword/signed dword) 255) goto main::@2
Succesful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN1#0 = ((byte*))1024
Constant (const byte*) SCREEN2#0 = ((byte*))1280
Constant (const byte) main::i#0 = 0
Constant (const byte) main::j#0 = 100
Succesful SSA optimization Pass2ConstantIdentification
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::j#2
Culled Empty Block (label) main::@3
Succesful SSA optimization Pass2CullEmptyBlocks
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::j#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::j#2
OPTIMIZING CONTROL FLOW GRAPH
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::j#0
Inlining constant with var siblings (const byte) main::j#0
Constant inlined main::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::j#0 = (byte/signed byte/word/signed word/dword/signed dword) 100
Succesful SSA optimization Pass2ConstantInlining
Block Sequence Planned @begin @1 @end main main::@1 main::@2 main::@return 
Added new block during phi lifting main::@5(between main::@1 and main::@1)
Added new block during phi lifting main::@6(between main::@2 and main::@2)
Block Sequence Planned @begin @1 @end main main::@1 main::@2 main::@return main::@6 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
CALL GRAPH
Calls in [] to main:2 

Propagating live ranges...
Propagating live ranges...
Created 2 initial phi equivalence classes
Coalesced [14] main::j#3 ← main::j#1
Coalesced [15] main::i#3 ← main::i#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@5
Block Sequence Planned @begin @1 @end main main::@1 main::@2 main::@return 
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
Propagating live ranges...
Propagating live ranges...

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi() [ ] ( )
  to:@1
@1: scope:[]  from @begin
  [1] phi() [ ] ( )
  [2] call main param-assignment [ ] ( )
  to:@end
@end: scope:[]  from @1
  [3] phi() [ ] ( )
main: scope:[main]  from @1
  [4] phi() [ ] ( main:2 [ ] )
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ] ( main:2 [ main::i#2 ] )
  [6] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] )
  [7] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] )
  [8] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [9] (byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(byte/signed byte/word/signed word/dword/signed dword) 100 ) [ main::j#2 ] ( main:2 [ main::j#2 ] )
  [10] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] ( main:2 [ main::j#2 ] )
  [11] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ] ( main:2 [ main::j#1 ] )
  [12] if((byte) main::j#1!=(byte/word/signed word/dword/signed dword) 255) goto main::@2 [ main::j#1 ] ( main:2 [ main::j#1 ] )
  to:main::@return
main::@return: scope:[main]  from main::@2
  [13] return  [ ] ( main:2 [ ] )
  to:@return

DOMINATORS
@begin dominated by  @begin 
@1 dominated by  @1 @begin 
@end dominated by  @1 @begin @end 
main dominated by  @1 @begin main 
main::@1 dominated by  @1 @begin main::@1 main 
main::@2 dominated by  @1 @begin main::@1 main::@2 main 
main::@return dominated by  main::@return @1 @begin main::@1 main::@2 main 

NATURAL LOOPS
Found back edge: Loop head: main::@1 tails: main::@1 blocks: null
Found back edge: Loop head: main::@2 tails: main::@2 blocks: null
Populated: Loop head: main::@1 tails: main::@1 blocks: main::@1 
Populated: Loop head: main::@2 tails: main::@2 blocks: main::@2 
Loop head: main::@1 tails: main::@1 blocks: main::@1 
Loop head: main::@2 tails: main::@2 blocks: main::@2 

NATURAL LOOPS WITH DEPTH
Found 0 loops in scope []
Found 2 loops in scope [main]
  Loop head: main::@1 tails: main::@1 blocks: main::@1 
  Loop head: main::@2 tails: main::@2 blocks: main::@2 
Loop head: main::@1 tails: main::@1 blocks: main::@1  depth: 1
Loop head: main::@2 tails: main::@2 blocks: main::@2  depth: 1


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN1
(byte*) SCREEN2
(void()) main()
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 22.0
(byte) main::j
(byte) main::j#1 16.5
(byte) main::j#2 22.0

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ main::j#2 main::j#1 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::j#2 main::j#1 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ main::j#2 main::j#1 ]

INITIAL ASM
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN1 = $400
  .label SCREEN2 = $500
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
//SEG4 @1
b1:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
    .label i = 2
    .label j = 3
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    jmp b1
  //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuz1=vbuz1 
    ldy i
    tya
    sta SCREEN1,y
  //SEG16 [7] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1=_inc_vbuz1 
    inc i
  //SEG17 [8] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1_neq_0_then_la1 
    lda i
    bne b1_from_b1
  //SEG18 [9] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
  //SEG19 [9] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 100 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #$64
    sta j
    jmp b2
  //SEG20 [9] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
  //SEG21 [9] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp b2
  //SEG22 main::@2
  b2:
  //SEG23 [10] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] ( main:2 [ main::j#2 ] ) -- pbuc1_derefidx_vbuz1=vbuz1 
    ldy j
    tya
    sta SCREEN2,y
  //SEG24 [11] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuz1=_dec_vbuz1 
    dec j
  //SEG25 [12] if((byte) main::j#1!=(byte/word/signed word/dword/signed dword) 255) goto main::@2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda j
    cmp #$ff
    bne b2_from_b2
    jmp breturn
  //SEG26 main::@return
  breturn:
  //SEG27 [13] return  [ ] ( main:2 [ ] )
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ main::j#2 main::j#1 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 38.5: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 38.5: zp ZP_BYTE:3 [ main::j#2 main::j#1 ] 
Uplift Scope [] 

Uplifting [main] best 478 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::j#2 main::j#1 ] 
Uplifting [] best 478 combination 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN1 = $400
  .label SCREEN2 = $500
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
//SEG4 @1
b1:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b1
  //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta SCREEN1,x
  //SEG16 [7] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG17 [8] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx_neq_0_then_la1 
    cpx #0
    bne b1_from_b1
  //SEG18 [9] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
  //SEG19 [9] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 100 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #$64
    jmp b2
  //SEG20 [9] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
  //SEG21 [9] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp b2
  //SEG22 main::@2
  b2:
  //SEG23 [10] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] ( main:2 [ main::j#2 ] ) -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta SCREEN2,x
  //SEG24 [11] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuxx=_dec_vbuxx 
    dex
  //SEG25 [12] if((byte) main::j#1!=(byte/word/signed word/dword/signed dword) 255) goto main::@2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #$ff
    bne b2_from_b2
    jmp breturn
  //SEG26 main::@return
  breturn:
  //SEG27 [13] return  [ ] ( main:2 [ ] )
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b1 with b1
Replacing label b2_from_b2 with b2
Removing instruction bbegin:
Removing instruction b1_from_bbegin:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b1:
Removing instruction b2_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b1:
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b2_from_b1:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN1
(const byte*) SCREEN1#0 SCREEN1 = ((byte*))(word/signed word/dword/signed dword) 1024
(byte*) SCREEN2
(const byte*) SCREEN2#0 SCREEN2 = ((byte*))(word/signed word/dword/signed dword) 1280
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 22.0
(byte) main::j
(byte) main::j#1 reg byte x 16.5
(byte) main::j#2 reg byte x 22.0

reg byte x [ main::i#2 main::i#1 ]
reg byte x [ main::j#2 main::j#1 ]


FINAL ASSEMBLER
Score: 322

//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN1 = $400
  .label SCREEN2 = $500
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
  //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  //SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
  //SEG14 main::@1
  b1:
  //SEG15 [6] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta SCREEN1,x
  //SEG16 [7] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG17 [8] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx_neq_0_then_la1 
    cpx #0
    bne b1
  //SEG18 [9] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  //SEG19 [9] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 100 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #$64
  //SEG20 [9] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  //SEG21 [9] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@2->main::@2#0] -- register_copy 
  //SEG22 main::@2
  b2:
  //SEG23 [10] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] ( main:2 [ main::j#2 ] ) -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta SCREEN2,x
  //SEG24 [11] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuxx=_dec_vbuxx 
    dex
  //SEG25 [12] if((byte) main::j#1!=(byte/word/signed word/dword/signed dword) 255) goto main::@2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #$ff
    bne b2
  //SEG26 main::@return
  //SEG27 [13] return  [ ] ( main:2 [ ] )
    rts
}

