
CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1
main: scope:[main]  from @1
  (byte[]) main::STRING#0 ← (const string) main::$5
  (byte*) main::PTR#0 ← ((byte*)) (word/dword/signed dword) 40958
  (byte~) main::$0 ← < (byte[]) main::STRING#0
  *((byte*) main::PTR#0) ← (byte~) main::$0
  (byte*~) main::$1 ← (byte*) main::PTR#0 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte~) main::$2 ← > (byte[]) main::STRING#0
  *((byte*~) main::$1) ← (byte~) main::$2
  (byte*~) main::$3 ← (byte*) main::PTR#0 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte*~) main::$4 ← ((byte*)) { *((byte*~) main::$3), *((byte*) main::PTR#0) }
  (byte*) main::ptr#0 ← (byte*~) main::$4
  (byte*) main::SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  *((byte*) main::SCREEN#0) ← *((byte*) main::ptr#0)
  to:main::@return
main::@return: scope:[main]  from main
  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()
(byte~) main::$0
(byte*~) main::$1
(byte~) main::$2
(byte*~) main::$3
(byte*~) main::$4
(const string) main::$5 = (string) "camelot"
(label) main::@return
(byte*) main::PTR
(byte*) main::PTR#0
(byte*) main::SCREEN
(byte*) main::SCREEN#0
(byte[]) main::STRING
(byte[]) main::STRING#0
(byte*) main::ptr
(byte*) main::ptr#0

Culled Empty Block (label) @2
Successful SSA optimization Pass2CullEmptyBlocks
Alias (byte*) main::ptr#0 = (byte*~) main::$4 
Successful SSA optimization Pass2AliasElimination
Constant (const byte[]) main::STRING#0 = main::$5
Constant (const byte*) main::PTR#0 = ((byte*))40958
Constant (const byte*) main::SCREEN#0 = ((byte*))1024
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) main::$0 = <main::STRING#0
Constant (const byte*) main::$1 = main::PTR#0+1
Constant (const byte) main::$2 = >main::STRING#0
Constant (const byte*) main::$3 = main::PTR#0+1
Successful SSA optimization Pass2ConstantIdentification
Fixing inline constructor with main::$6 ← *(main::$3) w= *(main::PTR#0)
Successful SSA optimization Pass2FixInlineConstructors
Eliminating Noop Cast (byte*) main::ptr#0 ← ((byte*)) (word~) main::$6
Successful SSA optimization Pass2NopCastElimination
Constant inlined main::$5 = (const byte[]) main::STRING#0
Constant inlined main::$3 = (const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1
Constant inlined main::$1 = (const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1
Constant inlined main::$2 = >(const byte[]) main::STRING#0
Constant inlined main::$0 = <(const byte[]) main::STRING#0
Successful SSA optimization Pass2ConstantInlining
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] *((const byte*) main::PTR#0) ← <(const byte[]) main::STRING#0
  [5] *((const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← >(const byte[]) main::STRING#0
  [6] (word~) main::$6 ← *((const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1) w= *((const byte*) main::PTR#0)
  [7] *((const byte*) main::SCREEN#0) ← *((byte*)(word~) main::$6)
  to:main::@return
main::@return: scope:[main]  from main
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(word~) main::$6 2.0
(byte*) main::PTR
(byte*) main::SCREEN
(byte[]) main::STRING
(byte*) main::ptr

Initial phi equivalence classes
Added variable main::$6 to zero page equivalence class [ main::$6 ]
Complete equivalence classes
[ main::$6 ]
Allocated zp ZP_WORD:2 [ main::$6 ]

INITIAL ASM
//SEG0 File Comments
// Test assigning address of inline string to pointer
// The result should be an labelled .text in the ASM
// Erroneously tries to inline the string completely leading to a CompileError
//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: {
    .label PTR = $9ffe
    .label SCREEN = $400
    .label _6 = 2
  //SEG10 [4] *((const byte*) main::PTR#0) ← <(const byte[]) main::STRING#0 -- _deref_pbuc1=vbuc2 
    lda #<STRING
    sta PTR
  //SEG11 [5] *((const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← >(const byte[]) main::STRING#0 -- _deref_pbuc1=vbuc2 
    lda #>STRING
    sta PTR+1
  //SEG12 [6] (word~) main::$6 ← *((const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1) w= *((const byte*) main::PTR#0) -- vwuz1=_deref_pbuc1_word__deref_pbuc2 
    lda PTR
    sta _6
    lda PTR+1
    sta _6+1
  //SEG13 [7] *((const byte*) main::SCREEN#0) ← *((byte*)(word~) main::$6) -- _deref_pbuc1=_deref_pbuz1 
    ldy #0
    lda (_6),y
    sta SCREEN
    jmp breturn
  //SEG14 main::@return
  breturn:
  //SEG15 [8] return 
    rts
    STRING: .text "camelot"
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) main::PTR#0) ← <(const byte[]) main::STRING#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] *((const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← >(const byte[]) main::STRING#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] (word~) main::$6 ← *((const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1) w= *((const byte*) main::PTR#0) [ main::$6 ] ( main:2 [ main::$6 ] ) always clobbers reg byte a 
Statement [7] *((const byte*) main::SCREEN#0) ← *((byte*)(word~) main::$6) [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte y 
Potential registers zp ZP_WORD:2 [ main::$6 ] : zp ZP_WORD:2 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 2: zp ZP_WORD:2 [ main::$6 ] 
Uplift Scope [] 

Uplifting [main] best 58 combination zp ZP_WORD:2 [ main::$6 ] 
Uplifting [] best 58 combination 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Test assigning address of inline string to pointer
// The result should be an labelled .text in the ASM
// Erroneously tries to inline the string completely leading to a CompileError
//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: {
    .label PTR = $9ffe
    .label SCREEN = $400
    .label _6 = 2
  //SEG10 [4] *((const byte*) main::PTR#0) ← <(const byte[]) main::STRING#0 -- _deref_pbuc1=vbuc2 
    lda #<STRING
    sta PTR
  //SEG11 [5] *((const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← >(const byte[]) main::STRING#0 -- _deref_pbuc1=vbuc2 
    lda #>STRING
    sta PTR+1
  //SEG12 [6] (word~) main::$6 ← *((const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1) w= *((const byte*) main::PTR#0) -- vwuz1=_deref_pbuc1_word__deref_pbuc2 
    lda PTR
    sta _6
    lda PTR+1
    sta _6+1
  //SEG13 [7] *((const byte*) main::SCREEN#0) ← *((byte*)(word~) main::$6) -- _deref_pbuc1=_deref_pbuz1 
    ldy #0
    lda (_6),y
    sta SCREEN
    jmp breturn
  //SEG14 main::@return
  breturn:
  //SEG15 [8] return 
    rts
    STRING: .text "camelot"
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
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) @1
(label) @begin
(label) @end
(void()) main()
(word~) main::$6 $6 zp ZP_WORD:2 2.0
(label) main::@return
(byte*) main::PTR
(const byte*) main::PTR#0 PTR = ((byte*))(word/dword/signed dword) 40958
(byte*) main::SCREEN
(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(byte[]) main::STRING
(const byte[]) main::STRING#0 STRING = (string) "camelot"
(byte*) main::ptr

zp ZP_WORD:2 [ main::$6 ]


FINAL ASSEMBLER
Score: 43

//SEG0 File Comments
// Test assigning address of inline string to pointer
// The result should be an labelled .text in the ASM
// Erroneously tries to inline the string completely leading to a CompileError
//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: {
    .label PTR = $9ffe
    .label SCREEN = $400
    .label _6 = 2
  //SEG10 [4] *((const byte*) main::PTR#0) ← <(const byte[]) main::STRING#0 -- _deref_pbuc1=vbuc2 
    lda #<STRING
    sta PTR
  //SEG11 [5] *((const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← >(const byte[]) main::STRING#0 -- _deref_pbuc1=vbuc2 
    lda #>STRING
    sta PTR+1
  //SEG12 [6] (word~) main::$6 ← *((const byte*) main::PTR#0+(byte/signed byte/word/signed word/dword/signed dword) 1) w= *((const byte*) main::PTR#0) -- vwuz1=_deref_pbuc1_word__deref_pbuc2 
    lda PTR
    sta _6
    lda PTR+1
    sta _6+1
  //SEG13 [7] *((const byte*) main::SCREEN#0) ← *((byte*)(word~) main::$6) -- _deref_pbuc1=_deref_pbuz1 
    ldy #0
    lda (_6),y
    sta SCREEN
  //SEG14 main::@return
  //SEG15 [8] return 
    rts
    STRING: .text "camelot"
}

