Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  main::i#0 = 0
  to:main::@1
main::@1: scope:[main]  from main main::@3
  main::i#4 = phi( main/main::i#0, main::@3/main::i#1 )
  main::j#0 = 0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  main::i#2 = phi( main::@1/main::i#4, main::@2/main::i#2 )
  main::j#2 = phi( main::@1/main::j#0, main::@2/main::j#1 )
  SCREEN[main::i#2] = main::j#2
  main::j#1 = main::j#2 + rangenext(0,$64)
  main::$0 = main::j#1 != rangelast(0,$64)
  if(main::$0) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  main::i#3 = phi( main::@2/main::i#2 )
  main::i#1 = main::i#3 + rangenext(0,$64)
  main::$1 = main::i#1 != rangelast(0,$64)
  if(main::$1) goto main::@1
  to:main::@4
main::@4: scope:[main]  from main::@3
  main::k#0 = 0
  to:main::@5
main::@5: scope:[main]  from main::@4 main::@7
  main::k#4 = phi( main::@4/main::k#0, main::@7/main::k#1 )
  main::l#0 = 0
  to:main::@6
main::@6: scope:[main]  from main::@5 main::@6
  main::k#2 = phi( main::@5/main::k#4, main::@6/main::k#2 )
  main::l#2 = phi( main::@5/main::l#0, main::@6/main::l#1 )
  asm { eor#$55 tax  }
  SCREEN[main::k#2] = main::l#2
  main::l#1 = main::l#2 + rangenext(0,$64)
  main::$2 = main::l#1 != rangelast(0,$64)
  if(main::$2) goto main::@6
  to:main::@7
main::@7: scope:[main]  from main::@6
  main::k#3 = phi( main::@6/main::k#2 )
  main::k#1 = main::k#3 + rangenext(0,$64)
  main::$3 = main::k#1 != rangelast(0,$64)
  if(main::$3) goto main::@5
  to:main::@return
main::@return: scope:[main]  from main::@7
  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::i
char main::i#0
char main::i#1
char main::i#2
char main::i#3
char main::i#4
char main::j
char main::j#0
char main::j#1
char main::j#2
char main::k
char main::k#0
char main::k#1
char main::k#2
char main::k#3
char main::k#4
char main::l
char main::l#0
char main::l#1
char main::l#2

Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Alias main::i#2 = main::i#3 
Alias main::k#2 = main::k#3 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values main::i#2 main::i#4
Identical Phi Values main::k#2 main::k#4
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition main::$0 [7] if(main::j#1!=rangelast(0,$64)) goto main::@2
Simple Condition main::$1 [10] if(main::i#1!=rangelast(0,$64)) goto main::@1
Simple Condition main::$2 [19] if(main::l#1!=rangelast(0,$64)) goto main::@6
Simple Condition main::$3 [22] if(main::k#1!=rangelast(0,$64)) goto main::@5
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::i#0 = 0
Constant main::j#0 = 0
Constant main::k#0 = 0
Constant main::l#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [5] main::j#1 = ++ main::j#2 to ++
Resolved ranged comparison value [7] if(main::j#1!=rangelast(0,$64)) goto main::@2 to $65
Resolved ranged next value [8] main::i#1 = ++ main::i#4 to ++
Resolved ranged comparison value [10] if(main::i#1!=rangelast(0,$64)) goto main::@1 to $65
Resolved ranged next value [17] main::l#1 = ++ main::l#2 to ++
Resolved ranged comparison value [19] if(main::l#1!=rangelast(0,$64)) goto main::@6 to $65
Resolved ranged next value [20] main::k#1 = ++ main::k#4 to ++
Resolved ranged comparison value [22] if(main::k#1!=rangelast(0,$64)) goto main::@5 to $65
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 (unumber) $65 in [4] if(main::j#1!=$65) goto main::@2
Adding number conversion cast (unumber) $65 in [6] if(main::i#1!=$65) goto main::@1
Adding number conversion cast (unumber) $65 in [12] if(main::l#1!=$65) goto main::@6
Adding number conversion cast (unumber) $65 in [14] if(main::k#1!=$65) goto main::@5
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $65
Simplifying constant integer cast $65
Simplifying constant integer cast $65
Simplifying constant integer cast $65
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $65
Finalized unsigned number type (char) $65
Finalized unsigned number type (char) $65
Finalized unsigned number type (char) $65
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings main::i#0
Inlining constant with var siblings main::j#0
Inlining constant with var siblings main::k#0
Inlining constant with var siblings main::l#0
Constant inlined main::i#0 = 0
Constant inlined main::k#0 = 0
Constant inlined main::j#0 = 0
Constant inlined main::l#0 = 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@8(between main::@3 and main::@1)
Added new block during phi lifting main::@9(between main::@2 and main::@2)
Added new block during phi lifting main::@10(between main::@7 and main::@5)
Added new block during phi lifting main::@11(between main::@6 and main::@6)
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@4
CALL GRAPH

Created 4 initial phi equivalence classes
Coalesced [18] main::k#5 = main::k#1
Coalesced [19] main::l#3 = main::l#1
Coalesced [20] main::i#5 = main::i#1
Coalesced [21] main::j#3 = main::j#1
Coalesced down to 4 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::@8
Culled Empty Block label main::@9
Renumbering block main::@5 to main::@4
Renumbering block main::@6 to main::@5
Renumbering block main::@7 to main::@6
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::@3
  [1] main::i#4 = phi( main/0, main::@3/main::i#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [2] main::j#2 = phi( main::@1/0, main::@2/main::j#1 )
  [3] SCREEN[main::i#4] = main::j#2
  [4] main::j#1 = ++ main::j#2
  [5] if(main::j#1!=$65) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  [6] main::i#1 = ++ main::i#4
  [7] if(main::i#1!=$65) goto main::@1
  to:main::@4
main::@4: scope:[main]  from main::@3 main::@6
  [8] main::k#4 = phi( main::@3/0, main::@6/main::k#1 )
  to:main::@5
main::@5: scope:[main]  from main::@4 main::@5
  [9] main::l#2 = phi( main::@4/0, main::@5/main::l#1 )
  asm { eor#$55 tax  }
  [11] SCREEN[main::k#4] = main::l#2
  [12] main::l#1 = ++ main::l#2
  [13] if(main::l#1!=$65) goto main::@5
  to:main::@6
main::@6: scope:[main]  from main::@5
  [14] main::k#1 = ++ main::k#4
  [15] if(main::k#1!=$65) goto main::@4
  to:main::@return
main::@return: scope:[main]  from main::@6
  [16] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char main::i
char main::i#1 // 16.5
char main::i#4 // 24.599999999999998
char main::j
char main::j#1 // 151.5
char main::j#2 // 151.5
char main::k
char main::k#1 // 16.5
char main::k#4 // 20.499999999999996
char main::l
char main::l#1 // 151.5
char main::l#2 // 101.0

Initial phi equivalence classes
[ main::i#4 main::i#1 ]
[ main::j#2 main::j#1 ]
[ main::k#4 main::k#1 ]
[ main::l#2 main::l#1 ]
Complete equivalence classes
[ main::i#4 main::i#1 ]
[ main::j#2 main::j#1 ]
[ main::k#4 main::k#1 ]
[ main::l#2 main::l#1 ]
Allocated zp[1]:2 [ main::j#2 main::j#1 ]
Allocated zp[1]:3 [ main::l#2 main::l#1 ]
Allocated zp[1]:4 [ main::i#4 main::i#1 ]
Allocated zp[1]:5 [ main::k#4 main::k#1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement asm { eor#$55 tax  } always clobbers reg byte a reg byte x 
Removing always clobbered register reg byte a as potential for zp[1]:5 [ main::k#4 main::k#1 ]
Removing always clobbered register reg byte x as potential for zp[1]:5 [ main::k#4 main::k#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:3 [ main::l#2 main::l#1 ]
Removing always clobbered register reg byte x as potential for zp[1]:3 [ main::l#2 main::l#1 ]
Statement [11] SCREEN[main::k#4] = main::l#2 [ main::k#4 main::l#2 ] (  [ main::k#4 main::l#2 ] { }  ) always clobbers reg byte a 
Statement asm { eor#$55 tax  } always clobbers reg byte a reg byte x 
Statement [11] SCREEN[main::k#4] = main::l#2 [ main::k#4 main::l#2 ] (  [ main::k#4 main::l#2 ] { }  ) always clobbers reg byte a 
Potential registers zp[1]:4 [ main::i#4 main::i#1 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:2 [ main::j#2 main::j#1 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:5 [ main::k#4 main::k#1 ] : zp[1]:5 , reg byte y , 
Potential registers zp[1]:3 [ main::l#2 main::l#1 ] : zp[1]:3 , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 303: zp[1]:2 [ main::j#2 main::j#1 ] 252.5: zp[1]:3 [ main::l#2 main::l#1 ] 41.1: zp[1]:4 [ main::i#4 main::i#1 ] 37: zp[1]:5 [ main::k#4 main::k#1 ] 
Uplift Scope [] 

Uplifting [main] best 6626 combination reg byte a [ main::j#2 main::j#1 ] zp[1]:3 [ main::l#2 main::l#1 ] reg byte x [ main::i#4 main::i#1 ] reg byte y [ main::k#4 main::k#1 ] 
Uplifting [] best 6626 combination 
Attempting to uplift remaining variables inzp[1]:3 [ main::l#2 main::l#1 ]
Uplifting [main] best 6626 combination zp[1]:3 [ main::l#2 main::l#1 ] 
Allocated (was zp[1]:3) zp[1]:2 [ main::l#2 main::l#1 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests that inline ASM clobbering is taken into account when assigning registers
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-asm-clobber.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: {
    .label l = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi main::i#4 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b1
  // First loop with no clobber
    // [1] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [1] phi main::i#4 = main::i#1 [phi:main::@3->main::@1#0] -- 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::j#2 = 0 [phi:main::@1->main::@2#0] -- vbuaa=vbuc1 
    lda #0
    jmp __b2
    // [2] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  __b2_from___b2:
    // [2] phi main::j#2 = main::j#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [3] SCREEN[main::i#4] = main::j#2 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // [4] main::j#1 = ++ main::j#2 -- vbuaa=_inc_vbuaa 
    clc
    adc #1
    // [5] if(main::j#1!=$65) goto main::@2 -- vbuaa_neq_vbuc1_then_la1 
    cmp #$65
    bne __b2_from___b2
    jmp __b3
    // main::@3
  __b3:
    // [6] main::i#1 = ++ main::i#4 -- vbuxx=_inc_vbuxx 
    inx
    // [7] if(main::i#1!=$65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne __b1_from___b3
    // [8] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  __b4_from___b3:
    // [8] phi main::k#4 = 0 [phi:main::@3->main::@4#0] -- vbuyy=vbuc1 
    ldy #0
    jmp __b4
  // Then loop with clobbering A&X
    // [8] phi from main::@6 to main::@4 [phi:main::@6->main::@4]
  __b4_from___b6:
    // [8] phi main::k#4 = main::k#1 [phi:main::@6->main::@4#0] -- register_copy 
    jmp __b4
    // main::@4
  __b4:
    // [9] phi from main::@4 to main::@5 [phi:main::@4->main::@5]
  __b5_from___b4:
    // [9] phi main::l#2 = 0 [phi:main::@4->main::@5#0] -- vbuz1=vbuc1 
    lda #0
    sta.z l
    jmp __b5
    // [9] phi from main::@5 to main::@5 [phi:main::@5->main::@5]
  __b5_from___b5:
    // [9] phi main::l#2 = main::l#1 [phi:main::@5->main::@5#0] -- register_copy 
    jmp __b5
    // main::@5
  __b5:
    // asm { eor#$55 tax  }
    eor #$55
    tax
    // [11] SCREEN[main::k#4] = main::l#2 -- pbuc1_derefidx_vbuyy=vbuz1 
    lda.z l
    sta SCREEN,y
    // [12] main::l#1 = ++ main::l#2 -- vbuz1=_inc_vbuz1 
    inc.z l
    // [13] if(main::l#1!=$65) goto main::@5 -- vbuz1_neq_vbuc1_then_la1 
    lda #$65
    cmp.z l
    bne __b5_from___b5
    jmp __b6
    // main::@6
  __b6:
    // [14] main::k#1 = ++ main::k#4 -- vbuyy=_inc_vbuyy 
    iny
    // [15] if(main::k#1!=$65) goto main::@4 -- vbuyy_neq_vbuc1_then_la1 
    cpy #$65
    bne __b4_from___b6
    jmp __breturn
    // main::@return
  __breturn:
    // [16] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __b4
Removing instruction jmp __b5
Removing instruction jmp __b6
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b2_from___b2 with __b2
Replacing label __b1_from___b3 with __b1
Replacing label __b5_from___b5 with __b5
Replacing label __b4_from___b6 with __b4
Removing instruction __b1_from___b3:
Removing instruction __b2_from___b1:
Removing instruction __b2_from___b2:
Removing instruction __b4_from___b6:
Removing instruction __b5_from___b4:
Removing instruction __b5_from___b5:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __b3:
Removing instruction __b4_from___b3:
Removing instruction __b6:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b4
Removing instruction jmp __b5
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
__constant char *SCREEN = (char *) 1024
void main()
char main::i
char main::i#1 // reg byte x 16.5
char main::i#4 // reg byte x 24.599999999999998
char main::j
char main::j#1 // reg byte a 151.5
char main::j#2 // reg byte a 151.5
char main::k
char main::k#1 // reg byte y 16.5
char main::k#4 // reg byte y 20.499999999999996
char main::l
char main::l#1 // l zp[1]:2 151.5
char main::l#2 // l zp[1]:2 101.0

reg byte x [ main::i#4 main::i#1 ]
reg byte a [ main::j#2 main::j#1 ]
reg byte y [ main::k#4 main::k#1 ]
zp[1]:2 [ main::l#2 main::l#1 ]


FINAL ASSEMBLER
Score: 4676

  // File Comments
// Tests that inline ASM clobbering is taken into account when assigning registers
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-asm-clobber.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: {
    .label l = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi main::i#4 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
  // First loop with no clobber
    // [1] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [1] phi main::i#4 = main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    // main::@1
  __b1:
    // [2] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [2] phi main::j#2 = 0 [phi:main::@1->main::@2#0] -- vbuaa=vbuc1 
    lda #0
    // [2] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
    // [2] phi main::j#2 = main::j#1 [phi:main::@2->main::@2#0] -- register_copy 
    // main::@2
  __b2:
    // SCREEN[i] = j
    // [3] SCREEN[main::i#4] = main::j#2 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // for(byte j: 0..100)
    // [4] main::j#1 = ++ main::j#2 -- vbuaa=_inc_vbuaa 
    clc
    adc #1
    // [5] if(main::j#1!=$65) goto main::@2 -- vbuaa_neq_vbuc1_then_la1 
    cmp #$65
    bne __b2
    // main::@3
    // for(byte i : 0..100)
    // [6] main::i#1 = ++ main::i#4 -- vbuxx=_inc_vbuxx 
    inx
    // [7] if(main::i#1!=$65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne __b1
    // [8] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
    // [8] phi main::k#4 = 0 [phi:main::@3->main::@4#0] -- vbuyy=vbuc1 
    ldy #0
  // Then loop with clobbering A&X
    // [8] phi from main::@6 to main::@4 [phi:main::@6->main::@4]
    // [8] phi main::k#4 = main::k#1 [phi:main::@6->main::@4#0] -- register_copy 
    // main::@4
  __b4:
    // [9] phi from main::@4 to main::@5 [phi:main::@4->main::@5]
    // [9] phi main::l#2 = 0 [phi:main::@4->main::@5#0] -- vbuz1=vbuc1 
    lda #0
    sta.z l
    // [9] phi from main::@5 to main::@5 [phi:main::@5->main::@5]
    // [9] phi main::l#2 = main::l#1 [phi:main::@5->main::@5#0] -- register_copy 
    // main::@5
  __b5:
    // asm
    // asm { eor#$55 tax  }
    eor #$55
    tax
    // SCREEN[k] = l
    // [11] SCREEN[main::k#4] = main::l#2 -- pbuc1_derefidx_vbuyy=vbuz1 
    lda.z l
    sta SCREEN,y
    // for(byte l: 0..100)
    // [12] main::l#1 = ++ main::l#2 -- vbuz1=_inc_vbuz1 
    inc.z l
    // [13] if(main::l#1!=$65) goto main::@5 -- vbuz1_neq_vbuc1_then_la1 
    lda #$65
    cmp.z l
    bne __b5
    // main::@6
    // for(byte k : 0..100)
    // [14] main::k#1 = ++ main::k#4 -- vbuyy=_inc_vbuyy 
    iny
    // [15] if(main::k#1!=$65) goto main::@4 -- vbuyy_neq_vbuc1_then_la1 
    cpy #$65
    bne __b4
    // main::@return
    // }
    // [16] return 
    rts
}
  // File Data

