Adding pointer type conversion cast (byte*) SCREEN in (byte*) SCREEN ← (number) $400

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1
main: scope:[main]  from @2
  (byte) idx#15 ← phi( @2/(byte) idx#16 )
  call print 
  to:main::@1
main::@1: scope:[main]  from main
  (byte) idx#8 ← phi( main/(byte) idx#6 )
  (byte) idx#0 ← (byte) idx#8
  call print 
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte) idx#9 ← phi( main::@1/(byte) idx#6 )
  (byte) idx#1 ← (byte) idx#9
  call print 
  to:main::@3
main::@3: scope:[main]  from main::@2
  (byte) idx#10 ← phi( main::@2/(byte) idx#6 )
  (byte) idx#2 ← (byte) idx#10
  to:main::@return
main::@return: scope:[main]  from main::@3
  (byte) idx#11 ← phi( main::@3/(byte) idx#2 )
  (byte) idx#3 ← (byte) idx#11
  return 
  to:@return
@1: scope:[]  from @begin
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  (byte) idx#4 ← (number) 0
  to:@2
print: scope:[print]  from main main::@1 main::@2
  (byte) idx#12 ← phi( main/(byte) idx#15 main::@1/(byte) idx#0 main::@2/(byte) idx#1 )
  *((byte*) SCREEN#0 + (byte) idx#12) ← (byte) '.'
  (byte) idx#5 ← ++ (byte) idx#12
  to:print::@return
print::@return: scope:[print]  from print
  (byte) idx#13 ← phi( print/(byte) idx#5 )
  (byte) idx#6 ← (byte) idx#13
  return 
  to:@return
@2: scope:[]  from @1
  (byte) idx#16 ← phi( @1/(byte) idx#4 )
  call main 
  to:@3
@3: scope:[]  from @2
  (byte) idx#14 ← phi( @2/(byte) idx#3 )
  (byte) idx#7 ← (byte) idx#14
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte) idx
(byte) idx#0
(byte) idx#1
(byte) idx#10
(byte) idx#11
(byte) idx#12
(byte) idx#13
(byte) idx#14
(byte) idx#15
(byte) idx#16
(byte) idx#2
(byte) idx#3
(byte) idx#4
(byte) idx#5
(byte) idx#6
(byte) idx#7
(byte) idx#8
(byte) idx#9
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(void()) print()
(label) print::@return

Adding number conversion cast (unumber) 0 in (byte) idx#4 ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) idx#4 ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) idx#0 = (byte) idx#8 
Alias (byte) idx#1 = (byte) idx#9 
Alias (byte) idx#10 = (byte) idx#2 (byte) idx#11 (byte) idx#3 
Alias (byte) idx#13 = (byte) idx#5 (byte) idx#6 
Alias (byte) idx#16 = (byte) idx#4 
Alias (byte) idx#14 = (byte) idx#7 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) idx#15 (byte) idx#16
Identical Phi Values (byte) idx#0 (byte) idx#13
Identical Phi Values (byte) idx#1 (byte) idx#13
Identical Phi Values (byte) idx#10 (byte) idx#13
Identical Phi Values (byte) idx#14 (byte) idx#10
Successful SSA optimization Pass2IdenticalPhiElimination
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) idx#16 = 0
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) idx#16
Constant inlined idx#16 = (byte) 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 @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@3
CALL GRAPH
Calls in [] to main:3 
Calls in [main] to print:7 print:9 print:11 

Created 1 initial phi equivalence classes
Coalesced [8] idx#17 ← idx#13
Coalesced (already) [10] idx#18 ← idx#13
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @1
Culled Empty Block (label) @3
Culled Empty Block (label) main::@3
Renumbering block @2 to @1
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
Adding NOP phi() at start of main::@1
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()
main: scope:[main]  from @1
  [4] phi()
  [5] call print 
  to:main::@1
main::@1: scope:[main]  from main
  [6] phi()
  [7] call print 
  to:main::@2
main::@2: scope:[main]  from main::@1
  [8] phi()
  [9] call print 
  to:main::@return
main::@return: scope:[main]  from main::@2
  [10] return 
  to:@return
print: scope:[print]  from main main::@1 main::@2
  [11] (byte) idx#12 ← phi( main/(byte) 0 main::@1/(byte) idx#13 main::@2/(byte) idx#13 )
  [12] *((const byte*) SCREEN#0 + (byte) idx#12) ← (byte) '.'
  [13] (byte) idx#13 ← ++ (byte) idx#12
  to:print::@return
print::@return: scope:[print]  from print
  [14] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte) idx
(byte) idx#12 4.0
(byte) idx#13 1.0
(void()) main()
(void()) print()

