Identified constant variable (byte*) SCREEN
Culled Empty Block (label) main::@6

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1
main: scope:[main]  from @1
  (byte) main::i#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@5
  (byte) main::i#6 ← phi( main/(byte) main::i#0 main::@5/(byte) main::i#1 )
  (byte) main::j#0 ← (byte) 0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@4
  (byte) main::i#5 ← phi( main::@1/(byte) main::i#6 main::@4/(byte) main::i#3 )
  (byte) main::j#4 ← phi( main::@1/(byte) main::j#0 main::@4/(byte) main::j#1 )
  (byte) main::k#0 ← (byte) 0
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@3
  (byte) main::i#4 ← phi( main::@2/(byte) main::i#5 main::@3/(byte) main::i#4 )
  (byte) main::j#3 ← phi( main::@2/(byte) main::j#4 main::@3/(byte) main::j#3 )
  (byte) main::k#2 ← phi( main::@2/(byte) main::k#0 main::@3/(byte) main::k#1 )
  asm { pha txa pha tya pha jsr$e544 pla tay pla tax pla  }
  (byte) main::k#1 ← (byte) main::k#2 + rangenext(0,$a)
  (bool~) main::$0 ← (byte) main::k#1 != rangelast(0,$a)
  if((bool~) main::$0) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@3
  (byte) main::i#3 ← phi( main::@3/(byte) main::i#4 )
  (byte) main::j#2 ← phi( main::@3/(byte) main::j#3 )
  (byte) main::j#1 ← (byte) main::j#2 + rangenext(0,$a)
  (bool~) main::$1 ← (byte) main::j#1 != rangelast(0,$a)
  if((bool~) main::$1) goto main::@2
  to:main::@5
main::@5: scope:[main]  from main::@4
  (byte) main::i#2 ← phi( main::@4/(byte) main::i#3 )
  (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,$a)
  (bool~) main::$2 ← (byte) main::i#1 != rangelast(0,$a)
  if((bool~) main::$2) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@5
  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
(void()) main()
(bool~) main::$0
(bool~) main::$1
(bool~) main::$2
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) main::i#4
(byte) main::i#5
(byte) main::i#6
(byte) main::j
(byte) main::j#0
(byte) main::j#1
(byte) main::j#2
(byte) main::j#3
(byte) main::j#4
(byte) main::k
(byte) main::k#0
(byte) main::k#1
(byte) main::k#2

