Inlined call call __init
Eliminating unused variable with no statement main::$0

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  main::i#0 = -$a
  to:main::@1
main::@1: scope:[main]  from main main::@1
  main::i#2 = phi( main/main::i#0, main::@1/main::i#1 )
  main::sc#0 = SCREEN + main::i#2
  *main::sc#0 = (char)main::i#2
  main::i#1 = main::i#2 + rangenext(-$a,$a)
  main::$1 = main::i#1 != rangelast(-$a,$a)
  if(main::$1) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  return 
  to:@return

SYMBOL TABLE SSA
__constant char *SCREEN = (char *)$400+$28*$a
void __start()
void main()
bool main::$1
int main::i
int main::i#0
int main::i#1
int main::i#2
char *main::sc
char *main::sc#0

Adding number conversion cast (unumber) $28*$a in 
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Simple Condition main::$1 [6] if(main::i#1!=rangelast(-$a,$a)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::i#0 = -$a
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [4] main::i#1 = ++ main::i#2 to ++
Resolved ranged comparison value [6] if(main::i#1!=rangelast(-$a,$a)) goto main::@1 to $b
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 (snumber) $b in [4] if(main::i#1!=$b) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $b
Successful SSA optimization PassNCastSimplification
Finalized signed number type (signed char) $b
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings main::i#0
Constant inlined main::i#0 = -$a
Successful SSA optimization Pass2ConstantInlining
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) $a
Successful SSA optimization PassNFinalizeNumberTypeConversions
Added new block during phi lifting main::@2(between main::@1 and main::@1)
Adding NOP phi() at start of main
CALL GRAPH

Created 1 initial phi equivalence classes
Coalesced [7] main::i#3 = main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block label main::@2
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [1] main::i#2 = phi( main/-$a, main::@1/main::i#1 )
  [2] main::sc#0 = SCREEN + main::i#2
  [3] *main::sc#0 = (char)main::i#2
  [4] main::i#1 = ++ main::i#2
  [5] if(main::i#1!=$b) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  [6] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
int main::i
int main::i#1 // 16.5
int main::i#2 // 11.0
char *main::sc
char *main::sc#0 // 22.0

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

REGISTER UPLIFT SCOPES
Uplift Scope [main] 27.5: zp[2]:2 [ main::i#2 main::i#1 ] 22: zp[2]:4 [ main::sc#0 ] 
Uplift Scope [] 

Uplifting [main] best 761 combination zp[2]:2 [ main::i#2 main::i#1 ] zp[2]:4 [ main::sc#0 ] 
Uplifting [] best 761 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test adding a signed word to a pointer
// Fragment pbuz1=pbuc1_plus_vwsz1.asm supplied by Richard-William Loerakker
  // Upstart
  // Commodore 64 PRG executable file
.file [name="pointer-plus-signed-word.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
  .label SCREEN = $400+$28*$a
.segment Code
  // main
main: {
    .label sc = 4
    .label i = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi main::i#2 = -$a [phi:main->main::@1#0] -- vwsz1=vwsc1 
    lda #<-$a
    sta.z i
    lda #>-$a
    sta.z i+1
    jmp __b1
    // [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  __b1_from___b1:
    // [1] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [2] main::sc#0 = SCREEN + main::i#2 -- pbuz1=pbuc1_plus_vwsz2 
    lda #<SCREEN
    clc
    adc.z i
    sta.z sc
    lda #>SCREEN
    adc.z i+1
    sta.z sc+1
    // [3] *main::sc#0 = (char)main::i#2 -- _deref_pbuz1=_byte_vwsz2 
    lda.z i
    ldy #0
    sta (sc),y
    // [4] main::i#1 = ++ main::i#2 -- vwsz1=_inc_vwsz1 
    inc.z i
    bne !+
    inc.z i+1
  !:
    // [5] if(main::i#1!=$b) goto main::@1 -- vwsz1_neq_vwuc1_then_la1 
    lda.z i+1
    cmp #>$b
    bne __b1_from___b1
    lda.z i
    cmp #<$b
    bne __b1_from___b1
    jmp __breturn
    // main::@return
  __breturn:
    // [6] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b1 with __b1
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 *SCREEN = (char *) 1024+(unsigned int)$28*$a
void main()
int main::i
int main::i#1 // i zp[2]:2 16.5
int main::i#2 // i zp[2]:2 11.0
char *main::sc
char *main::sc#0 // sc zp[2]:4 22.0

zp[2]:2 [ main::i#2 main::i#1 ]
zp[2]:4 [ main::sc#0 ]


FINAL ASSEMBLER
Score: 671

  // File Comments
// Test adding a signed word to a pointer
// Fragment pbuz1=pbuc1_plus_vwsz1.asm supplied by Richard-William Loerakker
  // Upstart
  // Commodore 64 PRG executable file
.file [name="pointer-plus-signed-word.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
  .label SCREEN = $400+$28*$a
.segment Code
  // main
main: {
    .label sc = 4
    .label i = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi main::i#2 = -$a [phi:main->main::@1#0] -- vwsz1=vwsc1 
    lda #<-$a
    sta.z i
    lda #>-$a
    sta.z i+1
    // [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
    // [1] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    // main::@1
  __b1:
    // char* sc = SCREEN + i
    // [2] main::sc#0 = SCREEN + main::i#2 -- pbuz1=pbuc1_plus_vwsz2 
    lda #<SCREEN
    clc
    adc.z i
    sta.z sc
    lda #>SCREEN
    adc.z i+1
    sta.z sc+1
    // *sc = (char)i
    // [3] *main::sc#0 = (char)main::i#2 -- _deref_pbuz1=_byte_vwsz2 
    lda.z i
    ldy #0
    sta (sc),y
    // for (signed word i : -10..10 )
    // [4] main::i#1 = ++ main::i#2 -- vwsz1=_inc_vwsz1 
    inc.z i
    bne !+
    inc.z i+1
  !:
    // [5] if(main::i#1!=$b) goto main::@1 -- vwsz1_neq_vwuc1_then_la1 
    lda.z i+1
    cmp #>$b
    bne __b1
    lda.z i
    cmp #<$b
    bne __b1
    // main::@return
    // }
    // [6] return 
    rts
}
  // File Data

