Identified constant variable (byte) c
Identified constant variable (word) d
Identified constant variable (byte) main::col
Identified constant variable (byte*) main::COLS
Identified constant variable (signed byte) main::x
Culled Empty Block (label) main::@2
Culled Empty Block (label) @1
Culled Empty Block (label) s::@1

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  (byte) b#0 ← (number) 2/(number) 2
  to:@2
main: scope:[main]  from @2
  (byte) b#13 ← phi( @2/(byte) b#14 )
  (byte) main::col#0 ← (number) 2
  (byte*) main::COLS#0 ← ((byte*)) (number) $d800
  call s 
  (byte) s::return#0 ← (byte) s::return#2
  to:main::@3
main::@3: scope:[main]  from main
  (byte) b#7 ← phi( main/(byte) b#5 )
  (byte) b#1 ← (byte) b#7
  (byte) b#2 ← ++ (byte) b#1
  (byte) main::i#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main::@1 main::@3
  (byte) b#8 ← phi( main::@1/(byte) b#8 main::@3/(byte) b#2 )
  (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@3/(byte) main::i#0 )
  *((byte*) main::COLS#0 + (byte) main::i#2) ← (byte) main::col#0
  *((byte*) SCREEN#0 + (byte) main::i#2) ← (byte) b#8
  (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,$64)
  (bool~) main::$4 ← (byte) main::i#1 != rangelast(0,$64)
  if((bool~) main::$4) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  (byte) b#9 ← phi( main::@1/(byte) b#8 )
  (byte) b#3 ← (byte) b#9
  return 
  to:@return
s: scope:[s]  from main
  (byte) b#10 ← phi( main/(byte) b#13 )
  (byte) b#4 ← ++ (byte) b#10
  (byte) s::return#1 ← (number) 2
  to:s::@return
s::@return: scope:[s]  from s
  (byte) b#11 ← phi( s/(byte) b#4 )
  (byte) s::return#3 ← phi( s/(byte) s::return#1 )
  (byte) s::return#2 ← (byte) s::return#3
  (byte) b#5 ← (byte) b#11
  return 
  to:@return
@2: scope:[]  from @begin
  (byte) b#14 ← phi( @begin/(byte) b#0 )
  call main 
  to:@3
@3: scope:[]  from @2
  (byte) b#12 ← phi( @2/(byte) b#3 )
  (byte) b#6 ← (byte) b#12
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte) b
(byte) b#0
(byte) b#1
(byte) b#10
(byte) b#11
(byte) b#12
(byte) b#13
(byte) b#14
(byte) b#2
(byte) b#3
(byte) b#4
(byte) b#5
(byte) b#6
(byte) b#7
(byte) b#8
(byte) b#9
(void()) main()
(bool~) main::$4
(label) main::@1
(label) main::@3
(label) main::@return
(byte*) main::COLS
(byte*) main::COLS#0
(byte) main::col
(byte) main::col#0
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte()) s()
(label) s::@return
(byte) s::return
(byte) s::return#0
(byte) s::return#1
(byte) s::return#2
(byte) s::return#3

Adding number conversion cast (unumber) 2/2 in (byte) b#0 ← (number) 2/(number) 2
Adding number conversion cast (unumber) 2 in (byte) main::col#0 ← (number) 2
Adding number conversion cast (unumber) 2 in (byte) s::return#1 ← (number) 2
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) b#0 ← (unumber)(number) 2/(number) 2
Inlining cast (byte) main::col#0 ← (unumber)(number) 2
Inlining cast (byte*) main::COLS#0 ← (byte*)(number) $d800
Inlining cast (byte) s::return#1 ← (unumber)(number) 2
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 2
Simplifying constant pointer cast (byte*) 55296
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) b#1 = (byte) b#7 
Alias (byte) b#3 = (byte) b#9 (byte) b#8 
Alias (byte) s::return#1 = (byte) s::return#3 (byte) s::return#2 
Alias (byte) b#11 = (byte) b#4 (byte) b#5 
Alias (byte) b#0 = (byte) b#14 
Alias (byte) b#12 = (byte) b#6 
Successful SSA optimization Pass2AliasElimination
Self Phi Eliminated (byte) b#3
Successful SSA optimization Pass2SelfPhiElimination
Identical Phi Values (byte) b#13 (byte) b#0
Identical Phi Values (byte) b#1 (byte) b#11
Identical Phi Values (byte) b#3 (byte) b#2
Identical Phi Values (byte) b#10 (byte) b#13
Identical Phi Values (byte) b#12 (byte) b#3
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$4 [16] if((byte) main::i#1!=rangelast(0,$64)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [1] (byte) b#0 ← (unumber)(number) 2/(number) 2
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) b#0 = (unumber)2/2
Constant (const byte) main::col#0 = 2
Constant (const byte*) main::COLS#0 = (byte*) 55296
Constant (const byte) main::i#0 = 0
Constant (const byte) s::return#1 = 2
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) s::return#0 = s::return#1
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [14] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [16] if(main::i#1!=rangelast(0,$64)) goto main::@1 to (number) $65
Eliminating unused constant (const byte) s::return#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const byte) s::return#1
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) $65 in if((byte) main::i#1!=(number) $65) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $65
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $65
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [8] (byte) b#11 ← ++ (const byte) b#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) b#11 = ++b#0
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [1] (byte) b#2 ← ++ (const byte) b#11
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) b#2 = ++b#11
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with different constant siblings (const byte) b#0
Inlining constant with different constant siblings (const byte) b#11
Inlining constant with different constant siblings (const byte) b#2
Constant inlined b#2 = ++++(byte)(number) 2/(number) 2
Constant inlined main::i#0 = (byte) 0
Constant inlined b#11 = ++(byte)(number) 2/(number) 2
Constant inlined b#0 = (byte)(number) 2/(number) 2
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@4(between main::@1 and main::@1)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of s
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to s:6 

