Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  main::dy#0 = -$80
  to:main::@1
main::@1: scope:[main]  from main main::@2
  main::dy#2 = phi( main/main::dy#0, main::@2/main::dy#1 )
  debug::dy#0 = main::dy#2
  call debug
  to:main::@2
main::@2: scope:[main]  from main::@1
  main::dy#3 = phi( main::@1/main::dy#2 )
  main::dy#1 = main::dy#3 + rangenext(-$80,$7f)
  main::$1 = main::dy#1 != rangelast(-$80,$7f)
  if(main::$1) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return

void debug(signed char dy)
debug: scope:[debug]  from main::@1
  debug::dy#1 = phi( main::@1/debug::dy#0 )
  debug::i#0 = (char)debug::dy#1
  debug::$0 = debug::dy#1 > -$78
  debug::$1 = ! debug::$0
  if(debug::$1) goto debug::@return
  to:debug::@1
debug::@1: scope:[debug]  from debug
  debug::i#1 = phi( debug/debug::i#0 )
  SCREEN[debug::i#1] = $a
  to:debug::@return
debug::@return: scope:[debug]  from debug debug::@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
void __start()
void debug(signed char dy)
bool debug::$0
bool debug::$1
signed char debug::dy
signed char debug::dy#0
signed char debug::dy#1
char debug::i
char debug::i#0
char debug::i#1
void main()
bool main::$1
signed char main::dy
signed char main::dy#0
signed char main::dy#1
signed char main::dy#2
signed char main::dy#3

Adding number conversion cast (snumber) -$78 in debug::$0 = debug::dy#1 > -$78
Adding number conversion cast (unumber) $a in SCREEN[debug::i#1] = $a
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast SCREEN[debug::i#1] = (unumber)$a
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast -$78
Simplifying constant integer cast $a
Successful SSA optimization PassNCastSimplification
Finalized signed number type (signed char) -$78
Finalized unsigned number type (char) $a
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [12] debug::$1 = debug::dy#1 <= -$78 from [11] debug::$0 = debug::dy#1 > -$78
Successful SSA optimization Pass2UnaryNotSimplification
Alias main::dy#2 = main::dy#3 
Alias debug::i#0 = debug::i#1 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values debug::dy#1 debug::dy#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition main::$1 [6] if(main::dy#1!=rangelast(-$80,$7f)) goto main::@1
Simple Condition debug::$1 [11] if(debug::dy#0<=-$78) goto debug::@return
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::dy#0 = -$80
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [4] main::dy#1 = ++ main::dy#2 to ++
Resolved ranged comparison value [6] if(main::dy#1!=rangelast(-$80,$7f)) goto main::@1 to -$80
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) -$80 in [4] if(main::dy#1!=-$80) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast -$80
Successful SSA optimization PassNCastSimplification
Finalized signed number type (signed char) -$80
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining Noop Cast [6] debug::i#0 = (char)debug::dy#0 keeping debug::dy#0
Successful SSA optimization Pass2NopCastInlining
Inlining constant with var siblings main::dy#0
Constant inlined main::dy#0 = -$80
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@3(between main::@2 and main::@1)
Adding NOP phi() at start of main
CALL GRAPH
Calls in [main] to debug:3 

Created 1 initial phi equivalence classes
Coalesced [7] main::dy#4 = main::dy#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block label main::@3
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::@2
  [1] main::dy#2 = phi( main/-$80, main::@2/main::dy#1 )
  [2] debug::dy#0 = main::dy#2
  [3] call debug
  to:main::@2
main::@2: scope:[main]  from main::@1
  [4] main::dy#1 = ++ main::dy#2
  [5] if(main::dy#1!=-$80) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  [6] return 
  to:@return

void debug(signed char dy)
debug: scope:[debug]  from main::@1
  [7] if(debug::dy#0<=-$78) goto debug::@return
  to:debug::@1
debug::@1: scope:[debug]  from debug
  [8] SCREEN[(char)debug::dy#0] = $a
  to:debug::@return
debug::@return: scope:[debug]  from debug debug::@1
  [9] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void debug(signed char dy)
signed char debug::dy
signed char debug::dy#0 // 56.0
char debug::i
void main()
signed char main::dy
signed char main::dy#1 // 16.5
signed char main::dy#2 // 11.0

Initial phi equivalence classes
[ main::dy#2 main::dy#1 ]
Added variable debug::dy#0 to live range equivalence class [ debug::dy#0 ]
Complete equivalence classes
[ main::dy#2 main::dy#1 ]
[ debug::dy#0 ]
Allocated zp[1]:2 [ debug::dy#0 ]
Allocated zp[1]:3 [ main::dy#2 main::dy#1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] if(debug::dy#0<=-$78) goto debug::@return [ debug::dy#0 ] ( debug:3 [ main::dy#2 debug::dy#0 ] { { debug::dy#0 = main::dy#2 } }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:3 [ main::dy#2 main::dy#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:2 [ debug::dy#0 ]
Statement [8] SCREEN[(char)debug::dy#0] = $a [ ] ( debug:3 [ main::dy#2 ] { { debug::dy#0 = main::dy#2 } }  ) always clobbers reg byte a 
Statement [7] if(debug::dy#0<=-$78) goto debug::@return [ debug::dy#0 ] ( debug:3 [ main::dy#2 debug::dy#0 ] { { debug::dy#0 = main::dy#2 } }  ) always clobbers reg byte a 
Statement [8] SCREEN[(char)debug::dy#0] = $a [ ] ( debug:3 [ main::dy#2 ] { { debug::dy#0 = main::dy#2 } }  ) always clobbers reg byte a 
Potential registers zp[1]:3 [ main::dy#2 main::dy#1 ] : zp[1]:3 , reg byte x , reg byte y , 
Potential registers zp[1]:2 [ debug::dy#0 ] : zp[1]:2 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [debug] 56: zp[1]:2 [ debug::dy#0 ] 
Uplift Scope [main] 27.5: zp[1]:3 [ main::dy#2 main::dy#1 ] 
Uplift Scope [] 

Uplifting [debug] best 425 combination reg byte x [ debug::dy#0 ] 
Uplifting [main] best 305 combination reg byte x [ main::dy#2 main::dy#1 ] 
Uplifting [] best 305 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Illustrates problem with > comparison of signed chars.
// Reported by Danny Spijksma
  // Upstart
  // Commodore 64 PRG executable file
.file [name="signed-char-comparison.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
.segment Code
  // main
main: {
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi main::dy#2 = -$80 [phi:main->main::@1#0] -- vbsxx=vbsc1 
    ldx #-$80
    jmp __b1
    // [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [1] phi main::dy#2 = main::dy#1 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [2] debug::dy#0 = main::dy#2
    // [3] call debug
    jsr debug
    jmp __b2
    // main::@2
  __b2:
    // [4] main::dy#1 = ++ main::dy#2 -- vbsxx=_inc_vbsxx 
    inx
    // [5] if(main::dy#1!=-$80) goto main::@1 -- vbsxx_neq_vbsc1_then_la1 
    cpx #-$80
    bne __b1_from___b2
    jmp __breturn
    // main::@return
  __breturn:
    // [6] return 
    rts
}
  // debug
// void debug(__register(X) signed char dy)
debug: {
    // [7] if(debug::dy#0<=-$78) goto debug::@return -- vbsxx_le_vbsc1_then_la1 
    txa
    sec
    sbc #-$78
    beq __breturn
    bvc !+
    eor #$80
  !:
    bmi __breturn
    jmp __b1
    // debug::@1
  __b1:
    // [8] SCREEN[(char)debug::dy#0] = $a -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #$a
    sta SCREEN,x
    jmp __breturn
    // debug::@return
  __breturn:
    // [9] return 
    rts
}
  // File Data

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

FINAL SYMBOL TABLE
__constant char *SCREEN = (char *) 1024
void debug(signed char dy)
signed char debug::dy
signed char debug::dy#0 // reg byte x 56.0
char debug::i
void main()
signed char main::dy
signed char main::dy#1 // reg byte x 16.5
signed char main::dy#2 // reg byte x 11.0

reg byte x [ main::dy#2 main::dy#1 ]
reg byte x [ debug::dy#0 ]


FINAL ASSEMBLER
Score: 179

  // File Comments
// Illustrates problem with > comparison of signed chars.
// Reported by Danny Spijksma
  // Upstart
  // Commodore 64 PRG executable file
.file [name="signed-char-comparison.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
.segment Code
  // main
main: {
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi main::dy#2 = -$80 [phi:main->main::@1#0] -- vbsxx=vbsc1 
    ldx #-$80
    // [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
    // [1] phi main::dy#2 = main::dy#1 [phi:main::@2->main::@1#0] -- register_copy 
    // main::@1
  __b1:
    // debug(dy)
    // [2] debug::dy#0 = main::dy#2
    // [3] call debug
    jsr debug
    // main::@2
    // for(signed char dy:-128..127)
    // [4] main::dy#1 = ++ main::dy#2 -- vbsxx=_inc_vbsxx 
    inx
    // [5] if(main::dy#1!=-$80) goto main::@1 -- vbsxx_neq_vbsc1_then_la1 
    cpx #-$80
    bne __b1
    // main::@return
    // }
    // [6] return 
    rts
}
  // debug
// void debug(__register(X) signed char dy)
debug: {
    // if (dy > -120)
    // [7] if(debug::dy#0<=-$78) goto debug::@return -- vbsxx_le_vbsc1_then_la1 
    txa
    sec
    sbc #-$78
    beq __breturn
    bvc !+
    eor #$80
  !:
    bmi __breturn
    // debug::@1
    // SCREEN[i] = 10
    // [8] SCREEN[(char)debug::dy#0] = $a -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #$a
    sta SCREEN,x
    // debug::@return
  __breturn:
    // }
    // [9] return 
    rts
}
  // File Data

