PARSING src/test/java/dk/camelot64/kickc/test/kc/inline-word.kc
const byte* SCREEN = $400;

void main() {
   byte[] his = { >SCREEN, >SCREEN+$100, >SCREEN+$200 }; // constant array
   for( byte h: 0..2) {
      for (byte l: 4..7) {
         word w = { his[h], l }; // inline word
         byte* sc = (byte*)w;
         *sc = '*';
      }
   }
}

STATEMENTS
  (byte*) SCREEN ← (word/signed word/dword/signed dword) 1024
proc (void()) main()
  (byte~) main::$0 ← > (byte*) SCREEN
  (byte*~) main::$1 ← (byte*) SCREEN + (word/signed word/dword/signed dword) 256
  (byte~) main::$2 ← > (byte*~) main::$1
  (byte*~) main::$3 ← (byte*) SCREEN + (word/signed word/dword/signed dword) 512
  (byte~) main::$4 ← > (byte*~) main::$3
  (byte[]) main::his ← { (byte~) main::$0, (byte~) main::$2, (byte~) main::$4 }
  (byte) main::h ← (byte/signed byte/word/signed word/dword/signed dword) 0
main::@1:
  (byte) main::l ← (byte/signed byte/word/signed word/dword/signed dword) 4
main::@2:
  (word) main::w ← { *((byte[]) main::his + (byte) main::h), (byte) main::l }
  (byte*~) main::$5 ← ((byte*)) (word) main::w
  (byte*) main::sc ← (byte*~) main::$5
  *((byte*) main::sc) ← (byte) '*'
  (byte) main::l ← ++ (byte) main::l
  (boolean~) main::$6 ← (byte) main::l != (byte/signed byte/word/signed word/dword/signed dword) 8
  if((boolean~) main::$6) goto main::@2
  (byte) main::h ← ++ (byte) main::h
  (boolean~) main::$7 ← (byte) main::h != (byte/signed byte/word/signed word/dword/signed dword) 3
  if((boolean~) main::$7) goto main::@1
main::@return:
  return 
endproc // main()
  call main 

SYMBOLS
(byte*) SCREEN
(void()) main()
(byte~) main::$0
(byte*~) main::$1
(byte~) main::$2
(byte*~) main::$3
(byte~) main::$4
(byte*~) main::$5
(boolean~) main::$6
(boolean~) main::$7
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::h
(byte[]) main::his
(byte) main::l
(byte*) main::sc
(word) main::w

Promoting word/signed word/dword/signed dword to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  (byte*) SCREEN ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@1
main: scope:[main]  from
  (byte~) main::$0 ← > (byte*) SCREEN
  (byte*~) main::$1 ← (byte*) SCREEN + (word/signed word/dword/signed dword) 256
  (byte~) main::$2 ← > (byte*~) main::$1
  (byte*~) main::$3 ← (byte*) SCREEN + (word/signed word/dword/signed dword) 512
  (byte~) main::$4 ← > (byte*~) main::$3
  (byte[]) main::his ← { (byte~) main::$0, (byte~) main::$2, (byte~) main::$4 }
  (byte) main::h ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@1
main::@1: scope:[main]  from main main::@3
  (byte) main::l ← (byte/signed byte/word/signed word/dword/signed dword) 4
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  (word) main::w ← { *((byte[]) main::his + (byte) main::h), (byte) main::l }
  (byte*~) main::$5 ← ((byte*)) (word) main::w
  (byte*) main::sc ← (byte*~) main::$5
  *((byte*) main::sc) ← (byte) '*'
  (byte) main::l ← ++ (byte) main::l
  (boolean~) main::$6 ← (byte) main::l != (byte/signed byte/word/signed word/dword/signed dword) 8
  if((boolean~) main::$6) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  (byte) main::h ← ++ (byte) main::h
  (boolean~) main::$7 ← (byte) main::h != (byte/signed byte/word/signed word/dword/signed dword) 3
  if((boolean~) main::$7) goto main::@1
  to:main::@4
main::@4: scope:[main]  from main::@3
  to:main::@return
main::@return: scope:[main]  from main::@4
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@end
@end: scope:[]  from @1

