Loading link script "xmega65.ld"
Warning! Adding boolean cast to non-boolean condition *((byte*) strcpy::src)
Warning! Adding boolean cast to non-boolean condition *((byte*) strlen::str)
Warning! Adding boolean cast to non-boolean condition *((byte*) main::msg)
Culled Empty Block (label) @1
Culled Empty Block (label) @2
Culled Empty Block (label) memset::@7
Culled Empty Block (label) memset::@6
Culled Empty Block (label) memset::@8
Culled Empty Block (label) memset::@9
Culled Empty Block (label) memset::@3
Culled Empty Block (label) @3
Culled Empty Block (label) @4
Culled Empty Block (label) @5
Culled Empty Block (label) main::@4
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@12
Culled Empty Block (label) main::@9
Culled Empty Block (label) main::@13
Culled Empty Block (label) main::@11
Culled Empty Block (label) main::@15
Culled Empty Block (label) main::@16
Culled Empty Block (label) @6
Culled Empty Block (label) @7

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@8

(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
memset: scope:[memset]  from main main::@17
  (byte) memset::c#5 ← phi( main/(byte) memset::c#0 main::@17/(byte) memset::c#1 )
  (void*) memset::str#4 ← phi( main/(void*) memset::str#0 main::@17/(void*) memset::str#1 )
  (word) memset::num#2 ← phi( main/(word) memset::num#0 main::@17/(word) memset::num#1 )
  (bool~) memset::$0 ← (word) memset::num#2 > (number) 0
  (bool~) memset::$1 ← ! (bool~) memset::$0
  if((bool~) memset::$1) goto memset::@1
  to:memset::@2
memset::@1: scope:[memset]  from memset memset::@4
  (void*) memset::str#2 ← phi( memset/(void*) memset::str#4 memset::@4/(void*) memset::str#5 )
  (void*) memset::return#0 ← (void*) memset::str#2
  to:memset::@return
memset::@2: scope:[memset]  from memset
  (byte) memset::c#4 ← phi( memset/(byte) memset::c#5 )
  (word) memset::num#3 ← phi( memset/(word) memset::num#2 )
  (void*) memset::str#3 ← phi( memset/(void*) memset::str#4 )
  (byte*~) memset::$2 ← ((byte*)) (void*) memset::str#3
  (byte*~) memset::$3 ← (byte*~) memset::$2 + (word) memset::num#3
  (byte*) memset::end#0 ← (byte*~) memset::$3
  (byte*) memset::dst#0 ← ((byte*)) (void*) memset::str#3
  to:memset::@4
memset::@4: scope:[memset]  from memset::@2 memset::@5
  (byte) memset::c#3 ← phi( memset::@2/(byte) memset::c#4 memset::@5/(byte) memset::c#2 )
  (void*) memset::str#5 ← phi( memset::@2/(void*) memset::str#3 memset::@5/(void*) memset::str#6 )
  (byte*) memset::end#1 ← phi( memset::@2/(byte*) memset::end#0 memset::@5/(byte*) memset::end#2 )
  (byte*) memset::dst#2 ← phi( memset::@2/(byte*) memset::dst#0 memset::@5/(byte*) memset::dst#1 )
  (bool~) memset::$4 ← (byte*) memset::dst#2 != (byte*) memset::end#1
  if((bool~) memset::$4) goto memset::@5
  to:memset::@1
memset::@5: scope:[memset]  from memset::@4
  (void*) memset::str#6 ← phi( memset::@4/(void*) memset::str#5 )
  (byte*) memset::end#2 ← phi( memset::@4/(byte*) memset::end#1 )
  (byte*) memset::dst#3 ← phi( memset::@4/(byte*) memset::dst#2 )
  (byte) memset::c#2 ← phi( memset::@4/(byte) memset::c#3 )
  *((byte*) memset::dst#3) ← (byte) memset::c#2
  (byte*) memset::dst#1 ← ++ (byte*) memset::dst#3
  to:memset::@4
memset::@return: scope:[memset]  from memset::@1
  (void*) memset::return#4 ← phi( memset::@1/(void*) memset::return#0 )
  (void*) memset::return#1 ← (void*) memset::return#4
  return 
  to:@return

(void()) main()
main: scope:[main]  from @8
  *((const byte*) VIC_MEMORY) ← (number) $14
  (void*) memset::str#0 ← (void*)(const byte*) SCREEN
  (byte) memset::c#0 ← (byte) ' '
  (word) memset::num#0 ← (number) $28*(number) $19
  call memset 
  (void*) memset::return#2 ← (void*) memset::return#1
  to:main::@17
main::@17: scope:[main]  from main
  (void*) memset::str#1 ← (void*)(const byte*) COLS
  (byte) memset::c#1 ← (const byte) WHITE
  (word) memset::num#1 ← (number) $28*(number) $19
  call memset 
  (void*) memset::return#3 ← (void*) memset::return#1
  to:main::@18
main::@18: scope:[main]  from main::@17
  (byte*) main::sc#0 ← (const byte*) SCREEN+(number) $28
  (byte*) main::msg#0 ← (const byte*) MESSAGE
  to:main::@1
main::@1: scope:[main]  from main::@18 main::@2
  (byte*) main::sc#3 ← phi( main::@18/(byte*) main::sc#0 main::@2/(byte*) main::sc#1 )
  (byte*) main::msg#2 ← phi( main::@18/(byte*) main::msg#0 main::@2/(byte*) main::msg#1 )
  (bool~) main::$5 ← (number) 0 != *((byte*) main::msg#2)
  if((bool~) main::$5) goto main::@2
  to:main::@7
main::@2: scope:[main]  from main::@1
  (byte*) main::sc#2 ← phi( main::@1/(byte*) main::sc#3 )
  (byte*) main::msg#3 ← phi( main::@1/(byte*) main::msg#2 )
  *((byte*) main::sc#2) ← *((byte*) main::msg#3)
  (byte*) main::sc#1 ← ++ (byte*) main::sc#2
  (byte*) main::msg#1 ← ++ (byte*) main::msg#3
  to:main::@1
main::@7: scope:[main]  from main::@1 main::@10 main::@14
  if(true) goto main::@8
  to:main::@return
main::@8: scope:[main]  from main::@7
  (bool~) main::$2 ← *((const byte*) RASTER) == (number) $36
  (bool~) main::$3 ← *((const byte*) RASTER) == (number) $42
  (bool~) main::$4 ← (bool~) main::$2 || (bool~) main::$3
  if((bool~) main::$4) goto main::@10
  to:main::@14
main::@10: scope:[main]  from main::@8
  *((const byte*) BGCOL) ← (const byte) WHITE
  to:main::@7
main::@14: scope:[main]  from main::@8
  *((const byte*) BGCOL) ← (const byte) BLACK
  to:main::@7
main::@return: scope:[main]  from main::@7
  return 
  to:@return

(void()) syscall1()
syscall1: scope:[syscall1]  from
  *((const byte*) SCREEN+(number) $4f) ← (byte) '>'
  to:syscall1::@return
syscall1::@return: scope:[syscall1]  from syscall1
  return 
  to:@return

(void()) syscall2()
syscall2: scope:[syscall2]  from
  *((const byte*) SCREEN+(number) $4e) ← (byte) '<'
  to:syscall2::@return
syscall2::@return: scope:[syscall2]  from syscall2
  return 
  to:@return
@8: scope:[]  from @begin
  call main 
  to:@9
@9: scope:[]  from @8
  to:@end
@end: scope:[]  from @9

SYMBOL TABLE SSA
(label) @8
(label) @9
(label) @begin
(label) @end
(const byte*) BGCOL = (byte*)(number) $d021
(const byte) BLACK = (byte) 0
(const byte*) COLS = (byte*)(number) $d800
(const byte) JMP = (byte) $4c
(const byte*) MESSAGE[]  = (string) "hello world!"
(const byte) NOP = (byte) $ea
(const byte*) RASTER = (byte*)(number) $d012
(const byte*) SCREEN = (byte*)(number) $400
(const struct SysCall*) SYSCALLS[]  = { { xjmp: (const byte) JMP, syscall: &(void()) syscall1(), xnop: (const byte) NOP }, { xjmp: (const byte) JMP, syscall: &(void()) syscall2(), xnop: (const byte) NOP } }
(const struct SysCall*) SYSCALL_RESET[]  = { { xjmp: (const byte) JMP, syscall: &(void()) main(), xnop: (const byte) NOP } }
(void()*) SysCall::syscall
(byte) SysCall::xjmp
(byte) SysCall::xnop
(const byte*) VIC_MEMORY = (byte*)(number) $d018
(const byte) WHITE = (byte) 1
(void()) main()
(bool~) main::$2
(bool~) main::$3
(bool~) main::$4
(bool~) main::$5
(label) main::@1
(label) main::@10
(label) main::@14
(label) main::@17
(label) main::@18
(label) main::@2
(label) main::@7
(label) main::@8
(label) main::@return
(byte*) main::msg
(byte*) main::msg#0
(byte*) main::msg#1
(byte*) main::msg#2
(byte*) main::msg#3
(byte*) main::sc
(byte*) main::sc#0
(byte*) main::sc#1
(byte*) main::sc#2
(byte*) main::sc#3
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
(bool~) memset::$0
(bool~) memset::$1
(byte*~) memset::$2
(byte*~) memset::$3
(bool~) memset::$4
(label) memset::@1
(label) memset::@2
(label) memset::@4
(label) memset::@5
(label) memset::@return
(byte) memset::c
(byte) memset::c#0
(byte) memset::c#1
(byte) memset::c#2
(byte) memset::c#3
(byte) memset::c#4
(byte) memset::c#5
(byte*) memset::dst
(byte*) memset::dst#0
(byte*) memset::dst#1
(byte*) memset::dst#2
(byte*) memset::dst#3
(byte*) memset::end
(byte*) memset::end#0
(byte*) memset::end#1
(byte*) memset::end#2
(word) memset::num
(word) memset::num#0
(word) memset::num#1
(word) memset::num#2
(word) memset::num#3
(void*) memset::return
(void*) memset::return#0
(void*) memset::return#1
(void*) memset::return#2
(void*) memset::return#3
(void*) memset::return#4
(void*) memset::str
(void*) memset::str#0
(void*) memset::str#1
(void*) memset::str#2
(void*) memset::str#3
(void*) memset::str#4
(void*) memset::str#5
(void*) memset::str#6
(void()) syscall1()
(label) syscall1::@return
(void()) syscall2()
(label) syscall2::@return

Adding number conversion cast (unumber) 0 in (bool~) memset::$0 ← (word) memset::num#2 > (number) 0
Adding number conversion cast (unumber) $14 in *((const byte*) VIC_MEMORY) ← (number) $14
Adding number conversion cast (unumber) $28*$19 in (word) memset::num#0 ← (number) $28*(number) $19
Adding number conversion cast (unumber) $28*$19 in (word) memset::num#1 ← (number) $28*(number) $19
Adding number conversion cast (unumber) $28 in (byte*) main::sc#0 ← (const byte*) SCREEN+(number) $28
Adding number conversion cast (unumber) 0 in (bool~) main::$5 ← (number) 0 != *((byte*) main::msg#2)
Adding number conversion cast (unumber) $36 in (bool~) main::$2 ← *((const byte*) RASTER) == (number) $36
Adding number conversion cast (unumber) $42 in (bool~) main::$3 ← *((const byte*) RASTER) == (number) $42
Adding number conversion cast (unumber) $4f in *((const byte*) SCREEN+(number) $4f) ← (byte) '>'
Adding number conversion cast (unumber) $4e in *((const byte*) SCREEN+(number) $4e) ← (byte) '<'
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*~) memset::$2 ← (byte*)(void*) memset::str#3
Inlining cast (byte*) memset::dst#0 ← (byte*)(void*) memset::str#3
Inlining cast *((const byte*) VIC_MEMORY) ← (unumber)(number) $14
Inlining cast (word) memset::num#0 ← (unumber)(number) $28*(number) $19
Inlining cast (word) memset::num#1 ← (unumber)(number) $28*(number) $19
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53266
Simplifying constant pointer cast (byte*) 53272
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (byte*) 53281
Simplifying constant pointer cast (byte*) 55296
Simplifying constant integer cast 0
Simplifying constant integer cast $14
Simplifying constant integer cast $28
Simplifying constant integer cast 0
Simplifying constant integer cast $36
Simplifying constant integer cast $42
Simplifying constant integer cast $4f
Simplifying constant integer cast $4e
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $14
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $36
Finalized unsigned number type (byte) $42
Finalized unsigned number type (byte) $4f
Finalized unsigned number type (byte) $4e
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [2] (bool~) memset::$1 ← (word) memset::num#2 <= (byte) 0 from [1] (bool~) memset::$0 ← (word) memset::num#2 > (byte) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias (void*) memset::return#0 = (void*) memset::str#2 (void*) memset::return#4 (void*) memset::return#1 
Alias (void*) memset::str#3 = (void*) memset::str#4 
Alias (word) memset::num#2 = (word) memset::num#3 
Alias (byte) memset::c#4 = (byte) memset::c#5 
Alias (byte*) memset::end#0 = (byte*~) memset::$3 
Alias (byte) memset::c#2 = (byte) memset::c#3 
Alias (byte*) memset::dst#2 = (byte*) memset::dst#3 
Alias (byte*) memset::end#1 = (byte*) memset::end#2 
Alias (void*) memset::str#5 = (void*) memset::str#6 
Alias (byte*) main::msg#2 = (byte*) main::msg#3 
Alias (byte*) main::sc#2 = (byte*) main::sc#3 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte*) memset::end#1 (byte*) memset::end#0
Identical Phi Values (void*) memset::str#5 (void*) memset::str#3
Identical Phi Values (byte) memset::c#2 (byte) memset::c#4
Successful SSA optimization Pass2IdenticalPhiElimination
Identical Phi Values (void*) memset::return#0 (void*) memset::str#3
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) memset::$1 [3] if((word) memset::num#2<=(byte) 0) goto memset::@1
Simple Condition (bool~) memset::$4 [13] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@5
Simple Condition (bool~) main::$5 [35] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Rewriting || if()-condition to two if()s [43] (bool~) main::$4 ← (bool~) main::$2 || (bool~) main::$3
Successful SSA optimization Pass2ConditionalAndOrRewriting
Constant right-side identified [23] (word) memset::num#0 ← (unumber)(number) $28*(number) $19
Constant right-side identified [28] (word) memset::num#1 ← (unumber)(number) $28*(number) $19
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const void*) memset::str#0 = (void*)SCREEN
Constant (const byte) memset::c#0 = ' '
Constant (const word) memset::num#0 = (unumber)$28*$19
Constant (const void*) memset::str#1 = (void*)COLS
Constant (const byte) memset::c#1 = WHITE
Constant (const word) memset::num#1 = (unumber)$28*$19
Constant (const byte*) main::sc#0 = SCREEN+$28
Constant (const byte*) main::msg#0 = MESSAGE
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [40] if(true) goto main::@8
Successful SSA optimization Pass2ConstantIfs
Eliminating unused variable (void*) memset::return#2 and assignment [12] (void*) memset::return#2 ← (void*) memset::str#3
Eliminating unused variable (void*) memset::return#3 and assignment [14] (void*) memset::return#3 ← (void*) memset::str#3
Successful SSA optimization PassNEliminateUnusedVars
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Simple Condition (bool~) main::$2 [20] if(*((const byte*) RASTER)==(byte) $36) goto main::@10
Simple Condition (bool~) main::$3 [28] if(*((const byte*) RASTER)==(byte) $42) goto main::@10
Successful SSA optimization Pass2ConditionalJumpSimplification
Inlining Noop Cast [2] (byte*~) memset::$2 ← (byte*)(void*) memset::str#3 keeping memset::str#3
Inlining Noop Cast [4] (byte*) memset::dst#0 ← (byte*)(void*) memset::str#3 keeping memset::str#3
Successful SSA optimization Pass2NopCastInlining
Inlining constant with var siblings (const void*) memset::str#0
Inlining constant with var siblings (const byte) memset::c#0
Inlining constant with var siblings (const word) memset::num#0
Inlining constant with var siblings (const void*) memset::str#1
Inlining constant with var siblings (const byte) memset::c#1
Inlining constant with var siblings (const word) memset::num#1
Inlining constant with var siblings (const byte*) main::sc#0
Inlining constant with var siblings (const byte*) main::msg#0
Constant inlined memset::str#1 = (void*)(const byte*) COLS
Constant inlined memset::str#0 = (void*)(const byte*) SCREEN
Constant inlined main::msg#0 = (const byte*) MESSAGE
Constant inlined memset::num#1 = (word)(number) $28*(number) $19
Constant inlined main::sc#0 = (const byte*) SCREEN+(byte) $28
Constant inlined memset::c#0 = (byte) ' '
Constant inlined memset::num#0 = (word)(number) $28*(number) $19
Constant inlined memset::c#1 = (const byte) WHITE
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @8
Adding NOP phi() at start of @9
Adding NOP phi() at start of @end
Adding NOP phi() at start of main::@17
Adding NOP phi() at start of main::@18
Adding NOP phi() at start of main::@7
Adding NOP phi() at start of memset::@1
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to memset:6 memset:8 

Created 6 initial phi equivalence classes
Coalesced [20] main::msg#4 ← main::msg#1
Coalesced [21] main::sc#4 ← main::sc#1
Coalesced [32] memset::dst#5 ← memset::dst#1
Coalesced down to 6 phi equivalence classes
Culled Empty Block (label) @9
Culled Empty Block (label) main::@18
Culled Empty Block (label) main::@7
Culled Empty Block (label) memset::@1
Renumbering block @8 to @1
Renumbering block memset::@2 to memset::@1
Renumbering block memset::@4 to memset::@2
Renumbering block memset::@5 to memset::@3
Renumbering block main::@8 to main::@3
Renumbering block main::@10 to main::@4
Renumbering block main::@14 to main::@5
Renumbering block main::@17 to main::@6
Renumbering block main::@19 to main::@7
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main::@6

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()

(void()) main()
main: scope:[main]  from @1
  [4] *((const byte*) VIC_MEMORY) ← (byte) $14
  [5] call memset 
  to:main::@6
main::@6: scope:[main]  from main
  [6] phi()
  [7] call memset 
  to:main::@1
main::@1: scope:[main]  from main::@2 main::@6
  [8] (byte*) main::sc#2 ← phi( main::@6/(const byte*) SCREEN+(byte) $28 main::@2/(byte*) main::sc#1 )
  [8] (byte*) main::msg#2 ← phi( main::@6/(const byte*) MESSAGE main::@2/(byte*) main::msg#1 )
  [9] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@1 main::@4 main::@5
  [10] if(*((const byte*) RASTER)==(byte) $36) goto main::@4
  to:main::@7
main::@7: scope:[main]  from main::@3
  [11] if(*((const byte*) RASTER)==(byte) $42) goto main::@4
  to:main::@5
main::@5: scope:[main]  from main::@7
  [12] *((const byte*) BGCOL) ← (const byte) BLACK
  to:main::@3
main::@4: scope:[main]  from main::@3 main::@7
  [13] *((const byte*) BGCOL) ← (const byte) WHITE
  to:main::@3
main::@2: scope:[main]  from main::@1
  [14] *((byte*) main::sc#2) ← *((byte*) main::msg#2)
  [15] (byte*) main::sc#1 ← ++ (byte*) main::sc#2
  [16] (byte*) main::msg#1 ← ++ (byte*) main::msg#2
  to:main::@1

(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
memset: scope:[memset]  from main main::@6
  [17] (byte) memset::c#4 ← phi( main/(byte) ' ' main::@6/(const byte) WHITE )
  [17] (void*) memset::str#3 ← phi( main/(void*)(const byte*) SCREEN main::@6/(void*)(const byte*) COLS )
  [17] (word) memset::num#2 ← phi( main/(word)(number) $28*(number) $19 main::@6/(word)(number) $28*(number) $19 )
  [18] if((word) memset::num#2<=(byte) 0) goto memset::@return
  to:memset::@1
memset::@1: scope:[memset]  from memset
  [19] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2
  [20] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3
  to:memset::@2
memset::@2: scope:[memset]  from memset::@1 memset::@3
  [21] (byte*) memset::dst#2 ← phi( memset::@1/(byte*) memset::dst#4 memset::@3/(byte*) memset::dst#1 )
  [22] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3
  to:memset::@return
memset::@return: scope:[memset]  from memset memset::@2
  [23] return 
  to:@return
memset::@3: scope:[memset]  from memset::@2
  [24] *((byte*) memset::dst#2) ← (byte) memset::c#4
  [25] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2
  to:memset::@2

(void()) syscall2()
syscall2: scope:[syscall2]  from
  [26] *((const byte*) SCREEN+(byte) $4e) ← (byte) '<'
  to:syscall2::@return
syscall2::@return: scope:[syscall2]  from syscall2
  [27] return 
  to:@return

(void()) syscall1()
syscall1: scope:[syscall1]  from
  [28] *((const byte*) SCREEN+(byte) $4f) ← (byte) '>'
  to:syscall1::@return
syscall1::@return: scope:[syscall1]  from syscall1
  [29] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()*) SysCall::syscall
(byte) SysCall::xjmp
(byte) SysCall::xnop
(void()) main()
(byte*) main::msg
(byte*) main::msg#1 22.0
(byte*) main::msg#2 11.0
(byte*) main::sc
(byte*) main::sc#1 11.0
(byte*) main::sc#2 11.0
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
(byte) memset::c
(byte) memset::c#4 1.375
(byte*) memset::dst
(byte*) memset::dst#1 22.0
(byte*) memset::dst#2 15.333333333333332
(byte*) memset::dst#4 4.0
(byte*) memset::end
(byte*) memset::end#0 2.1666666666666665
(word) memset::num
(word) memset::num#2 2.0
(void*) memset::return
(void*) memset::str
(void*) memset::str#3
(void()) syscall1()
(void()) syscall2()

Initial phi equivalence classes
[ main::msg#2 main::msg#1 ]
[ main::sc#2 main::sc#1 ]
[ memset::num#2 ]
[ memset::str#3 ]
[ memset::c#4 ]
[ memset::dst#2 memset::dst#4 memset::dst#1 ]
Added variable memset::end#0 to live range equivalence class [ memset::end#0 ]
Complete equivalence classes
[ main::msg#2 main::msg#1 ]
[ main::sc#2 main::sc#1 ]
[ memset::num#2 ]
[ memset::str#3 ]
[ memset::c#4 ]
[ memset::dst#2 memset::dst#4 memset::dst#1 ]
[ memset::end#0 ]
Allocated zp[2]:2 [ main::msg#2 main::msg#1 ]
Allocated zp[2]:4 [ main::sc#2 main::sc#1 ]
Allocated zp[2]:6 [ memset::num#2 ]
Allocated zp[2]:8 [ memset::str#3 ]
Allocated zp[1]:10 [ memset::c#4 ]
Allocated zp[2]:11 [ memset::dst#2 memset::dst#4 memset::dst#1 ]
Allocated zp[2]:13 [ memset::end#0 ]

INITIAL ASM
Target platform is custom / MOS6502X
  // File Comments
// XMega65 Kernal Development Template
// Each function of the kernal is a no-args function
// The functions are placed in the SYSCALLS table surrounded by JMP and NOP
  // Upstart
  .file [name="xmega65.bin", type="bin", segments="XMega65Bin"]
.segmentdef XMega65Bin [segments="Syscall, Code, Data, Stack, Zeropage"]
.segmentdef Syscall [start=$8000, max=$81ff]
.segmentdef Code [start=$8200, min=$8200, max=$bdff]
.segmentdef Data [startAfter="Code", min=$8200, max=$bdff]
.segmentdef Stack [min=$be00, max=$beff, fill]
.segmentdef Zeropage [min=$bf00, max=$bfff, fill]
  // Global Constants & labels
  .label RASTER = $d012
  .label VIC_MEMORY = $d018
  .label SCREEN = $400
  .label BGCOL = $d021
  .label COLS = $d800
  .const BLACK = 0
  .const WHITE = 1
  .const JMP = $4c
  .const NOP = $ea
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
.segment Code
  // main
main: {
    // Print message
    .label sc = 4
    .label msg = 2
    // [4] *((const byte*) VIC_MEMORY) ← (byte) $14 -- _deref_pbuc1=vbuc2 
    // Initialize screen memory
    lda #$14
    sta VIC_MEMORY
    // [5] call memset 
    // [17] phi from main to memset [phi:main->memset]
  memset_from_main:
    // [17] phi (byte) memset::c#4 = (byte) ' ' [phi:main->memset#0] -- vbuz1=vbuc1 
    lda #' '
    sta.z memset.c
    // [17] phi (void*) memset::str#3 = (void*)(const byte*) SCREEN [phi:main->memset#1] -- pvoz1=pvoc1 
    lda #<SCREEN
    sta.z memset.str
    lda #>SCREEN
    sta.z memset.str+1
    // [17] phi (word) memset::num#2 = (word)(number) $28*(number) $19 [phi:main->memset#2] -- vwuz1=vwuc1 
    lda #<$28*$19
    sta.z memset.num
    lda #>$28*$19
    sta.z memset.num+1
    jsr memset
    // [6] phi from main to main::@6 [phi:main->main::@6]
  __b6_from_main:
    jmp __b6
    // main::@6
  __b6:
    // [7] call memset 
    // [17] phi from main::@6 to memset [phi:main::@6->memset]
  memset_from___b6:
    // [17] phi (byte) memset::c#4 = (const byte) WHITE [phi:main::@6->memset#0] -- vbuz1=vbuc1 
    lda #WHITE
    sta.z memset.c
    // [17] phi (void*) memset::str#3 = (void*)(const byte*) COLS [phi:main::@6->memset#1] -- pvoz1=pvoc1 
    lda #<COLS
    sta.z memset.str
    lda #>COLS
    sta.z memset.str+1
    // [17] phi (word) memset::num#2 = (word)(number) $28*(number) $19 [phi:main::@6->memset#2] -- vwuz1=vwuc1 
    lda #<$28*$19
    sta.z memset.num
    lda #>$28*$19
    sta.z memset.num+1
    jsr memset
    // [8] phi from main::@6 to main::@1 [phi:main::@6->main::@1]
  __b1_from___b6:
    // [8] phi (byte*) main::sc#2 = (const byte*) SCREEN+(byte) $28 [phi:main::@6->main::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN+$28
    sta.z sc
    lda #>SCREEN+$28
    sta.z sc+1
    // [8] phi (byte*) main::msg#2 = (const byte*) MESSAGE [phi:main::@6->main::@1#1] -- pbuz1=pbuc1 
    lda #<MESSAGE
    sta.z msg
    lda #>MESSAGE
    sta.z msg+1
    jmp __b1
    // main::@1
  __b1:
    // [9] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 -- vbuc1_neq__deref_pbuz1_then_la1 
    ldy #0
    lda (msg),y
    cmp #0
    bne __b2
    jmp __b3
    // main::@3
  __b3:
    // [10] if(*((const byte*) RASTER)==(byte) $36) goto main::@4 -- _deref_pbuc1_eq_vbuc2_then_la1 
    lda #$36
    cmp RASTER
    beq __b4
    jmp __b7
    // main::@7
  __b7:
    // [11] if(*((const byte*) RASTER)==(byte) $42) goto main::@4 -- _deref_pbuc1_eq_vbuc2_then_la1 
    lda #$42
    cmp RASTER
    beq __b4
    jmp __b5
    // main::@5
  __b5:
    // [12] *((const byte*) BGCOL) ← (const byte) BLACK -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BGCOL
    jmp __b3
    // main::@4
  __b4:
    // [13] *((const byte*) BGCOL) ← (const byte) WHITE -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BGCOL
    jmp __b3
    // main::@2
  __b2:
    // [14] *((byte*) main::sc#2) ← *((byte*) main::msg#2) -- _deref_pbuz1=_deref_pbuz2 
    ldy #0
    lda (msg),y
    ldy #0
    sta (sc),y
    // [15] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 
    inc.z sc
    bne !+
    inc.z sc+1
  !:
    // [16] (byte*) main::msg#1 ← ++ (byte*) main::msg#2 -- pbuz1=_inc_pbuz1 
    inc.z msg
    bne !+
    inc.z msg+1
  !:
    // [8] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [8] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@2->main::@1#0] -- register_copy 
    // [8] phi (byte*) main::msg#2 = (byte*) main::msg#1 [phi:main::@2->main::@1#1] -- register_copy 
    jmp __b1
}
  // memset
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// memset(void* zp(8) str, byte zp($a) c, word zp(6) num)
memset: {
    .label end = $d
    .label dst = $b
    .label num = 6
    .label str = 8
    .label c = $a
    // [18] if((word) memset::num#2<=(byte) 0) goto memset::@return -- vwuz1_le_0_then_la1 
    lda.z num
    bne !+
    lda.z num+1
    beq __breturn
  !:
    jmp __b1
    // memset::@1
  __b1:
    // [19] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2 -- pbuz1=pbuz2_plus_vwuz3 
    lda.z str
    clc
    adc.z num
    sta.z end
    lda.z str+1
    adc.z num+1
    sta.z end+1
    // [20] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3 -- pbuz1=pbuz2 
    lda.z str
    sta.z dst
    lda.z str+1
    sta.z dst+1
    // [21] phi from memset::@1 memset::@3 to memset::@2 [phi:memset::@1/memset::@3->memset::@2]
  __b2_from___b1:
  __b2_from___b3:
    // [21] phi (byte*) memset::dst#2 = (byte*) memset::dst#4 [phi:memset::@1/memset::@3->memset::@2#0] -- register_copy 
    jmp __b2
    // memset::@2
  __b2:
    // [22] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3 -- pbuz1_neq_pbuz2_then_la1 
    lda.z dst+1
    cmp.z end+1
    bne __b3
    lda.z dst
    cmp.z end
    bne __b3
    jmp __breturn
    // memset::@return
  __breturn:
    // [23] return 
    rts
    // memset::@3
  __b3:
    // [24] *((byte*) memset::dst#2) ← (byte) memset::c#4 -- _deref_pbuz1=vbuz2 
    lda.z c
    ldy #0
    sta (dst),y
    // [25] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2 -- pbuz1=_inc_pbuz1 
    inc.z dst
    bne !+
    inc.z dst+1
  !:
    jmp __b2_from___b3
}
  // syscall2
syscall2: {
    // [26] *((const byte*) SCREEN+(byte) $4e) ← (byte) '<' -- _deref_pbuc1=vbuc2 
    lda #'<'
    sta SCREEN+$4e
    jmp __breturn
    // syscall2::@return
  __breturn:
    // [27] return 
    rts
}
  // syscall1
syscall1: {
    // [28] *((const byte*) SCREEN+(byte) $4f) ← (byte) '>' -- _deref_pbuc1=vbuc2 
    lda #'>'
    sta SCREEN+$4f
    jmp __breturn
    // syscall1::@return
  __breturn:
    // [29] return 
    rts
}
  // File Data
.segment Data
  MESSAGE: .text "hello world!"
  .byte 0
.segment Syscall
  SYSCALLS: .byte JMP
  .word syscall1
  .byte NOP, JMP
  .word syscall2
  .byte NOP
  .align $100
  SYSCALL_RESET: .byte JMP
  .word main
  .byte NOP

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) VIC_MEMORY) ← (byte) $14 [ ] (  [ ] main:2 [ ] ) always clobbers reg byte a 
Statement [9] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 [ main::msg#2 main::sc#2 ] (  [ main::msg#2 main::sc#2 ] main:2 [ main::msg#2 main::sc#2 ] ) always clobbers reg byte a reg byte y 
Statement [10] if(*((const byte*) RASTER)==(byte) $36) goto main::@4 [ ] (  [ ] main:2 [ ] ) always clobbers reg byte a 
Statement [11] if(*((const byte*) RASTER)==(byte) $42) goto main::@4 [ ] (  [ ] main:2 [ ] ) always clobbers reg byte a 
Statement [12] *((const byte*) BGCOL) ← (const byte) BLACK [ ] (  [ ] main:2 [ ] ) always clobbers reg byte a 
Statement [13] *((const byte*) BGCOL) ← (const byte) WHITE [ ] (  [ ] main:2 [ ] ) always clobbers reg byte a 
Statement [14] *((byte*) main::sc#2) ← *((byte*) main::msg#2) [ main::msg#2 main::sc#2 ] (  [ main::msg#2 main::sc#2 ] main:2 [ main::msg#2 main::sc#2 ] ) always clobbers reg byte a reg byte y 
Statement [18] if((word) memset::num#2<=(byte) 0) goto memset::@return [ memset::num#2 memset::str#3 memset::c#4 ] ( memset:5 [ memset::num#2 memset::str#3 memset::c#4 ] main:2::memset:5 [ memset::num#2 memset::str#3 memset::c#4 ] memset:7 [ memset::num#2 memset::str#3 memset::c#4 ] main:2::memset:7 [ memset::num#2 memset::str#3 memset::c#4 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:10 [ memset::c#4 ]
Statement [19] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2 [ memset::str#3 memset::c#4 memset::end#0 ] ( memset:5 [ memset::str#3 memset::c#4 memset::end#0 ] main:2::memset:5 [ memset::str#3 memset::c#4 memset::end#0 ] memset:7 [ memset::str#3 memset::c#4 memset::end#0 ] main:2::memset:7 [ memset::str#3 memset::c#4 memset::end#0 ] ) always clobbers reg byte a 
Statement [20] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3 [ memset::c#4 memset::end#0 memset::dst#4 ] ( memset:5 [ memset::c#4 memset::end#0 memset::dst#4 ] main:2::memset:5 [ memset::c#4 memset::end#0 memset::dst#4 ] memset:7 [ memset::c#4 memset::end#0 memset::dst#4 ] main:2::memset:7 [ memset::c#4 memset::end#0 memset::dst#4 ] ) always clobbers reg byte a 
Statement [22] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3 [ memset::c#4 memset::end#0 memset::dst#2 ] ( memset:5 [ memset::c#4 memset::end#0 memset::dst#2 ] main:2::memset:5 [ memset::c#4 memset::end#0 memset::dst#2 ] memset:7 [ memset::c#4 memset::end#0 memset::dst#2 ] main:2::memset:7 [ memset::c#4 memset::end#0 memset::dst#2 ] ) always clobbers reg byte a 
Statement [24] *((byte*) memset::dst#2) ← (byte) memset::c#4 [ memset::c#4 memset::end#0 memset::dst#2 ] ( memset:5 [ memset::c#4 memset::end#0 memset::dst#2 ] main:2::memset:5 [ memset::c#4 memset::end#0 memset::dst#2 ] memset:7 [ memset::c#4 memset::end#0 memset::dst#2 ] main:2::memset:7 [ memset::c#4 memset::end#0 memset::dst#2 ] ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte y as potential for zp[1]:10 [ memset::c#4 ]
Statement [26] *((const byte*) SCREEN+(byte) $4e) ← (byte) '<' [ ] (  [ ] ) always clobbers reg byte a 
Statement [28] *((const byte*) SCREEN+(byte) $4f) ← (byte) '>' [ ] (  [ ] ) always clobbers reg byte a 
Statement [4] *((const byte*) VIC_MEMORY) ← (byte) $14 [ ] (  [ ] main:2 [ ] ) always clobbers reg byte a 
Statement [9] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 [ main::msg#2 main::sc#2 ] (  [ main::msg#2 main::sc#2 ] main:2 [ main::msg#2 main::sc#2 ] ) always clobbers reg byte a reg byte y 
Statement [10] if(*((const byte*) RASTER)==(byte) $36) goto main::@4 [ ] (  [ ] main:2 [ ] ) always clobbers reg byte a 
Statement [11] if(*((const byte*) RASTER)==(byte) $42) goto main::@4 [ ] (  [ ] main:2 [ ] ) always clobbers reg byte a 
Statement [12] *((const byte*) BGCOL) ← (const byte) BLACK [ ] (  [ ] main:2 [ ] ) always clobbers reg byte a 
Statement [13] *((const byte*) BGCOL) ← (const byte) WHITE [ ] (  [ ] main:2 [ ] ) always clobbers reg byte a 
Statement [14] *((byte*) main::sc#2) ← *((byte*) main::msg#2) [ main::msg#2 main::sc#2 ] (  [ main::msg#2 main::sc#2 ] main:2 [ main::msg#2 main::sc#2 ] ) always clobbers reg byte a reg byte y 
Statement [18] if((word) memset::num#2<=(byte) 0) goto memset::@return [ memset::num#2 memset::str#3 memset::c#4 ] ( memset:5 [ memset::num#2 memset::str#3 memset::c#4 ] main:2::memset:5 [ memset::num#2 memset::str#3 memset::c#4 ] memset:7 [ memset::num#2 memset::str#3 memset::c#4 ] main:2::memset:7 [ memset::num#2 memset::str#3 memset::c#4 ] ) always clobbers reg byte a 
Statement [19] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2 [ memset::str#3 memset::c#4 memset::end#0 ] ( memset:5 [ memset::str#3 memset::c#4 memset::end#0 ] main:2::memset:5 [ memset::str#3 memset::c#4 memset::end#0 ] memset:7 [ memset::str#3 memset::c#4 memset::end#0 ] main:2::memset:7 [ memset::str#3 memset::c#4 memset::end#0 ] ) always clobbers reg byte a 
Statement [20] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3 [ memset::c#4 memset::end#0 memset::dst#4 ] ( memset:5 [ memset::c#4 memset::end#0 memset::dst#4 ] main:2::memset:5 [ memset::c#4 memset::end#0 memset::dst#4 ] memset:7 [ memset::c#4 memset::end#0 memset::dst#4 ] main:2::memset:7 [ memset::c#4 memset::end#0 memset::dst#4 ] ) always clobbers reg byte a 
Statement [22] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3 [ memset::c#4 memset::end#0 memset::dst#2 ] ( memset:5 [ memset::c#4 memset::end#0 memset::dst#2 ] main:2::memset:5 [ memset::c#4 memset::end#0 memset::dst#2 ] memset:7 [ memset::c#4 memset::end#0 memset::dst#2 ] main:2::memset:7 [ memset::c#4 memset::end#0 memset::dst#2 ] ) always clobbers reg byte a 
Statement [24] *((byte*) memset::dst#2) ← (byte) memset::c#4 [ memset::c#4 memset::end#0 memset::dst#2 ] ( memset:5 [ memset::c#4 memset::end#0 memset::dst#2 ] main:2::memset:5 [ memset::c#4 memset::end#0 memset::dst#2 ] memset:7 [ memset::c#4 memset::end#0 memset::dst#2 ] main:2::memset:7 [ memset::c#4 memset::end#0 memset::dst#2 ] ) always clobbers reg byte a reg byte y 
Statement [26] *((const byte*) SCREEN+(byte) $4e) ← (byte) '<' [ ] (  [ ] ) always clobbers reg byte a 
Statement [28] *((const byte*) SCREEN+(byte) $4f) ← (byte) '>' [ ] (  [ ] ) always clobbers reg byte a 
Potential registers zp[2]:2 [ main::msg#2 main::msg#1 ] : zp[2]:2 , 
Potential registers zp[2]:4 [ main::sc#2 main::sc#1 ] : zp[2]:4 , 
Potential registers zp[2]:6 [ memset::num#2 ] : zp[2]:6 , 
Potential registers zp[2]:8 [ memset::str#3 ] : zp[2]:8 , 
Potential registers zp[1]:10 [ memset::c#4 ] : zp[1]:10 , reg byte x , 
Potential registers zp[2]:11 [ memset::dst#2 memset::dst#4 memset::dst#1 ] : zp[2]:11 , 
Potential registers zp[2]:13 [ memset::end#0 ] : zp[2]:13 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 33: zp[2]:2 [ main::msg#2 main::msg#1 ] 22: zp[2]:4 [ main::sc#2 main::sc#1 ] 
Uplift Scope [memset] 41.33: zp[2]:11 [ memset::dst#2 memset::dst#4 memset::dst#1 ] 2.17: zp[2]:13 [ memset::end#0 ] 2: zp[2]:6 [ memset::num#2 ] 1.38: zp[1]:10 [ memset::c#4 ] 0: zp[2]:8 [ memset::str#3 ] 
Uplift Scope [syscall1] 
Uplift Scope [syscall2] 
Uplift Scope [SysCall] 
Uplift Scope [] 

Uplifting [main] best 1885 combination zp[2]:2 [ main::msg#2 main::msg#1 ] zp[2]:4 [ main::sc#2 main::sc#1 ] 
Uplifting [memset] best 1869 combination zp[2]:11 [ memset::dst#2 memset::dst#4 memset::dst#1 ] zp[2]:13 [ memset::end#0 ] zp[2]:6 [ memset::num#2 ] reg byte x [ memset::c#4 ] zp[2]:8 [ memset::str#3 ] 
Uplifting [syscall1] best 1869 combination 
Uplifting [syscall2] best 1869 combination 
Uplifting [SysCall] best 1869 combination 
Uplifting [] best 1869 combination 
Coalescing zero page register [ zp[2]:6 [ memset::num#2 ] ] with [ zp[2]:13 [ memset::end#0 ] ] - score: 1
Coalescing zero page register [ zp[2]:8 [ memset::str#3 ] ] with [ zp[2]:11 [ memset::dst#2 memset::dst#4 memset::dst#1 ] ] - score: 1
Coalescing zero page register [ zp[2]:6 [ memset::num#2 memset::end#0 ] ] with [ zp[2]:2 [ main::msg#2 main::msg#1 ] ]
Coalescing zero page register [ zp[2]:8 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ] ] with [ zp[2]:4 [ main::sc#2 main::sc#1 ] ]
Allocated (was zp[2]:6) zp[2]:2 [ memset::num#2 memset::end#0 main::msg#2 main::msg#1 ]
Allocated (was zp[2]:8) zp[2]:4 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 main::sc#2 main::sc#1 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// XMega65 Kernal Development Template
// Each function of the kernal is a no-args function
// The functions are placed in the SYSCALLS table surrounded by JMP and NOP
  // Upstart
  .file [name="xmega65.bin", type="bin", segments="XMega65Bin"]
.segmentdef XMega65Bin [segments="Syscall, Code, Data, Stack, Zeropage"]
.segmentdef Syscall [start=$8000, max=$81ff]
.segmentdef Code [start=$8200, min=$8200, max=$bdff]
.segmentdef Data [startAfter="Code", min=$8200, max=$bdff]
.segmentdef Stack [min=$be00, max=$beff, fill]
.segmentdef Zeropage [min=$bf00, max=$bfff, fill]
  // Global Constants & labels
  .label RASTER = $d012
  .label VIC_MEMORY = $d018
  .label SCREEN = $400
  .label BGCOL = $d021
  .label COLS = $d800
  .const BLACK = 0
  .const WHITE = 1
  .const JMP = $4c
  .const NOP = $ea
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
.segment Code
  // main
main: {
    // Print message
    .label sc = 4
    .label msg = 2
    // [4] *((const byte*) VIC_MEMORY) ← (byte) $14 -- _deref_pbuc1=vbuc2 
    // Initialize screen memory
    lda #$14
    sta VIC_MEMORY
    // [5] call memset 
    // [17] phi from main to memset [phi:main->memset]
  memset_from_main:
    // [17] phi (byte) memset::c#4 = (byte) ' ' [phi:main->memset#0] -- vbuxx=vbuc1 
    ldx #' '
    // [17] phi (void*) memset::str#3 = (void*)(const byte*) SCREEN [phi:main->memset#1] -- pvoz1=pvoc1 
    lda #<SCREEN
    sta.z memset.str
    lda #>SCREEN
    sta.z memset.str+1
    // [17] phi (word) memset::num#2 = (word)(number) $28*(number) $19 [phi:main->memset#2] -- vwuz1=vwuc1 
    lda #<$28*$19
    sta.z memset.num
    lda #>$28*$19
    sta.z memset.num+1
    jsr memset
    // [6] phi from main to main::@6 [phi:main->main::@6]
  __b6_from_main:
    jmp __b6
    // main::@6
  __b6:
    // [7] call memset 
    // [17] phi from main::@6 to memset [phi:main::@6->memset]
  memset_from___b6:
    // [17] phi (byte) memset::c#4 = (const byte) WHITE [phi:main::@6->memset#0] -- vbuxx=vbuc1 
    ldx #WHITE
    // [17] phi (void*) memset::str#3 = (void*)(const byte*) COLS [phi:main::@6->memset#1] -- pvoz1=pvoc1 
    lda #<COLS
    sta.z memset.str
    lda #>COLS
    sta.z memset.str+1
    // [17] phi (word) memset::num#2 = (word)(number) $28*(number) $19 [phi:main::@6->memset#2] -- vwuz1=vwuc1 
    lda #<$28*$19
    sta.z memset.num
    lda #>$28*$19
    sta.z memset.num+1
    jsr memset
    // [8] phi from main::@6 to main::@1 [phi:main::@6->main::@1]
  __b1_from___b6:
    // [8] phi (byte*) main::sc#2 = (const byte*) SCREEN+(byte) $28 [phi:main::@6->main::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN+$28
    sta.z sc
    lda #>SCREEN+$28
    sta.z sc+1
    // [8] phi (byte*) main::msg#2 = (const byte*) MESSAGE [phi:main::@6->main::@1#1] -- pbuz1=pbuc1 
    lda #<MESSAGE
    sta.z msg
    lda #>MESSAGE
    sta.z msg+1
    jmp __b1
    // main::@1
  __b1:
    // [9] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 -- vbuc1_neq__deref_pbuz1_then_la1 
    ldy #0
    lda (msg),y
    cmp #0
    bne __b2
    jmp __b3
    // main::@3
  __b3:
    // [10] if(*((const byte*) RASTER)==(byte) $36) goto main::@4 -- _deref_pbuc1_eq_vbuc2_then_la1 
    lda #$36
    cmp RASTER
    beq __b4
    jmp __b7
    // main::@7
  __b7:
    // [11] if(*((const byte*) RASTER)==(byte) $42) goto main::@4 -- _deref_pbuc1_eq_vbuc2_then_la1 
    lda #$42
    cmp RASTER
    beq __b4
    jmp __b5
    // main::@5
  __b5:
    // [12] *((const byte*) BGCOL) ← (const byte) BLACK -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BGCOL
    jmp __b3
    // main::@4
  __b4:
    // [13] *((const byte*) BGCOL) ← (const byte) WHITE -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BGCOL
    jmp __b3
    // main::@2
  __b2:
    // [14] *((byte*) main::sc#2) ← *((byte*) main::msg#2) -- _deref_pbuz1=_deref_pbuz2 
    ldy #0
    lda (msg),y
    ldy #0
    sta (sc),y
    // [15] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 
    inc.z sc
    bne !+
    inc.z sc+1
  !:
    // [16] (byte*) main::msg#1 ← ++ (byte*) main::msg#2 -- pbuz1=_inc_pbuz1 
    inc.z msg
    bne !+
    inc.z msg+1
  !:
    // [8] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [8] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@2->main::@1#0] -- register_copy 
    // [8] phi (byte*) main::msg#2 = (byte*) main::msg#1 [phi:main::@2->main::@1#1] -- register_copy 
    jmp __b1
}
  // memset
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// memset(void* zp(4) str, byte register(X) c, word zp(2) num)
memset: {
    .label end = 2
    .label dst = 4
    .label num = 2
    .label str = 4
    // [18] if((word) memset::num#2<=(byte) 0) goto memset::@return -- vwuz1_le_0_then_la1 
    lda.z num
    bne !+
    lda.z num+1
    beq __breturn
  !:
    jmp __b1
    // memset::@1
  __b1:
    // [19] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2 -- pbuz1=pbuz2_plus_vwuz1 
    lda.z end
    clc
    adc.z str
    sta.z end
    lda.z end+1
    adc.z str+1
    sta.z end+1
    // [20] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3
    // [21] phi from memset::@1 memset::@3 to memset::@2 [phi:memset::@1/memset::@3->memset::@2]
  __b2_from___b1:
  __b2_from___b3:
    // [21] phi (byte*) memset::dst#2 = (byte*) memset::dst#4 [phi:memset::@1/memset::@3->memset::@2#0] -- register_copy 
    jmp __b2
    // memset::@2
  __b2:
    // [22] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3 -- pbuz1_neq_pbuz2_then_la1 
    lda.z dst+1
    cmp.z end+1
    bne __b3
    lda.z dst
    cmp.z end
    bne __b3
    jmp __breturn
    // memset::@return
  __breturn:
    // [23] return 
    rts
    // memset::@3
  __b3:
    // [24] *((byte*) memset::dst#2) ← (byte) memset::c#4 -- _deref_pbuz1=vbuxx 
    txa
    ldy #0
    sta (dst),y
    // [25] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2 -- pbuz1=_inc_pbuz1 
    inc.z dst
    bne !+
    inc.z dst+1
  !:
    jmp __b2_from___b3
}
  // syscall2
syscall2: {
    // [26] *((const byte*) SCREEN+(byte) $4e) ← (byte) '<' -- _deref_pbuc1=vbuc2 
    lda #'<'
    sta SCREEN+$4e
    jmp __breturn
    // syscall2::@return
  __breturn:
    // [27] return 
    rts
}
  // syscall1
syscall1: {
    // [28] *((const byte*) SCREEN+(byte) $4f) ← (byte) '>' -- _deref_pbuc1=vbuc2 
    lda #'>'
    sta SCREEN+$4f
    jmp __breturn
    // syscall1::@return
  __breturn:
    // [29] return 
    rts
}
  // File Data
.segment Data
  MESSAGE: .text "hello world!"
  .byte 0
.segment Syscall
  SYSCALLS: .byte JMP
  .word syscall1
  .byte NOP, JMP
  .word syscall2
  .byte NOP
  .align $100
  SYSCALL_RESET: .byte JMP
  .word main
  .byte NOP

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b6
Removing instruction jmp __b1
Removing instruction jmp __b3
Removing instruction jmp __b7
Removing instruction jmp __b5
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction ldy #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label __b2_from___b3 with __b2
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction __bend_from___b1:
Removing instruction __b6_from_main:
Removing instruction memset_from___b6:
Removing instruction __b2_from___b1:
Removing instruction __b2_from___b3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1:
Removing instruction __bend:
Removing instruction memset_from_main:
Removing instruction __b6:
Removing instruction __b1_from___b6:
Removing instruction __b7:
Removing instruction __b5:
Removing instruction __b1_from___b2:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) BGCOL = (byte*) 53281
(const byte) BLACK = (byte) 0
(const byte*) COLS = (byte*) 55296
(const byte) JMP = (byte) $4c
(const byte*) MESSAGE[]  = (string) "hello world!"
(const byte) NOP = (byte) $ea
(const byte*) RASTER = (byte*) 53266
(const byte*) SCREEN = (byte*) 1024
(const struct SysCall*) SYSCALLS[]  = { { xjmp: (const byte) JMP, syscall: &(void()) syscall1(), xnop: (const byte) NOP }, { xjmp: (const byte) JMP, syscall: &(void()) syscall2(), xnop: (const byte) NOP } }
(const struct SysCall*) SYSCALL_RESET[]  = { { xjmp: (const byte) JMP, syscall: &(void()) main(), xnop: (const byte) NOP } }
(void()*) SysCall::syscall
(byte) SysCall::xjmp
(byte) SysCall::xnop
(const byte*) VIC_MEMORY = (byte*) 53272
(const byte) WHITE = (byte) 1
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@7
(byte*) main::msg
(byte*) main::msg#1 msg zp[2]:2 22.0
(byte*) main::msg#2 msg zp[2]:2 11.0
(byte*) main::sc
(byte*) main::sc#1 sc zp[2]:4 11.0
(byte*) main::sc#2 sc zp[2]:4 11.0
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
(label) memset::@1
(label) memset::@2
(label) memset::@3
(label) memset::@return
(byte) memset::c
(byte) memset::c#4 reg byte x 1.375
(byte*) memset::dst
(byte*) memset::dst#1 dst zp[2]:4 22.0
(byte*) memset::dst#2 dst zp[2]:4 15.333333333333332
(byte*) memset::dst#4 dst zp[2]:4 4.0
(byte*) memset::end
(byte*) memset::end#0 end zp[2]:2 2.1666666666666665
(word) memset::num
(word) memset::num#2 num zp[2]:2 2.0
(void*) memset::return
(void*) memset::str
(void*) memset::str#3 str zp[2]:4
(void()) syscall1()
(label) syscall1::@return
(void()) syscall2()
(label) syscall2::@return

zp[2]:2 [ memset::num#2 memset::end#0 main::msg#2 main::msg#1 ]
zp[2]:4 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 main::sc#2 main::sc#1 ]
reg byte x [ memset::c#4 ]


FINAL ASSEMBLER
Score: 1633

  // File Comments
// XMega65 Kernal Development Template
// Each function of the kernal is a no-args function
// The functions are placed in the SYSCALLS table surrounded by JMP and NOP
  // Upstart
  .file [name="xmega65.bin", type="bin", segments="XMega65Bin"]
.segmentdef XMega65Bin [segments="Syscall, Code, Data, Stack, Zeropage"]
.segmentdef Syscall [start=$8000, max=$81ff]
.segmentdef Code [start=$8200, min=$8200, max=$bdff]
.segmentdef Data [startAfter="Code", min=$8200, max=$bdff]
.segmentdef Stack [min=$be00, max=$beff, fill]
.segmentdef Zeropage [min=$bf00, max=$bfff, fill]
  // Global Constants & labels
  .label RASTER = $d012
  .label VIC_MEMORY = $d018
  .label SCREEN = $400
  .label BGCOL = $d021
  .label COLS = $d800
  .const BLACK = 0
  .const WHITE = 1
  .const JMP = $4c
  .const NOP = $ea
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
.segment Code
  // main
main: {
    // Print message
    .label sc = 4
    .label msg = 2
    // *VIC_MEMORY = 0x14
    // [4] *((const byte*) VIC_MEMORY) ← (byte) $14 -- _deref_pbuc1=vbuc2 
    // Initialize screen memory
    lda #$14
    sta VIC_MEMORY
    // memset(SCREEN, ' ', 40*25)
    // [5] call memset 
    // [17] phi from main to memset [phi:main->memset]
    // [17] phi (byte) memset::c#4 = (byte) ' ' [phi:main->memset#0] -- vbuxx=vbuc1 
    ldx #' '
    // [17] phi (void*) memset::str#3 = (void*)(const byte*) SCREEN [phi:main->memset#1] -- pvoz1=pvoc1 
    lda #<SCREEN
    sta.z memset.str
    lda #>SCREEN
    sta.z memset.str+1
    // [17] phi (word) memset::num#2 = (word)(number) $28*(number) $19 [phi:main->memset#2] -- vwuz1=vwuc1 
    lda #<$28*$19
    sta.z memset.num
    lda #>$28*$19
    sta.z memset.num+1
    jsr memset
    // [6] phi from main to main::@6 [phi:main->main::@6]
    // main::@6
    // memset(COLS, WHITE, 40*25)
    // [7] call memset 
    // [17] phi from main::@6 to memset [phi:main::@6->memset]
    // [17] phi (byte) memset::c#4 = (const byte) WHITE [phi:main::@6->memset#0] -- vbuxx=vbuc1 
    ldx #WHITE
    // [17] phi (void*) memset::str#3 = (void*)(const byte*) COLS [phi:main::@6->memset#1] -- pvoz1=pvoc1 
    lda #<COLS
    sta.z memset.str
    lda #>COLS
    sta.z memset.str+1
    // [17] phi (word) memset::num#2 = (word)(number) $28*(number) $19 [phi:main::@6->memset#2] -- vwuz1=vwuc1 
    lda #<$28*$19
    sta.z memset.num
    lda #>$28*$19
    sta.z memset.num+1
    jsr memset
    // [8] phi from main::@6 to main::@1 [phi:main::@6->main::@1]
    // [8] phi (byte*) main::sc#2 = (const byte*) SCREEN+(byte) $28 [phi:main::@6->main::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN+$28
    sta.z sc
    lda #>SCREEN+$28
    sta.z sc+1
    // [8] phi (byte*) main::msg#2 = (const byte*) MESSAGE [phi:main::@6->main::@1#1] -- pbuz1=pbuc1 
    lda #<MESSAGE
    sta.z msg
    lda #>MESSAGE
    sta.z msg+1
    // main::@1
  __b1:
    // while(*msg)
    // [9] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 -- vbuc1_neq__deref_pbuz1_then_la1 
    ldy #0
    lda (msg),y
    cmp #0
    bne __b2
    // main::@3
  __b3:
    // if(*RASTER==54 || *RASTER==66)
    // [10] if(*((const byte*) RASTER)==(byte) $36) goto main::@4 -- _deref_pbuc1_eq_vbuc2_then_la1 
    lda #$36
    cmp RASTER
    beq __b4
    // main::@7
    // [11] if(*((const byte*) RASTER)==(byte) $42) goto main::@4 -- _deref_pbuc1_eq_vbuc2_then_la1 
    lda #$42
    cmp RASTER
    beq __b4
    // main::@5
    // *BGCOL = BLACK
    // [12] *((const byte*) BGCOL) ← (const byte) BLACK -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BGCOL
    jmp __b3
    // main::@4
  __b4:
    // *BGCOL = WHITE
    // [13] *((const byte*) BGCOL) ← (const byte) WHITE -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BGCOL
    jmp __b3
    // main::@2
  __b2:
    // *sc++ = *msg++
    // [14] *((byte*) main::sc#2) ← *((byte*) main::msg#2) -- _deref_pbuz1=_deref_pbuz2 
    ldy #0
    lda (msg),y
    sta (sc),y
    // *sc++ = *msg++;
    // [15] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 
    inc.z sc
    bne !+
    inc.z sc+1
  !:
    // [16] (byte*) main::msg#1 ← ++ (byte*) main::msg#2 -- pbuz1=_inc_pbuz1 
    inc.z msg
    bne !+
    inc.z msg+1
  !:
    // [8] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
    // [8] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@2->main::@1#0] -- register_copy 
    // [8] phi (byte*) main::msg#2 = (byte*) main::msg#1 [phi:main::@2->main::@1#1] -- register_copy 
    jmp __b1
}
  // memset
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// memset(void* zp(4) str, byte register(X) c, word zp(2) num)
memset: {
    .label end = 2
    .label dst = 4
    .label num = 2
    .label str = 4
    // if(num>0)
    // [18] if((word) memset::num#2<=(byte) 0) goto memset::@return -- vwuz1_le_0_then_la1 
    lda.z num
    bne !+
    lda.z num+1
    beq __breturn
  !:
    // memset::@1
    // end = (char*)str + num
    // [19] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2 -- pbuz1=pbuz2_plus_vwuz1 
    lda.z end
    clc
    adc.z str
    sta.z end
    lda.z end+1
    adc.z str+1
    sta.z end+1
    // [20] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3
    // [21] phi from memset::@1 memset::@3 to memset::@2 [phi:memset::@1/memset::@3->memset::@2]
    // [21] phi (byte*) memset::dst#2 = (byte*) memset::dst#4 [phi:memset::@1/memset::@3->memset::@2#0] -- register_copy 
    // memset::@2
  __b2:
    // for(char* dst = str; dst!=end; dst++)
    // [22] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3 -- pbuz1_neq_pbuz2_then_la1 
    lda.z dst+1
    cmp.z end+1
    bne __b3
    lda.z dst
    cmp.z end
    bne __b3
    // memset::@return
  __breturn:
    // }
    // [23] return 
    rts
    // memset::@3
  __b3:
    // *dst = c
    // [24] *((byte*) memset::dst#2) ← (byte) memset::c#4 -- _deref_pbuz1=vbuxx 
    txa
    ldy #0
    sta (dst),y
    // for(char* dst = str; dst!=end; dst++)
    // [25] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2 -- pbuz1=_inc_pbuz1 
    inc.z dst
    bne !+
    inc.z dst+1
  !:
    jmp __b2
}
  // syscall2
syscall2: {
    // *(SCREEN+78) = '<'
    // [26] *((const byte*) SCREEN+(byte) $4e) ← (byte) '<' -- _deref_pbuc1=vbuc2 
    lda #'<'
    sta SCREEN+$4e
    // syscall2::@return
    // }
    // [27] return 
    rts
}
  // syscall1
syscall1: {
    // *(SCREEN+79) = '>'
    // [28] *((const byte*) SCREEN+(byte) $4f) ← (byte) '>' -- _deref_pbuc1=vbuc2 
    lda #'>'
    sta SCREEN+$4f
    // syscall1::@return
    // }
    // [29] return 
    rts
}
  // File Data
.segment Data
  MESSAGE: .text "hello world!"
  .byte 0
.segment Syscall
  SYSCALLS: .byte JMP
  .word syscall1
  .byte NOP, JMP
  .word syscall2
  .byte NOP
  .align $100
  SYSCALL_RESET: .byte JMP
  .word main
  .byte NOP

