
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::i#0 = 0
  main::b#0 = 0
  to:main::@1
main::@1: scope:[main]  from main main::@9
  main::i#8 = phi( main/main::i#0, main::@9/main::i#10 )
  main::b#4 = phi( main/main::b#0, main::@9/main::b#1 )
  main::v#0 = 0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@5
  main::i#5 = phi( main::@1/main::i#8, main::@5/main::i#1 )
  main::v#4 = phi( main::@1/main::v#0, main::@5/main::v#1 )
  main::b#2 = phi( main::@1/main::b#4, main::@5/main::b#5 )
  main::$11 = 0 != main::b#2
  if(main::$11) goto main::@3
  to:main::@4
main::@3: scope:[main]  from main::@2
  main::b#10 = phi( main::@2/main::b#2 )
  main::i#9 = phi( main::@2/main::i#5 )
  main::v#2 = phi( main::@2/main::v#4 )
  main::$1 = main::v#2 & 2
  main::$12 = 0 != main::$1
  if(main::$12) goto main::@6
  to:main::@7
main::@4: scope:[main]  from main::@2
  main::b#6 = phi( main::@2/main::b#2 )
  main::v#5 = phi( main::@2/main::v#4 )
  main::i#3 = phi( main::@2/main::i#5 )
  main::$0 = 0
  to:main::@5
