Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@9
Culled Empty Block (label) main::@10
Culled Empty Block (label) @1

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@2

(void()) main()
main: scope:[main]  from @2
  asm { sei  }
  to:main::@1
main::@1: scope:[main]  from main main::@11 main::@8
  if(true) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  (bool~) main::$0 ← *((const byte*) RASTER) < (number) $1e
  if((bool~) main::$0) goto main::@4
  to:main::@8
main::@4: scope:[main]  from main::@2
  call incScreen 
  to:main::@11
main::@11: scope:[main]  from main::@4
  to:main::@1
main::@8: scope:[main]  from main::@2
  *((const byte*) BGCOL) ← (number) 0
  to:main::@1
main::@return: scope:[main]  from main::@1
  return 
  to:@return

(void()) incScreen()
incScreen: scope:[incScreen]  from main::@4
  *((const byte*) BGCOL) ← *((const byte*) RASTER)
  to:incScreen::@return
incScreen::@return: scope:[incScreen]  from incScreen
  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
(const byte*) BGCOL = (byte*)(number) $d021
(const byte*) RASTER = (byte*)(number) $d012
(void()) incScreen()
(label) incScreen::@return
(void()) main()
(bool~) main::$0
(label) main::@1
(label) main::@11
(label) main::@2
(label) main::@4
(label) main::@8
(label) main::@return

Adding number conversion cast (unumber) $1e in (bool~) main::$0 ← *((const byte*) RASTER) < (number) $1e
Adding number conversion cast (unumber) 0 in *((const byte*) BGCOL) ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((const byte*) BGCOL) ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53281
Simplifying constant pointer cast (byte*) 53266
Simplifying constant integer cast $1e
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $1e
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition (bool~) main::$0 [3] if(*((const byte*) RASTER)<(byte) $1e) goto main::@4
Successful SSA optimization Pass2ConditionalJumpSimplification
if() condition always true - replacing block destination [1] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
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::@1
Adding NOP phi() at start of main::@4
Adding NOP phi() at start of main::@11
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to incScreen:10 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @3
Culled Empty Block (label) main::@1
Culled Empty Block (label) main::@11
Renumbering block @2 to @1
Renumbering block main::@2 to main::@1
Renumbering block main::@4 to main::@2
Renumbering block main::@8 to main::@3
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::@2

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()

(void()) main()
main: scope:[main]  from @1
  asm { sei  }
  to:main::@1
main::@1: scope:[main]  from main main::@2 main::@3
  [5] if(*((const byte*) RASTER)<(byte) $1e) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@1
  [6] *((const byte*) BGCOL) ← (byte) 0
  to:main::@1
main::@2: scope:[main]  from main::@1
  [7] phi()
  [8] call incScreen 
  to:main::@1

(void()) incScreen()
incScreen: scope:[incScreen]  from main::@2
  [9] *((const byte*) BGCOL) ← *((const byte*) RASTER)
  to:incScreen::@return
incScreen::@return: scope:[incScreen]  from incScreen
  [10] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) incScreen()
(void()) main()

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Test setting the program PC through a #pc directive
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $2000 "Program"
  // Global Constants & labels
  .label BGCOL = $d021
  .label RASTER = $d012
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    // asm { sei  }
    sei
    jmp __b1
    // main::@1
  __b1:
    // [5] if(*((const byte*) RASTER)<(byte) $1e) goto main::@2 -- _deref_pbuc1_lt_vbuc2_then_la1 
    lda RASTER
    cmp #$1e
    bcc __b2_from___b1
    jmp __b3
    // main::@3
  __b3:
    // [6] *((const byte*) BGCOL) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta BGCOL
    jmp __b1
    // [7] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    jmp __b2
    // main::@2
  __b2:
    // [8] call incScreen 
    jsr incScreen
    jmp __b1
}
  // incScreen
incScreen: {
    // [9] *((const byte*) BGCOL) ← *((const byte*) RASTER) -- _deref_pbuc1=_deref_pbuc2 
    lda RASTER
    sta BGCOL
    jmp __breturn
    // incScreen::@return
  __breturn:
    // [10] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] if(*((const byte*) RASTER)<(byte) $1e) goto main::@2 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) BGCOL) ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [9] *((const byte*) BGCOL) ← *((const byte*) RASTER) [ ] ( main:2::incScreen:8 [ ] ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [incScreen] 
Uplift Scope [] 

Uplifting [main] best 359 combination 
Uplifting [incScreen] best 359 combination 
Uplifting [] best 359 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test setting the program PC through a #pc directive
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $2000 "Program"
  // Global Constants & labels
  .label BGCOL = $d021
  .label RASTER = $d012
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    // asm { sei  }
    sei
    jmp __b1
    // main::@1
  __b1:
    // [5] if(*((const byte*) RASTER)<(byte) $1e) goto main::@2 -- _deref_pbuc1_lt_vbuc2_then_la1 
    lda RASTER
    cmp #$1e
    bcc __b2_from___b1
    jmp __b3
    // main::@3
  __b3:
    // [6] *((const byte*) BGCOL) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta BGCOL
    jmp __b1
    // [7] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    jmp __b2
    // main::@2
  __b2:
    // [8] call incScreen 
    jsr incScreen
    jmp __b1
}
  // incScreen
incScreen: {
    // [9] *((const byte*) BGCOL) ← *((const byte*) RASTER) -- _deref_pbuc1=_deref_pbuc2 
    lda RASTER
    sta BGCOL
    jmp __breturn
    // incScreen::@return
  __breturn:
    // [10] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b3
Removing instruction jmp __b2
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b2_from___b1 with __b2
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction __bend_from___b1:
Removing instruction __b2_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b3:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) BGCOL = (byte*) 53281
(const byte*) RASTER = (byte*) 53266
(void()) incScreen()
(label) incScreen::@return
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3



FINAL ASSEMBLER
Score: 281

  // File Comments
// Test setting the program PC through a #pc directive
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $2000 "Program"
  // Global Constants & labels
  .label BGCOL = $d021
  .label RASTER = $d012
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    // asm
    // asm { sei  }
    sei
    // main::@1
  __b1:
    // if(*RASTER<30)
    // [5] if(*((const byte*) RASTER)<(byte) $1e) goto main::@2 -- _deref_pbuc1_lt_vbuc2_then_la1 
    lda RASTER
    cmp #$1e
    bcc __b2
    // main::@3
    // *BGCOL = 0
    // [6] *((const byte*) BGCOL) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta BGCOL
    jmp __b1
    // [7] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // main::@2
  __b2:
    // incScreen()
    // [8] call incScreen 
    jsr incScreen
    jmp __b1
}
  // incScreen
incScreen: {
    // *BGCOL = *RASTER
    // [9] *((const byte*) BGCOL) ← *((const byte*) RASTER) -- _deref_pbuc1=_deref_pbuc2 
    lda RASTER
    sta BGCOL
    // incScreen::@return
    // }
    // [10] return 
    rts
}
  // File Data

