Updating intermediate variable memory area to MAIN_MEMORY main::$0
Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  screen#11 = phi( __start::@1/screen#12 )
  main::i = 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  screen#7 = phi( main/screen#11, main::@1/screen#2 )
  *screen#7 = a
  screen#0 = ++ screen#7
  *screen#0 = main::b
  screen#1 = ++ screen#0
  *screen#1 = main::i
  screen#2 = ++ screen#1
  main::i = main::i + rangenext(0,5)
  main::$0 = main::i != rangelast(0,5)
  if(main::$0) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  screen#8 = phi( main::@1/screen#2 )
  screen#3 = screen#8
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  screen#4 = (char *)$400
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  screen#12 = phi( __start::__init1/screen#4 )
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  screen#9 = phi( __start::@1/screen#3 )
  screen#5 = screen#9
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  screen#10 = phi( __start::@2/screen#5 )
  screen#6 = screen#10
  return 
  to:@return

SYMBOL TABLE SSA
void __start()
__constant char a = 'a'
void main()
bool main::$0
__constant char main::b = 'b'
__loadstore char main::i
char *screen
char *screen#0
char *screen#1
char *screen#10
char *screen#11
char *screen#12
char *screen#2
char *screen#3
char *screen#4
char *screen#5
char *screen#6
char *screen#7
char *screen#8
char *screen#9

Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Alias screen#2 = screen#8 screen#3 
Alias screen#12 = screen#4 
Alias screen#10 = screen#5 screen#9 screen#6 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values screen#11 screen#12
Identical Phi Values screen#10 screen#2
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition main::$0 [11] if(main::i!=rangelast(0,5)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant screen#12 = (char *) 1024
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [9] main::i = ++ main::i to ++
Resolved ranged comparison value [11] if(main::i!=rangelast(0,5)) goto main::@1 to 6
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::__init1
Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Adding number conversion cast (unumber) 6 in [9] if(main::i!=6) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 6
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 6
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings screen#12
Constant inlined screen#12 = (char *) 1024
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@2(between main::@1 and main::@1)
CALL GRAPH

Created 1 initial phi equivalence classes
Coalesced [11] screen#13 = screen#2
Coalesced down to 1 phi equivalence classes
Culled Empty Block label main::@2

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] main::i = 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [1] screen#7 = phi( main/(char *) 1024, main::@1/screen#2 )
  [2] *screen#7 = a
  [3] screen#0 = ++ screen#7
  [4] *screen#0 = main::b
  [5] screen#1 = ++ screen#0
  [6] *screen#1 = main::i
  [7] screen#2 = ++ screen#1
  [8] main::i = ++ main::i
  [9] if(main::i!=6) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  [10] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
__loadstore char main::i // 4.6000000000000005
char *screen
char *screen#0 // 16.5
char *screen#1 // 16.5
char *screen#2 // 7.333333333333333
char *screen#7 // 16.5