main::@5: scope:[main]  from main::@4 main::@8
  main::b#5 = phi( main::@4/main::b#6, main::@8/main::b#7 )
  main::v#3 = phi( main::@4/main::v#5, main::@8/main::v#6 )
  main::i#2 = phi( main::@4/main::i#3, main::@8/main::i#4 )
  main::$8 = phi( main::@8/main::$7, main::@4/main::$0 )
  main::x#0 = main::$8
  main::SCREEN[main::i#2] = main::x#0
  main::i#1 = ++ main::i#2
  main::v#1 = main::v#3 + rangenext(0,3)
  main::$9 = main::v#1 != rangelast(0,3)
  if(main::$9) goto main::@2
  to:main::@9
main::@6: scope:[main]  from main::@3
  main::b#8 = phi( main::@3/main::b#10 )
  main::v#7 = phi( main::@3/main::v#2 )
  main::i#6 = phi( main::@3/main::i#9 )
  main::$3 = 8
  to:main::@8
main::@7: scope:[main]  from main::@3
  main::b#9 = phi( main::@3/main::b#10 )
  main::v#8 = phi( main::@3/main::v#2 )
  main::i#7 = phi( main::@3/main::i#9 )
  main::$2 = $d
  to:main::@8
main::@8: scope:[main]  from main::@6 main::@7
  main::b#7 = phi( main::@6/main::b#8, main::@7/main::b#9 )
  main::v#6 = phi( main::@6/main::v#7, main::@7/main::v#8 )
  main::i#4 = phi( main::@6/main::i#6, main::@7/main::i#7 )
  main::$4 = phi( main::@6/main::$3, main::@7/main::$2 )
  main::$5 = main::$4 * 8
  main::$6 = $18 + main::$5
  main::$7 = main::$6
  to:main::@5
main::@9: scope:[main]  from main::@5
  main::i#10 = phi( main::@5/main::i#1 )
  main::b#3 = phi( main::@5/main::b#5 )
  main::b#1 = main::b#3 + rangenext(0,3)
  main::$10 = main::b#1 != rangelast(0,3)
  if(main::$10) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@9
  return 
  to:@return

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

SYMBOL TABLE SSA
void __start()
void main()
number main::$0
number main::$1
bool main::$10
bool main::$11
bool main::$12
number main::$2
number main::$3
number main::$4
number main::$5
number main::$6
number main::$7
number main::$8
bool main::$9
__constant char * const main::SCREEN = (char *)$400
char main::b
char main::b#0
char main::b#1
char main::b#10
char main::b#2
char main::b#3
char main::b#4
char main::b#5
char main::b#6
char main::b#7
char main::b#8
char main::b#9
char main::i
char main::i#0
char main::i#1
char main::i#10
char main::i#2
char main::i#3
char main::i#4
char main::i#5
char main::i#6
char main::i#7
char main::i#8
char main::i#9
char main::v
char main::v#0
char main::v#1
char main::v#2
char main::v#3
char main::v#4
char main::v#5
char main::v#6
char main::v#7
char main::v#8
char main::x
char main::x#0

Adding number conversion cast (unumber) 0 in main::$11 = 0 != main::b#2
Adding number conversion cast (unumber) 2 in main::$1 = main::v#2 & 2
Adding number conversion cast (unumber) main::$1 in main::$1 = main::v#2 & (unumber)2
Adding number conversion cast (unumber) 0 in main::$12 = 0 != main::$1
Adding number conversion cast (unumber) main::$8 in main::x#0 = main::$8
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast main::x#0 = (unumber)main::$8
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 2
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to char in main::$1 = main::v#2 & 2
Alias main::v#2 = main::v#4 main::v#5 main::v#7 main::v#8 
Alias main::i#3 = main::i#9 main::i#5 main::i#6 main::i#7 
Alias main::b#10 = main::b#2 main::b#6 main::b#8 main::b#9 
Alias main::$7 = main::$6 
Alias main::b#3 = main::b#5 
Alias main::i#1 = main::i#10 
Successful SSA optimization Pass2AliasElimination
Alias main::i#3 = main::i#4 
Alias main::v#2 = main::v#6 
Alias main::b#10 = main::b#7 
Successful SSA optimization Pass2AliasElimination
Alias main::i#2 = main::i#3 
Alias main::v#2 = main::v#3 
Alias main::b#10 = main::b#3 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values main::b#10 main::b#4
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition main::$11 [6] if(0!=main::b#4) goto main::@3
Simple Condition main::$12 [9] if(0!=main::$1) goto main::@6
Simple Condition main::$9 [17] if(main::v#1!=rangelast(0,3)) goto main::@2
Simple Condition main::$10 [25] if(main::b#1!=rangelast(0,3)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::i#0 = 0
Constant main::b#0 = 0
Constant main::v#0 = 0
Constant main::$0 = 0
Constant main::$3 = 8
Constant main::$2 = $d
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [15] main::v#1 = ++ main::v#2 to ++
Resolved ranged comparison value [17] if(main::v#1!=rangelast(0,3)) goto main::@2 to 4
Resolved ranged next value [23] main::b#1 = ++ main::b#4 to ++
Resolved ranged comparison value [25] if(main::b#1!=rangelast(0,3)) goto main::@1 to 4
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Adding number conversion cast (unumber) 4 in [10] if(main::v#1!=4) goto main::@2
Adding number conversion cast (unumber) 4 in [15] if(main::b#1!=4) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 4
Simplifying constant integer cast 4
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) 4
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift [12] main::$5 = main::$4 * 8
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings main::i#0
Inlining constant with var siblings main::b#0
Inlining constant with var siblings main::v#0
Constant inlined main::i#0 = 0
Constant inlined main::$3 = 8
Constant inlined main::b#0 = 0
Constant inlined main::v#0 = 0
Constant inlined main::$2 = $d
Constant inlined main::$0 = 0
Successful SSA optimization Pass2ConstantInlining
Adding number conversion cast (unumber) main::$4 in [12] main::$5 = main::$4 << 3
Adding number conversion cast (unumber) main::$5 in [12] main::$5 = main::$13 << 3
Adding number conversion cast (unumber) $18 in [13] main::$7 = $18 + main::$5
Adding number conversion cast (unumber) main::$7 in [13] main::$7 = (unumber)$18 + main::$5
Successful SSA optimization PassNAddNumberTypeConversions
Adding number conversion cast (unumber) main::$8 in [5] main::$8 = phi( main::@8/main::$7, main::@4/0 )
Adding number conversion cast (unumber) 0 in [5] main::$8 = phi( main::@8/main::$7, main::@4/0 )
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast main::$13 = (unumber)main::$4
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 0
Simplifying constant integer cast main::$8
Simplifying constant integer cast $18
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) $18
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::x#0 = main::$8 
Successful SSA optimization Pass2AliasElimination
Finalized unsigned number type (char) 8
Finalized unsigned number type (char) $d
Successful SSA optimization PassNFinalizeNumberTypeConversions
Adding number conversion cast (unumber) main::$4 in main::$4 = phi( main::@6/8, main::@7/$d )
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast main::$4
Successful SSA optimization PassNCastSimplification
Inferred type updated to char for main::$4
Inferred type updated to char in main::$13 = main::$4
Inferred type updated to char in main::$5 = main::$13 << 3
Inferred type updated to char in main::$7 = $18 + main::$5
Alias main::$13 = main::$4 
Successful SSA optimization Pass2AliasElimination
Added new block during phi lifting main::@10(between main::@9 and main::@1)
Added new block during phi lifting main::@11(between main::@5 and main::@2)
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@4
Adding NOP phi() at start of main::@7
Adding NOP phi() at start of main::@6
CALL GRAPH

Created 6 initial phi equivalence classes
Coalesced [2] main::i#12 = main::i#8
Coalesced [14] main::b#11 = main::b#1
Coalesced [15] main::i#11 = main::i#1
Coalesced [16] main::v#9 = main::v#1
Coalesced (already) [17] main::i#13 = main::i#1
Coalesced [24] main::x#1 = main::$7
Coalesced down to 5 phi equivalence classes
Culled Empty Block label main::@4
Culled Empty Block label main::@10
Culled Empty Block label main::@11
Culled Empty Block label main::@7
Renumbering block main::@5 to main::@4
Renumbering block main::@6 to main::@5
Renumbering block main::@8 to main::@6
Renumbering block main::@9 to main::@7
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@5

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@7
  [1] main::i#8 = phi( main/0, main::@7/main::i#1 )
  [1] main::b#4 = phi( main/0, main::@7/main::b#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@4
  [2] main::i#2 = phi( main::@1/main::i#8, main::@4/main::i#1 )
  [2] main::v#2 = phi( main::@1/0, main::@4/main::v#1 )
  [3] if(0!=main::b#4) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@2 main::@6
  [4] main::x#0 = phi( main::@6/main::$7, main::@2/0 )
  [5] main::SCREEN[main::i#2] = main::x#0
  [6] main::i#1 = ++ main::i#2
  [7] main::v#1 = ++ main::v#2
  [8] if(main::v#1!=4) goto main::@2
  to:main::@7
main::@7: scope:[main]  from main::@4
  [9] main::b#1 = ++ main::b#4
  [10] if(main::b#1!=4) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@7
  [11] return 
  to:@return
main::@3: scope:[main]  from main::@2
  [12] main::$1 = main::v#2 & 2
  [13] if(0!=main::$1) goto main::@5
  to:main::@6
main::@5: scope:[main]  from main::@3
  [14] phi()
  to:main::@6
main::@6: scope:[main]  from main::@3 main::@5
  [15] main::$13 = phi( main::@5/8, main::@3/$d )
  [16] main::$5 = main::$13 << 3
  [17] main::$7 = $18 + main::$5
  to:main::@4


VARIABLE REGISTER WEIGHTS
void main()
char main::$1 // 202.0
char main::$13 // 101.0
char main::$5 // 202.0
char main::$7 // 202.0
char main::b
char main::b#1 // 16.5
char main::b#4 // 8.785714285714286
char main::i
char main::i#1 // 42.599999999999994
char main::i#2 // 31.4
char main::i#8 // 22.0
char main::v
char main::v#1 // 151.5
char main::v#2 // 27.545454545454547
char main::x
char main::x#0 // 202.0

Initial phi equivalence classes
[ main::b#4 main::b#1 ]
[ main::v#2 main::v#1 ]
[ main::i#2 main::i#8 main::i#1 ]
[ main::x#0 main::$7 ]
[ main::$13 ]
Added variable main::$1 to live range equivalence class [ main::$1 ]
Added variable main::$5 to live range equivalence class [ main::$5 ]
Complete equivalence classes
[ main::b#4 main::b#1 ]
[ main::v#2 main::v#1 ]
[ main::i#2 main::i#8 main::i#1 ]
[ main::x#0 main::$7 ]
[ main::$13 ]
[ main::$1 ]
[ main::$5 ]
Allocated zp[1]:2 [ main::x#0 main::$7 ]
Allocated zp[1]:3 [ main::$1 ]
Allocated zp[1]:4 [ main::$5 ]
Allocated zp[1]:5 [ main::v#2 main::v#1 ]
Allocated zp[1]:6 [ main::$13 ]
Allocated zp[1]:7 [ main::i#2 main::i#8 main::i#1 ]
Allocated zp[1]:8 [ main::b#4 main::b#1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [16] main::$5 = main::$13 << 3 [ main::b#4 main::v#2 main::i#2 main::$5 ] (  [ main::b#4 main::v#2 main::i#2 main::$5 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:8 [ main::b#4 main::b#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:5 [ main::v#2 main::v#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:7 [ main::i#2 main::i#8 main::i#1 ]
Statement [12] main::$1 = main::v#2 & 2 [ main::b#4 main::v#2 main::i#2 main::$1 ] (  [ main::b#4 main::v#2 main::i#2 main::$1 ] { }  ) always clobbers reg byte a 
Statement [16] main::$5 = main::$13 << 3 [ main::b#4 main::v#2 main::i#2 main::$5 ] (  [ main::b#4 main::v#2 main::i#2 main::$5 ] { }  ) always clobbers reg byte a 
Potential registers zp[1]:8 [ main::b#4 main::b#1 ] : zp[1]:8 , reg byte x , reg byte y , 
Potential registers zp[1]:5 [ main::v#2 main::v#1 ] : zp[1]:5 , reg byte x , reg byte y , 
Potential registers zp[1]:7 [ main::i#2 main::i#8 main::i#1 ] : zp[1]:7 , reg byte x , reg byte y , 
Potential registers zp[1]:2 [ main::x#0 main::$7 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:6 [ main::$13 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ main::$1 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ main::$5 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 404: zp[1]:2 [ main::x#0 main::$7 ] 202: zp[1]:3 [ main::$1 ] 202: zp[1]:4 [ main::$5 ] 179.05: zp[1]:5 [ main::v#2 main::v#1 ] 101: zp[1]:6 [ main::$13 ] 96: zp[1]:7 [ main::i#2 main::i#8 main::i#1 ] 25.29: zp[1]:8 [ main::b#4 main::b#1 ] 
Uplift Scope [] 

Uplifting [main] best 8771 combination reg byte a [ main::x#0 main::$7 ] reg byte a [ main::$1 ] reg byte a [ main::$5 ] reg byte x [ main::v#2 main::v#1 ] zp[1]:6 [ main::$13 ] zp[1]:7 [ main::i#2 main::i#8 main::i#1 ] zp[1]:8 [ main::b#4 main::b#1 ] 
Limited combination testing to 100 combinations of 6912 possible.
Uplifting [] best 8771 combination 
Attempting to uplift remaining variables inzp[1]:6 [ main::$13 ]
Uplifting [main] best 7871 combination reg byte a [ main::$13 ] 
Attempting to uplift remaining variables inzp[1]:7 [ main::i#2 main::i#8 main::i#1 ]
Uplifting [main] best 7241 combination reg byte y [ main::i#2 main::i#8 main::i#1 ] 
Attempting to uplift remaining variables inzp[1]:8 [ main::b#4 main::b#1 ]
Uplifting [main] best 7241 combination zp[1]:8 [ main::b#4 main::b#1 ] 
Allocated (was zp[1]:8) zp[1]:2 [ main::b#4 main::b#1 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests the ternary operator - complex nested conditional operators
  // Upstart
  // Commodore 64 PRG executable file
.file [name="ternary-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
.segment Code
  // main
main: {
    .label SCREEN = $400
    .label b = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi main::i#8 = 0 [phi:main->main::@1#0] -- vbuyy=vbuc1 
    ldy #0
    // [1] phi main::b#4 = 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta.z b
    jmp __b1
    // [1] phi from main::@7 to main::@1 [phi:main::@7->main::@1]
  __b1_from___b7:
    // [1] phi main::i#8 = main::i#1 [phi:main::@7->main::@1#0] -- register_copy 
    // [1] phi main::b#4 = main::b#1 [phi:main::@7->main::@1#1] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [2] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    // [2] phi main::i#2 = main::i#8 [phi:main::@1->main::@2#0] -- register_copy 
    // [2] phi main::v#2 = 0 [phi:main::@1->main::@2#1] -- vbuxx=vbuc1 
    ldx #0
    jmp __b2
    // [2] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
  __b2_from___b4:
    // [2] phi main::i#2 = main::i#1 [phi:main::@4->main::@2#0] -- register_copy 
    // [2] phi main::v#2 = main::v#1 [phi:main::@4->main::@2#1] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [3] if(0!=main::b#4) goto main::@3 -- 0_neq_vbuz1_then_la1 
    lda.z b
    bne __b3
    // [4] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
  __b4_from___b2:
    // [4] phi main::x#0 = 0 [phi:main::@2->main::@4#0] -- vbuaa=vbuc1 
    lda #0
    jmp __b4
    // main::@4
  __b4:
    // [5] main::SCREEN[main::i#2] = main::x#0 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    // [6] main::i#1 = ++ main::i#2 -- vbuyy=_inc_vbuyy 
    iny
    // [7] main::v#1 = ++ main::v#2 -- vbuxx=_inc_vbuxx 
    inx
    // [8] if(main::v#1!=4) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #4
    bne __b2_from___b4
    jmp __b7
    // main::@7
  __b7:
    // [9] main::b#1 = ++ main::b#4 -- vbuz1=_inc_vbuz1 
    inc.z b
    // [10] if(main::b#1!=4) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #4
    cmp.z b
    bne __b1_from___b7
    jmp __breturn
    // main::@return
  __breturn:
    // [11] return 
    rts
    // main::@3
  __b3:
    // [12] main::$1 = main::v#2 & 2 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #2
    // [13] if(0!=main::$1) goto main::@5 -- 0_neq_vbuaa_then_la1 
    cmp #0
    bne __b5_from___b3
    // [15] phi from main::@3 to main::@6 [phi:main::@3->main::@6]
  __b6_from___b3:
    // [15] phi main::$13 = $d [phi:main::@3->main::@6#0] -- vbuaa=vbuc1 
    lda #$d
    jmp __b6
    // [14] phi from main::@3 to main::@5 [phi:main::@3->main::@5]
  __b5_from___b3:
    jmp __b5
    // main::@5
  __b5:
    // [15] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
  __b6_from___b5:
    // [15] phi main::$13 = 8 [phi:main::@5->main::@6#0] -- vbuaa=vbuc1 
    lda #8
    jmp __b6
    // main::@6
  __b6:
    // [16] main::$5 = main::$13 << 3 -- vbuaa=vbuaa_rol_3 
    asl
    asl
    asl
    // [17] main::$7 = $18 + main::$5 -- vbuaa=vbuc1_plus_vbuaa 
    clc
    adc #$18
    // [4] phi from main::@6 to main::@4 [phi:main::@6->main::@4]
  __b4_from___b6:
    // [4] phi main::x#0 = main::$7 [phi:main::@6->main::@4#0] -- register_copy 
    jmp __b4
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b4
Removing instruction jmp __b7
Removing instruction jmp __breturn
Removing instruction jmp __b5
Removing instruction jmp __b6
Succesful ASM optimization Pass5NextJumpElimination
Replacing instruction lda #0 with TYA
Replacing label __b2_from___b4 with __b2
Replacing label __b1_from___b7 with __b1
Replacing label __b5_from___b3 with __b5
Removing instruction __b1_from___b7:
Removing instruction __b2_from___b1:
Removing instruction __b2_from___b4:
Removing instruction __b5_from___b3:
Removing instruction __b6_from___b5:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __b4_from___b2:
Removing instruction __b7:
Removing instruction __breturn:
Removing instruction __b6_from___b3:
Removing instruction __b4_from___b6:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
Removing instruction jmp __b2
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
void main()
char main::$1 // reg byte a 202.0
char main::$13 // reg byte a 101.0
char main::$5 // reg byte a 202.0
char main::$7 // reg byte a 202.0
__constant char * const main::SCREEN = (char *) 1024
char main::b
char main::b#1 // b zp[1]:2 16.5
char main::b#4 // b zp[1]:2 8.785714285714286
char main::i
char main::i#1 // reg byte y 42.599999999999994
char main::i#2 // reg byte y 31.4
char main::i#8 // reg byte y 22.0
char main::v
char main::v#1 // reg byte x 151.5
char main::v#2 // reg byte x 27.545454545454547
char main::x
char main::x#0 // reg byte a 202.0

zp[1]:2 [ main::b#4 main::b#1 ]
reg byte x [ main::v#2 main::v#1 ]
reg byte y [ main::i#2 main::i#8 main::i#1 ]
reg byte a [ main::x#0 main::$7 ]
reg byte a [ main::$13 ]
reg byte a [ main::$1 ]
reg byte a [ main::$5 ]


FINAL ASSEMBLER
Score: 5351

  // File Comments
// Tests the ternary operator - complex nested conditional operators
  // Upstart
  // Commodore 64 PRG executable file
.file [name="ternary-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
.segment Code
  // main
main: {
    .label SCREEN = $400
    .label b = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi main::i#8 = 0 [phi:main->main::@1#0] -- vbuyy=vbuc1 
    ldy #0
    // [1] phi main::b#4 = 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    tya
    sta.z b
    // [1] phi from main::@7 to main::@1 [phi:main::@7->main::@1]
    // [1] phi main::i#8 = main::i#1 [phi:main::@7->main::@1#0] -- register_copy 
    // [1] phi main::b#4 = main::b#1 [phi:main::@7->main::@1#1] -- register_copy 
    // main::@1
  __b1:
    // [2] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [2] phi main::i#2 = main::i#8 [phi:main::@1->main::@2#0] -- register_copy 
    // [2] phi main::v#2 = 0 [phi:main::@1->main::@2#1] -- vbuxx=vbuc1 
    ldx #0
    // [2] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
    // [2] phi main::i#2 = main::i#1 [phi:main::@4->main::@2#0] -- register_copy 
    // [2] phi main::v#2 = main::v#1 [phi:main::@4->main::@2#1] -- register_copy 
    // main::@2
  __b2:
    // (b) ? 24 + (v & 2 ? 8 : 13) * 8 : 0
    // [3] if(0!=main::b#4) goto main::@3 -- 0_neq_vbuz1_then_la1 
    lda.z b
    bne __b3
    // [4] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
    // [4] phi main::x#0 = 0 [phi:main::@2->main::@4#0] -- vbuaa=vbuc1 
    lda #0
    // main::@4
  __b4:
    // SCREEN[i++] = x
    // [5] main::SCREEN[main::i#2] = main::x#0 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    // SCREEN[i++] = x;
    // [6] main::i#1 = ++ main::i#2 -- vbuyy=_inc_vbuyy 
    iny
    // for( char v: 0..3)
    // [7] main::v#1 = ++ main::v#2 -- vbuxx=_inc_vbuxx 
    inx
    // [8] if(main::v#1!=4) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #4
    bne __b2
    // main::@7
    // for(char b: 0..3)
    // [9] main::b#1 = ++ main::b#4 -- vbuz1=_inc_vbuz1 
    inc.z b
    // [10] if(main::b#1!=4) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #4
    cmp.z b
    bne __b1
    // main::@return
    // }
    // [11] return 
    rts
    // main::@3
  __b3:
    // v & 2
    // [12] main::$1 = main::v#2 & 2 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #2
    // v & 2 ? 8 : 13
    // [13] if(0!=main::$1) goto main::@5 -- 0_neq_vbuaa_then_la1 
    cmp #0
    bne __b5
    // [15] phi from main::@3 to main::@6 [phi:main::@3->main::@6]
    // [15] phi main::$13 = $d [phi:main::@3->main::@6#0] -- vbuaa=vbuc1 
    lda #$d
    jmp __b6
    // [14] phi from main::@3 to main::@5 [phi:main::@3->main::@5]
    // main::@5
  __b5:
    // v & 2 ? 8 : 13
    // [15] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
    // [15] phi main::$13 = 8 [phi:main::@5->main::@6#0] -- vbuaa=vbuc1 
    lda #8
    // main::@6
  __b6:
    // (v & 2 ? 8 : 13) * 8
    // [16] main::$5 = main::$13 << 3 -- vbuaa=vbuaa_rol_3 
    asl
    asl
    asl
    // (b) ? 24 + (v & 2 ? 8 : 13) * 8 : 0
    // [17] main::$7 = $18 + main::$5 -- vbuaa=vbuc1_plus_vbuaa 
    clc
    adc #$18
    // [4] phi from main::@6 to main::@4 [phi:main::@6->main::@4]
    // [4] phi main::x#0 = main::$7 [phi:main::@6->main::@4#0] -- register_copy 
    jmp __b4
}
  // File Data

