
CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1
main: scope:[main]  from @1
  (bool*) main::bscreen#0 ← ((bool*)) (word/signed word/dword/signed dword) 1024
  *((bool*) main::bscreen#0 + (byte/signed byte/word/signed word/dword/signed dword) 0) ← true
  *((bool*) main::bscreen#0 + (byte/signed byte/word/signed word/dword/signed dword) 1) ← false
  (bool*~) main::$0 ← (bool*) main::bscreen#0 + (byte/signed byte/word/signed word/dword/signed dword) 2
  (bool*) main::bscreen#1 ← (bool*~) main::$0
  *((bool*) main::bscreen#1) ← true
  (bool~) main::$1 ← ! *((bool*) main::bscreen#1)
  if((bool~) main::$1) goto main::@1
  to:main::@2
main::@1: scope:[main]  from main
  to:main::@return
main::@2: scope:[main]  from main
  (bool*) main::bscreen#3 ← phi( main/(bool*) main::bscreen#1 )
  (bool*) main::bscreen#2 ← ++ (bool*) main::bscreen#3
  *((bool*) main::bscreen#2) ← true
  to:main::@return
main::@return: scope:[main]  from main::@1 main::@2
  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
(label) main::@1
(label) main::@2
(label) main::@return
(bool*) main::bscreen
(bool*) main::bscreen#0
(bool*) main::bscreen#1
(bool*) main::bscreen#2
(bool*) main::bscreen#3

Culled Empty Block (label) main::@1
Culled Empty Block (label) @2
Successful SSA optimization Pass2CullEmptyBlocks
Alias (bool*) main::bscreen#1 = (bool*~) main::$0 (bool*) main::bscreen#3 
Successful SSA optimization Pass2AliasElimination
Rewriting ! if()-condition to reversed if() [6] (bool~) main::$1 ← ! *((bool*) main::bscreen#1)
Successful SSA optimization Pass2ConditionalAndOrRewriting
Constant (const bool*) main::bscreen#0 = ((bool*))1024
Successful SSA optimization Pass2ConstantIdentification
Constant (const bool*) main::bscreen#1 = main::bscreen#0+2
Successful SSA optimization Pass2ConstantIdentification
Constant (const bool*) main::bscreen#2 = ++main::bscreen#1
Successful SSA optimization Pass2ConstantIdentification
Consolidated array index constant in *(main::bscreen#0+0)
Consolidated array index constant in *(main::bscreen#0+1)
Successful SSA optimization Pass2ConstantAdditionElimination
Inlining constant with different constant siblings (const bool*) main::bscreen#0
Inlining constant with different constant siblings (const bool*) main::bscreen#1
Inlining constant with different constant siblings (const bool*) main::bscreen#2
Constant inlined main::bscreen#2 = ++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2
Constant inlined main::bscreen#0 = ((bool*))(word/signed word/dword/signed dword) 1024
Constant inlined main::bscreen#1 = ((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2
Successful SSA optimization Pass2ConstantInlining
Simplifying constant plus zero ((bool*))1024+0
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2 

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

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] *(((bool*))(word/signed word/dword/signed dword) 1024) ← true
  [5] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false
  [6] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true
  [7] if(*(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main main::@2
  [8] return 
  to:@return
main::@2: scope:[main]  from main
  [9] *(++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true
  to:main::@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(bool*) main::bscreen

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
//SEG0 File Comments
// Tests a pointer to a boolean
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main 
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
  //SEG10 [4] *(((bool*))(word/signed word/dword/signed dword) 1024) ← true -- _deref_pboc1=vboc2 
    lda #1
    sta $400
  //SEG11 [5] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false -- _deref_pboc1=vboc2 
    lda #0
    sta $400+1
  //SEG12 [6] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true -- _deref_pboc1=vboc2 
    lda #1
    sta $400+2
  //SEG13 [7] if(*(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 -- _deref_pboc1_then_la1 
    lda $400+2
    cmp #0
    bne b2
    jmp breturn
  //SEG14 main::@return
  breturn:
  //SEG15 [8] return 
    rts
  //SEG16 main::@2
  b2:
  //SEG17 [9] *(++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true -- _deref_pboc1=vboc2 
    lda #1
    sta $400+2+1
    jmp breturn
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *(((bool*))(word/signed word/dword/signed dword) 1024) ← true [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] if(*(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [9] *(++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) always clobbers reg byte a 

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

Uplifting [main] best 56 combination 
Uplifting [] best 56 combination 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Tests a pointer to a boolean
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main 
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
  //SEG10 [4] *(((bool*))(word/signed word/dword/signed dword) 1024) ← true -- _deref_pboc1=vboc2 
    lda #1
    sta $400
  //SEG11 [5] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false -- _deref_pboc1=vboc2 
    lda #0
    sta $400+1
  //SEG12 [6] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true -- _deref_pboc1=vboc2 
    lda #1
    sta $400+2
  //SEG13 [7] if(*(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 -- _deref_pboc1_then_la1 
    lda $400+2
    cmp #0
    bne b2
    jmp breturn
  //SEG14 main::@return
  breturn:
  //SEG15 [8] return 
    rts
  //SEG16 main::@2
  b2:
  //SEG17 [9] *(++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true -- _deref_pboc1=vboc2 
    lda #1
    sta $400+2+1
    jmp breturn
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda $400+2
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
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) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@2
(label) main::@return
(bool*) main::bscreen



FINAL ASSEMBLER
Score: 37

//SEG0 File Comments
// Tests a pointer to a boolean
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG5 @1
//SEG6 [2] call main 
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
  //SEG10 [4] *(((bool*))(word/signed word/dword/signed dword) 1024) ← true -- _deref_pboc1=vboc2 
    lda #1
    sta $400
  //SEG11 [5] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false -- _deref_pboc1=vboc2 
    lda #0
    sta $400+1
  //SEG12 [6] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true -- _deref_pboc1=vboc2 
    lda #1
    sta $400+2
  //SEG13 [7] if(*(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 -- _deref_pboc1_then_la1 
    cmp #0
    bne b2
  //SEG14 main::@return
  breturn:
  //SEG15 [8] return 
    rts
  //SEG16 main::@2
  b2:
  //SEG17 [9] *(++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true -- _deref_pboc1=vboc2 
    lda #1
    sta $400+2+1
    jmp breturn
}

