
CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@2
main: scope:[main]  from @2
  (byte*) main::screen#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  (byte*) main::z#0 ← ((byte*)) (word/signed word/dword/signed dword) 1104
  *((byte*) main::z#0 + (byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/word/signed word/dword/signed dword) 240
  *((byte*) main::z#0 + (byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte/signed byte/word/signed word/dword/signed dword) 15
  (byte) main::x#0 ← (byte/word/signed word/dword/signed dword) 170
  (byte) fct::x#0 ← (byte) main::x#0
  (byte*) fct::z#0 ← (byte*) main::z#0
  call fct 
  (byte) fct::return#0 ← (byte) fct::return#3
  to:main::@1
main::@1: scope:[main]  from main
  (byte*) main::z#2 ← phi( main/(byte*) main::z#0 )
  (byte*) main::screen#1 ← phi( main/(byte*) main::screen#0 )
  (byte) fct::return#4 ← phi( main/(byte) fct::return#0 )
  (byte~) main::$0 ← (byte) fct::return#4
  (byte) main::a1#0 ← (byte~) main::$0
  *((byte*) main::screen#1 + (byte/signed byte/word/signed word/dword/signed dword) 0) ← (byte) main::a1#0
  (byte*) main::z#1 ← ++ (byte*) main::z#2
  (byte) main::x#1 ← (byte/signed byte/word/signed word/dword/signed dword) 85
  (byte) fct::x#1 ← (byte) main::x#1
  (byte*) fct::z#1 ← (byte*) main::z#1
  call fct 
  (byte) fct::return#1 ← (byte) fct::return#3
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte*) main::screen#2 ← phi( main::@1/(byte*) main::screen#1 )
  (byte) fct::return#5 ← phi( main::@1/(byte) fct::return#1 )
  (byte~) main::$1 ← (byte) fct::return#5
  (byte) main::a2#0 ← (byte~) main::$1
  *((byte*) main::screen#2 + (byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) main::a2#0
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return
fct: scope:[fct]  from main main::@1
  (byte*) fct::z#2 ← phi( main/(byte*) fct::z#0 main::@1/(byte*) fct::z#1 )
  (byte) fct::x#2 ← phi( main/(byte) fct::x#0 main::@1/(byte) fct::x#1 )
  (byte~) fct::$0 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (byte/signed byte/word/signed word/dword/signed dword) 2)
  (byte) fct::a#0 ← (byte~) fct::$0
  (byte) fct::return#2 ← (byte) fct::a#0
  to:fct::@return
fct::@return: scope:[fct]  from fct
  (byte) fct::return#6 ← phi( fct/(byte) fct::return#2 )
  (byte) fct::return#3 ← (byte) fct::return#6
  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
(byte()) fct((byte) fct::x , (byte*) fct::z)
(byte~) fct::$0
(label) fct::@return
(byte) fct::a !reg byte a
(byte) fct::a#0 !reg byte a
(byte) fct::return
(byte) fct::return#0
(byte) fct::return#1
(byte) fct::return#2
(byte) fct::return#3
(byte) fct::return#4
(byte) fct::return#5
(byte) fct::return#6
(byte) fct::x !reg byte x
(byte) fct::x#0 !reg byte x
(byte) fct::x#1 !reg byte x
(byte) fct::x#2 !reg byte x
(byte*) fct::z
(byte*) fct::z#0
(byte*) fct::z#1
(byte*) fct::z#2
(void()) main()
(byte~) main::$0
(byte~) main::$1
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::a1
(byte) main::a1#0
(byte) main::a2
(byte) main::a2#0
(byte*) main::screen
(byte*) main::screen#0
(byte*) main::screen#1
(byte*) main::screen#2
(byte) main::x
(byte) main::x#0
(byte) main::x#1
(byte*) main::z
(byte*) main::z#0
(byte*) main::z#1
(byte*) main::z#2

Culled Empty Block (label) @3
Successful SSA optimization Pass2CullEmptyBlocks
Alias (byte) fct::return#0 = (byte) fct::return#4 
Alias (byte*) main::screen#0 = (byte*) main::screen#1 (byte*) main::screen#2 
Alias (byte*) main::z#0 = (byte*) main::z#2 
Alias (byte) main::a1#0 = (byte~) main::$0 
Alias (byte) fct::return#1 = (byte) fct::return#5 
Alias (byte) main::a2#0 = (byte~) main::$1 
Alias (byte) fct::return#2 = (byte) fct::a#0 (byte~) fct::$0 (byte) fct::return#6 (byte) fct::return#3 
Successful SSA optimization Pass2AliasElimination
Constant (const byte*) main::screen#0 = ((byte*))1024
Constant (const byte*) main::z#0 = ((byte*))1104
Constant (const byte) main::x#0 = 170
Constant (const byte) main::x#1 = 85
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) fct::x#0 = main::x#0
Constant (const byte*) fct::z#0 = main::z#0
Constant (const byte*) main::z#1 = ++main::z#0
Constant (const byte) fct::x#1 = main::x#1
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) fct::z#1 = main::z#1
Successful SSA optimization Pass2ConstantIdentification
Consolidated array index constant in *(main::z#0+2)
Consolidated array index constant in *(main::z#0+3)
Consolidated array index constant in *(main::screen#0+0)
Consolidated array index constant in *(main::screen#0+1)
Successful SSA optimization Pass2ConstantAdditionElimination
Inlining constant with different constant siblings (const byte*) main::z#0
Inlining constant with different constant siblings (const byte) main::x#0
Inlining constant with different constant siblings (const byte) main::x#1
Inlining constant with different constant siblings (const byte*) main::z#1
Inlining constant with var siblings (const byte) fct::x#0
Inlining constant with var siblings (const byte*) fct::z#0
Inlining constant with var siblings (const byte) fct::x#1
Inlining constant with var siblings (const byte*) fct::z#1
Constant inlined fct::z#0 = ((byte*))(word/signed word/dword/signed dword) 1104
Constant inlined fct::z#1 = ++((byte*))(word/signed word/dword/signed dword) 1104
Constant inlined main::z#0 = ((byte*))(word/signed word/dword/signed dword) 1104
Constant inlined main::z#1 = ++((byte*))(word/signed word/dword/signed dword) 1104
Constant inlined main::x#0 = (byte/word/signed word/dword/signed dword) 170
Constant inlined main::x#1 = (byte/signed byte/word/signed word/dword/signed dword) 85
Constant inlined fct::x#0 = (byte/word/signed word/dword/signed dword) 170
Constant inlined fct::x#1 = (byte/signed byte/word/signed word/dword/signed dword) 85
Successful SSA optimization Pass2ConstantInlining
Simplifying constant plus zero main::screen#0+0
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to fct:6 fct:10 

Created 2 initial phi equivalence classes
Coalesced down to 2 phi equivalence classes
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@2
@2: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @2
  [3] phi()
main: scope:[main]  from @2
  [4] *(((byte*))(word/signed word/dword/signed dword) 1104+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/word/signed word/dword/signed dword) 240
  [5] *(((byte*))(word/signed word/dword/signed dword) 1104+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte/signed byte/word/signed word/dword/signed dword) 15
  [6] call fct 
  [7] (byte) fct::return#0 ← (byte) fct::return#2
  to:main::@1
main::@1: scope:[main]  from main
  [8] (byte) main::a1#0 ← (byte) fct::return#0
  [9] *((const byte*) main::screen#0) ← (byte) main::a1#0
  [10] call fct 
  [11] (byte) fct::return#1 ← (byte) fct::return#2
  to:main::@2
main::@2: scope:[main]  from main::@1
  [12] (byte) main::a2#0 ← (byte) fct::return#1
  [13] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) main::a2#0
  to:main::@return
main::@return: scope:[main]  from main::@2
  [14] return 
  to:@return
fct: scope:[fct]  from main main::@1
  [15] (byte*) fct::z#2 ← phi( main/((byte*))(word/signed word/dword/signed dword) 1104 main::@1/++((byte*))(word/signed word/dword/signed dword) 1104 )
  [15] (byte) fct::x#2 ← phi( main/(byte/word/signed word/dword/signed dword) 170 main::@1/(byte/signed byte/word/signed word/dword/signed dword) 85 )
  [16] (byte) fct::return#2 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (byte/signed byte/word/signed word/dword/signed dword) 2)
  to:fct::@return
fct::@return: scope:[fct]  from fct
  [17] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte()) fct((byte) fct::x , (byte*) fct::z)
(byte) fct::a !reg byte a
(byte) fct::return
(byte) fct::return#0 4.0
(byte) fct::return#1 4.0
(byte) fct::return#2 1.5
(byte) fct::x !reg byte x
(byte) fct::x#2 !reg byte x 2.0
(byte*) fct::z
(byte*) fct::z#2 2.0
(void()) main()
(byte) main::a1
(byte) main::a1#0 4.0
(byte) main::a2
(byte) main::a2#0 4.0
(byte*) main::screen
(byte) main::x
(byte*) main::z

Initial phi equivalence classes
[ fct::x#2 ]
[ fct::z#2 ]
Added variable fct::return#0 to zero page equivalence class [ fct::return#0 ]
Added variable main::a1#0 to zero page equivalence class [ main::a1#0 ]
Added variable fct::return#1 to zero page equivalence class [ fct::return#1 ]
Added variable main::a2#0 to zero page equivalence class [ main::a2#0 ]
Added variable fct::return#2 to zero page equivalence class [ fct::return#2 ]
Complete equivalence classes
[ fct::x#2 ]
[ fct::z#2 ]
[ fct::return#0 ]
[ main::a1#0 ]
[ fct::return#1 ]
[ main::a2#0 ]
[ fct::return#2 ]
Allocated zp ZP_WORD:2 [ fct::z#2 ]
Allocated zp ZP_BYTE:4 [ fct::return#0 ]
Allocated zp ZP_BYTE:5 [ main::a1#0 ]
Allocated zp ZP_BYTE:6 [ fct::return#1 ]
Allocated zp ZP_BYTE:7 [ main::a2#0 ]
Allocated zp ZP_BYTE:8 [ fct::return#2 ]

INITIAL ASM
//SEG0 File Comments
// Tests a sub-optimal fragment synthesis
// vbuaa=vbuxx_band_pbuz1_derefidx_vbuc1 < vbuaa=pbuz1_derefidx_vbuc1_band_vbuxx < vbuaa=pbuz1_derefidx_vbuaa_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuaa < vbuaa=vbuaa_band_pbuz1_derefidx_vbuyy - clobber:A Y  cycles:11.5
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG5 @2
b2:
//SEG6 [2] call main 
  jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
    .label screen = $400
    .label a1 = 5
    .label a2 = 7
  //SEG10 [4] *(((byte*))(word/signed word/dword/signed dword) 1104+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/word/signed word/dword/signed dword) 240 -- _deref_pbuc1=vbuc2 
    lda #$f0
    sta $450+2
  //SEG11 [5] *(((byte*))(word/signed word/dword/signed dword) 1104+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte/signed byte/word/signed word/dword/signed dword) 15 -- _deref_pbuc1=vbuc2 
    lda #$f
    sta $450+3
  //SEG12 [6] call fct 
  //SEG13 [15] phi from main to fct [phi:main->fct]
  fct_from_main:
  //SEG14 [15] phi (byte*) fct::z#2 = ((byte*))(word/signed word/dword/signed dword) 1104 [phi:main->fct#0] -- pbuz1=pbuc1 
    lda #<$450
    sta fct.z
    lda #>$450
    sta fct.z+1
  //SEG15 [15] phi (byte) fct::x#2 = (byte/word/signed word/dword/signed dword) 170 [phi:main->fct#1] -- vbuxx=vbuc1 
    ldx #$aa
    jsr fct
  //SEG16 [7] (byte) fct::return#0 ← (byte) fct::return#2 -- vbuz1=vbuz2 
    lda fct.return_2
    sta fct.return
    jmp b1
  //SEG17 main::@1
  b1:
  //SEG18 [8] (byte) main::a1#0 ← (byte) fct::return#0 -- vbuz1=vbuz2 
    lda fct.return
    sta a1
  //SEG19 [9] *((const byte*) main::screen#0) ← (byte) main::a1#0 -- _deref_pbuc1=vbuz1 
    lda a1
    sta screen
  //SEG20 [10] call fct 
  //SEG21 [15] phi from main::@1 to fct [phi:main::@1->fct]
  fct_from_b1:
  //SEG22 [15] phi (byte*) fct::z#2 = ++((byte*))(word/signed word/dword/signed dword) 1104 [phi:main::@1->fct#0] -- pbuz1=pbuc1 
    lda #<$450+1
    sta fct.z
    lda #>$450+1
    sta fct.z+1
  //SEG23 [15] phi (byte) fct::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 85 [phi:main::@1->fct#1] -- vbuxx=vbuc1 
    ldx #$55
    jsr fct
  //SEG24 [11] (byte) fct::return#1 ← (byte) fct::return#2 -- vbuz1=vbuz2 
    lda fct.return_2
    sta fct.return_1
    jmp b2
  //SEG25 main::@2
  b2:
  //SEG26 [12] (byte) main::a2#0 ← (byte) fct::return#1 -- vbuz1=vbuz2 
    lda fct.return_1
    sta a2
  //SEG27 [13] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) main::a2#0 -- _deref_pbuc1=vbuz1 
    lda a2
    sta screen+1
    jmp breturn
  //SEG28 main::@return
  breturn:
  //SEG29 [14] return 
    rts
}
//SEG30 fct
// fct(byte register(X) x, byte* zeropage(2) z)
fct: {
    .label return = 4
    .label return_1 = 6
    .label return_2 = 8
    .label z = 2
  //SEG31 [16] (byte) fct::return#2 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (byte/signed byte/word/signed word/dword/signed dword) 2) -- vbuz1=vbuxx_band_pbuz2_derefidx_vbuc1 
    ldy #2
    txa
    and (z),y
    sta return_2
    jmp breturn
  //SEG32 fct::@return
  breturn:
  //SEG33 [17] return 
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *(((byte*))(word/signed word/dword/signed dword) 1104+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/word/signed word/dword/signed dword) 240 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] *(((byte*))(word/signed word/dword/signed dword) 1104+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte/signed byte/word/signed word/dword/signed dword) 15 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [16] (byte) fct::return#2 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (byte/signed byte/word/signed word/dword/signed dword) 2) [ fct::return#2 ] ( main:2::fct:6 [ fct::return#2 ] main:2::fct:10 [ fct::return#2 ] ) always clobbers reg byte a reg byte y 
Potential registers reg byte x [ fct::x#2 ] : reg byte x , 
Potential registers zp ZP_WORD:2 [ fct::z#2 ] : zp ZP_WORD:2 , 
Potential registers zp ZP_BYTE:4 [ fct::return#0 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ main::a1#0 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:6 [ fct::return#1 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:7 [ main::a2#0 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:8 [ fct::return#2 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [fct] 4: zp ZP_BYTE:4 [ fct::return#0 ] 4: zp ZP_BYTE:6 [ fct::return#1 ] 2: reg byte x [ fct::x#2 ] 2: zp ZP_WORD:2 [ fct::z#2 ] 1.5: zp ZP_BYTE:8 [ fct::return#2 ] 
Uplift Scope [main] 4: zp ZP_BYTE:5 [ main::a1#0 ] 4: zp ZP_BYTE:7 [ main::a2#0 ] 
Uplift Scope [] 

Uplifting [fct] best 113 combination reg byte a [ fct::return#0 ] reg byte a [ fct::return#1 ] reg byte x [ fct::x#2 ] zp ZP_WORD:2 [ fct::z#2 ] reg byte a [ fct::return#2 ] 
Uplifting [main] best 101 combination reg byte a [ main::a1#0 ] reg byte a [ main::a2#0 ] 
Uplifting [] best 101 combination 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Tests a sub-optimal fragment synthesis
// vbuaa=vbuxx_band_pbuz1_derefidx_vbuc1 < vbuaa=pbuz1_derefidx_vbuc1_band_vbuxx < vbuaa=pbuz1_derefidx_vbuaa_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuaa < vbuaa=vbuaa_band_pbuz1_derefidx_vbuyy - clobber:A Y  cycles:11.5
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG5 @2
b2:
//SEG6 [2] call main 
  jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
    .label screen = $400
  //SEG10 [4] *(((byte*))(word/signed word/dword/signed dword) 1104+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/word/signed word/dword/signed dword) 240 -- _deref_pbuc1=vbuc2 
    lda #$f0
    sta $450+2
  //SEG11 [5] *(((byte*))(word/signed word/dword/signed dword) 1104+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte/signed byte/word/signed word/dword/signed dword) 15 -- _deref_pbuc1=vbuc2 
    lda #$f
    sta $450+3
  //SEG12 [6] call fct 
  //SEG13 [15] phi from main to fct [phi:main->fct]
  fct_from_main:
  //SEG14 [15] phi (byte*) fct::z#2 = ((byte*))(word/signed word/dword/signed dword) 1104 [phi:main->fct#0] -- pbuz1=pbuc1 
    lda #<$450
    sta fct.z
    lda #>$450
    sta fct.z+1
  //SEG15 [15] phi (byte) fct::x#2 = (byte/word/signed word/dword/signed dword) 170 [phi:main->fct#1] -- vbuxx=vbuc1 
    ldx #$aa
    jsr fct
  //SEG16 [7] (byte) fct::return#0 ← (byte) fct::return#2
    jmp b1
  //SEG17 main::@1
  b1:
  //SEG18 [8] (byte) main::a1#0 ← (byte) fct::return#0
  //SEG19 [9] *((const byte*) main::screen#0) ← (byte) main::a1#0 -- _deref_pbuc1=vbuaa 
    sta screen
  //SEG20 [10] call fct 
  //SEG21 [15] phi from main::@1 to fct [phi:main::@1->fct]
  fct_from_b1:
  //SEG22 [15] phi (byte*) fct::z#2 = ++((byte*))(word/signed word/dword/signed dword) 1104 [phi:main::@1->fct#0] -- pbuz1=pbuc1 
    lda #<$450+1
    sta fct.z
    lda #>$450+1
    sta fct.z+1
  //SEG23 [15] phi (byte) fct::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 85 [phi:main::@1->fct#1] -- vbuxx=vbuc1 
    ldx #$55
    jsr fct
  //SEG24 [11] (byte) fct::return#1 ← (byte) fct::return#2
    jmp b2
  //SEG25 main::@2
  b2:
  //SEG26 [12] (byte) main::a2#0 ← (byte) fct::return#1
  //SEG27 [13] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) main::a2#0 -- _deref_pbuc1=vbuaa 
    sta screen+1
    jmp breturn
  //SEG28 main::@return
  breturn:
  //SEG29 [14] return 
    rts
}
//SEG30 fct
// fct(byte register(X) x, byte* zeropage(2) z)
fct: {
    .label z = 2
  //SEG31 [16] (byte) fct::return#2 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (byte/signed byte/word/signed word/dword/signed dword) 2) -- vbuaa=vbuxx_band_pbuz1_derefidx_vbuc1 
    ldy #2
    txa
    and (z),y
    jmp breturn
  //SEG32 fct::@return
  breturn:
  //SEG33 [17] return 
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b2
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b2_from_bbegin:
Removing instruction b2:
Removing instruction bend_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction fct_from_main:
Removing instruction b1:
Removing instruction fct_from_b1:
Removing instruction b2:
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 bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @2
(label) @begin
(label) @end
(byte()) fct((byte) fct::x , (byte*) fct::z)
(label) fct::@return
(byte) fct::a !reg byte a
(byte) fct::return
(byte) fct::return#0 reg byte a 4.0
(byte) fct::return#1 reg byte a 4.0
(byte) fct::return#2 reg byte a 1.5
(byte) fct::x !reg byte x
(byte) fct::x#2 !reg byte x 2.0
(byte*) fct::z
(byte*) fct::z#2 z zp ZP_WORD:2 2.0
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::a1
(byte) main::a1#0 reg byte a 4.0
(byte) main::a2
(byte) main::a2#0 reg byte a 4.0
(byte*) main::screen
(const byte*) main::screen#0 screen = ((byte*))(word/signed word/dword/signed dword) 1024
(byte) main::x
(byte*) main::z

reg byte x [ fct::x#2 ]
zp ZP_WORD:2 [ fct::z#2 ]
reg byte a [ fct::return#0 ]
reg byte a [ main::a1#0 ]
reg byte a [ fct::return#1 ]
reg byte a [ main::a2#0 ]
reg byte a [ fct::return#2 ]


FINAL ASSEMBLER
Score: 77

//SEG0 File Comments
// Tests a sub-optimal fragment synthesis
// vbuaa=vbuxx_band_pbuz1_derefidx_vbuc1 < vbuaa=pbuz1_derefidx_vbuc1_band_vbuxx < vbuaa=pbuz1_derefidx_vbuaa_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuaa < vbuaa=vbuaa_band_pbuz1_derefidx_vbuyy - clobber:A Y  cycles:11.5
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG5 @2
//SEG6 [2] call main 
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
//SEG8 @end
//SEG9 main
main: {
    .label screen = $400
  //SEG10 [4] *(((byte*))(word/signed word/dword/signed dword) 1104+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/word/signed word/dword/signed dword) 240 -- _deref_pbuc1=vbuc2 
    lda #$f0
    sta $450+2
  //SEG11 [5] *(((byte*))(word/signed word/dword/signed dword) 1104+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte/signed byte/word/signed word/dword/signed dword) 15 -- _deref_pbuc1=vbuc2 
    lda #$f
    sta $450+3
  //SEG12 [6] call fct 
  //SEG13 [15] phi from main to fct [phi:main->fct]
  //SEG14 [15] phi (byte*) fct::z#2 = ((byte*))(word/signed word/dword/signed dword) 1104 [phi:main->fct#0] -- pbuz1=pbuc1 
    lda #<$450
    sta fct.z
    lda #>$450
    sta fct.z+1
  //SEG15 [15] phi (byte) fct::x#2 = (byte/word/signed word/dword/signed dword) 170 [phi:main->fct#1] -- vbuxx=vbuc1 
    ldx #$aa
    jsr fct
  //SEG16 [7] (byte) fct::return#0 ← (byte) fct::return#2
  //SEG17 main::@1
  //SEG18 [8] (byte) main::a1#0 ← (byte) fct::return#0
  //SEG19 [9] *((const byte*) main::screen#0) ← (byte) main::a1#0 -- _deref_pbuc1=vbuaa 
    sta screen
  //SEG20 [10] call fct 
  //SEG21 [15] phi from main::@1 to fct [phi:main::@1->fct]
  //SEG22 [15] phi (byte*) fct::z#2 = ++((byte*))(word/signed word/dword/signed dword) 1104 [phi:main::@1->fct#0] -- pbuz1=pbuc1 
    lda #<$450+1
    sta fct.z
    lda #>$450+1
    sta fct.z+1
  //SEG23 [15] phi (byte) fct::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 85 [phi:main::@1->fct#1] -- vbuxx=vbuc1 
    ldx #$55
    jsr fct
  //SEG24 [11] (byte) fct::return#1 ← (byte) fct::return#2
  //SEG25 main::@2
  //SEG26 [12] (byte) main::a2#0 ← (byte) fct::return#1
  //SEG27 [13] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) main::a2#0 -- _deref_pbuc1=vbuaa 
    sta screen+1
  //SEG28 main::@return
  //SEG29 [14] return 
    rts
}
//SEG30 fct
// fct(byte register(X) x, byte* zeropage(2) z)
fct: {
    .label z = 2
  //SEG31 [16] (byte) fct::return#2 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (byte/signed byte/word/signed word/dword/signed dword) 2) -- vbuaa=vbuxx_band_pbuz1_derefidx_vbuc1 
    ldy #2
    txa
    and (z),y
  //SEG32 fct::@return
  //SEG33 [17] return 
    rts
}

