Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  main::min#0 = $ff
  main::max#0 = 0
  main::pos#0 = 0
  to:main::@1
main::@1: scope:[main]  from main main::@4
  main::max#6 = phi( main/main::max#0, main::@4/main::max#3 )
  main::min#4 = phi( main/main::min#0, main::@4/main::min#3 )
  main::pos#7 = phi( main/main::pos#0, main::@4/main::pos#5 )
  if(true) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  main::max#4 = phi( main::@1/main::max#6 )
  main::min#2 = phi( main::@1/main::min#4 )
  main::pos#2 = phi( main::@1/main::pos#7 )
  main::pos#1 = ++ main::pos#2
  main::$0 = main::pos#1 < main::min#2
  main::$1 = ! main::$0
  if(main::$1) goto main::@3
  to:main::@5
main::@3: scope:[main]  from main::@2 main::@5
  main::min#5 = phi( main::@2/main::min#2, main::@5/main::min#1 )
  main::max#2 = phi( main::@2/main::max#4, main::@5/main::max#5 )
  main::pos#3 = phi( main::@2/main::pos#1, main::@5/main::pos#4 )
  main::$2 = main::pos#3 > main::max#2
  main::$3 = ! main::$2
  if(main::$3) goto main::@4
  to:main::@6
main::@5: scope:[main]  from main::@2
  main::max#5 = phi( main::@2/main::max#4 )
  main::pos#4 = phi( main::@2/main::pos#1 )
  main::min#1 = main::pos#4
  to:main::@3
main::@4: scope:[main]  from main::@3 main::@6
  main::pos#5 = phi( main::@3/main::pos#3, main::@6/main::pos#6 )
  main::max#3 = phi( main::@3/main::max#2, main::@6/main::max#1 )
  main::min#3 = phi( main::@3/main::min#5, main::@6/main::min#6 )
  SCREEN[0] = main::min#3
  SCREEN[1] = main::max#3
  SCREEN[2] = main::pos#5
  to:main::@1
main::@6: scope:[main]  from main::@3
  main::min#6 = phi( main::@3/main::min#5 )
  main::pos#6 = phi( main::@3/main::pos#3 )
  main::max#1 = main::pos#6
  to:main::@4
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
void __start()
void main()
bool main::$0
bool main::$1
bool main::$2
bool main::$3
char main::max
char main::max#0
char main::max#1
char main::max#2
char main::max#3
char main::max#4
char main::max#5
char main::max#6
char main::min
char main::min#0
char main::min#1
char main::min#2
char main::min#3
char main::min#4
char main::min#5
char main::min#6
char main::pos
char main::pos#0
char main::pos#1
char main::pos#2
char main::pos#3
char main::pos#4
char main::pos#5
char main::pos#6
char main::pos#7