Created 1 initial phi equivalence classes
Coalesced [14] main::i#3 ← main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @3
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@4
Renumbering block @2 to @1
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 s

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 s 
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [6] (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main/(byte) 0 )
  [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0
  [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte)(number) 2/(number) 2
  [9] (byte) main::i#1 ← ++ (byte) main::i#2
  [10] if((byte) main::i#1!=(byte) $65) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  [11] return 
  to:@return
s: scope:[s]  from main
  [12] phi()
  to:s::@return
s::@return: scope:[s]  from s
  [13] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte) b
(void()) main()
(byte*) main::COLS
(byte) main::col
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 14.666666666666666
(byte()) s()
(byte) s::return

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

INITIAL ASM
  // File Comments
// used vars
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .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: {
    // used vars
    .const col = 2
    .label COLS = $d800
    .label i = 2
    // [5] call s 
    // [12] phi from main to s [phi:main->s]
  s_from_main:
    jsr s
    // [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [6] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    jmp b1
    // [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
    // [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #col
    ldy i
    sta COLS,y
    // [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte)(number) 2/(number) 2 -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #2/2+1+1
    ldy i
    sta SCREEN,y
    // [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc i
    // [10] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$65
    cmp i
    bne b1_from_b1
    jmp breturn
    // main::@return
  breturn:
    // [11] return 
    rts
}
  // s
s: {
    jmp breturn
    // s::@return
  breturn:
    // [13] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Statement [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte)(number) 2/(number) 2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Statement [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Statement [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte)(number) 2/(number) 2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 31.17: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 
Uplift Scope [s] 
Uplift Scope [] 

Uplifting [main] best 375 combination reg byte x [ main::i#2 main::i#1 ] 
Uplifting [s] best 375 combination 
Uplifting [] best 375 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// used vars
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .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: {
    // used vars
    .const col = 2
    .label COLS = $d800
    // [5] call s 
    // [12] phi from main to s [phi:main->s]
  s_from_main:
    jsr s
    // [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [6] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b1
    // [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
    // [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #col
    sta COLS,x
    // [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte)(number) 2/(number) 2 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #2/2+1+1
    sta SCREEN,x
    // [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [10] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne b1_from_b1
    jmp breturn
    // main::@return
  breturn:
    // [11] return 
    rts
}
  // s
s: {
    jmp breturn
    // s::@return
  breturn:
    // [13] 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 breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b1 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction s_from_main:
Removing instruction b1_from_main:
Removing instruction breturn:
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
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte) b
(void()) main()
(label) main::@1
(label) main::@return
(byte*) main::COLS
(const byte*) main::COLS#0 COLS = (byte*) 55296
(byte) main::col
(const byte) main::col#0 col = (byte) 2
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 14.666666666666666
(byte()) s()
(label) s::@return
(byte) s::return

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


FINAL ASSEMBLER
Score: 243

  // File Comments
// used vars
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .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: {
    // used vars
    .const col = 2
    .label COLS = $d800
    // s()
    // [5] call s 
    // [12] phi from main to s [phi:main->s]
    jsr s
    // [6] phi from main to main::@1 [phi:main->main::@1]
    // [6] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
    // [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    // main::@1
  b1:
    // COLS[i] = col
    // [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #col
    sta COLS,x
    // SCREEN[i] = b
    // [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte)(number) 2/(number) 2 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #2/2+1+1
    sta SCREEN,x
    // for(byte i : 0..100)
    // [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [10] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne b1
    // main::@return
    // }
    // [11] return 
    rts
}
  // s
s: {
    // s::@return
    // [13] return 
    rts
}
  // File Data