Initial phi equivalence classes
[ screen#7 screen#2 ]
Added variable main::i to live range equivalence class [ main::i ]
Added variable screen#0 to live range equivalence class [ screen#0 ]
Added variable screen#1 to live range equivalence class [ screen#1 ]
Complete equivalence classes
[ screen#7 screen#2 ]
[ main::i ]
[ screen#0 ]
[ screen#1 ]
Allocated zp[2]:2 [ screen#7 screen#2 ]
Allocated zp[2]:4 [ screen#0 ]
Allocated zp[2]:6 [ screen#1 ]
Allocated mem[1] [ main::i ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] main::i = 0 [ main::i ] (  [ main::i ] { }  ) always clobbers reg byte a 
Statement [2] *screen#7 = a [ main::i screen#7 ] (  [ main::i screen#7 ] { }  ) always clobbers reg byte a reg byte y 
Statement [3] screen#0 = ++ screen#7 [ main::i screen#0 ] (  [ main::i screen#0 ] { }  ) always clobbers reg byte a 
Statement [4] *screen#0 = main::b [ main::i screen#0 ] (  [ main::i screen#0 ] { }  ) always clobbers reg byte a reg byte y 
Statement [5] screen#1 = ++ screen#0 [ main::i screen#1 ] (  [ main::i screen#1 ] { }  ) always clobbers reg byte a 
Statement [6] *screen#1 = main::i [ main::i screen#1 ] (  [ main::i screen#1 ] { }  ) always clobbers reg byte a reg byte y 
Statement [7] screen#2 = ++ screen#1 [ main::i screen#2 ] (  [ main::i screen#2 ] { }  ) always clobbers reg byte a 
Statement [9] if(main::i!=6) goto main::@1 [ main::i screen#2 ] (  [ main::i screen#2 ] { }  ) always clobbers reg byte a 
Potential registers zp[2]:2 [ screen#7 screen#2 ] : zp[2]:2 , 
Potential registers mem[1] [ main::i ] : mem[1] , 
Potential registers zp[2]:4 [ screen#0 ] : zp[2]:4 , 
Potential registers zp[2]:6 [ screen#1 ] : zp[2]:6 , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 23.83: zp[2]:2 [ screen#7 screen#2 ] 16.5: zp[2]:4 [ screen#0 ] 16.5: zp[2]:6 [ screen#1 ] 
Uplift Scope [main] 4.6: mem[1] [ main::i ] 

Uplifting [] best 1207 combination zp[2]:2 [ screen#7 screen#2 ] zp[2]:4 [ screen#0 ] zp[2]:6 [ screen#1 ] 
Uplifting [main] best 1207 combination mem[1] [ main::i ] 
Attempting to uplift remaining variables inmem[1] [ main::i ]
Uplifting [main] best 1207 combination mem[1] [ main::i ] 
Coalescing zero page register [ zp[2]:2 [ screen#7 screen#2 ] ] with [ zp[2]:4 [ screen#0 ] ] - score: 1
Coalescing zero page register [ zp[2]:2 [ screen#7 screen#2 screen#0 ] ] with [ zp[2]:6 [ screen#1 ] ] - score: 1

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test memory model
// Constant memory variables
  // Upstart
  // Commodore 64 PRG executable file
.file [name="varmodel-ma_mem-4.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .const a = 'a'
  .label screen = 2
.segment Code
  // main
main: {
    .const b = 'b'
    // [0] main::i = 0 -- vbum1=vbuc1 
    lda #0
    sta i
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi screen#7 = (char *) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
    jmp __b1
    // [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  __b1_from___b1:
    // [1] phi screen#7 = screen#2 [phi:main::@1->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [2] *screen#7 = a -- _deref_pbuz1=vbuc1 
    lda #a
    ldy #0
    sta (screen),y
    // [3] screen#0 = ++ screen#7 -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // [4] *screen#0 = main::b -- _deref_pbuz1=vbuc1 
    lda #b
    ldy #0
    sta (screen),y
    // [5] screen#1 = ++ screen#0 -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // [6] *screen#1 = main::i -- _deref_pbuz1=vbum2 
    lda i
    ldy #0
    sta (screen),y
    // [7] screen#2 = ++ screen#1 -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // [8] main::i = ++ main::i -- vbum1=_inc_vbum1 
    inc i
    // [9] if(main::i!=6) goto main::@1 -- vbum1_neq_vbuc1_then_la1 
    lda #6
    cmp i
    bne __b1_from___b1
    jmp __breturn
    // main::@return
  __breturn:
    // [10] return 
    rts
  .segment Data
    i: .byte 0
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b1 with __b1
Removing instruction __b1_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
__constant char a = 'a'
void main()
__constant char main::b = 'b'
__loadstore char main::i // mem[1] 4.6000000000000005
char *screen
char *screen#0 // screen zp[2]:2 16.5
char *screen#1 // screen zp[2]:2 16.5
char *screen#2 // screen zp[2]:2 7.333333333333333
char *screen#7 // screen zp[2]:2 16.5

zp[2]:2 [ screen#7 screen#2 screen#0 screen#1 ]
mem[1] [ main::i ]


FINAL ASSEMBLER
Score: 952

  // File Comments
// Test memory model
// Constant memory variables
  // Upstart
  // Commodore 64 PRG executable file
.file [name="varmodel-ma_mem-4.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .const a = 'a'
  .label screen = 2
.segment Code
  // main
main: {
    .const b = 'b'
    // for( char i: 0..5 )
    // [0] main::i = 0 -- vbum1=vbuc1 
    lda #0
    sta i
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi screen#7 = (char *) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
    // [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
    // [1] phi screen#7 = screen#2 [phi:main::@1->main::@1#0] -- register_copy 
    // main::@1
  __b1:
    // *(screen++) = a
    // [2] *screen#7 = a -- _deref_pbuz1=vbuc1 
    lda #a
    ldy #0
    sta (screen),y
    // *(screen++) = a;
    // [3] screen#0 = ++ screen#7 -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // *(screen++) = b
    // [4] *screen#0 = main::b -- _deref_pbuz1=vbuc1 
    lda #b
    ldy #0
    sta (screen),y
    // *(screen++) = b;
    // [5] screen#1 = ++ screen#0 -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // *(screen++) = i
    // [6] *screen#1 = main::i -- _deref_pbuz1=vbum2 
    lda i
    ldy #0
    sta (screen),y
    // *(screen++) = i;
    // [7] screen#2 = ++ screen#1 -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // for( char i: 0..5 )
    // [8] main::i = ++ main::i -- vbum1=_inc_vbum1 
    inc i
    // [9] if(main::i!=6) goto main::@1 -- vbum1_neq_vbuc1_then_la1 
    lda #6
    cmp i
    bne __b1
    // main::@return
    // }
    // [10] return 
    rts
  .segment Data
    i: .byte 0
}
  // File Data