Alias (byte) main::j#2 = (byte) main::j#3 
Alias (byte) main::i#2 = (byte) main::i#3 (byte) main::i#4 
Successful SSA optimization Pass2AliasElimination
Self Phi Eliminated (byte) main::j#2
Self Phi Eliminated (byte) main::i#2
Successful SSA optimization Pass2SelfPhiElimination
Identical Phi Values (byte) main::j#2 (byte) main::j#4
Identical Phi Values (byte) main::i#2 (byte) main::i#5
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$0 [9] if((byte) main::k#1!=rangelast(0,$a)) goto main::@3
Simple Condition (bool~) main::$1 [13] if((byte) main::j#1!=rangelast(0,$a)) goto main::@2
Simple Condition (bool~) main::$2 [17] if((byte) main::i#1!=rangelast(0,$a)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::i#0 = 0
Constant (const byte) main::j#0 = 0
Constant (const byte) main::k#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [7] main::k#1 ← ++ main::k#2 to ++
Resolved ranged comparison value [9] if(main::k#1!=rangelast(0,$a)) goto main::@3 to (number) $b
Resolved ranged next value [11] main::j#1 ← ++ main::j#4 to ++
Resolved ranged comparison value [13] if(main::j#1!=rangelast(0,$a)) goto main::@2 to (number) $b
Resolved ranged next value [15] main::i#1 ← ++ main::i#5 to ++
Resolved ranged comparison value [17] if(main::i#1!=rangelast(0,$a)) goto main::@1 to (number) $b
Adding number conversion cast (unumber) $b in if((byte) main::k#1!=(number) $b) goto main::@3
Adding number conversion cast (unumber) $b in if((byte) main::j#1!=(number) $b) goto main::@2
Adding number conversion cast (unumber) $b in if((byte) main::i#1!=(number) $b) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $b
Simplifying constant integer cast $b
Simplifying constant integer cast $b
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $b
Finalized unsigned number type (byte) $b
Finalized unsigned number type (byte) $b
Successful SSA optimization PassNFinalizeNumberTypeConversions
Self Phi Eliminated (byte) main::i#5
Successful SSA optimization Pass2SelfPhiElimination
Identical Phi Values (byte) main::i#5 (byte) main::i#6
Successful SSA optimization Pass2IdenticalPhiElimination
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::k#0
Constant inlined main::i#0 = (byte) 0
Constant inlined main::k#0 = (byte) 0
Constant inlined main::j#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@7(between main::@5 and main::@1)
Added new block during phi lifting main::@8(between main::@4 and main::@2)
Added new block during phi lifting main::@9(between main::@3 and main::@3)
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 3 initial phi equivalence classes
Coalesced [17] main::i#7 ← main::i#1
Coalesced [18] main::j#5 ← main::j#1
Coalesced [19] main::k#3 ← main::k#1
Coalesced down to 3 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@8
Culled Empty Block (label) main::@9
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::@5
  [5] (byte) main::i#6 ← phi( main/(byte) 0 main::@5/(byte) main::i#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@4
  [6] (byte) main::j#4 ← phi( main::@1/(byte) 0 main::@4/(byte) main::j#1 )
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@3
  [7] (byte) main::k#2 ← phi( main::@2/(byte) 0 main::@3/(byte) main::k#1 )
  asm { pha txa pha tya pha jsr$e544 pla tay pla tax pla  }
  [9] (byte) main::k#1 ← ++ (byte) main::k#2
  [10] if((byte) main::k#1!=(byte) $b) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@3
  [11] (byte) main::j#1 ← ++ (byte) main::j#4
  [12] if((byte) main::j#1!=(byte) $b) goto main::@2
  to:main::@5
main::@5: scope:[main]  from main::@4
  [13] (byte) main::i#1 ← ++ (byte) main::i#6
  [14] if((byte) main::i#1!=(byte) $b) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@5
  [15] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#6 2.75
(byte) main::j
(byte) main::j#1 151.5
(byte) main::j#4 40.4
(byte) main::k
(byte) main::k#1 1501.5
(byte) main::k#2 1001.0

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

INITIAL ASM
  // File Comments
// Tests that inline ASM JSR clobbers all registers
  // Basic 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 k = 4
    .label j = 3
    .label i = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::i#6 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    jmp b1
    // [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
  b1_from_b5:
    // [5] phi (byte) main::i#6 = (byte) main::i#1 [phi:main::@5->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [6] phi (byte) main::j#4 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta j
    jmp b2
    // [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
  b2_from_b4:
    // [6] phi (byte) main::j#4 = (byte) main::j#1 [phi:main::@4->main::@2#0] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [7] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  b3_from_b2:
    // [7] phi (byte) main::k#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuz1=vbuc1 
    lda #0
    sta k
    jmp b3
    // [7] phi from main::@3 to main::@3 [phi:main::@3->main::@3]
  b3_from_b3:
    // [7] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@3->main::@3#0] -- register_copy 
    jmp b3
    // main::@3
  b3:
    // asm { pha txa pha tya pha jsr$e544 pla tay pla tax pla  }
    pha
    txa
    pha
    tya
    pha
    jsr $e544
    pla
    tay
    pla
    tax
    pla
    // [9] (byte) main::k#1 ← ++ (byte) main::k#2 -- vbuz1=_inc_vbuz1 
    inc k
    // [10] if((byte) main::k#1!=(byte) $b) goto main::@3 -- vbuz1_neq_vbuc1_then_la1 
    lda #$b
    cmp k
    bne b3_from_b3
    jmp b4
    // main::@4
  b4:
    // [11] (byte) main::j#1 ← ++ (byte) main::j#4 -- vbuz1=_inc_vbuz1 
    inc j
    // [12] if((byte) main::j#1!=(byte) $b) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #$b
    cmp j
    bne b2_from_b4
    jmp b5
    // main::@5
  b5:
    // [13] (byte) main::i#1 ← ++ (byte) main::i#6 -- vbuz1=_inc_vbuz1 
    inc i
    // [14] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$b
    cmp i
    bne b1_from_b5
    jmp breturn
    // main::@return
  breturn:
    // [15] return 
    rts
}
  // File Data

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

REGISTER UPLIFT SCOPES
Uplift Scope [main] 2,502.5: zp ZP_BYTE:4 [ main::k#2 main::k#1 ] 191.9: zp ZP_BYTE:3 [ main::j#4 main::j#1 ] 19.25: zp ZP_BYTE:2 [ main::i#6 main::i#1 ] 
Uplift Scope [] 

Uplifting [main] best 54463 combination reg byte y [ main::k#2 main::k#1 ] reg byte x [ main::j#4 main::j#1 ] reg byte a [ main::i#6 main::i#1 ] 
Uplifting [] best 54463 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests that inline ASM JSR clobbers all registers
  // Basic 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: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::i#6 = (byte) 0 [phi:main->main::@1#0] -- vbuaa=vbuc1 
    lda #0
    jmp b1
    // [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
  b1_from_b5:
    // [5] phi (byte) main::i#6 = (byte) main::i#1 [phi:main::@5->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [6] phi (byte) main::j#4 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b2
    // [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
  b2_from_b4:
    // [6] phi (byte) main::j#4 = (byte) main::j#1 [phi:main::@4->main::@2#0] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [7] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  b3_from_b2:
    // [7] phi (byte) main::k#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuyy=vbuc1 
    ldy #0
    jmp b3
    // [7] phi from main::@3 to main::@3 [phi:main::@3->main::@3]
  b3_from_b3:
    // [7] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@3->main::@3#0] -- register_copy 
    jmp b3
    // main::@3
  b3:
    // asm { pha txa pha tya pha jsr$e544 pla tay pla tax pla  }
    pha
    txa
    pha
    tya
    pha
    jsr $e544
    pla
    tay
    pla
    tax
    pla
    // [9] (byte) main::k#1 ← ++ (byte) main::k#2 -- vbuyy=_inc_vbuyy 
    iny
    // [10] if((byte) main::k#1!=(byte) $b) goto main::@3 -- vbuyy_neq_vbuc1_then_la1 
    cpy #$b
    bne b3_from_b3
    jmp b4
    // main::@4
  b4:
    // [11] (byte) main::j#1 ← ++ (byte) main::j#4 -- vbuxx=_inc_vbuxx 
    inx
    // [12] if((byte) main::j#1!=(byte) $b) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b2_from_b4
    jmp b5
    // main::@5
  b5:
    // [13] (byte) main::i#1 ← ++ (byte) main::i#6 -- vbuaa=_inc_vbuaa 
    clc
    adc #1
    // [14] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuaa_neq_vbuc1_then_la1 
    cmp #$b
    bne b1_from_b5
    jmp breturn
    // main::@return
  breturn:
    // [15] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b3
Removing instruction jmp b4
Removing instruction jmp b5
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b3_from_b3 with b3
Replacing label b2_from_b4 with b2
Replacing label b1_from_b5 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b5:
Removing instruction b2_from_b1:
Removing instruction b2_from_b4:
Removing instruction b3_from_b2:
Removing instruction b3_from_b3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b4:
Removing instruction b5:
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 b2
Removing instruction jmp b3
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte a 16.5
(byte) main::i#6 reg byte a 2.75
(byte) main::j
(byte) main::j#1 reg byte x 151.5
(byte) main::j#4 reg byte x 40.4
(byte) main::k
(byte) main::k#1 reg byte y 1501.5
(byte) main::k#2 reg byte y 1001.0

reg byte a [ main::i#6 main::i#1 ]
reg byte x [ main::j#4 main::j#1 ]
reg byte y [ main::k#2 main::k#1 ]


FINAL ASSEMBLER
Score: 44461

  // File Comments
// Tests that inline ASM JSR clobbers all registers
  // Basic 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: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::i#6 = (byte) 0 [phi:main->main::@1#0] -- vbuaa=vbuc1 
    lda #0
    // [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
    // [5] phi (byte) main::i#6 = (byte) main::i#1 [phi:main::@5->main::@1#0] -- register_copy 
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [6] phi (byte) main::j#4 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    // [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
    // [6] phi (byte) main::j#4 = (byte) main::j#1 [phi:main::@4->main::@2#0] -- register_copy 
    // main::@2
  b2:
    // [7] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
    // [7] phi (byte) main::k#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuyy=vbuc1 
    ldy #0
    // [7] phi from main::@3 to main::@3 [phi:main::@3->main::@3]
    // [7] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@3->main::@3#0] -- register_copy 
    // main::@3
  b3:
    // asm
    // asm { pha txa pha tya pha jsr$e544 pla tay pla tax pla  }
    pha
    txa
    pha
    tya
    pha
    jsr $e544
    pla
    tay
    pla
    tax
    pla
    // for( byte k:0..10)
    // [9] (byte) main::k#1 ← ++ (byte) main::k#2 -- vbuyy=_inc_vbuyy 
    iny
    // [10] if((byte) main::k#1!=(byte) $b) goto main::@3 -- vbuyy_neq_vbuc1_then_la1 
    cpy #$b
    bne b3
    // main::@4
    // for( byte j:0..10)
    // [11] (byte) main::j#1 ← ++ (byte) main::j#4 -- vbuxx=_inc_vbuxx 
    inx
    // [12] if((byte) main::j#1!=(byte) $b) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b2
    // main::@5
    // for( byte i:0..10)
    // [13] (byte) main::i#1 ← ++ (byte) main::i#6 -- vbuaa=_inc_vbuaa 
    clc
    adc #1
    // [14] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuaa_neq_vbuc1_then_la1 
    cmp #$b
    bne b1
    // main::@return
    // }
    // [15] return 
    rts
}
  // File Data