Adding number conversion cast (unumber) 0 in SCREEN[0] = main::min#3
Adding number conversion cast (unumber) 1 in SCREEN[1] = main::max#3
Adding number conversion cast (unumber) 2 in SCREEN[2] = main::pos#5
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [8] main::$1 = main::pos#1 >= main::min#2 from [7] main::$0 = main::pos#1 < main::min#2
Inversing boolean not [12] main::$3 = main::pos#3 <= main::max#2 from [11] main::$2 = main::pos#3 > main::max#2
Successful SSA optimization Pass2UnaryNotSimplification
Alias main::pos#2 = main::pos#7 
Alias main::min#2 = main::min#4 
Alias main::max#4 = main::max#6 main::max#5 
Alias main::pos#1 = main::pos#4 main::min#1 
Alias main::pos#3 = main::pos#6 main::max#1 
Alias main::min#5 = main::min#6 
Successful SSA optimization Pass2AliasElimination
Alias candidate removed (phi-usage) main::pos#1 = main::pos#3 main::pos#5 
Alias main::max#2 = main::max#4 
Alias main::min#3 = main::min#5 
Successful SSA optimization Pass2AliasElimination
Alias candidate removed (phi-usage) main::pos#1 = main::pos#3 main::pos#5 
Identical Phi Values main::pos#3 main::pos#1
Identical Phi Values main::pos#5 main::pos#3
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition main::$1 [7] if(main::pos#1>=main::min#2) goto main::@3
Simple Condition main::$3 [10] if(main::pos#1<=main::max#2) goto main::@4
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::min#0 = $ff
Constant main::max#0 = 0
Constant main::pos#0 = 0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [4] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Simplifying expression containing zero SCREEN in [12] SCREEN[0] = main::min#3
Successful SSA optimization PassNSimplifyExpressionWithZero
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
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
Inlining constant with var siblings main::min#0
Inlining constant with var siblings main::max#0
Inlining constant with var siblings main::pos#0
Constant inlined main::min#0 = $ff
Constant inlined main::max#0 = 0
Constant inlined main::pos#0 = 0
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN+1)
Consolidated array index constant in *(SCREEN+2)
Successful SSA optimization Pass2ConstantAdditionElimination
Added new block during phi lifting main::@7(between main::@2 and main::@3)
Added new block during phi lifting main::@8(between main::@3 and main::@4)
Adding NOP phi() at start of main
CALL GRAPH

Created 5 initial phi equivalence classes
Not coalescing [4] main::min#9 = main::pos#1
Not coalescing [7] main::max#9 = main::pos#1
Coalesced [12] main::pos#8 = main::pos#1
Coalesced [13] main::min#7 = main::min#3
Coalesced [14] main::max#7 = main::max#3
Coalesced (already) [15] main::max#8 = main::max#2
Coalesced (already) [16] main::min#8 = main::min#2
Coalesced down to 3 phi equivalence classes
Culled Empty Block label main::@8
Culled Empty Block label main::@7
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::@4
  [1] main::max#2 = phi( main/0, main::@4/main::max#3 )
  [1] main::min#2 = phi( main/$ff, main::@4/main::min#3 )
  [1] main::pos#2 = phi( main/0, main::@4/main::pos#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1
  [2] main::pos#1 = ++ main::pos#2
  [3] if(main::pos#1>=main::min#2) goto main::@3
  to:main::@5
main::@5: scope:[main]  from main::@2
  [4] main::min#9 = main::pos#1
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@5
  [5] main::min#3 = phi( main::@2/main::min#2, main::@5/main::min#9 )
  [6] if(main::pos#1<=main::max#2) goto main::@4
  to:main::@6
main::@6: scope:[main]  from main::@3
  [7] main::max#9 = main::pos#1
  to:main::@4
main::@4: scope:[main]  from main::@3 main::@6
  [8] main::max#3 = phi( main::@3/main::max#2, main::@6/main::max#9 )
  [9] *SCREEN = main::min#3
  [10] *(SCREEN+1) = main::max#3
  [11] *(SCREEN+2) = main::pos#1
  to:main::@1


VARIABLE REGISTER WEIGHTS
void main()
char main::max
char main::max#2 // 5.5
char main::max#3 // 11.0
char main::max#9 // 22.0
char main::min
char main::min#2 // 11.0
char main::min#3 // 6.285714285714286
char main::min#9 // 22.0
char main::pos
char main::pos#1 // 7.699999999999999
char main::pos#2 // 22.0

Initial phi equivalence classes
[ main::pos#2 main::pos#1 ]
[ main::min#2 main::min#3 main::min#9 ]
[ main::max#2 main::max#3 main::max#9 ]
Complete equivalence classes
[ main::pos#2 main::pos#1 ]
[ main::min#2 main::min#3 main::min#9 ]
[ main::max#2 main::max#3 main::max#9 ]
Allocated zp[1]:2 [ main::min#2 main::min#3 main::min#9 ]
Allocated zp[1]:3 [ main::max#2 main::max#3 main::max#9 ]
Allocated zp[1]:4 [ main::pos#2 main::pos#1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp[1]:4 [ main::pos#2 main::pos#1 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:2 [ main::min#2 main::min#3 main::min#9 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ main::max#2 main::max#3 main::max#9 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 39.29: zp[1]:2 [ main::min#2 main::min#3 main::min#9 ] 38.5: zp[1]:3 [ main::max#2 main::max#3 main::max#9 ] 29.7: zp[1]:4 [ main::pos#2 main::pos#1 ] 
Uplift Scope [] 

Uplifting [main] best 640 combination reg byte x [ main::min#2 main::min#3 main::min#9 ] reg byte y [ main::max#2 main::max#3 main::max#9 ] reg byte a [ main::pos#2 main::pos#1 ] 
Uplifting [] best 640 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Results in infinite compile loop as the compiler keeps trying to remove the same (empty) alias
  // Upstart
  // Commodore 64 PRG executable file
.file [name="infloop-error.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::max#2 = 0 [phi:main->main::@1#0] -- vbuyy=vbuc1 
    ldy #0
    // [1] phi main::min#2 = $ff [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #$ff
    // [1] phi main::pos#2 = 0 [phi:main->main::@1#2] -- vbuaa=vbuc1 
    lda #0
    jmp __b1
    // main::@1
  __b1:
    jmp __b2
    // main::@2
  __b2:
    // [2] main::pos#1 = ++ main::pos#2 -- vbuaa=_inc_vbuaa 
    clc
    adc #1
    // [3] if(main::pos#1>=main::min#2) goto main::@3 -- vbuaa_ge_vbuxx_then_la1 
    stx.z $ff
    cmp.z $ff
    bcs __b3_from___b2
    jmp __b5
    // main::@5
  __b5:
    // [4] main::min#9 = main::pos#1 -- vbuxx=vbuaa 
    tax
    // [5] phi from main::@2 main::@5 to main::@3 [phi:main::@2/main::@5->main::@3]
  __b3_from___b2:
  __b3_from___b5:
    // [5] phi main::min#3 = main::min#2 [phi:main::@2/main::@5->main::@3#0] -- register_copy 
    jmp __b3
    // main::@3
  __b3:
    // [6] if(main::pos#1<=main::max#2) goto main::@4 -- vbuaa_le_vbuyy_then_la1 
    sta.z $ff
    cpy.z $ff
    bcs __b4_from___b3
    jmp __b6
    // main::@6
  __b6:
    // [7] main::max#9 = main::pos#1 -- vbuyy=vbuaa 
    tay
    // [8] phi from main::@3 main::@6 to main::@4 [phi:main::@3/main::@6->main::@4]
  __b4_from___b3:
  __b4_from___b6:
    // [8] phi main::max#3 = main::max#2 [phi:main::@3/main::@6->main::@4#0] -- register_copy 
    jmp __b4
    // main::@4
  __b4:
    // [9] *SCREEN = main::min#3 -- _deref_pbuc1=vbuxx 
    stx SCREEN
    // [10] *(SCREEN+1) = main::max#3 -- _deref_pbuc1=vbuyy 
    sty SCREEN+1
    // [11] *(SCREEN+2) = main::pos#1 -- _deref_pbuc1=vbuaa 
    sta SCREEN+2
    // [1] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  __b1_from___b4:
    // [1] phi main::max#2 = main::max#3 [phi:main::@4->main::@1#0] -- register_copy 
    // [1] phi main::min#2 = main::min#3 [phi:main::@4->main::@1#1] -- register_copy 
    // [1] phi main::pos#2 = main::pos#1 [phi:main::@4->main::@1#2] -- register_copy 
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b5
Removing instruction jmp __b3
Removing instruction jmp __b6
Removing instruction jmp __b4
Succesful ASM optimization Pass5NextJumpElimination
Replacing instruction lda #0 with TYA
Replacing label __b3_from___b2 with __b3
Replacing label __b4_from___b3 with __b4
Replacing label __b1 with __b2
Removing instruction __b1:
Removing instruction __b3_from___b2:
Removing instruction __b3_from___b5:
Removing instruction __b4_from___b3:
Removing instruction __b4_from___b6:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __b5:
Removing instruction __b6:
Removing instruction __b1_from___b4:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char *SCREEN = (char *) 1024
void main()
char main::max
char main::max#2 // reg byte y 5.5
char main::max#3 // reg byte y 11.0
char main::max#9 // reg byte y 22.0
char main::min
char main::min#2 // reg byte x 11.0
char main::min#3 // reg byte x 6.285714285714286
char main::min#9 // reg byte x 22.0
char main::pos
char main::pos#1 // reg byte a 7.699999999999999
char main::pos#2 // reg byte a 22.0

reg byte a [ main::pos#2 main::pos#1 ]
reg byte x [ main::min#2 main::min#3 main::min#9 ]
reg byte y [ main::max#2 main::max#3 main::max#9 ]


FINAL ASSEMBLER
Score: 460

  // File Comments
// Results in infinite compile loop as the compiler keeps trying to remove the same (empty) alias
  // Upstart
  // Commodore 64 PRG executable file
.file [name="infloop-error.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::max#2 = 0 [phi:main->main::@1#0] -- vbuyy=vbuc1 
    ldy #0
    // [1] phi main::min#2 = $ff [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #$ff
    // [1] phi main::pos#2 = 0 [phi:main->main::@1#2] -- vbuaa=vbuc1 
    tya
    // main::@1
    // main::@2
  __b2:
    // pos++;
    // [2] main::pos#1 = ++ main::pos#2 -- vbuaa=_inc_vbuaa 
    clc
    adc #1
    // if(pos<min)
    // [3] if(main::pos#1>=main::min#2) goto main::@3 -- vbuaa_ge_vbuxx_then_la1 
    stx.z $ff
    cmp.z $ff
    bcs __b3
    // main::@5
    // [4] main::min#9 = main::pos#1 -- vbuxx=vbuaa 
    tax
    // [5] phi from main::@2 main::@5 to main::@3 [phi:main::@2/main::@5->main::@3]
    // [5] phi main::min#3 = main::min#2 [phi:main::@2/main::@5->main::@3#0] -- register_copy 
    // main::@3
  __b3:
    // if(pos>max)
    // [6] if(main::pos#1<=main::max#2) goto main::@4 -- vbuaa_le_vbuyy_then_la1 
    sta.z $ff
    cpy.z $ff
    bcs __b4
    // main::@6
    // [7] main::max#9 = main::pos#1 -- vbuyy=vbuaa 
    tay
    // [8] phi from main::@3 main::@6 to main::@4 [phi:main::@3/main::@6->main::@4]
    // [8] phi main::max#3 = main::max#2 [phi:main::@3/main::@6->main::@4#0] -- register_copy 
    // main::@4
  __b4:
    // SCREEN[0] = min
    // [9] *SCREEN = main::min#3 -- _deref_pbuc1=vbuxx 
    stx SCREEN
    // SCREEN[1] = max
    // [10] *(SCREEN+1) = main::max#3 -- _deref_pbuc1=vbuyy 
    sty SCREEN+1
    // SCREEN[2] = pos
    // [11] *(SCREEN+2) = main::pos#1 -- _deref_pbuc1=vbuaa 
    sta SCREEN+2
    // [1] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
    // [1] phi main::max#2 = main::max#3 [phi:main::@4->main::@1#0] -- register_copy 
    // [1] phi main::min#2 = main::min#3 [phi:main::@4->main::@1#1] -- register_copy 
    // [1] phi main::pos#2 = main::pos#1 [phi:main::@4->main::@1#2] -- register_copy 
    jmp __b2
}
  // File Data

