Identified constant variable (byte*) main::screen
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
Culled Empty Block (label) @1
Culled Empty Block (label) isSet::@1

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@2
main: scope:[main]  from @2
  (byte*) main::screen#0 ← ((byte*)) (number) $400
  (byte) main::i#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@3
  (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
  (number~) main::$0 ← (byte) main::i#2 & (number) 1
  (bool~) main::$1 ← (number~) main::$0 == (number) 0
  (byte) isSet::i#0 ← (byte) main::i#2
  (bool) isSet::b#0 ← (bool~) main::$1
  call isSet 
  (bool) isSet::return#0 ← (bool) isSet::return#2
  to:main::@7
main::@7: scope:[main]  from main::@1
  (byte) main::i#6 ← phi( main::@1/(byte) main::i#2 )
  (bool) isSet::return#3 ← phi( main::@1/(bool) isSet::return#0 )
  (bool~) main::$2 ← (bool) isSet::return#3
  if((bool~) main::$2) goto main::@2
  to:main::@4
main::@2: scope:[main]  from main::@7
  (byte) main::i#3 ← phi( main::@7/(byte) main::i#6 )
  *((byte*) main::screen#0 + (byte) main::i#3) ← (byte) '*'
  to:main::@3
main::@4: scope:[main]  from main::@7
  (byte) main::i#4 ← phi( main::@7/(byte) main::i#6 )
  *((byte*) main::screen#0 + (byte) main::i#4) ← (byte) ' '
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@4
  (byte) main::i#5 ← phi( main::@2/(byte) main::i#3 main::@4/(byte) main::i#4 )
  (byte) main::i#1 ← (byte) main::i#5 + rangenext(0,$64)
  (bool~) main::$3 ← (byte) main::i#1 != rangelast(0,$64)
  if((bool~) main::$3) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return
isSet: scope:[isSet]  from main::@1
  (bool) isSet::b#1 ← phi( main::@1/(bool) isSet::b#0 )
  (byte) isSet::i#1 ← phi( main::@1/(byte) isSet::i#0 )
  (number~) isSet::$0 ← (byte) isSet::i#1 & (number) 8
  (bool~) isSet::$1 ← (number~) isSet::$0 != (number) 0
  (bool~) isSet::$2 ← (bool) isSet::b#1 || (bool~) isSet::$1
  (bool) isSet::return#1 ← (bool~) isSet::$2
  to:isSet::@return
isSet::@return: scope:[isSet]  from isSet
  (bool) isSet::return#4 ← phi( isSet/(bool) isSet::return#1 )
  (bool) isSet::return#2 ← (bool) isSet::return#4
  return 
  to:@return
@2: scope:[]  from @begin
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(bool()) isSet((byte) isSet::i , (bool) isSet::b)
(number~) isSet::$0
(bool~) isSet::$1
(bool~) isSet::$2
(label) isSet::@return
(bool) isSet::b
(bool) isSet::b#0
(bool) isSet::b#1
(byte) isSet::i
(byte) isSet::i#0
(byte) isSet::i#1
(bool) isSet::return
(bool) isSet::return#0
(bool) isSet::return#1
(bool) isSet::return#2
(bool) isSet::return#3
(bool) isSet::return#4
(void()) main()
(number~) main::$0
(bool~) main::$1
(bool~) main::$2
(bool~) main::$3
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@7
(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::screen
(byte*) main::screen#0

Adding number conversion cast (unumber) 1 in (number~) main::$0 ← (byte) main::i#2 & (number) 1
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (byte) main::i#2 & (unumber)(number) 1
Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (unumber~) main::$0 == (number) 0
Adding number conversion cast (unumber) 8 in (number~) isSet::$0 ← (byte) isSet::i#1 & (number) 8
Adding number conversion cast (unumber) isSet::$0 in (number~) isSet::$0 ← (byte) isSet::i#1 & (unumber)(number) 8
Adding number conversion cast (unumber) 0 in (bool~) isSet::$1 ← (unumber~) isSet::$0 != (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) main::screen#0 ← (byte*)(number) $400
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast 8
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$0 ← (byte) main::i#2 & (byte) 1
Inferred type updated to byte in (unumber~) isSet::$0 ← (byte) isSet::i#1 & (byte) 8
Alias (bool) isSet::b#0 = (bool~) main::$1 
Alias (bool) isSet::return#0 = (bool) isSet::return#3 
Alias (byte) main::i#2 = (byte) main::i#6 (byte) main::i#3 (byte) main::i#4 
Alias (bool) isSet::return#1 = (bool~) isSet::$2 (bool) isSet::return#4 (bool) isSet::return#2 
Successful SSA optimization Pass2AliasElimination
Alias (byte) main::i#2 = (byte) main::i#5 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) isSet::i#1 (byte) isSet::i#0
Identical Phi Values (bool) isSet::b#1 (bool) isSet::b#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$3 [19] if((byte) main::i#1!=rangelast(0,$64)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) main::screen#0 = (byte*) 1024
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [17] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [19] if(main::i#1!=rangelast(0,$64)) goto main::@1 to (number) $65
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
Inlining constant with var siblings (const byte) main::i#0
Constant inlined main::i#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@8(between main::@3 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
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to isSet:10 

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

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::@3
  [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@3/(byte) main::i#1 )
  [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1
  [7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0
  [8] (byte) isSet::i#0 ← (byte) main::i#2
  [9] call isSet 
  [10] (bool) isSet::return#0 ← (bool) isSet::return#1
  to:main::@5
main::@5: scope:[main]  from main::@1
  [11] (bool~) main::$2 ← (bool) isSet::return#0
  [12] if((bool~) main::$2) goto main::@2
  to:main::@4
main::@4: scope:[main]  from main::@5
  [13] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) ' '
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@4
  [14] (byte) main::i#1 ← ++ (byte) main::i#2
  [15] if((byte) main::i#1!=(byte) $65) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  [16] return 
  to:@return
main::@2: scope:[main]  from main::@5
  [17] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) '*'
  to:main::@3
isSet: scope:[isSet]  from main::@1
  [18] (byte~) isSet::$0 ← (byte) isSet::i#0 & (byte) 8
  [19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0
  [20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1
  to:isSet::@return
isSet::@return: scope:[isSet]  from isSet
  [21] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(bool()) isSet((byte) isSet::i , (bool) isSet::b)
(byte~) isSet::$0 4.0
(bool~) isSet::$1 4.0
(bool) isSet::b
(bool) isSet::b#0 3.25
(byte) isSet::i
(byte) isSet::i#0 13.0
(bool) isSet::return
(bool) isSet::return#0 22.0
(bool) isSet::return#1 4.333333333333333
(void()) main()
(byte~) main::$0 22.0
(bool~) main::$2 22.0
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 6.6
(byte*) main::screen

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Added variable main::$0 to zero page equivalence class [ main::$0 ]
Added variable isSet::b#0 to zero page equivalence class [ isSet::b#0 ]
Added variable isSet::i#0 to zero page equivalence class [ isSet::i#0 ]
Added variable isSet::return#0 to zero page equivalence class [ isSet::return#0 ]
Added variable main::$2 to zero page equivalence class [ main::$2 ]
Added variable isSet::$0 to zero page equivalence class [ isSet::$0 ]
Added variable isSet::$1 to zero page equivalence class [ isSet::$1 ]
Added variable isSet::return#1 to zero page equivalence class [ isSet::return#1 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::$0 ]
[ isSet::b#0 ]
[ isSet::i#0 ]
[ isSet::return#0 ]
[ main::$2 ]
[ isSet::$0 ]
[ isSet::$1 ]
[ isSet::return#1 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ main::$0 ]
Allocated zp ZP_BOOL:4 [ isSet::b#0 ]
Allocated zp ZP_BYTE:5 [ isSet::i#0 ]
Allocated zp ZP_BOOL:6 [ isSet::return#0 ]
Allocated zp ZP_BOOL:7 [ main::$2 ]
Allocated zp ZP_BYTE:8 [ isSet::$0 ]
Allocated zp ZP_BOOL:9 [ isSet::$1 ]
Allocated zp ZP_BOOL:10 [ isSet::return#1 ]

INITIAL ASM
  // File Comments
// Test a function taking boolean parameter and returning boolean result
  // 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 screen = $400
    .label _0 = 3
    .label _2 = 7
    .label i = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    jmp b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  b1_from_b3:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1 -- vbuz1=vbuz2_band_vbuc1 
    lda #1
    and i
    sta _0
    // [7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0 -- vboz1=vbuz2_eq_vbuc1 
    lda _0
    eor #0
    beq !+
    lda #1
  !:
    eor #1
    sta isSet.b
    // [8] (byte) isSet::i#0 ← (byte) main::i#2 -- vbuz1=vbuz2 
    lda i
    sta isSet.i
    // [9] call isSet 
    jsr isSet
    // [10] (bool) isSet::return#0 ← (bool) isSet::return#1 -- vboz1=vboz2 
    lda isSet.return_1
    sta isSet.return
    jmp b5
    // main::@5
  b5:
    // [11] (bool~) main::$2 ← (bool) isSet::return#0 -- vboz1=vboz2 
    lda isSet.return
    sta _2
    // [12] if((bool~) main::$2) goto main::@2 -- vboz1_then_la1 
    lda _2
    cmp #0
    bne b2
    jmp b4
    // main::@4
  b4:
    // [13] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) ' ' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #' '
    ldy i
    sta screen,y
    jmp b3
    // main::@3
  b3:
    // [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc i
    // [15] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$65
    cmp i
    bne b1_from_b3
    jmp breturn
    // main::@return
  breturn:
    // [16] return 
    rts
    // main::@2
  b2:
    // [17] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) '*' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #'*'
    ldy i
    sta screen,y
    jmp b3
}
  // isSet
// Determine whether to set a char to '*.
// Returns true if i&8!=0 or b=true
// isSet(byte zeropage(5) i, bool zeropage(4) b)
isSet: {
    .label _0 = 8
    .label _1 = 9
    .label i = 5
    .label b = 4
    .label return = 6
    .label return_1 = $a
    // [18] (byte~) isSet::$0 ← (byte) isSet::i#0 & (byte) 8 -- vbuz1=vbuz2_band_vbuc1 
    lda #8
    and i
    sta _0
    // [19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0 -- vboz1=vbuz2_neq_vbuc1 
    lda _0
    eor #0
    beq !+
    lda #1
  !:
    sta _1
    // [20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1 -- vboz1=vboz2_or_vboz3 
    lda b
    ora _1
    sta return_1
    jmp breturn
    // isSet::@return
  breturn:
    // [21] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0 [ main::i#2 isSet::b#0 ] ( main:2 [ main::i#2 isSet::b#0 ] ) 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 [13] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) ' ' [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Statement [17] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) '*' [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Statement [19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0 [ isSet::b#0 isSet::$1 ] ( main:2::isSet:9 [ main::i#2 isSet::b#0 isSet::$1 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BOOL:4 [ isSet::b#0 ]
Statement [20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1 [ isSet::return#1 ] ( main:2::isSet:9 [ main::i#2 isSet::return#1 ] ) always clobbers reg byte a 
Statement [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1 [ main::i#2 main::$0 ] ( main:2 [ main::i#2 main::$0 ] ) always clobbers reg byte a 
Statement [7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0 [ main::i#2 isSet::b#0 ] ( main:2 [ main::i#2 isSet::b#0 ] ) always clobbers reg byte a 
Statement [13] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) ' ' [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Statement [17] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) '*' [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Statement [19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0 [ isSet::b#0 isSet::$1 ] ( main:2::isSet:9 [ main::i#2 isSet::b#0 isSet::$1 ] ) always clobbers reg byte a 
Statement [20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1 [ isSet::return#1 ] ( main:2::isSet:9 [ main::i#2 isSet::return#1 ] ) 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 , 
Potential registers zp ZP_BYTE:3 [ main::$0 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BOOL:4 [ isSet::b#0 ] : zp ZP_BOOL:4 , 
Potential registers zp ZP_BYTE:5 [ isSet::i#0 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BOOL:6 [ isSet::return#0 ] : zp ZP_BOOL:6 , reg byte a , 
Potential registers zp ZP_BOOL:7 [ main::$2 ] : zp ZP_BOOL:7 , reg byte a , 
Potential registers zp ZP_BYTE:8 [ isSet::$0 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BOOL:9 [ isSet::$1 ] : zp ZP_BOOL:9 , reg byte a , 
Potential registers zp ZP_BOOL:10 [ isSet::return#1 ] : zp ZP_BOOL:10 , reg byte a , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 23.1: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 22: zp ZP_BYTE:3 [ main::$0 ] 22: zp ZP_BOOL:7 [ main::$2 ] 
Uplift Scope [isSet] 22: zp ZP_BOOL:6 [ isSet::return#0 ] 13: zp ZP_BYTE:5 [ isSet::i#0 ] 4.33: zp ZP_BOOL:10 [ isSet::return#1 ] 4: zp ZP_BYTE:8 [ isSet::$0 ] 4: zp ZP_BOOL:9 [ isSet::$1 ] 3.25: zp ZP_BOOL:4 [ isSet::b#0 ] 
Uplift Scope [] 

Uplifting [main] best 871 combination reg byte x [ main::i#2 main::i#1 ] reg byte a [ main::$0 ] reg byte a [ main::$2 ] 
Uplifting [isSet] best 735 combination reg byte a [ isSet::return#0 ] reg byte x [ isSet::i#0 ] reg byte a [ isSet::return#1 ] reg byte a [ isSet::$0 ] reg byte a [ isSet::$1 ] zp ZP_BOOL:4 [ isSet::b#0 ] 
Limited combination testing to 100 combinations of 128 possible.
Uplifting [] best 735 combination 
Allocated (was zp ZP_BOOL:4) zp ZP_BOOL:2 [ isSet::b#0 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test a function taking boolean parameter and returning boolean result
  // 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 screen = $400
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  b1_from_b3:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #1
    // [7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0 -- vboz1=vbuaa_eq_vbuc1 
    eor #0
    beq !+
    lda #1
  !:
    eor #1
    sta isSet.b
    // [8] (byte) isSet::i#0 ← (byte) main::i#2
    // [9] call isSet 
    jsr isSet
    // [10] (bool) isSet::return#0 ← (bool) isSet::return#1
    jmp b5
    // main::@5
  b5:
    // [11] (bool~) main::$2 ← (bool) isSet::return#0
    // [12] if((bool~) main::$2) goto main::@2 -- vboaa_then_la1 
    cmp #0
    bne b2
    jmp b4
    // main::@4
  b4:
    // [13] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) ' ' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #' '
    sta screen,x
    jmp b3
    // main::@3
  b3:
    // [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [15] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne b1_from_b3
    jmp breturn
    // main::@return
  breturn:
    // [16] return 
    rts
    // main::@2
  b2:
    // [17] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) '*' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'*'
    sta screen,x
    jmp b3
}
  // isSet
// Determine whether to set a char to '*.
// Returns true if i&8!=0 or b=true
// isSet(byte register(X) i, bool zeropage(2) b)
isSet: {
    .label b = 2
    // [18] (byte~) isSet::$0 ← (byte) isSet::i#0 & (byte) 8 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #8
    // [19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0 -- vboaa=vbuaa_neq_vbuc1 
    eor #0
    beq !+
    lda #1
  !:
    // [20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1 -- vboaa=vboz1_or_vboaa 
    ora b
    jmp breturn
    // isSet::@return
  breturn:
    // [21] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b5
Removing instruction jmp b4
Removing instruction jmp b3
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b3 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b5:
Removing instruction b4:
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
(bool()) isSet((byte) isSet::i , (bool) isSet::b)
(byte~) isSet::$0 reg byte a 4.0
(bool~) isSet::$1 reg byte a 4.0
(label) isSet::@return
(bool) isSet::b
(bool) isSet::b#0 b zp ZP_BOOL:2 3.25
(byte) isSet::i
(byte) isSet::i#0 reg byte x 13.0
(bool) isSet::return
(bool) isSet::return#0 reg byte a 22.0
(bool) isSet::return#1 reg byte a 4.333333333333333
(void()) main()
(byte~) main::$0 reg byte a 22.0
(bool~) main::$2 reg byte a 22.0
(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 x 16.5
(byte) main::i#2 reg byte x 6.6
(byte*) main::screen
(const byte*) main::screen#0 screen = (byte*) 1024

reg byte x [ main::i#2 main::i#1 ]
reg byte a [ main::$0 ]
zp ZP_BOOL:2 [ isSet::b#0 ]
reg byte x [ isSet::i#0 ]
reg byte a [ isSet::return#0 ]
reg byte a [ main::$2 ]
reg byte a [ isSet::$0 ]
reg byte a [ isSet::$1 ]
reg byte a [ isSet::return#1 ]


FINAL ASSEMBLER
Score: 540

  // File Comments
// Test a function taking boolean parameter and returning boolean result
  // 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: {
    .label screen = $400
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    // main::@1
  b1:
    // i&1
    // [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #1
    // isSet(i, (i&1)==0)
    // [7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0 -- vboz1=vbuaa_eq_vbuc1 
    eor #0
    beq !+
    lda #1
  !:
    eor #1
    sta isSet.b
    // [8] (byte) isSet::i#0 ← (byte) main::i#2
    // [9] call isSet 
    jsr isSet
    // [10] (bool) isSet::return#0 ← (bool) isSet::return#1
    // main::@5
    // [11] (bool~) main::$2 ← (bool) isSet::return#0
    // if( isSet(i, (i&1)==0))
    // [12] if((bool~) main::$2) goto main::@2 -- vboaa_then_la1 
    cmp #0
    bne b2
    // main::@4
    // screen[i] = ' '
    // [13] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) ' ' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #' '
    sta screen,x
    // main::@3
  b3:
    // for(byte i: 0..100)
    // [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [15] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne b1
    // main::@return
    // }
    // [16] return 
    rts
    // main::@2
  b2:
    // screen[i] = '*'
    // [17] *((const byte*) main::screen#0 + (byte) main::i#2) ← (byte) '*' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'*'
    sta screen,x
    jmp b3
}
  // isSet
// Determine whether to set a char to '*.
// Returns true if i&8!=0 or b=true
// isSet(byte register(X) i, bool zeropage(2) b)
isSet: {
    .label b = 2
    // i&8
    // [18] (byte~) isSet::$0 ← (byte) isSet::i#0 & (byte) 8 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #8
    // (i&8)!=0
    // [19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0 -- vboaa=vbuaa_neq_vbuc1 
    eor #0
    beq !+
    lda #1
  !:
    // b || ((i&8)!=0)
    // [20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1 -- vboaa=vboz1_or_vboaa 
    ora b
    // isSet::@return
    // }
    // [21] return 
    rts
}
  // File Data

