
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::i#0 = 0
  to:main::first
main::first: scope:[main]  from main main::@2
  main::i#2 = phi( main/main::i#0, main::@2/main::i#4 )
  main::SCREEN[$28] = ++ main::SCREEN[$28]
  main::i#1 = ++ main::i#2
  to:main::@1
main::@1: scope:[main]  from main::first
  main::i#3 = phi( main::first/main::i#1 )
  main::$0 = main::i#3 < $a
  if(main::$0) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  main::i#4 = phi( main::@1/main::i#3 )
  main::SCREEN[main::i#4] = '*'
  to:main::first
main::@return: scope:[main]  from main::@1
  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()
bool main::$0
__constant char * const main::SCREEN = (char *)$400
char main::i
char main::i#0
char main::i#1
char main::i#2
char main::i#3
char main::i#4

Adding number conversion cast (unumber) $28 in main::SCREEN[$28] = ++ main::SCREEN[$28]
Adding number conversion cast (unumber) $28 in main::SCREEN[$28] = ++ main::SCREEN[(unumber)$28]
Adding number conversion cast (unumber) $a in main::$0 = main::i#3 < $a
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast $28
Simplifying constant integer cast $28
Simplifying constant integer cast $a
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) $a
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::i#1 = main::i#3 main::i#4 
Successful SSA optimization Pass2AliasElimination
Simple Condition main::$0 [5] if(main::i#1<$a) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
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
Inlining constant with var siblings main::i#0
Constant inlined main::i#0 = 0
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(main::SCREEN+$28)
Consolidated array index constant in *(main::SCREEN+$28)
Successful SSA optimization Pass2ConstantAdditionElimination
Adding NOP phi() at start of main
CALL GRAPH

Created 1 initial phi equivalence classes
Coalesced [7] main::i#5 = main::i#1
Coalesced down to 1 phi equivalence classes
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::first
main::first: scope:[main]  from main main::@2
  [1] main::i#2 = phi( main/0, main::@2/main::i#1 )
  [2] *(main::SCREEN+$28) = ++ *(main::SCREEN+$28)
  [3] main::i#1 = ++ main::i#2
  to:main::@1
main::@1: scope:[main]  from main::first
  [4] if(main::i#1<$a) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@1
  [5] return 
  to:@return
main::@2: scope:[main]  from main::@1
  [6] main::SCREEN[main::i#1] = '*'
  to:main::first


VARIABLE REGISTER WEIGHTS
void main()
char main::i
char main::i#1 // 14.666666666666666
char main::i#2 // 11.0

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] main::SCREEN[main::i#1] = '*' [ main::i#1 ] (  [ main::i#1 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [6] main::SCREEN[main::i#1] = '*' [ main::i#1 ] (  [ main::i#1 ] { }  ) always clobbers reg byte a 
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 25.67: zp[1]:2 [ main::i#2 main::i#1 ] 
Uplift Scope [] 

Uplifting [main] best 341 combination reg byte x [ main::i#2 main::i#1 ] 
Uplifting [] best 341 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test labels/goto
// goto a label nested in a loop
  // Upstart
  // Commodore 64 PRG executable file
.file [name="labelgoto-5.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
    // [1] phi from main to main::first [phi:main->main::first]
  first_from_main:
    // [1] phi main::i#2 = 0 [phi:main->main::first#0] -- vbuxx=vbuc1 
    ldx #0
    jmp first
    // main::first
  first:
    // [2] *(main::SCREEN+$28) = ++ *(main::SCREEN+$28) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc SCREEN+$28
    // [3] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    jmp __b1
    // main::@1
  __b1:
    // [4] if(main::i#1<$a) goto main::@2 -- vbuxx_lt_vbuc1_then_la1 
    cpx #$a
    bcc __b2
    jmp __breturn
    // main::@return
  __breturn:
    // [5] return 
    rts
    // main::@2
  __b2:
    // [6] main::SCREEN[main::i#1] = '*' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'*'
    sta SCREEN,x
    // [1] phi from main::@2 to main::first [phi:main::@2->main::first]
  first_from___b2:
    // [1] phi main::i#2 = main::i#1 [phi:main::@2->main::first#0] -- register_copy 
    jmp first
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp first
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction first_from_main:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction first_from___b2:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
void main()
__constant char * const main::SCREEN = (char *) 1024
char main::i
char main::i#1 // reg byte x 14.666666666666666
char main::i#2 // reg byte x 11.0

reg byte x [ main::i#2 main::i#1 ]


FINAL ASSEMBLER
Score: 251

  // File Comments
// Test labels/goto
// goto a label nested in a loop
  // Upstart
  // Commodore 64 PRG executable file
.file [name="labelgoto-5.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
    // [1] phi from main to main::first [phi:main->main::first]
    // [1] phi main::i#2 = 0 [phi:main->main::first#0] -- vbuxx=vbuc1 
    ldx #0
    // main::first
  first:
    // SCREEN[40]++;
    // [2] *(main::SCREEN+$28) = ++ *(main::SCREEN+$28) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc SCREEN+$28
    // for(;i<10;i++)
    // [3] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // main::@1
    // [4] if(main::i#1<$a) goto main::@2 -- vbuxx_lt_vbuc1_then_la1 
    cpx #$a
    bcc __b2
    // main::@return
    // }
    // [5] return 
    rts
    // main::@2
  __b2:
    // SCREEN[i] = '*'
    // [6] main::SCREEN[main::i#1] = '*' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'*'
    sta SCREEN,x
    // [1] phi from main::@2 to main::first [phi:main::@2->main::first]
    // [1] phi main::i#2 = main::i#1 [phi:main::@2->main::first#0] -- register_copy 
    jmp first
}
  // File Data