Removing empty block main::@4
PROCEDURE MODIFY VARIABLE ANALYSIS

Completing Phi functions...
Completing Phi functions...

CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN
@begin: scope:[]  from
  (byte*) SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@1
main: scope:[main]  from @1
  (byte~) main::$0 ← > (byte*) SCREEN#0
  (byte*~) main::$1 ← (byte*) SCREEN#0 + (word/signed word/dword/signed dword) 256
  (byte~) main::$2 ← > (byte*~) main::$1
  (byte*~) main::$3 ← (byte*) SCREEN#0 + (word/signed word/dword/signed dword) 512
  (byte~) main::$4 ← > (byte*~) main::$3
  (byte[]) main::his#0 ← { (byte~) main::$0, (byte~) main::$2, (byte~) main::$4 }
  (byte) main::h#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@1
main::@1: scope:[main]  from main main::@3
  (byte) main::h#4 ← phi( main/(byte) main::h#0 main::@3/(byte) main::h#1 )
  (byte) main::l#0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  (byte) main::l#2 ← phi( main::@1/(byte) main::l#0 main::@2/(byte) main::l#1 )
  (byte) main::h#2 ← phi( main::@1/(byte) main::h#4 main::@2/(byte) main::h#2 )
  (word) main::w#0 ← { *((byte[]) main::his#0 + (byte) main::h#2), (byte) main::l#2 }
  (byte*~) main::$5 ← ((byte*)) (word) main::w#0
  (byte*) main::sc#0 ← (byte*~) main::$5
  *((byte*) main::sc#0) ← (byte) '*'
  (byte) main::l#1 ← ++ (byte) main::l#2
  (boolean~) main::$6 ← (byte) main::l#1 != (byte/signed byte/word/signed word/dword/signed dword) 8
  if((boolean~) main::$6) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  (byte) main::h#3 ← phi( main::@2/(byte) main::h#2 )
  (byte) main::h#1 ← ++ (byte) main::h#3
  (boolean~) main::$7 ← (byte) main::h#1 != (byte/signed byte/word/signed word/dword/signed dword) 3
  if((boolean~) main::$7) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return
@1: scope:[]  from @begin
  call main param-assignment
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(void()) main()
(byte~) main::$0
(byte*~) main::$1
(byte~) main::$2
(byte*~) main::$3
(byte~) main::$4
(byte*~) main::$5
(boolean~) main::$6
(boolean~) main::$7
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::h
(byte) main::h#0
(byte) main::h#1
(byte) main::h#2
(byte) main::h#3
(byte) main::h#4
(byte[]) main::his
(byte[]) main::his#0
(byte) main::l
(byte) main::l#0
(byte) main::l#1
(byte) main::l#2
(byte*) main::sc
(byte*) main::sc#0
(word) main::w
(word) main::w#0

OPTIMIZING CONTROL FLOW GRAPH
Culled Empty Block (label) @2
Succesful SSA optimization Pass2CullEmptyBlocks
Alias (byte*) main::sc#0 = (byte*~) main::$5 
Alias (byte) main::h#2 = (byte) main::h#3 
Succesful SSA optimization Pass2AliasElimination
Self Phi Eliminated (byte) main::h#2
Succesful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte) main::h#2 (byte) main::h#4
Succesful SSA optimization Pass2RedundantPhiElimination
Simple Condition (boolean~) main::$6 if((byte) main::l#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@2
Simple Condition (boolean~) main::$7 if((byte) main::h#1!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto main::@1
Succesful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN#0 = ((byte*))1024
Constant (const byte) main::h#0 = 0
Constant (const byte) main::l#0 = 4
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte) main::$0 = >SCREEN#0
Constant (const byte*) main::$1 = SCREEN#0+256
Constant (const byte*) main::$3 = SCREEN#0+512
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte) main::$2 = >main::$1
Constant (const byte) main::$4 = >main::$3
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte[]) main::his#0 = { main::$0, main::$2, main::$4 }
Succesful SSA optimization Pass2ConstantIdentification
Fixing word constructor with main::$8 ← *(main::his#0 + main::h#4) w= main::l#2
Succesful SSA optimization Pass2FixWordConstructors
Eliminating Noop Cast (byte*) main::sc#0 ← ((byte*)) (word) main::w#0
Succesful SSA optimization Pass2NopCastElimination
Alias (word) main::w#0 = (word~) main::$8 
Succesful SSA optimization Pass2AliasElimination
OPTIMIZING CONTROL FLOW GRAPH
Inlining constant with var siblings (const byte) main::h#0
Inlining constant with var siblings (const byte) main::h#0
Inlining constant with var siblings (const byte) main::l#0
Inlining constant with var siblings (const byte) main::l#0
Constant inlined main::$1 = (const byte*) SCREEN#0+(word/signed word/dword/signed dword) 256
Constant inlined main::$2 = >(const byte*) SCREEN#0+(word/signed word/dword/signed dword) 256
Constant inlined main::l#0 = (byte/signed byte/word/signed word/dword/signed dword) 4
Constant inlined main::$0 = >(const byte*) SCREEN#0
Constant inlined main::h#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::$3 = (const byte*) SCREEN#0+(word/signed word/dword/signed dword) 512
Constant inlined main::$4 = >(const byte*) SCREEN#0+(word/signed word/dword/signed dword) 512
Succesful SSA optimization Pass2ConstantInlining
Block Sequence Planned @begin @1 @end main main::@1 main::@2 main::@3 main::@return 
Added new block during phi lifting main::@5(between main::@3 and main::@1)
Added new block during phi lifting main::@6(between main::@2 and main::@2)
Block Sequence Planned @begin @1 @end main main::@1 main::@2 main::@3 main::@return main::@5 main::@6 
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
CALL GRAPH
Calls in [] to main:2 

Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Created 2 initial phi equivalence classes
Coalesced [14] main::h#5 ← main::h#1
Coalesced [15] main::l#3 ← main::l#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
Block Sequence Planned @begin @1 @end main main::@1 main::@2 main::@3 main::@return 
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
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi() [ ] ( )
  to:@1
@1: scope:[]  from @begin
  [1] phi() [ ] ( )
  [2] call main param-assignment [ ] ( )
  to:@end
@end: scope:[]  from @1
  [3] phi() [ ] ( )
main: scope:[main]  from @1
  [4] phi() [ ] ( main:2 [ ] )
  to:main::@1
main::@1: scope:[main]  from main main::@3
  [5] (byte) main::h#4 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@3/(byte) main::h#1 ) [ main::h#4 ] ( main:2 [ main::h#4 ] )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [6] (byte) main::l#2 ← phi( main::@1/(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte) main::l#1 ) [ main::h#4 main::l#2 ] ( main:2 [ main::h#4 main::l#2 ] )
  [7] (word) main::w#0 ← *((const byte[]) main::his#0 + (byte) main::h#4) w= (byte) main::l#2 [ main::h#4 main::l#2 main::w#0 ] ( main:2 [ main::h#4 main::l#2 main::w#0 ] )
  [8] *((byte*)(word) main::w#0) ← (byte) '*' [ main::h#4 main::l#2 ] ( main:2 [ main::h#4 main::l#2 ] )
  [9] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::h#4 main::l#1 ] ( main:2 [ main::h#4 main::l#1 ] )
  [10] if((byte) main::l#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@2 [ main::h#4 main::l#1 ] ( main:2 [ main::h#4 main::l#1 ] )
  to:main::@3
main::@3: scope:[main]  from main::@2
  [11] (byte) main::h#1 ← ++ (byte) main::h#4 [ main::h#1 ] ( main:2 [ main::h#1 ] )
  [12] if((byte) main::h#1!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto main::@1 [ main::h#1 ] ( main:2 [ main::h#1 ] )
  to:main::@return
main::@return: scope:[main]  from main::@3
  [13] return  [ ] ( main:2 [ ] )
  to:@return

DOMINATORS
@begin dominated by  @begin 
@1 dominated by  @1 @begin 
@end dominated by  @1 @begin @end 
main dominated by  @1 @begin main 
main::@1 dominated by  @1 @begin main::@1 main 
main::@2 dominated by  @1 @begin main::@1 main::@2 main 
main::@3 dominated by  @1 @begin main::@1 main::@2 main main::@3 
main::@return dominated by  main::@return @1 @begin main::@1 main::@2 main main::@3 

NATURAL LOOPS
Found back edge: Loop head: main::@2 tails: main::@2 blocks: null
Found back edge: Loop head: main::@1 tails: main::@3 blocks: null
Populated: Loop head: main::@2 tails: main::@2 blocks: main::@2 
Populated: Loop head: main::@1 tails: main::@3 blocks: main::@3 main::@2 main::@1 
Loop head: main::@2 tails: main::@2 blocks: main::@2 
Loop head: main::@1 tails: main::@3 blocks: main::@3 main::@2 main::@1 

NATURAL LOOPS WITH DEPTH
Found 0 loops in scope []
Found 2 loops in scope [main]
  Loop head: main::@2 tails: main::@2 blocks: main::@2 
  Loop head: main::@1 tails: main::@3 blocks: main::@3 main::@2 main::@1 
Loop head: main::@2 tails: main::@2 blocks: main::@2  depth: 2
Loop head: main::@1 tails: main::@3 blocks: main::@3 main::@2 main::@1  depth: 1


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(void()) main()
(byte) main::h
(byte) main::h#1 16.5
(byte) main::h#4 20.499999999999996
(byte[]) main::his
(byte) main::l
(byte) main::l#1 151.5
(byte) main::l#2 101.0
(byte*) main::sc
(word) main::w
(word) main::w#0 101.0

Initial phi equivalence classes
[ main::h#4 main::h#1 ]
[ main::l#2 main::l#1 ]
Added variable main::w#0 to zero page equivalence class [ main::w#0 ]
Complete equivalence classes
[ main::h#4 main::h#1 ]
[ main::l#2 main::l#1 ]
[ main::w#0 ]
Allocated zp ZP_BYTE:2 [ main::h#4 main::h#1 ]
Allocated zp ZP_BYTE:3 [ main::l#2 main::l#1 ]
Allocated zp ZP_WORD:4 [ main::w#0 ]

INITIAL ASM
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN = $400
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
//SEG4 @1
b1:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
    .label w = 4
    .label l = 3
    .label h = 2
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [5] phi (byte) main::h#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta h
    jmp b1
  //SEG12 [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  b1_from_b3:
  //SEG13 [5] phi (byte) main::h#4 = (byte) main::h#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
  //SEG16 [6] phi (byte) main::l#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #4
    sta l
    jmp b2
  //SEG17 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
  //SEG18 [6] phi (byte) main::l#2 = (byte) main::l#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp b2
  //SEG19 main::@2
  b2:
  //SEG20 [7] (word) main::w#0 ← *((const byte[]) main::his#0 + (byte) main::h#4) w= (byte) main::l#2 [ main::h#4 main::l#2 main::w#0 ] ( main:2 [ main::h#4 main::l#2 main::w#0 ] ) -- vwuz1=pbuc1_derefidx_vbuz2_word_vbuz3 
    ldy h
    lda his,y
    sta w+1
    lda l
    sta w
  //SEG21 [8] *((byte*)(word) main::w#0) ← (byte) '*' [ main::h#4 main::l#2 ] ( main:2 [ main::h#4 main::l#2 ] ) -- _deref_pbuz1=vbuc1 
    lda #'*'
    ldy #0
    sta (w),y
  //SEG22 [9] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::h#4 main::l#1 ] ( main:2 [ main::h#4 main::l#1 ] ) -- vbuz1=_inc_vbuz1 
    inc l
  //SEG23 [10] if((byte) main::l#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@2 [ main::h#4 main::l#1 ] ( main:2 [ main::h#4 main::l#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda l
    cmp #8
    bne b2_from_b2
    jmp b3
  //SEG24 main::@3
  b3:
  //SEG25 [11] (byte) main::h#1 ← ++ (byte) main::h#4 [ main::h#1 ] ( main:2 [ main::h#1 ] ) -- vbuz1=_inc_vbuz1 
    inc h
  //SEG26 [12] if((byte) main::h#1!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto main::@1 [ main::h#1 ] ( main:2 [ main::h#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda h
    cmp #3
    bne b1_from_b3
    jmp breturn
  //SEG27 main::@return
  breturn:
  //SEG28 [13] return  [ ] ( main:2 [ ] )
    rts
    his: .byte >SCREEN, >SCREEN+$100, >SCREEN+$200
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] (word) main::w#0 ← *((const byte[]) main::his#0 + (byte) main::h#4) w= (byte) main::l#2 [ main::h#4 main::l#2 main::w#0 ] ( main:2 [ main::h#4 main::l#2 main::w#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::h#4 main::h#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::l#2 main::l#1 ]
Statement [8] *((byte*)(word) main::w#0) ← (byte) '*' [ main::h#4 main::l#2 ] ( main:2 [ main::h#4 main::l#2 ] ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ main::h#4 main::h#1 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:3 [ main::l#2 main::l#1 ]
Statement [7] (word) main::w#0 ← *((const byte[]) main::his#0 + (byte) main::h#4) w= (byte) main::l#2 [ main::h#4 main::l#2 main::w#0 ] ( main:2 [ main::h#4 main::l#2 main::w#0 ] ) always clobbers reg byte a 
Statement [8] *((byte*)(word) main::w#0) ← (byte) '*' [ main::h#4 main::l#2 ] ( main:2 [ main::h#4 main::l#2 ] ) always clobbers reg byte a reg byte y 
Potential registers zp ZP_BYTE:2 [ main::h#4 main::h#1 ] : zp ZP_BYTE:2 , reg byte x , 
Potential registers zp ZP_BYTE:3 [ main::l#2 main::l#1 ] : zp ZP_BYTE:3 , reg byte x , 
Potential registers zp ZP_WORD:4 [ main::w#0 ] : zp ZP_WORD:4 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 252.5: zp ZP_BYTE:3 [ main::l#2 main::l#1 ] 101: zp ZP_WORD:4 [ main::w#0 ] 37: zp ZP_BYTE:2 [ main::h#4 main::h#1 ] 
Uplift Scope [] 

Uplifting [main] best 4383 combination reg byte x [ main::l#2 main::l#1 ] zp ZP_WORD:4 [ main::w#0 ] zp ZP_BYTE:2 [ main::h#4 main::h#1 ] 
Uplifting [] best 4383 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::h#4 main::h#1 ]
Uplifting [main] best 4383 combination zp ZP_BYTE:2 [ main::h#4 main::h#1 ] 
Allocated (was zp ZP_WORD:4) zp ZP_WORD:3 [ main::w#0 ]

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN = $400
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
//SEG4 @1
b1:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
    .label w = 3
    .label h = 2
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [5] phi (byte) main::h#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta h
    jmp b1
  //SEG12 [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  b1_from_b3:
  //SEG13 [5] phi (byte) main::h#4 = (byte) main::h#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
  //SEG16 [6] phi (byte) main::l#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #4
    jmp b2
  //SEG17 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
  //SEG18 [6] phi (byte) main::l#2 = (byte) main::l#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp b2
  //SEG19 main::@2
  b2:
  //SEG20 [7] (word) main::w#0 ← *((const byte[]) main::his#0 + (byte) main::h#4) w= (byte) main::l#2 [ main::h#4 main::l#2 main::w#0 ] ( main:2 [ main::h#4 main::l#2 main::w#0 ] ) -- vwuz1=pbuc1_derefidx_vbuz2_word_vbuxx 
    ldy h
    lda his,y
    sta w+1
    stx w
  //SEG21 [8] *((byte*)(word) main::w#0) ← (byte) '*' [ main::h#4 main::l#2 ] ( main:2 [ main::h#4 main::l#2 ] ) -- _deref_pbuz1=vbuc1 
    lda #'*'
    ldy #0
    sta (w),y
  //SEG22 [9] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::h#4 main::l#1 ] ( main:2 [ main::h#4 main::l#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG23 [10] if((byte) main::l#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@2 [ main::h#4 main::l#1 ] ( main:2 [ main::h#4 main::l#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne b2_from_b2
    jmp b3
  //SEG24 main::@3
  b3:
  //SEG25 [11] (byte) main::h#1 ← ++ (byte) main::h#4 [ main::h#1 ] ( main:2 [ main::h#1 ] ) -- vbuz1=_inc_vbuz1 
    inc h
  //SEG26 [12] if((byte) main::h#1!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto main::@1 [ main::h#1 ] ( main:2 [ main::h#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda h
    cmp #3
    bne b1_from_b3
    jmp breturn
  //SEG27 main::@return
  breturn:
  //SEG28 [13] return  [ ] ( main:2 [ ] )
    rts
    his: .byte >SCREEN, >SCREEN+$100, >SCREEN+$200
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b3
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b2_from_b2 with b2
Replacing label b1_from_b3 with b1
Removing instruction bbegin:
Removing instruction b1_from_bbegin:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b3:
Removing instruction b2_from_b1:
Removing instruction b2_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b1:
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b3:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::h
(byte) main::h#1 h zp ZP_BYTE:2 16.5
(byte) main::h#4 h zp ZP_BYTE:2 20.499999999999996
(byte[]) main::his
(const byte[]) main::his#0 his = { >(const byte*) SCREEN#0, >(const byte*) SCREEN#0+(word/signed word/dword/signed dword) 256, >(const byte*) SCREEN#0+(word/signed word/dword/signed dword) 512 }
(byte) main::l
(byte) main::l#1 reg byte x 151.5
(byte) main::l#2 reg byte x 101.0
(byte*) main::sc
(word) main::w
(word) main::w#0 w zp ZP_WORD:3 101.0

zp ZP_BYTE:2 [ main::h#4 main::h#1 ]
reg byte x [ main::l#2 main::l#1 ]
zp ZP_WORD:3 [ main::w#0 ]


FINAL ASSEMBLER
Score: 3387

//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN = $400
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
    .label w = 3
    .label h = 2
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  //SEG11 [5] phi (byte) main::h#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta h
  //SEG12 [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  //SEG13 [5] phi (byte) main::h#4 = (byte) main::h#1 [phi:main::@3->main::@1#0] -- register_copy 
  //SEG14 main::@1
  b1:
  //SEG15 [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  //SEG16 [6] phi (byte) main::l#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #4
  //SEG17 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  //SEG18 [6] phi (byte) main::l#2 = (byte) main::l#1 [phi:main::@2->main::@2#0] -- register_copy 
  //SEG19 main::@2
  b2:
  //SEG20 [7] (word) main::w#0 ← *((const byte[]) main::his#0 + (byte) main::h#4) w= (byte) main::l#2 [ main::h#4 main::l#2 main::w#0 ] ( main:2 [ main::h#4 main::l#2 main::w#0 ] ) -- vwuz1=pbuc1_derefidx_vbuz2_word_vbuxx 
    ldy h
    lda his,y
    sta w+1
    stx w
  //SEG21 [8] *((byte*)(word) main::w#0) ← (byte) '*' [ main::h#4 main::l#2 ] ( main:2 [ main::h#4 main::l#2 ] ) -- _deref_pbuz1=vbuc1 
    lda #'*'
    ldy #0
    sta (w),y
  //SEG22 [9] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::h#4 main::l#1 ] ( main:2 [ main::h#4 main::l#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG23 [10] if((byte) main::l#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@2 [ main::h#4 main::l#1 ] ( main:2 [ main::h#4 main::l#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne b2
  //SEG24 main::@3
  //SEG25 [11] (byte) main::h#1 ← ++ (byte) main::h#4 [ main::h#1 ] ( main:2 [ main::h#1 ] ) -- vbuz1=_inc_vbuz1 
    inc h
  //SEG26 [12] if((byte) main::h#1!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto main::@1 [ main::h#1 ] ( main:2 [ main::h#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda h
    cmp #3
    bne b1
  //SEG27 main::@return
  //SEG28 [13] return  [ ] ( main:2 [ ] )
    rts
    his: .byte >SCREEN, >SCREEN+$100, >SCREEN+$200
}