Initial phi equivalence classes
[ idx#12 idx#13 ]
Complete equivalence classes
[ idx#12 idx#13 ]
Allocated zp ZP_BYTE:2 [ idx#12 idx#13 ]

INITIAL ASM
//SEG0 File Comments
// Test that void-parameter works top specify function takes no parameters
// Output is "..." in the top left corner of the screen
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label SCREEN = $400
  .label idx = 2
//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 
//SEG7 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
  //SEG11 [5] call print 
  //SEG12 [11] phi from main to print [phi:main->print]
  print_from_main:
  //SEG13 [11] phi (byte) idx#12 = (byte) 0 [phi:main->print#0] -- vbuz1=vbuc1 
    lda #0
    sta idx
    jsr print
  //SEG14 [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    jmp b1
  //SEG15 main::@1
  b1:
  //SEG16 [7] call print 
  //SEG17 [11] phi from main::@1 to print [phi:main::@1->print]
  print_from_b1:
  //SEG18 [11] phi (byte) idx#12 = (byte) idx#13 [phi:main::@1->print#0] -- register_copy 
    jsr print
  //SEG19 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    jmp b2
  //SEG20 main::@2
  b2:
  //SEG21 [9] call print 
  //SEG22 [11] phi from main::@2 to print [phi:main::@2->print]
  print_from_b2:
  //SEG23 [11] phi (byte) idx#12 = (byte) idx#13 [phi:main::@2->print#0] -- register_copy 
    jsr print
    jmp breturn
  //SEG24 main::@return
  breturn:
  //SEG25 [10] return 
    rts
}
//SEG26 print
print: {
  //SEG27 [12] *((const byte*) SCREEN#0 + (byte) idx#12) ← (byte) '.' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #'.'
    ldy idx
    sta SCREEN,y
  //SEG28 [13] (byte) idx#13 ← ++ (byte) idx#12 -- vbuz1=_inc_vbuz1 
    inc idx
    jmp breturn
  //SEG29 print::@return
  breturn:
  //SEG30 [14] return 
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [12] *((const byte*) SCREEN#0 + (byte) idx#12) ← (byte) '.' [ idx#12 ] ( main:2::print:5 [ idx#12 ] main:2::print:7 [ idx#12 ] main:2::print:9 [ idx#12 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ idx#12 idx#13 ]
Statement [12] *((const byte*) SCREEN#0 + (byte) idx#12) ← (byte) '.' [ idx#12 ] ( main:2::print:5 [ idx#12 ] main:2::print:7 [ idx#12 ] main:2::print:9 [ idx#12 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ idx#12 idx#13 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 5: zp ZP_BYTE:2 [ idx#12 idx#13 ] 
Uplift Scope [main] 
Uplift Scope [print] 

Uplifting [] best 65 combination reg byte x [ idx#12 idx#13 ] 
Uplifting [main] best 65 combination 
Uplifting [print] best 65 combination 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Test that void-parameter works top specify function takes no parameters
// Output is "..." in the top left corner of the screen
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label SCREEN = $400
//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 
//SEG7 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
  //SEG11 [5] call print 
  //SEG12 [11] phi from main to print [phi:main->print]
  print_from_main:
  //SEG13 [11] phi (byte) idx#12 = (byte) 0 [phi:main->print#0] -- vbuxx=vbuc1 
    ldx #0
    jsr print
  //SEG14 [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    jmp b1
  //SEG15 main::@1
  b1:
  //SEG16 [7] call print 
  //SEG17 [11] phi from main::@1 to print [phi:main::@1->print]
  print_from_b1:
  //SEG18 [11] phi (byte) idx#12 = (byte) idx#13 [phi:main::@1->print#0] -- register_copy 
    jsr print
  //SEG19 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    jmp b2
  //SEG20 main::@2
  b2:
  //SEG21 [9] call print 
  //SEG22 [11] phi from main::@2 to print [phi:main::@2->print]
  print_from_b2:
  //SEG23 [11] phi (byte) idx#12 = (byte) idx#13 [phi:main::@2->print#0] -- register_copy 
    jsr print
    jmp breturn
  //SEG24 main::@return
  breturn:
  //SEG25 [10] return 
    rts
}
//SEG26 print
print: {
  //SEG27 [12] *((const byte*) SCREEN#0 + (byte) idx#12) ← (byte) '.' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'.'
    sta SCREEN,x
  //SEG28 [13] (byte) idx#13 ← ++ (byte) idx#12 -- vbuxx=_inc_vbuxx 
    inx
    jmp breturn
  //SEG29 print::@return
  breturn:
  //SEG30 [14] return 
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
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 b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_main:
Removing instruction print_from_b1:
Removing instruction b2_from_b1:
Removing instruction print_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction print_from_main:
Removing instruction 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) @1
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte) idx
(byte) idx#12 reg byte x 4.0
(byte) idx#13 reg byte x 1.0
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(void()) print()
(label) print::@return

reg byte x [ idx#12 idx#13 ]


FINAL ASSEMBLER
Score: 41

//SEG0 File Comments
// Test that void-parameter works top specify function takes no parameters
// Output is "..." in the top left corner of the screen
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label SCREEN = $400
//SEG3 @begin
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG5 @1
//SEG6 [2] call main 
//SEG7 [4] phi from @1 to main [phi:@1->main]
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
//SEG9 @end
//SEG10 main
main: {
  //SEG11 [5] call print 
  //SEG12 [11] phi from main to print [phi:main->print]
  //SEG13 [11] phi (byte) idx#12 = (byte) 0 [phi:main->print#0] -- vbuxx=vbuc1 
    ldx #0
    jsr print
  //SEG14 [6] phi from main to main::@1 [phi:main->main::@1]
  //SEG15 main::@1
  //SEG16 [7] call print 
  //SEG17 [11] phi from main::@1 to print [phi:main::@1->print]
  //SEG18 [11] phi (byte) idx#12 = (byte) idx#13 [phi:main::@1->print#0] -- register_copy 
    jsr print
  //SEG19 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  //SEG20 main::@2
  //SEG21 [9] call print 
  //SEG22 [11] phi from main::@2 to print [phi:main::@2->print]
  //SEG23 [11] phi (byte) idx#12 = (byte) idx#13 [phi:main::@2->print#0] -- register_copy 
    jsr print
  //SEG24 main::@return
  //SEG25 [10] return 
    rts
}
//SEG26 print
print: {
  //SEG27 [12] *((const byte*) SCREEN#0 + (byte) idx#12) ← (byte) '.' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'.'
    sta SCREEN,x
  //SEG28 [13] (byte) idx#13 ← ++ (byte) idx#12 -- vbuxx=_inc_vbuxx 
    inx
  //SEG29 print::@return
  //SEG30 [14] return 
    rts
}

