
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::screen#0 = (char *)$400
  to:main::@1
main::@1: scope:[main]  from main main::@2
  main::screen#2 = phi( main/main::screen#0, main::@2/main::screen#1 )
  main::$0 = main::screen#2 < $400+$3e8
  if(main::$0) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  main::screen#3 = phi( main::@1/main::screen#2 )
  *main::screen#3 = '*'
  main::screen#1 = ++ main::screen#3
  to:main::@1
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
char *main::screen
char *main::screen#0
char *main::screen#1
char *main::screen#2
char *main::screen#3

Adding number conversion cast (unumber) $400+$3e8 in main::$0 = main::screen#2 < $400+$3e8
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Alias main::screen#2 = main::screen#3 
Successful SSA optimization Pass2AliasElimination
Simple Condition main::$0 [3] if(main::screen#2<(unsigned int)$400+$3e8) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::screen#0 = (char *) 1024
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::screen#0
Constant inlined main::screen#0 = (char *) 1024
Successful SSA optimization Pass2ConstantInlining
Finalized unsigned number type (unsigned int) $400
Finalized unsigned number type (unsigned int) $3e8
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying constant integer cast $400+$3e8
Successful SSA optimization PassNCastSimplification
Adding NOP phi() at start of main
CALL GRAPH

Created 1 initial phi equivalence classes
Coalesced [6] main::screen#4 = main::screen#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::@1
main::@1: scope:[main]  from main main::@2
  [1] main::screen#2 = phi( main/(char *) 1024, main::@2/main::screen#1 )
  [2] if(main::screen#2<$400+$3e8) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@1
  [3] return 
  to:@return
main::@2: scope:[main]  from main::@1
  [4] *main::screen#2 = '*'
  [5] main::screen#1 = ++ main::screen#2
  to:main::@1


VARIABLE REGISTER WEIGHTS
void main()
char *main::screen
char *main::screen#1 // 22.0
char *main::screen#2 // 14.666666666666666

Initial phi equivalence classes
[ main::screen#2 main::screen#1 ]
Complete equivalence classes
[ main::screen#2 main::screen#1 ]
Allocated zp[2]:2 [ main::screen#2 main::screen#1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [2] if(main::screen#2<$400+$3e8) goto main::@2 [ main::screen#2 ] (  [ main::screen#2 ] { }  ) always clobbers reg byte a 
Statement [4] *main::screen#2 = '*' [ main::screen#2 ] (  [ main::screen#2 ] { }  ) always clobbers reg byte a reg byte y 
Potential registers zp[2]:2 [ main::screen#2 main::screen#1 ] : zp[2]:2 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 36.67: zp[2]:2 [ main::screen#2 main::screen#1 ] 
Uplift Scope [] 

Uplifting [main] best 596 combination zp[2]:2 [ main::screen#2 main::screen#1 ] 
Uplifting [] best 596 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test an empty statement ';'
  // Upstart
  // Commodore 64 PRG executable file
.file [name="stmt-empty.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 = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi main::screen#2 = (char *) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
    jmp __b1
  // Fill screen with '*'. Body is an empty statement.
    // main::@1
  __b1:
    // [2] if(main::screen#2<$400+$3e8) goto main::@2 -- pbuz1_lt_vwuc1_then_la1 
    lda.z screen+1
    cmp #>$400+$3e8
    bcc __b2
    bne !+
    lda.z screen
    cmp #<$400+$3e8
    bcc __b2
  !:
    jmp __breturn
    // main::@return
  __breturn:
    // [3] return 
    rts
    // main::@2
  __b2:
    // [4] *main::screen#2 = '*' -- _deref_pbuz1=vbuc1 
    lda #'*'
    ldy #0
    sta (screen),y
    // [5] main::screen#1 = ++ main::screen#2 -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [1] phi main::screen#2 = main::screen#1 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
void main()
char *main::screen
char *main::screen#1 // screen zp[2]:2 22.0
char *main::screen#2 // screen zp[2]:2 14.666666666666666

zp[2]:2 [ main::screen#2 main::screen#1 ]


FINAL ASSEMBLER
Score: 536

  // File Comments
// Test an empty statement ';'
  // Upstart
  // Commodore 64 PRG executable file
.file [name="stmt-empty.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 = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi main::screen#2 = (char *) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
  // Fill screen with '*'. Body is an empty statement.
    // main::@1
  __b1:
    // for( char * screen = (char*)0x0400; screen<0x400+1000; (*screen++)='*')
    // [2] if(main::screen#2<$400+$3e8) goto main::@2 -- pbuz1_lt_vwuc1_then_la1 
    lda.z screen+1
    cmp #>$400+$3e8
    bcc __b2
    bne !+
    lda.z screen
    cmp #<$400+$3e8
    bcc __b2
  !:
    // main::@return
    // }
    // [3] return 
    rts
    // main::@2
  __b2:
    // (*screen++)='*'
    // [4] *main::screen#2 = '*' -- _deref_pbuz1=vbuc1 
    lda #'*'
    ldy #0
    sta (screen),y
    // for( char * screen = (char*)0x0400; screen<0x400+1000; (*screen++)='*')
    // [5] main::screen#1 = ++ main::screen#2 -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
    // [1] phi main::screen#2 = main::screen#1 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
}
  // File Data

