Inlined call call __init
Eliminating unused variable with no statement memset::$2

CONTROL FLOW GRAPH SSA

void print_str(char *str)
print_str: scope:[print_str]  from main::@1 main::@4
  print_char_cursor#48 = phi( main::@1/print_char_cursor#11, main::@4/print_char_cursor#14 )
  print_str::str#6 = phi( main::@1/print_str::str#1, main::@4/print_str::str#2 )
  to:print_str::@1
print_str::@1: scope:[print_str]  from print_str print_str::@3
  print_char_cursor#43 = phi( print_str/print_char_cursor#48, print_str::@3/print_char_cursor#0 )
  print_str::str#3 = phi( print_str/print_str::str#6, print_str::@3/print_str::str#0 )
  print_str::$1 = 0 != *print_str::str#3
  if(print_str::$1) goto print_str::@2
  to:print_str::@return
print_str::@2: scope:[print_str]  from print_str::@1
  print_char_cursor#42 = phi( print_str::@1/print_char_cursor#43 )
  print_str::str#4 = phi( print_str::@1/print_str::str#3 )
  print_char::ch#0 = *print_str::str#4
  call print_char
  to:print_str::@3
print_str::@3: scope:[print_str]  from print_str::@2
  print_str::str#5 = phi( print_str::@2/print_str::str#4 )
  print_char_cursor#22 = phi( print_str::@2/print_char_cursor#8 )
  print_char_cursor#0 = print_char_cursor#22
  print_str::str#0 = ++ print_str::str#5
  to:print_str::@1
print_str::@return: scope:[print_str]  from print_str::@1
  print_char_cursor#23 = phi( print_str::@1/print_char_cursor#43 )
  print_char_cursor#1 = print_char_cursor#23
  return 
  to:@return

void print_ln()
print_ln: scope:[print_ln]  from main::@3 main::@6
  print_char_cursor#44 = phi( main::@3/print_char_cursor#13, main::@6/print_char_cursor#16 )
  print_line_cursor#21 = phi( main::@3/print_line_cursor#23, main::@6/print_line_cursor#24 )
  to:print_ln::@1
print_ln::@1: scope:[print_ln]  from print_ln print_ln::@1
  print_char_cursor#24 = phi( print_ln/print_char_cursor#44, print_ln::@1/print_char_cursor#24 )
  print_line_cursor#11 = phi( print_ln/print_line_cursor#21, print_ln::@1/print_line_cursor#0 )
  print_ln::$0 = print_line_cursor#11 + $28
  print_line_cursor#0 = print_ln::$0
  print_ln::$1 = print_line_cursor#0 < print_char_cursor#24
  if(print_ln::$1) goto print_ln::@1
  to:print_ln::@2
print_ln::@2: scope:[print_ln]  from print_ln::@1
  print_line_cursor#12 = phi( print_ln::@1/print_line_cursor#0 )
  print_char_cursor#2 = print_line_cursor#12
  to:print_ln::@return
print_ln::@return: scope:[print_ln]  from print_ln::@2
  print_char_cursor#25 = phi( print_ln::@2/print_char_cursor#2 )
  print_line_cursor#13 = phi( print_ln::@2/print_line_cursor#12 )
  print_line_cursor#1 = print_line_cursor#13
  print_char_cursor#3 = print_char_cursor#25
  return 
  to:@return

void print_uchar(char b)
print_uchar: scope:[print_uchar]  from main::@2 main::@5
  print_char_cursor#45 = phi( main::@2/print_char_cursor#12, main::@5/print_char_cursor#15 )
  print_uchar::b#2 = phi( main::@2/print_uchar::b#0, main::@5/print_uchar::b#1 )
  print_uchar::$0 = print_uchar::b#2 >> 4
  print_char::ch#1 = print_hextab[print_uchar::$0]
  call print_char
  to:print_uchar::@1
print_uchar::@1: scope:[print_uchar]  from print_uchar
  print_uchar::b#3 = phi( print_uchar/print_uchar::b#2 )
  print_char_cursor#26 = phi( print_uchar/print_char_cursor#8 )
  print_char_cursor#4 = print_char_cursor#26
  print_uchar::$2 = print_uchar::b#3 & $f
  print_char::ch#2 = print_hextab[print_uchar::$2]
  call print_char
  to:print_uchar::@2
print_uchar::@2: scope:[print_uchar]  from print_uchar::@1
  print_char_cursor#27 = phi( print_uchar::@1/print_char_cursor#8 )
  print_char_cursor#5 = print_char_cursor#27
  to:print_uchar::@return
print_uchar::@return: scope:[print_uchar]  from print_uchar::@2
  print_char_cursor#28 = phi( print_uchar::@2/print_char_cursor#5 )
  print_char_cursor#6 = print_char_cursor#28
  return 
  to:@return

void print_char(char ch)
print_char: scope:[print_char]  from print_str::@2 print_uchar print_uchar::@1
  print_char_cursor#29 = phi( print_str::@2/print_char_cursor#42, print_uchar/print_char_cursor#45, print_uchar::@1/print_char_cursor#4 )
  print_char::ch#3 = phi( print_str::@2/print_char::ch#0, print_uchar/print_char::ch#1, print_uchar::@1/print_char::ch#2 )
  *print_char_cursor#29 = print_char::ch#3
  print_char_cursor#7 = ++ print_char_cursor#29
  to:print_char::@return
print_char::@return: scope:[print_char]  from print_char
  print_char_cursor#30 = phi( print_char/print_char_cursor#7 )
  print_char_cursor#8 = print_char_cursor#30
  return 
  to:@return

void print_cls()
print_cls: scope:[print_cls]  from main
  print_screen#2 = phi( main/print_screen#5 )
  memset::str#0 = (void *)print_screen#2
  memset::c#0 = ' '
  memset::num#0 = $3e8
  call memset
  memset::return#0 = memset::return#2
  to:print_cls::@1
print_cls::@1: scope:[print_cls]  from print_cls
  print_screen#3 = phi( print_cls/print_screen#2 )
  print_line_cursor#2 = print_screen#3
  print_char_cursor#9 = print_line_cursor#2
  to:print_cls::@return
print_cls::@return: scope:[print_cls]  from print_cls::@1
  print_char_cursor#31 = phi( print_cls::@1/print_char_cursor#9 )
  print_line_cursor#14 = phi( print_cls::@1/print_line_cursor#2 )
  print_line_cursor#3 = print_line_cursor#14
  print_char_cursor#10 = print_char_cursor#31
  return 
  to:@return

void * memset(void *str , char c , unsigned int num)
memset: scope:[memset]  from print_cls
  memset::c#4 = phi( print_cls/memset::c#0 )
  memset::str#3 = phi( print_cls/memset::str#0 )
  memset::num#1 = phi( print_cls/memset::num#0 )
  memset::$0 = memset::num#1 > 0
  memset::$1 = ! memset::$0
  if(memset::$1) goto memset::@1
  to:memset::@2
memset::@1: scope:[memset]  from memset memset::@3
  memset::str#1 = phi( memset/memset::str#3, memset::@3/memset::str#4 )
  memset::return#1 = memset::str#1
  to:memset::@return
memset::@2: scope:[memset]  from memset
  memset::c#3 = phi( memset/memset::c#4 )
  memset::num#2 = phi( memset/memset::num#1 )
  memset::str#2 = phi( memset/memset::str#3 )
  memset::$4 = (char *)memset::str#2
  memset::end#0 = memset::$4 + memset::num#2
  memset::dst#0 = ((char *)) memset::str#2
  to:memset::@3
memset::@3: scope:[memset]  from memset::@2 memset::@4
  memset::c#2 = phi( memset::@2/memset::c#3, memset::@4/memset::c#1 )
  memset::str#4 = phi( memset::@2/memset::str#2, memset::@4/memset::str#5 )
  memset::end#1 = phi( memset::@2/memset::end#0, memset::@4/memset::end#2 )
  memset::dst#2 = phi( memset::@2/memset::dst#0, memset::@4/memset::dst#1 )
  memset::$3 = memset::dst#2 != memset::end#1
  if(memset::$3) goto memset::@4
  to:memset::@1
memset::@4: scope:[memset]  from memset::@3
  memset::str#5 = phi( memset::@3/memset::str#4 )
  memset::end#2 = phi( memset::@3/memset::end#1 )
  memset::dst#3 = phi( memset::@3/memset::dst#2 )
  memset::c#1 = phi( memset::@3/memset::c#2 )
  *memset::dst#3 = memset::c#1
  memset::dst#1 = ++ memset::dst#3
  to:memset::@3
memset::@return: scope:[memset]  from memset::@1
  memset::return#3 = phi( memset::@1/memset::return#1 )
  memset::return#2 = memset::return#3
  return 
  to:@return

int main()
main: scope:[main]  from __start::@1
  print_char_cursor#46 = phi( __start::@1/print_char_cursor#47 )
  print_line_cursor#22 = phi( __start::@1/print_line_cursor#25 )
  print_screen#5 = phi( __start::@1/print_screen#7 )
  file#0 = files
  main::$10 = (char **)file#0
  main::$7 = main::$10 + OFFSET_STRUCT_FILEENTRY_BUFEDIT
  *main::$7 = (char *)$4000
  main::$11 = (char **)file#0
  main::$8 = main::$11 + OFFSET_STRUCT_FILEENTRY_BUFEDIT
  (*main::$8)[3] = $aa
  main::$12 = (char **)file#0
  main::$9 = main::$12 + OFFSET_STRUCT_FILEENTRY_BUFEDIT
  main::$13 = (char *)*main::$9
  main::$13[4] = $cc
  call print_cls
  to:main::@1
main::@1: scope:[main]  from main
  file#15 = phi( main/file#0 )
  print_char_cursor#32 = phi( main/print_char_cursor#10 )
  print_line_cursor#15 = phi( main/print_line_cursor#3 )
  print_line_cursor#4 = print_line_cursor#15
  print_char_cursor#11 = print_char_cursor#32
  print_str::str#1 = main::str
  call print_str
  to:main::@2
main::@2: scope:[main]  from main::@1
  file#14 = phi( main::@1/file#15 )
  print_line_cursor#26 = phi( main::@1/print_line_cursor#4 )
  print_char_cursor#33 = phi( main::@1/print_char_cursor#1 )
  print_char_cursor#12 = print_char_cursor#33
  print_uchar::b#0 = *((char *)0)
  call print_uchar
  to:main::@3
main::@3: scope:[main]  from main::@2
  file#13 = phi( main::@2/file#14 )
  print_line_cursor#23 = phi( main::@2/print_line_cursor#26 )
  print_char_cursor#34 = phi( main::@2/print_char_cursor#6 )
  print_char_cursor#13 = print_char_cursor#34
  call print_ln
  to:main::@4
main::@4: scope:[main]  from main::@3
  file#12 = phi( main::@3/file#13 )
  print_char_cursor#35 = phi( main::@3/print_char_cursor#3 )
  print_line_cursor#16 = phi( main::@3/print_line_cursor#1 )
  print_line_cursor#5 = print_line_cursor#16
  print_char_cursor#14 = print_char_cursor#35
  print_str::str#2 = main::str1
  call print_str
  to:main::@5
main::@5: scope:[main]  from main::@4
  file#11 = phi( main::@4/file#12 )
  print_line_cursor#27 = phi( main::@4/print_line_cursor#5 )
  print_char_cursor#36 = phi( main::@4/print_char_cursor#1 )
  print_char_cursor#15 = print_char_cursor#36
  print_uchar::b#1 = *((char *)$4004)
  call print_uchar
  to:main::@6
main::@6: scope:[main]  from main::@5
  file#10 = phi( main::@5/file#11 )
  print_line_cursor#24 = phi( main::@5/print_line_cursor#27 )
  print_char_cursor#37 = phi( main::@5/print_char_cursor#6 )
  print_char_cursor#16 = print_char_cursor#37
  call print_ln
  to:main::@7
main::@7: scope:[main]  from main::@6
  file#8 = phi( main::@6/file#10 )
  print_char_cursor#38 = phi( main::@6/print_char_cursor#3 )
  print_line_cursor#17 = phi( main::@6/print_line_cursor#1 )
  print_line_cursor#6 = print_line_cursor#17
  print_char_cursor#17 = print_char_cursor#38
  main::return#0 = 0
  to:main::@return
main::@return: scope:[main]  from main::@7
  print_char_cursor#39 = phi( main::@7/print_char_cursor#17 )
  print_line_cursor#18 = phi( main::@7/print_line_cursor#6 )
  file#5 = phi( main::@7/file#8 )
  main::return#3 = phi( main::@7/main::return#0 )
  main::return#1 = main::return#3
  file#1 = file#5
  print_line_cursor#7 = print_line_cursor#18
  print_char_cursor#18 = print_char_cursor#39
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  print_screen#0 = (char *)$400
  print_line_cursor#8 = print_screen#0
  print_char_cursor#19 = print_line_cursor#8
  file#2 = (struct fileentry *) 0
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  print_screen#7 = phi( __start::__init1/print_screen#0 )
  print_char_cursor#47 = phi( __start::__init1/print_char_cursor#19 )
  print_line_cursor#25 = phi( __start::__init1/print_line_cursor#8 )
  file#9 = phi( __start::__init1/file#2 )
  call main
  main::return#2 = main::return#1
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  print_screen#6 = phi( __start::@1/print_screen#7 )
  print_char_cursor#40 = phi( __start::@1/print_char_cursor#18 )
  print_line_cursor#19 = phi( __start::@1/print_line_cursor#7 )
  file#6 = phi( __start::@1/file#1 )
  file#3 = file#6
  print_line_cursor#9 = print_line_cursor#19
  print_char_cursor#20 = print_char_cursor#40
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  file#7 = phi( __start::@2/file#3 )
  print_char_cursor#41 = phi( __start::@2/print_char_cursor#20 )
  print_line_cursor#20 = phi( __start::@2/print_line_cursor#9 )
  print_screen#4 = phi( __start::@2/print_screen#6 )
  print_screen#1 = print_screen#4
  print_line_cursor#10 = print_line_cursor#20
  print_char_cursor#21 = print_char_cursor#41
  file#4 = file#7
  return 
  to:@return

SYMBOL TABLE SSA
__constant char OFFSET_STRUCT_FILEENTRY_BUFEDIT = 0
__constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
void __start()
struct fileentry *file
struct fileentry *file#0
struct fileentry *file#1
struct fileentry *file#10
struct fileentry *file#11
struct fileentry *file#12
struct fileentry *file#13
struct fileentry *file#14
struct fileentry *file#15
struct fileentry *file#2
struct fileentry *file#3
struct fileentry *file#4
struct fileentry *file#5
struct fileentry *file#6
struct fileentry *file#7
struct fileentry *file#8
struct fileentry *file#9
__constant struct fileentry files[$a] = { fill( $a, 0) }
int main()
char **main::$10
char **main::$11
char **main::$12
char *main::$13
char **main::$7
char **main::$8
char **main::$9
int main::return
int main::return#0
int main::return#1
int main::return#2
int main::return#3
__constant char main::str[7] = "$0000="
__constant char main::str1[7] = "$4004="
void * memset(void *str , char c , unsigned int num)
bool memset::$0
bool memset::$1
bool memset::$3
char *memset::$4
char memset::c
char memset::c#0
char memset::c#1
char memset::c#2
char memset::c#3
char memset::c#4
char *memset::dst
char *memset::dst#0
char *memset::dst#1
char *memset::dst#2
char *memset::dst#3
char *memset::end
char *memset::end#0
char *memset::end#1
char *memset::end#2
unsigned int memset::num
unsigned int memset::num#0
unsigned int memset::num#1
unsigned int memset::num#2
void *memset::return
void *memset::return#0
void *memset::return#1
void *memset::return#2
void *memset::return#3
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 print_char(char ch)
char print_char::ch
char print_char::ch#0
char print_char::ch#1
char print_char::ch#2
char print_char::ch#3
char *print_char_cursor
char *print_char_cursor#0
char *print_char_cursor#1
char *print_char_cursor#10
char *print_char_cursor#11
char *print_char_cursor#12
char *print_char_cursor#13
char *print_char_cursor#14
char *print_char_cursor#15
char *print_char_cursor#16
char *print_char_cursor#17
char *print_char_cursor#18
char *print_char_cursor#19
char *print_char_cursor#2
char *print_char_cursor#20
char *print_char_cursor#21
char *print_char_cursor#22
char *print_char_cursor#23
char *print_char_cursor#24
char *print_char_cursor#25
char *print_char_cursor#26
char *print_char_cursor#27
char *print_char_cursor#28
char *print_char_cursor#29
char *print_char_cursor#3
char *print_char_cursor#30
char *print_char_cursor#31
char *print_char_cursor#32
char *print_char_cursor#33
char *print_char_cursor#34
char *print_char_cursor#35
char *print_char_cursor#36
char *print_char_cursor#37
char *print_char_cursor#38
char *print_char_cursor#39
char *print_char_cursor#4
char *print_char_cursor#40
char *print_char_cursor#41
char *print_char_cursor#42
char *print_char_cursor#43
char *print_char_cursor#44
char *print_char_cursor#45
char *print_char_cursor#46
char *print_char_cursor#47
char *print_char_cursor#48
char *print_char_cursor#5
char *print_char_cursor#6
char *print_char_cursor#7
char *print_char_cursor#8
char *print_char_cursor#9
void print_cls()
__constant const char print_hextab[] = "0123456789abcdef"z
char *print_line_cursor
char *print_line_cursor#0
char *print_line_cursor#1
char *print_line_cursor#10
char *print_line_cursor#11
char *print_line_cursor#12
char *print_line_cursor#13
char *print_line_cursor#14
char *print_line_cursor#15
char *print_line_cursor#16
char *print_line_cursor#17
char *print_line_cursor#18
char *print_line_cursor#19
char *print_line_cursor#2
char *print_line_cursor#20
char *print_line_cursor#21
char *print_line_cursor#22
char *print_line_cursor#23
char *print_line_cursor#24
char *print_line_cursor#25
char *print_line_cursor#26
char *print_line_cursor#27
char *print_line_cursor#3
char *print_line_cursor#4
char *print_line_cursor#5
char *print_line_cursor#6
char *print_line_cursor#7
char *print_line_cursor#8
char *print_line_cursor#9
void print_ln()
char *print_ln::$0
bool print_ln::$1
char *print_screen
char *print_screen#0
char *print_screen#1
char *print_screen#2
char *print_screen#3
char *print_screen#4
char *print_screen#5
char *print_screen#6
char *print_screen#7
void print_str(char *str)
bool print_str::$1
char *print_str::str
char *print_str::str#0
char *print_str::str#1
char *print_str::str#2
char *print_str::str#3
char *print_str::str#4
char *print_str::str#5
char *print_str::str#6
void print_uchar(char b)
char print_uchar::$0
number print_uchar::$2
char print_uchar::b
char print_uchar::b#0
char print_uchar::b#1
char print_uchar::b#2
char print_uchar::b#3

Adding number conversion cast (unumber) 0 in print_str::$1 = 0 != *print_str::str#3
Adding number conversion cast (unumber) $28 in print_ln::$0 = print_line_cursor#11 + $28
Adding number conversion cast (unumber) 4 in print_uchar::$0 = print_uchar::b#2 >> 4
Adding number conversion cast (unumber) $f in print_uchar::$2 = print_uchar::b#3 & $f
Adding number conversion cast (unumber) print_uchar::$2 in print_uchar::$2 = print_uchar::b#3 & (unumber)$f
Adding number conversion cast (unumber) $3e8 in memset::num#0 = $3e8
Adding number conversion cast (unumber) 0 in memset::$0 = memset::num#1 > 0
Adding number conversion cast (unumber) $aa in (*main::$8)[3] = $aa
Adding number conversion cast (unumber) 3 in (*main::$8)[3] = ((unumber)) $aa
Adding number conversion cast (unumber) $cc in main::$13[4] = $cc
Adding number conversion cast (unumber) 4 in main::$13[4] = ((unumber)) $cc
Adding number conversion cast (snumber) 0 in main::return#0 = 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast memset::num#0 = (unumber)$3e8
Inlining cast memset::dst#0 = (char *)memset::str#2
Inlining cast (*main::$8)[(unumber)3] = (unumber)$aa
Inlining cast main::$13[(unumber)4] = (unumber)$cc
Inlining cast main::return#0 = (snumber)0
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 0
Simplifying constant integer cast $28
Simplifying constant integer cast 4
Simplifying constant integer cast $f
Simplifying constant integer cast $3e8
Simplifying constant integer cast 0
Simplifying constant pointer cast (char *) 16384
Simplifying constant integer cast $aa
Simplifying constant integer cast 3
Simplifying constant integer cast *main::$9
Simplifying constant integer cast $cc
Simplifying constant integer cast 4
Simplifying constant pointer cast (char *) 0
Simplifying constant pointer cast (char *) 16388
Simplifying constant integer cast 0
Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) $f
Finalized unsigned number type (unsigned int) $3e8
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) $aa
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) $cc
Finalized unsigned number type (char) 4
Finalized signed number type (signed char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to char in print_uchar::$2 = print_uchar::b#3 & $f
Inversing boolean not [60] memset::$1 = memset::num#1 <= 0 from [59] memset::$0 = memset::num#1 > 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias print_str::str#3 = print_str::str#4 print_str::str#5 
Alias print_char_cursor#1 = print_char_cursor#42 print_char_cursor#43 print_char_cursor#23 
Alias print_char_cursor#0 = print_char_cursor#22 
Alias print_line_cursor#0 = print_ln::$0 print_line_cursor#12 print_char_cursor#2 print_line_cursor#13 print_char_cursor#25 print_line_cursor#1 print_char_cursor#3 
Alias print_uchar::b#2 = print_uchar::b#3 
Alias print_char_cursor#26 = print_char_cursor#4 
Alias print_char_cursor#27 = print_char_cursor#5 print_char_cursor#28 print_char_cursor#6 
Alias print_char_cursor#30 = print_char_cursor#7 print_char_cursor#8 
Alias print_line_cursor#14 = print_screen#3 print_screen#2 print_line_cursor#2 print_char_cursor#9 print_char_cursor#31 print_line_cursor#3 print_char_cursor#10 
Alias memset::return#1 = memset::str#1 memset::return#3 memset::return#2 
Alias memset::str#2 = memset::str#3 
Alias memset::num#1 = memset::num#2 
Alias memset::c#3 = memset::c#4 
Alias memset::c#1 = memset::c#2 
Alias memset::dst#2 = memset::dst#3 
Alias memset::end#1 = memset::end#2 
Alias memset::str#4 = memset::str#5 
Alias file#0 = file#15 file#14 file#13 file#12 file#11 file#10 file#8 file#5 file#1 
Alias print_line_cursor#15 = print_line_cursor#4 print_line_cursor#26 print_line_cursor#23 
Alias print_char_cursor#11 = print_char_cursor#32 
Alias print_char_cursor#12 = print_char_cursor#33 
Alias print_char_cursor#13 = print_char_cursor#34 
Alias print_line_cursor#16 = print_line_cursor#5 print_line_cursor#27 print_line_cursor#24 
Alias print_char_cursor#14 = print_char_cursor#35 
Alias print_char_cursor#15 = print_char_cursor#36 
Alias print_char_cursor#16 = print_char_cursor#37 
Alias print_line_cursor#17 = print_line_cursor#6 print_line_cursor#18 print_line_cursor#7 
Alias print_char_cursor#17 = print_char_cursor#38 print_char_cursor#39 print_char_cursor#18 
Alias main::return#0 = main::return#3 main::return#1 
Alias print_screen#0 = print_line_cursor#8 print_char_cursor#19 print_line_cursor#25 print_char_cursor#47 print_screen#7 print_screen#6 print_screen#4 print_screen#1 
Alias file#2 = file#9 
Alias file#3 = file#6 file#7 file#4 
Alias print_line_cursor#10 = print_line_cursor#9 print_line_cursor#19 print_line_cursor#20 
Alias print_char_cursor#20 = print_char_cursor#40 print_char_cursor#41 print_char_cursor#21 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values print_char_cursor#0 print_char_cursor#30
Identical Phi Values print_char_cursor#24 print_char_cursor#44
Identical Phi Values print_char_cursor#26 print_char_cursor#30
Identical Phi Values print_char_cursor#27 print_char_cursor#30
Identical Phi Values print_line_cursor#14 print_screen#5
Identical Phi Values memset::num#1 memset::num#0
Identical Phi Values memset::str#2 memset::str#0
Identical Phi Values memset::c#3 memset::c#0
Identical Phi Values memset::end#1 memset::end#0
Identical Phi Values memset::str#4 memset::str#2
Identical Phi Values memset::c#1 memset::c#3
Identical Phi Values print_screen#5 print_screen#0
Identical Phi Values print_line_cursor#22 print_screen#0
Identical Phi Values print_char_cursor#46 print_screen#0
Identical Phi Values print_line_cursor#15 print_line_cursor#14
Identical Phi Values print_char_cursor#11 print_line_cursor#14
Identical Phi Values print_char_cursor#12 print_char_cursor#1
Identical Phi Values print_char_cursor#13 print_char_cursor#27
Identical Phi Values print_line_cursor#16 print_line_cursor#0
Identical Phi Values print_char_cursor#14 print_line_cursor#0
Identical Phi Values print_char_cursor#15 print_char_cursor#1
Identical Phi Values print_char_cursor#16 print_char_cursor#27
Identical Phi Values print_line_cursor#17 print_line_cursor#0
Identical Phi Values print_char_cursor#17 print_line_cursor#0
Identical Phi Values file#3 file#0
Identical Phi Values print_line_cursor#10 print_line_cursor#17
Identical Phi Values print_char_cursor#20 print_char_cursor#17
Successful SSA optimization Pass2IdenticalPhiElimination
Identical Phi Values print_char_cursor#44 print_char_cursor#30
Identical Phi Values print_char_cursor#45 print_char_cursor#1
Identical Phi Values memset::return#1 memset::str#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition print_str::$1 [3] if(0!=*print_str::str#3) goto print_str::@2
Simple Condition print_ln::$1 [13] if(print_line_cursor#0<print_char_cursor#30) goto print_ln::@1
Simple Condition memset::$1 [38] if(memset::num#0<=0) goto memset::@1
Simple Condition memset::$3 [45] if(memset::dst#2!=memset::end#0) goto memset::@4
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant memset::c#0 = ' '
Constant memset::num#0 = $3e8
Constant file#0 = files
Constant print_str::str#1 = main::str
Constant print_str::str#2 = main::str1
Constant main::return#0 = 0
Constant print_screen#0 = (char *) 1024
Constant file#2 = (struct fileentry *) 0
Successful SSA optimization Pass2ConstantIdentification
Constant memset::str#0 = (void *)print_screen#0
Constant main::$10 = (char **)file#0
Constant main::$11 = (char **)file#0
Constant main::$12 = (char **)file#0
Constant main::return#2 = main::return#0
Successful SSA optimization Pass2ConstantIdentification
Constant memset::return#0 = memset::str#0
Constant memset::$4 = (char *)memset::str#0
Constant memset::dst#0 = (char *)memset::str#0
Successful SSA optimization Pass2ConstantIdentification
if() condition always false - eliminating [38] if(memset::num#0<=0) goto memset::@1
Successful SSA optimization Pass2ConstantIfs
Converting *(pointer+n) to pointer[n] [53] *main::$7 = (char *) 16384  -- main::$10[OFFSET_STRUCT_FILEENTRY_BUFEDIT]
Converting *(pointer+n) to pointer[n] [56] (*main::$8)[3] = $aa  -- main::$11[OFFSET_STRUCT_FILEENTRY_BUFEDIT]
Converting *(pointer+n) to pointer[n] [59] main::$13 = *main::$9  -- main::$12[OFFSET_STRUCT_FILEENTRY_BUFEDIT]
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero main::$10 in [52] main::$7 = main::$10 + OFFSET_STRUCT_FILEENTRY_BUFEDIT
Simplifying expression containing zero main::$10 in [53] main::$10[OFFSET_STRUCT_FILEENTRY_BUFEDIT] = (char *) 16384
Simplifying expression containing zero main::$11 in [55] main::$8 = main::$11 + OFFSET_STRUCT_FILEENTRY_BUFEDIT
Simplifying expression containing zero main::$11 in [56] (main::$11[OFFSET_STRUCT_FILEENTRY_BUFEDIT])[3] = $aa
Simplifying expression containing zero main::$12 in [58] main::$9 = main::$12 + OFFSET_STRUCT_FILEENTRY_BUFEDIT
Simplifying expression containing zero main::$12 in [59] main::$13 = main::$12[OFFSET_STRUCT_FILEENTRY_BUFEDIT]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable main::$7 and assignment [32] main::$7 = main::$10
Eliminating unused variable main::$8 and assignment [34] main::$8 = main::$11
Eliminating unused variable main::$9 and assignment [36] main::$9 = main::$12
Eliminating unused constant memset::return#0
Eliminating unused constant main::return#2
Eliminating unused constant OFFSET_STRUCT_FILEENTRY_BUFEDIT
Eliminating unused constant file#2
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant main::return#0
Successful SSA optimization PassNEliminateUnusedVars
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
Constant right-side identified [26] memset::end#0 = memset::$4 + memset::num#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant memset::end#0 = memset::$4+memset::num#0
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings print_str::str#1
Inlining constant with var siblings print_str::str#2
Inlining constant with var siblings memset::dst#0
Constant inlined file#0 = files
Constant inlined memset::$4 = (char *)memset::str#0
Constant inlined main::$12 = (char **)files
Constant inlined print_str::str#2 = main::str1
Constant inlined memset::dst#0 = (char *)memset::str#0
Constant inlined print_str::str#1 = main::str
Constant inlined main::$10 = (char **)files
Constant inlined main::$11 = (char **)files
Successful SSA optimization Pass2ConstantInlining
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 8
Finalized unsigned number type (char) $a
Finalized unsigned number type (char) $10
Finalized unsigned number type (char) $a
Finalized unsigned number type (char) $a
Successful SSA optimization PassNFinalizeNumberTypeConversions
Added new block during phi lifting print_ln::@3(between print_ln::@1 and print_ln::@1)
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of main::@7
Adding NOP phi() at start of print_cls
Adding NOP phi() at start of print_cls::@1
Adding NOP phi() at start of print_uchar::@2
Adding NOP phi() at start of print_ln::@2
Adding NOP phi() at start of memset
Adding NOP phi() at start of memset::@2
Adding NOP phi() at start of memset::@1
CALL GRAPH
Calls in [main] to print_cls:4 print_str:6 print_uchar:9 print_ln:11 print_str:13 print_uchar:16 print_ln:18 
Calls in [print_cls] to memset:22 
Calls in [print_str] to print_char:34 
Calls in [print_uchar] to print_char:43 print_char:48 

Created 10 initial phi equivalence classes
Coalesced [8] print_uchar::b#4 = print_uchar::b#0
Not coalescing [12] print_char_cursor#49 = print_line_cursor#0
Coalesced [15] print_uchar::b#5 = print_uchar::b#1
Coalesced [17] print_line_cursor#28 = print_line_cursor#0
Coalesced [26] print_str::str#7 = print_str::str#6
Coalesced [27] print_char_cursor#50 = print_char_cursor#48
Coalesced [32] print_char::ch#4 = print_char::ch#0
Coalesced [33] print_char_cursor#52 = print_char_cursor#1
Coalesced [36] print_str::str#8 = print_str::str#0
Coalesced [37] print_char_cursor#51 = print_char_cursor#30
Coalesced [41] print_char::ch#5 = print_char::ch#1
Coalesced (already) [42] print_char_cursor#53 = print_char_cursor#1
Coalesced [46] print_char::ch#6 = print_char::ch#2
Coalesced (already) [47] print_char_cursor#54 = print_char_cursor#30
Coalesced [52] print_line_cursor#29 = print_line_cursor#21
Coalesced (already) [58] print_line_cursor#30 = print_line_cursor#0
Coalesced [67] memset::dst#4 = memset::dst#1
Coalesced down to 6 phi equivalence classes
Culled Empty Block label main::@7
Culled Empty Block label print_cls::@1
Culled Empty Block label print_uchar::@2
Culled Empty Block label print_ln::@2
Culled Empty Block label print_ln::@3
Culled Empty Block label memset::@2
Culled Empty Block label memset::@1
Renumbering block memset::@3 to memset::@1
Renumbering block memset::@4 to memset::@2
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of main::@6
Adding NOP phi() at start of print_cls
Adding NOP phi() at start of memset

FINAL CONTROL FLOW GRAPH

int main()
main: scope:[main]  from
  [0] *((char **)files) = (char *) 16384
  [1] (*((char **)files))[3] = $aa
  [2] main::$13 = *((char **)files)
  [3] main::$13[4] = $cc
  [4] call print_cls
  to:main::@1
main::@1: scope:[main]  from main
  [5] phi()
  [6] call print_str
  to:main::@2
main::@2: scope:[main]  from main::@1
  [7] print_uchar::b#0 = *((char *) 0)
  [8] call print_uchar
  to:main::@3
main::@3: scope:[main]  from main::@2
  [9] phi()
  [10] call print_ln
  to:main::@4
main::@4: scope:[main]  from main::@3
  [11] print_char_cursor#49 = print_line_cursor#0
  [12] call print_str
  to:main::@5
main::@5: scope:[main]  from main::@4
  [13] print_uchar::b#1 = *((char *) 16388)
  [14] call print_uchar
  to:main::@6
main::@6: scope:[main]  from main::@5
  [15] phi()
  [16] call print_ln
  to:main::@return
main::@return: scope:[main]  from main::@6
  [17] return 
  to:@return

void print_cls()
print_cls: scope:[print_cls]  from main
  [18] phi()
  [19] call memset
  to:print_cls::@return
print_cls::@return: scope:[print_cls]  from print_cls
  [20] return 
  to:@return

void print_str(char *str)
print_str: scope:[print_str]  from main::@1 main::@4
  [21] print_char_cursor#48 = phi( main::@1/print_screen#0, main::@4/print_char_cursor#49 )
  [21] print_str::str#6 = phi( main::@1/main::str, main::@4/main::str1 )
  to:print_str::@1
print_str::@1: scope:[print_str]  from print_str print_str::@3
  [22] print_char_cursor#1 = phi( print_str/print_char_cursor#48, print_str::@3/print_char_cursor#30 )
  [22] print_str::str#3 = phi( print_str/print_str::str#6, print_str::@3/print_str::str#0 )
  [23] if(0!=*print_str::str#3) goto print_str::@2
  to:print_str::@return
print_str::@return: scope:[print_str]  from print_str::@1
  [24] return 
  to:@return
print_str::@2: scope:[print_str]  from print_str::@1
  [25] print_char::ch#0 = *print_str::str#3
  [26] call print_char
  to:print_str::@3
print_str::@3: scope:[print_str]  from print_str::@2
  [27] print_str::str#0 = ++ print_str::str#3
  to:print_str::@1

void print_uchar(char b)
print_uchar: scope:[print_uchar]  from main::@2 main::@5
  [28] print_uchar::b#2 = phi( main::@2/print_uchar::b#0, main::@5/print_uchar::b#1 )
  [29] print_uchar::$0 = print_uchar::b#2 >> 4
  [30] print_char::ch#1 = print_hextab[print_uchar::$0]
  [31] call print_char
  to:print_uchar::@1
print_uchar::@1: scope:[print_uchar]  from print_uchar
  [32] print_uchar::$2 = print_uchar::b#2 & $f
  [33] print_char::ch#2 = print_hextab[print_uchar::$2]
  [34] call print_char
  to:print_uchar::@return
print_uchar::@return: scope:[print_uchar]  from print_uchar::@1
  [35] return 
  to:@return

void print_ln()
print_ln: scope:[print_ln]  from main::@3 main::@6
  [36] print_line_cursor#21 = phi( main::@3/print_screen#0, main::@6/print_line_cursor#0 )
  to:print_ln::@1
print_ln::@1: scope:[print_ln]  from print_ln print_ln::@1
  [37] print_line_cursor#11 = phi( print_ln/print_line_cursor#21, print_ln::@1/print_line_cursor#0 )
  [38] print_line_cursor#0 = print_line_cursor#11 + $28
  [39] if(print_line_cursor#0<print_char_cursor#30) goto print_ln::@1
  to:print_ln::@return
print_ln::@return: scope:[print_ln]  from print_ln::@1
  [40] return 
  to:@return

void * memset(void *str , char c , unsigned int num)
memset: scope:[memset]  from print_cls
  [41] phi()
  to:memset::@1
memset::@1: scope:[memset]  from memset memset::@2
  [42] memset::dst#2 = phi( memset/(char *)memset::str#0, memset::@2/memset::dst#1 )
  [43] if(memset::dst#2!=memset::end#0) goto memset::@2
  to:memset::@return
memset::@return: scope:[memset]  from memset::@1
  [44] return 
  to:@return
memset::@2: scope:[memset]  from memset::@1
  [45] *memset::dst#2 = memset::c#0
  [46] memset::dst#1 = ++ memset::dst#2
  to:memset::@1

void print_char(char ch)
print_char: scope:[print_char]  from print_str::@2 print_uchar print_uchar::@1
  [47] print_char_cursor#29 = phi( print_str::@2/print_char_cursor#1, print_uchar/print_char_cursor#1, print_uchar::@1/print_char_cursor#30 )
  [47] print_char::ch#3 = phi( print_str::@2/print_char::ch#0, print_uchar/print_char::ch#1, print_uchar::@1/print_char::ch#2 )
  [48] *print_char_cursor#29 = print_char::ch#3
  [49] print_char_cursor#30 = ++ print_char_cursor#29
  to:print_char::@return
print_char::@return: scope:[print_char]  from print_char
  [50] return 
  to:@return


VARIABLE REGISTER WEIGHTS
struct fileentry *file
int main()
char *main::$13 // 4.0
int main::return
void * memset(void *str , char c , unsigned int num)
char memset::c
char *memset::dst
char *memset::dst#1 // 2002.0
char *memset::dst#2 // 1334.6666666666667
char *memset::end
unsigned int memset::num
void *memset::return
void *memset::str
void print_char(char ch)
char print_char::ch
char print_char::ch#0 // 202.0
char print_char::ch#1 // 22.0
char print_char::ch#2 // 22.0
char print_char::ch#3 // 1124.0
char *print_char_cursor
char *print_char_cursor#1 // 20.363636363636363
char *print_char_cursor#29 // 1062.5
char *print_char_cursor#30 // 71.41176470588235
char *print_char_cursor#48 // 13.0
char *print_char_cursor#49 // 4.0
void print_cls()
char *print_line_cursor
char *print_line_cursor#0 // 34.11111111111111
char *print_line_cursor#11 // 213.0
char *print_line_cursor#21 // 13.0
void print_ln()
char *print_screen
void print_str(char *str)
char *print_str::str
char *print_str::str#0 // 202.0
char *print_str::str#3 // 103.75
char *print_str::str#6 // 11.0
void print_uchar(char b)
char print_uchar::$0 // 22.0
char print_uchar::$2 // 22.0
char print_uchar::b
char print_uchar::b#0 // 4.0
char print_uchar::b#1 // 4.0
char print_uchar::b#2 // 6.5

Initial phi equivalence classes
[ print_str::str#3 print_str::str#6 print_str::str#0 ]
[ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
[ print_line_cursor#11 print_line_cursor#21 print_line_cursor#0 ]
[ memset::dst#2 memset::dst#1 ]
[ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ]
[ print_char_cursor#29 print_char_cursor#1 print_char_cursor#48 print_char_cursor#49 print_char_cursor#30 ]
Added variable main::$13 to live range equivalence class [ main::$13 ]
Added variable print_uchar::$0 to live range equivalence class [ print_uchar::$0 ]
Added variable print_uchar::$2 to live range equivalence class [ print_uchar::$2 ]
Complete equivalence classes
[ print_str::str#3 print_str::str#6 print_str::str#0 ]
[ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
[ print_line_cursor#11 print_line_cursor#21 print_line_cursor#0 ]
[ memset::dst#2 memset::dst#1 ]
[ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ]
[ print_char_cursor#29 print_char_cursor#1 print_char_cursor#48 print_char_cursor#49 print_char_cursor#30 ]
[ main::$13 ]
[ print_uchar::$0 ]
[ print_uchar::$2 ]
Allocated zp[2]:2 [ memset::dst#2 memset::dst#1 ]
Allocated zp[1]:4 [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ]
Allocated zp[2]:5 [ print_char_cursor#29 print_char_cursor#1 print_char_cursor#48 print_char_cursor#49 print_char_cursor#30 ]
Allocated zp[2]:7 [ print_str::str#3 print_str::str#6 print_str::str#0 ]
Allocated zp[2]:9 [ print_line_cursor#11 print_line_cursor#21 print_line_cursor#0 ]
Allocated zp[1]:11 [ print_uchar::$0 ]
Allocated zp[1]:12 [ print_uchar::$2 ]
Allocated zp[1]:13 [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Allocated zp[2]:14 [ main::$13 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *((char **)files) = (char *) 16384 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] (*((char **)files))[3] = $aa [ ] (  [ ] { }  ) always clobbers reg byte a reg byte x reg byte y 
Statement [2] main::$13 = *((char **)files) [ main::$13 ] (  [ main::$13 ] { }  ) always clobbers reg byte a 
Statement [3] main::$13[4] = $cc [ ] (  [ ] { }  ) always clobbers reg byte a reg byte y 
Statement [11] print_char_cursor#49 = print_line_cursor#0 [ print_char_cursor#49 print_line_cursor#0 ] (  [ print_char_cursor#49 print_line_cursor#0 ] { { print_char_cursor#48 = print_char_cursor#49 } }  ) always clobbers reg byte a 
Statement [23] if(0!=*print_str::str#3) goto print_str::@2 [ print_str::str#3 print_char_cursor#1 ] ( print_str:6 [ print_str::str#3 print_char_cursor#1 ] { }  print_str:12 [ print_line_cursor#0 print_str::str#3 print_char_cursor#1 ] { { print_char_cursor#48 = print_char_cursor#49 } }  ) always clobbers reg byte a reg byte y 
Statement [25] print_char::ch#0 = *print_str::str#3 [ print_str::str#3 print_char_cursor#1 print_char::ch#0 ] ( print_str:6 [ print_str::str#3 print_char_cursor#1 print_char::ch#0 ] { { print_char::ch#0 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_str:12 [ print_line_cursor#0 print_str::str#3 print_char_cursor#1 print_char::ch#0 ] { { print_char_cursor#48 = print_char_cursor#49 } { print_char::ch#0 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  ) always clobbers reg byte a reg byte y 
Statement [29] print_uchar::$0 = print_uchar::b#2 >> 4 [ print_char_cursor#1 print_uchar::b#2 print_uchar::$0 ] ( print_uchar:8 [ print_char_cursor#1 print_uchar::b#2 print_uchar::$0 ] { { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_uchar:14 [ print_line_cursor#0 print_char_cursor#1 print_uchar::b#2 print_uchar::$0 ] { { print_uchar::b#1 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:13 [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Statement [32] print_uchar::$2 = print_uchar::b#2 & $f [ print_char_cursor#30 print_uchar::$2 ] ( print_uchar:8 [ print_char_cursor#30 print_uchar::$2 ] { { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#2 = print_char::ch#3 } { print_char_cursor#29 = print_char_cursor#30 } }  print_uchar:14 [ print_line_cursor#0 print_char_cursor#30 print_uchar::$2 ] { { print_uchar::b#1 = print_uchar::b#2 } { print_char::ch#2 = print_char::ch#3 } { print_char_cursor#29 = print_char_cursor#30 } }  ) always clobbers reg byte a 
Statement [38] print_line_cursor#0 = print_line_cursor#11 + $28 [ print_line_cursor#0 print_char_cursor#30 ] ( print_ln:10 [ print_line_cursor#0 print_char_cursor#30 ] { }  print_ln:16 [ print_line_cursor#0 print_char_cursor#30 ] { { print_line_cursor#0 = print_line_cursor#21 } }  ) always clobbers reg byte a 
Statement [39] if(print_line_cursor#0<print_char_cursor#30) goto print_ln::@1 [ print_line_cursor#0 print_char_cursor#30 ] ( print_ln:10 [ print_line_cursor#0 print_char_cursor#30 ] { }  print_ln:16 [ print_line_cursor#0 print_char_cursor#30 ] { { print_line_cursor#0 = print_line_cursor#21 } }  ) always clobbers reg byte a 
Statement [43] if(memset::dst#2!=memset::end#0) goto memset::@2 [ memset::dst#2 ] ( print_cls:4::memset:19 [ memset::dst#2 ] { }  ) always clobbers reg byte a 
Statement [45] *memset::dst#2 = memset::c#0 [ memset::dst#2 ] ( print_cls:4::memset:19 [ memset::dst#2 ] { }  ) always clobbers reg byte a reg byte y 
Statement [48] *print_char_cursor#29 = print_char::ch#3 [ print_char_cursor#29 ] ( print_str:6::print_char:26 [ print_str::str#3 print_char_cursor#29 ] { { print_char::ch#0 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_str:12::print_char:26 [ print_line_cursor#0 print_str::str#3 print_char_cursor#29 ] { { print_char_cursor#48 = print_char_cursor#49 } { print_char::ch#0 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_uchar:8::print_char:31 [ print_uchar::b#2 print_char_cursor#29 ] { { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_uchar:14::print_char:31 [ print_line_cursor#0 print_uchar::b#2 print_char_cursor#29 ] { { print_uchar::b#1 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_uchar:8::print_char:34 [ print_char_cursor#29 ] { { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#2 = print_char::ch#3 } { print_char_cursor#29 = print_char_cursor#30 } }  print_uchar:14::print_char:34 [ print_line_cursor#0 print_char_cursor#29 ] { { print_uchar::b#1 = print_uchar::b#2 } { print_char::ch#2 = print_char::ch#3 } { print_char_cursor#29 = print_char_cursor#30 } }  ) always clobbers reg byte y 
Removing always clobbered register reg byte y as potential for zp[1]:13 [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Statement [0] *((char **)files) = (char *) 16384 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] (*((char **)files))[3] = $aa [ ] (  [ ] { }  ) always clobbers reg byte a reg byte x reg byte y 
Statement [2] main::$13 = *((char **)files) [ main::$13 ] (  [ main::$13 ] { }  ) always clobbers reg byte a 
Statement [3] main::$13[4] = $cc [ ] (  [ ] { }  ) always clobbers reg byte a reg byte y 
Statement [11] print_char_cursor#49 = print_line_cursor#0 [ print_char_cursor#49 print_line_cursor#0 ] (  [ print_char_cursor#49 print_line_cursor#0 ] { { print_char_cursor#48 = print_char_cursor#49 } }  ) always clobbers reg byte a 
Statement [23] if(0!=*print_str::str#3) goto print_str::@2 [ print_str::str#3 print_char_cursor#1 ] ( print_str:6 [ print_str::str#3 print_char_cursor#1 ] { }  print_str:12 [ print_line_cursor#0 print_str::str#3 print_char_cursor#1 ] { { print_char_cursor#48 = print_char_cursor#49 } }  ) always clobbers reg byte a reg byte y 
Statement [25] print_char::ch#0 = *print_str::str#3 [ print_str::str#3 print_char_cursor#1 print_char::ch#0 ] ( print_str:6 [ print_str::str#3 print_char_cursor#1 print_char::ch#0 ] { { print_char::ch#0 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_str:12 [ print_line_cursor#0 print_str::str#3 print_char_cursor#1 print_char::ch#0 ] { { print_char_cursor#48 = print_char_cursor#49 } { print_char::ch#0 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  ) always clobbers reg byte a reg byte y 
Statement [29] print_uchar::$0 = print_uchar::b#2 >> 4 [ print_char_cursor#1 print_uchar::b#2 print_uchar::$0 ] ( print_uchar:8 [ print_char_cursor#1 print_uchar::b#2 print_uchar::$0 ] { { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_uchar:14 [ print_line_cursor#0 print_char_cursor#1 print_uchar::b#2 print_uchar::$0 ] { { print_uchar::b#1 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  ) always clobbers reg byte a 
Statement [32] print_uchar::$2 = print_uchar::b#2 & $f [ print_char_cursor#30 print_uchar::$2 ] ( print_uchar:8 [ print_char_cursor#30 print_uchar::$2 ] { { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#2 = print_char::ch#3 } { print_char_cursor#29 = print_char_cursor#30 } }  print_uchar:14 [ print_line_cursor#0 print_char_cursor#30 print_uchar::$2 ] { { print_uchar::b#1 = print_uchar::b#2 } { print_char::ch#2 = print_char::ch#3 } { print_char_cursor#29 = print_char_cursor#30 } }  ) always clobbers reg byte a 
Statement [38] print_line_cursor#0 = print_line_cursor#11 + $28 [ print_line_cursor#0 print_char_cursor#30 ] ( print_ln:10 [ print_line_cursor#0 print_char_cursor#30 ] { }  print_ln:16 [ print_line_cursor#0 print_char_cursor#30 ] { { print_line_cursor#0 = print_line_cursor#21 } }  ) always clobbers reg byte a 
Statement [39] if(print_line_cursor#0<print_char_cursor#30) goto print_ln::@1 [ print_line_cursor#0 print_char_cursor#30 ] ( print_ln:10 [ print_line_cursor#0 print_char_cursor#30 ] { }  print_ln:16 [ print_line_cursor#0 print_char_cursor#30 ] { { print_line_cursor#0 = print_line_cursor#21 } }  ) always clobbers reg byte a 
Statement [43] if(memset::dst#2!=memset::end#0) goto memset::@2 [ memset::dst#2 ] ( print_cls:4::memset:19 [ memset::dst#2 ] { }  ) always clobbers reg byte a 
Statement [45] *memset::dst#2 = memset::c#0 [ memset::dst#2 ] ( print_cls:4::memset:19 [ memset::dst#2 ] { }  ) always clobbers reg byte a reg byte y 
Statement [48] *print_char_cursor#29 = print_char::ch#3 [ print_char_cursor#29 ] ( print_str:6::print_char:26 [ print_str::str#3 print_char_cursor#29 ] { { print_char::ch#0 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_str:12::print_char:26 [ print_line_cursor#0 print_str::str#3 print_char_cursor#29 ] { { print_char_cursor#48 = print_char_cursor#49 } { print_char::ch#0 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_uchar:8::print_char:31 [ print_uchar::b#2 print_char_cursor#29 ] { { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_uchar:14::print_char:31 [ print_line_cursor#0 print_uchar::b#2 print_char_cursor#29 ] { { print_uchar::b#1 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#3 } { print_char_cursor#1 = print_char_cursor#29 } }  print_uchar:8::print_char:34 [ print_char_cursor#29 ] { { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#2 = print_char::ch#3 } { print_char_cursor#29 = print_char_cursor#30 } }  print_uchar:14::print_char:34 [ print_line_cursor#0 print_char_cursor#29 ] { { print_uchar::b#1 = print_uchar::b#2 } { print_char::ch#2 = print_char::ch#3 } { print_char_cursor#29 = print_char_cursor#30 } }  ) always clobbers reg byte y 
Potential registers zp[2]:7 [ print_str::str#3 print_str::str#6 print_str::str#0 ] : zp[2]:7 , 
Potential registers zp[1]:13 [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ] : zp[1]:13 , reg byte x , 
Potential registers zp[2]:9 [ print_line_cursor#11 print_line_cursor#21 print_line_cursor#0 ] : zp[2]:9 , 
Potential registers zp[2]:2 [ memset::dst#2 memset::dst#1 ] : zp[2]:2 , 
Potential registers zp[1]:4 [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[2]:5 [ print_char_cursor#29 print_char_cursor#1 print_char_cursor#48 print_char_cursor#49 print_char_cursor#30 ] : zp[2]:5 , 
Potential registers zp[2]:14 [ main::$13 ] : zp[2]:14 , 
Potential registers zp[1]:11 [ print_uchar::$0 ] : zp[1]:11 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:12 [ print_uchar::$2 ] : zp[1]:12 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [memset] 3,336.67: zp[2]:2 [ memset::dst#2 memset::dst#1 ] 
Uplift Scope [] 1,171.28: zp[2]:5 [ print_char_cursor#29 print_char_cursor#1 print_char_cursor#48 print_char_cursor#49 print_char_cursor#30 ] 260.11: zp[2]:9 [ print_line_cursor#11 print_line_cursor#21 print_line_cursor#0 ] 
Uplift Scope [print_char] 1,370: zp[1]:4 [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ] 
Uplift Scope [print_str] 316.75: zp[2]:7 [ print_str::str#3 print_str::str#6 print_str::str#0 ] 
Uplift Scope [print_uchar] 22: zp[1]:11 [ print_uchar::$0 ] 22: zp[1]:12 [ print_uchar::$2 ] 14.5: zp[1]:13 [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ] 
Uplift Scope [main] 4: zp[2]:14 [ main::$13 ] 
Uplift Scope [print_ln] 
Uplift Scope [print_cls] 
Uplift Scope [RADIX] 
Uplift Scope [fileentry] 

Uplifting [memset] best 1770 combination zp[2]:2 [ memset::dst#2 memset::dst#1 ] 
Uplifting [] best 1770 combination zp[2]:5 [ print_char_cursor#29 print_char_cursor#1 print_char_cursor#48 print_char_cursor#49 print_char_cursor#30 ] zp[2]:9 [ print_line_cursor#11 print_line_cursor#21 print_line_cursor#0 ] 
Uplifting [print_char] best 1731 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ] 
Uplifting [print_str] best 1731 combination zp[2]:7 [ print_str::str#3 print_str::str#6 print_str::str#0 ] 
Uplifting [print_uchar] best 1713 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ] 
Uplifting [main] best 1713 combination zp[2]:14 [ main::$13 ] 
Uplifting [print_ln] best 1713 combination 
Uplifting [print_cls] best 1713 combination 
Uplifting [RADIX] best 1713 combination 
Uplifting [fileentry] best 1713 combination 
Coalescing zero page register [ zp[2]:2 [ memset::dst#2 memset::dst#1 ] ] with [ zp[2]:7 [ print_str::str#3 print_str::str#6 print_str::str#0 ] ]
Coalescing zero page register [ zp[2]:14 [ main::$13 ] ] with [ zp[2]:9 [ print_line_cursor#11 print_line_cursor#21 print_line_cursor#0 ] ]
Allocated (was zp[2]:5) zp[2]:4 [ print_char_cursor#29 print_char_cursor#1 print_char_cursor#48 print_char_cursor#49 print_char_cursor#30 ]
Allocated (was zp[2]:14) zp[2]:6 [ main::$13 print_line_cursor#11 print_line_cursor#21 print_line_cursor#0 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Demonstrates problem with missing parenthesis in double-dereferencing
// https://gitlab.com/camelot/kickc/issues/270
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-ptr-22.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 print_screen = $400
  .label print_char_cursor = 4
  .label print_line_cursor = 6
.segment Code
  // main
main: {
    .label __13 = 6
    // [0] *((char **)files) = (char *) 16384 -- _deref_qbuc1=pbuc2 
    lda #<$4000
    sta files
    lda #>$4000
    sta files+1
    // [1] (*((char **)files))[3] = $aa -- (_deref_qbuc1)_derefidx_vbuc2=vbuc3 
    lda #$aa
    ldy #3
    ldx files
    stx.z $fe
    ldx files+1
    stx.z $ff
    sta ($fe),y
    // [2] main::$13 = *((char **)files) -- pbuz1=_deref_qbuc1 
    lda files
    sta.z __13
    lda files+1
    sta.z __13+1
    // [3] main::$13[4] = $cc -- pbuz1_derefidx_vbuc1=vbuc2 
    // writes address 0x0000 (wrong!)
    lda #$cc
    ldy #4
    sta (__13),y
    // [4] call print_cls
  // writes address 0x4004 (right!)
    // [18] phi from main to print_cls [phi:main->print_cls]
  print_cls_from_main:
    jsr print_cls
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    jmp __b1
    // main::@1
  __b1:
    // [6] call print_str
    // [21] phi from main::@1 to print_str [phi:main::@1->print_str]
  print_str_from___b1:
    // [21] phi print_char_cursor#48 = print_screen#0 [phi:main::@1->print_str#0] -- pbuz1=pbuc1 
    lda #<print_screen
    sta.z print_char_cursor
    lda #>print_screen
    sta.z print_char_cursor+1
    // [21] phi print_str::str#6 = main::str [phi:main::@1->print_str#1] -- pbuz1=pbuc1 
    lda #<str
    sta.z print_str.str
    lda #>str
    sta.z print_str.str+1
    jsr print_str
    jmp __b2
    // main::@2
  __b2:
    // [7] print_uchar::b#0 = *((char *) 0) -- vbuxx=_deref_pbuc1 
    ldx 0
    // [8] call print_uchar
    // [28] phi from main::@2 to print_uchar [phi:main::@2->print_uchar]
  print_uchar_from___b2:
    // [28] phi print_uchar::b#2 = print_uchar::b#0 [phi:main::@2->print_uchar#0] -- register_copy 
    jsr print_uchar
    // [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  __b3_from___b2:
    jmp __b3
    // main::@3
  __b3:
    // [10] call print_ln
    // [36] phi from main::@3 to print_ln [phi:main::@3->print_ln]
  print_ln_from___b3:
    // [36] phi print_line_cursor#21 = print_screen#0 [phi:main::@3->print_ln#0] -- pbuz1=pbuc1 
    lda #<print_screen
    sta.z print_line_cursor
    lda #>print_screen
    sta.z print_line_cursor+1
    jsr print_ln
    jmp __b4
    // main::@4
  __b4:
    // [11] print_char_cursor#49 = print_line_cursor#0 -- pbuz1=pbuz2 
    lda.z print_line_cursor
    sta.z print_char_cursor
    lda.z print_line_cursor+1
    sta.z print_char_cursor+1
    // [12] call print_str
    // [21] phi from main::@4 to print_str [phi:main::@4->print_str]
  print_str_from___b4:
    // [21] phi print_char_cursor#48 = print_char_cursor#49 [phi:main::@4->print_str#0] -- register_copy 
    // [21] phi print_str::str#6 = main::str1 [phi:main::@4->print_str#1] -- pbuz1=pbuc1 
    lda #<str1
    sta.z print_str.str
    lda #>str1
    sta.z print_str.str+1
    jsr print_str
    jmp __b5
    // main::@5
  __b5:
    // [13] print_uchar::b#1 = *((char *) 16388) -- vbuxx=_deref_pbuc1 
    ldx $4004
    // [14] call print_uchar
    // [28] phi from main::@5 to print_uchar [phi:main::@5->print_uchar]
  print_uchar_from___b5:
    // [28] phi print_uchar::b#2 = print_uchar::b#1 [phi:main::@5->print_uchar#0] -- register_copy 
    jsr print_uchar
    // [15] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
  __b6_from___b5:
    jmp __b6
    // main::@6
  __b6:
    // [16] call print_ln
    // [36] phi from main::@6 to print_ln [phi:main::@6->print_ln]
  print_ln_from___b6:
    // [36] phi print_line_cursor#21 = print_line_cursor#0 [phi:main::@6->print_ln#0] -- register_copy 
    jsr print_ln
    jmp __breturn
    // main::@return
  __breturn:
    // [17] return 
    rts
  .segment Data
    str: .text "$0000="
    .byte 0
    str1: .text "$4004="
    .byte 0
}
.segment Code
  // print_cls
// Clear the screen. Also resets current line/char cursor.
print_cls: {
    // [19] call memset
    // [41] phi from print_cls to memset [phi:print_cls->memset]
  memset_from_print_cls:
    jsr memset
    jmp __breturn
    // print_cls::@return
  __breturn:
    // [20] return 
    rts
}
  // print_str
// Print a zero-terminated string
// void print_str(__zp(2) char *str)
print_str: {
    .label str = 2
    // [22] phi from print_str print_str::@3 to print_str::@1 [phi:print_str/print_str::@3->print_str::@1]
  __b1_from_print_str:
  __b1_from___b3:
    // [22] phi print_char_cursor#1 = print_char_cursor#48 [phi:print_str/print_str::@3->print_str::@1#0] -- register_copy 
    // [22] phi print_str::str#3 = print_str::str#6 [phi:print_str/print_str::@3->print_str::@1#1] -- register_copy 
    jmp __b1
    // print_str::@1
  __b1:
    // [23] if(0!=*print_str::str#3) goto print_str::@2 -- 0_neq__deref_pbuz1_then_la1 
    ldy #0
    lda (str),y
    cmp #0
    bne __b2
    jmp __breturn
    // print_str::@return
  __breturn:
    // [24] return 
    rts
    // print_str::@2
  __b2:
    // [25] print_char::ch#0 = *print_str::str#3 -- vbuaa=_deref_pbuz1 
    ldy #0
    lda (str),y
    // [26] call print_char
    // [47] phi from print_str::@2 to print_char [phi:print_str::@2->print_char]
  print_char_from___b2:
    // [47] phi print_char_cursor#29 = print_char_cursor#1 [phi:print_str::@2->print_char#0] -- register_copy 
    // [47] phi print_char::ch#3 = print_char::ch#0 [phi:print_str::@2->print_char#1] -- register_copy 
    jsr print_char
    jmp __b3
    // print_str::@3
  __b3:
    // [27] print_str::str#0 = ++ print_str::str#3 -- pbuz1=_inc_pbuz1 
    inc.z str
    bne !+
    inc.z str+1
  !:
    jmp __b1_from___b3
}
  // print_uchar
// Print a char as HEX
// void print_uchar(__register(X) char b)
print_uchar: {
    // [29] print_uchar::$0 = print_uchar::b#2 >> 4 -- vbuaa=vbuxx_ror_4 
    txa
    lsr
    lsr
    lsr
    lsr
    // [30] print_char::ch#1 = print_hextab[print_uchar::$0] -- vbuaa=pbuc1_derefidx_vbuaa 
    tay
    lda print_hextab,y
    // [31] call print_char
  // Table of hexadecimal digits
    // [47] phi from print_uchar to print_char [phi:print_uchar->print_char]
  print_char_from_print_uchar:
    // [47] phi print_char_cursor#29 = print_char_cursor#1 [phi:print_uchar->print_char#0] -- register_copy 
    // [47] phi print_char::ch#3 = print_char::ch#1 [phi:print_uchar->print_char#1] -- register_copy 
    jsr print_char
    jmp __b1
    // print_uchar::@1
  __b1:
    // [32] print_uchar::$2 = print_uchar::b#2 & $f -- vbuxx=vbuxx_band_vbuc1 
    lda #$f
    axs #0
    // [33] print_char::ch#2 = print_hextab[print_uchar::$2] -- vbuaa=pbuc1_derefidx_vbuxx 
    lda print_hextab,x
    // [34] call print_char
    // [47] phi from print_uchar::@1 to print_char [phi:print_uchar::@1->print_char]
  print_char_from___b1:
    // [47] phi print_char_cursor#29 = print_char_cursor#30 [phi:print_uchar::@1->print_char#0] -- register_copy 
    // [47] phi print_char::ch#3 = print_char::ch#2 [phi:print_uchar::@1->print_char#1] -- register_copy 
    jsr print_char
    jmp __breturn
    // print_uchar::@return
  __breturn:
    // [35] return 
    rts
}
  // print_ln
// Print a newline
print_ln: {
    // [37] phi from print_ln print_ln::@1 to print_ln::@1 [phi:print_ln/print_ln::@1->print_ln::@1]
  __b1_from_print_ln:
  __b1_from___b1:
    // [37] phi print_line_cursor#11 = print_line_cursor#21 [phi:print_ln/print_ln::@1->print_ln::@1#0] -- register_copy 
    jmp __b1
    // print_ln::@1
  __b1:
    // [38] print_line_cursor#0 = print_line_cursor#11 + $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z print_line_cursor
    sta.z print_line_cursor
    bcc !+
    inc.z print_line_cursor+1
  !:
    // [39] if(print_line_cursor#0<print_char_cursor#30) goto print_ln::@1 -- pbuz1_lt_pbuz2_then_la1 
    lda.z print_line_cursor+1
    cmp.z print_char_cursor+1
    bcc __b1_from___b1
    bne !+
    lda.z print_line_cursor
    cmp.z print_char_cursor
    bcc __b1_from___b1
  !:
    jmp __breturn
    // print_ln::@return
  __breturn:
    // [40] return 
    rts
}
  // memset
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// void * memset(void *str, char c, unsigned int num)
memset: {
    .const c = ' '
    .const num = $3e8
    .label str = print_screen
    .label end = str+num
    .label dst = 2
    // [42] phi from memset to memset::@1 [phi:memset->memset::@1]
  __b1_from_memset:
    // [42] phi memset::dst#2 = (char *)memset::str#0 [phi:memset->memset::@1#0] -- pbuz1=pbuc1 
    lda #<str
    sta.z dst
    lda #>str
    sta.z dst+1
    jmp __b1
    // memset::@1
  __b1:
    // [43] if(memset::dst#2!=memset::end#0) goto memset::@2 -- pbuz1_neq_pbuc1_then_la1 
    lda.z dst+1
    cmp #>end
    bne __b2
    lda.z dst
    cmp #<end
    bne __b2
    jmp __breturn
    // memset::@return
  __breturn:
    // [44] return 
    rts
    // memset::@2
  __b2:
    // [45] *memset::dst#2 = memset::c#0 -- _deref_pbuz1=vbuc1 
    lda #c
    ldy #0
    sta (dst),y
    // [46] memset::dst#1 = ++ memset::dst#2 -- pbuz1=_inc_pbuz1 
    inc.z dst
    bne !+
    inc.z dst+1
  !:
    // [42] phi from memset::@2 to memset::@1 [phi:memset::@2->memset::@1]
  __b1_from___b2:
    // [42] phi memset::dst#2 = memset::dst#1 [phi:memset::@2->memset::@1#0] -- register_copy 
    jmp __b1
}
  // print_char
// Print a single char
// void print_char(__register(A) char ch)
print_char: {
    // [48] *print_char_cursor#29 = print_char::ch#3 -- _deref_pbuz1=vbuaa 
    ldy #0
    sta (print_char_cursor),y
    // [49] print_char_cursor#30 = ++ print_char_cursor#29 -- pbuz1=_inc_pbuz1 
    inc.z print_char_cursor
    bne !+
    inc.z print_char_cursor+1
  !:
    jmp __breturn
    // print_char::@return
  __breturn:
    // [50] return 
    rts
}
  // File Data
.segment Data
  print_hextab: .text "0123456789abcdef"
  files: .fill 2*$a, 0

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
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b3
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b3 with __b1
Replacing label __b1_from___b1 with __b1
Replacing label __b1_from___b1 with __b1
Removing instruction __b1_from_main:
Removing instruction print_str_from___b1:
Removing instruction __b3_from___b2:
Removing instruction print_ln_from___b3:
Removing instruction __b6_from___b5:
Removing instruction print_ln_from___b6:
Removing instruction __b1_from_print_str:
Removing instruction __b1_from___b3:
Removing instruction __b1_from_print_ln:
Removing instruction __b1_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction print_cls_from_main:
Removing instruction __b1:
Removing instruction __b2:
Removing instruction print_uchar_from___b2:
Removing instruction __b3:
Removing instruction __b4:
Removing instruction print_str_from___b4:
Removing instruction __b5:
Removing instruction print_uchar_from___b5:
Removing instruction __b6:
Removing instruction __breturn:
Removing instruction memset_from_print_cls:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction print_char_from___b2:
Removing instruction __b3:
Removing instruction print_char_from_print_uchar:
Removing instruction __b1:
Removing instruction print_char_from___b1:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __b1_from_memset:
Removing instruction __breturn:
Removing instruction __b1_from___b2:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
struct fileentry *file
__constant struct fileentry files[$a] = { fill( $a, 0) }
int main()
char *main::$13 // zp[2]:6 4.0
int main::return
__constant char main::str[7] = "$0000="
__constant char main::str1[7] = "$4004="
void * memset(void *str , char c , unsigned int num)
char memset::c
__constant char memset::c#0 = ' ' // c
char *memset::dst
char *memset::dst#1 // dst zp[2]:2 2002.0
char *memset::dst#2 // dst zp[2]:2 1334.6666666666667
char *memset::end
__constant char *memset::end#0 = (char *)memset::str#0+memset::num#0 // end
unsigned int memset::num
__constant unsigned int memset::num#0 = $3e8 // num
void *memset::return
void *memset::str
__constant void *memset::str#0 = (void *)print_screen#0 // str
void print_char(char ch)
char print_char::ch
char print_char::ch#0 // reg byte a 202.0
char print_char::ch#1 // reg byte a 22.0
char print_char::ch#2 // reg byte a 22.0
char print_char::ch#3 // reg byte a 1124.0
char *print_char_cursor
char *print_char_cursor#1 // print_char_cursor zp[2]:4 20.363636363636363
char *print_char_cursor#29 // print_char_cursor zp[2]:4 1062.5
char *print_char_cursor#30 // print_char_cursor zp[2]:4 71.41176470588235
char *print_char_cursor#48 // print_char_cursor zp[2]:4 13.0
char *print_char_cursor#49 // print_char_cursor zp[2]:4 4.0
void print_cls()
__constant const char print_hextab[] = "0123456789abcdef"z
char *print_line_cursor
char *print_line_cursor#0 // print_line_cursor zp[2]:6 34.11111111111111
char *print_line_cursor#11 // print_line_cursor zp[2]:6 213.0
char *print_line_cursor#21 // print_line_cursor zp[2]:6 13.0
void print_ln()
char *print_screen
__constant char *print_screen#0 = (char *) 1024 // print_screen
void print_str(char *str)
char *print_str::str
char *print_str::str#0 // str zp[2]:2 202.0
char *print_str::str#3 // str zp[2]:2 103.75
char *print_str::str#6 // str zp[2]:2 11.0
void print_uchar(char b)
char print_uchar::$0 // reg byte a 22.0
char print_uchar::$2 // reg byte x 22.0
char print_uchar::b
char print_uchar::b#0 // reg byte x 4.0
char print_uchar::b#1 // reg byte x 4.0
char print_uchar::b#2 // reg byte x 6.5

reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
zp[2]:2 [ memset::dst#2 memset::dst#1 print_str::str#3 print_str::str#6 print_str::str#0 ]
reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ]
zp[2]:4 [ print_char_cursor#29 print_char_cursor#1 print_char_cursor#48 print_char_cursor#49 print_char_cursor#30 ]
zp[2]:6 [ main::$13 print_line_cursor#11 print_line_cursor#21 print_line_cursor#0 ]
reg byte a [ print_uchar::$0 ]
reg byte x [ print_uchar::$2 ]


FINAL ASSEMBLER
Score: 1497

  // File Comments
// Demonstrates problem with missing parenthesis in double-dereferencing
// https://gitlab.com/camelot/kickc/issues/270
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-ptr-22.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 print_screen = $400
  .label print_char_cursor = 4
  .label print_line_cursor = 6
.segment Code
  // main
main: {
    .label __13 = 6
    // file->bufEdit = (char*)0x4000
    // [0] *((char **)files) = (char *) 16384 -- _deref_qbuc1=pbuc2 
    lda #<$4000
    sta files
    lda #>$4000
    sta files+1
    // file->bufEdit[3] = 0xAA
    // [1] (*((char **)files))[3] = $aa -- (_deref_qbuc1)_derefidx_vbuc2=vbuc3 
    lda #$aa
    ldy #3
    ldx files
    stx.z $fe
    ldx files+1
    stx.z $ff
    sta ($fe),y
    // ((char *)file->bufEdit)[4] = 0xCC
    // [2] main::$13 = *((char **)files) -- pbuz1=_deref_qbuc1 
    lda files
    sta.z __13
    lda files+1
    sta.z __13+1
    // [3] main::$13[4] = $cc -- pbuz1_derefidx_vbuc1=vbuc2 
    // writes address 0x0000 (wrong!)
    lda #$cc
    ldy #4
    sta (__13),y
    // print_cls()
    // [4] call print_cls
  // writes address 0x4004 (right!)
    // [18] phi from main to print_cls [phi:main->print_cls]
    jsr print_cls
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // main::@1
    // print_str("$0000=")
    // [6] call print_str
    // [21] phi from main::@1 to print_str [phi:main::@1->print_str]
    // [21] phi print_char_cursor#48 = print_screen#0 [phi:main::@1->print_str#0] -- pbuz1=pbuc1 
    lda #<print_screen
    sta.z print_char_cursor
    lda #>print_screen
    sta.z print_char_cursor+1
    // [21] phi print_str::str#6 = main::str [phi:main::@1->print_str#1] -- pbuz1=pbuc1 
    lda #<str
    sta.z print_str.str
    lda #>str
    sta.z print_str.str+1
    jsr print_str
    // main::@2
    // print_uchar(*(char *)0x0000)
    // [7] print_uchar::b#0 = *((char *) 0) -- vbuxx=_deref_pbuc1 
    ldx 0
    // [8] call print_uchar
    // [28] phi from main::@2 to print_uchar [phi:main::@2->print_uchar]
    // [28] phi print_uchar::b#2 = print_uchar::b#0 [phi:main::@2->print_uchar#0] -- register_copy 
    jsr print_uchar
    // [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
    // main::@3
    // print_ln()
    // [10] call print_ln
    // [36] phi from main::@3 to print_ln [phi:main::@3->print_ln]
    // [36] phi print_line_cursor#21 = print_screen#0 [phi:main::@3->print_ln#0] -- pbuz1=pbuc1 
    lda #<print_screen
    sta.z print_line_cursor
    lda #>print_screen
    sta.z print_line_cursor+1
    jsr print_ln
    // main::@4
    // [11] print_char_cursor#49 = print_line_cursor#0 -- pbuz1=pbuz2 
    lda.z print_line_cursor
    sta.z print_char_cursor
    lda.z print_line_cursor+1
    sta.z print_char_cursor+1
    // print_str("$4004=")
    // [12] call print_str
    // [21] phi from main::@4 to print_str [phi:main::@4->print_str]
    // [21] phi print_char_cursor#48 = print_char_cursor#49 [phi:main::@4->print_str#0] -- register_copy 
    // [21] phi print_str::str#6 = main::str1 [phi:main::@4->print_str#1] -- pbuz1=pbuc1 
    lda #<str1
    sta.z print_str.str
    lda #>str1
    sta.z print_str.str+1
    jsr print_str
    // main::@5
    // print_uchar(*(char *)0x4004)
    // [13] print_uchar::b#1 = *((char *) 16388) -- vbuxx=_deref_pbuc1 
    ldx $4004
    // [14] call print_uchar
    // [28] phi from main::@5 to print_uchar [phi:main::@5->print_uchar]
    // [28] phi print_uchar::b#2 = print_uchar::b#1 [phi:main::@5->print_uchar#0] -- register_copy 
    jsr print_uchar
    // [15] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
    // main::@6
    // print_ln()
    // [16] call print_ln
    // [36] phi from main::@6 to print_ln [phi:main::@6->print_ln]
    // [36] phi print_line_cursor#21 = print_line_cursor#0 [phi:main::@6->print_ln#0] -- register_copy 
    jsr print_ln
    // main::@return
    // }
    // [17] return 
    rts
  .segment Data
    str: .text "$0000="
    .byte 0
    str1: .text "$4004="
    .byte 0
}
.segment Code
  // print_cls
// Clear the screen. Also resets current line/char cursor.
print_cls: {
    // memset(print_screen, ' ', 1000)
    // [19] call memset
    // [41] phi from print_cls to memset [phi:print_cls->memset]
    jsr memset
    // print_cls::@return
    // }
    // [20] return 
    rts
}
  // print_str
// Print a zero-terminated string
// void print_str(__zp(2) char *str)
print_str: {
    .label str = 2
    // [22] phi from print_str print_str::@3 to print_str::@1 [phi:print_str/print_str::@3->print_str::@1]
    // [22] phi print_char_cursor#1 = print_char_cursor#48 [phi:print_str/print_str::@3->print_str::@1#0] -- register_copy 
    // [22] phi print_str::str#3 = print_str::str#6 [phi:print_str/print_str::@3->print_str::@1#1] -- register_copy 
    // print_str::@1
  __b1:
    // while(*str)
    // [23] if(0!=*print_str::str#3) goto print_str::@2 -- 0_neq__deref_pbuz1_then_la1 
    ldy #0
    lda (str),y
    cmp #0
    bne __b2
    // print_str::@return
    // }
    // [24] return 
    rts
    // print_str::@2
  __b2:
    // print_char(*(str++))
    // [25] print_char::ch#0 = *print_str::str#3 -- vbuaa=_deref_pbuz1 
    ldy #0
    lda (str),y
    // [26] call print_char
    // [47] phi from print_str::@2 to print_char [phi:print_str::@2->print_char]
    // [47] phi print_char_cursor#29 = print_char_cursor#1 [phi:print_str::@2->print_char#0] -- register_copy 
    // [47] phi print_char::ch#3 = print_char::ch#0 [phi:print_str::@2->print_char#1] -- register_copy 
    jsr print_char
    // print_str::@3
    // print_char(*(str++));
    // [27] print_str::str#0 = ++ print_str::str#3 -- pbuz1=_inc_pbuz1 
    inc.z str
    bne !+
    inc.z str+1
  !:
    jmp __b1
}
  // print_uchar
// Print a char as HEX
// void print_uchar(__register(X) char b)
print_uchar: {
    // b>>4
    // [29] print_uchar::$0 = print_uchar::b#2 >> 4 -- vbuaa=vbuxx_ror_4 
    txa
    lsr
    lsr
    lsr
    lsr
    // print_char(print_hextab[b>>4])
    // [30] print_char::ch#1 = print_hextab[print_uchar::$0] -- vbuaa=pbuc1_derefidx_vbuaa 
    tay
    lda print_hextab,y
    // [31] call print_char
  // Table of hexadecimal digits
    // [47] phi from print_uchar to print_char [phi:print_uchar->print_char]
    // [47] phi print_char_cursor#29 = print_char_cursor#1 [phi:print_uchar->print_char#0] -- register_copy 
    // [47] phi print_char::ch#3 = print_char::ch#1 [phi:print_uchar->print_char#1] -- register_copy 
    jsr print_char
    // print_uchar::@1
    // b&$f
    // [32] print_uchar::$2 = print_uchar::b#2 & $f -- vbuxx=vbuxx_band_vbuc1 
    lda #$f
    axs #0
    // print_char(print_hextab[b&$f])
    // [33] print_char::ch#2 = print_hextab[print_uchar::$2] -- vbuaa=pbuc1_derefidx_vbuxx 
    lda print_hextab,x
    // [34] call print_char
    // [47] phi from print_uchar::@1 to print_char [phi:print_uchar::@1->print_char]
    // [47] phi print_char_cursor#29 = print_char_cursor#30 [phi:print_uchar::@1->print_char#0] -- register_copy 
    // [47] phi print_char::ch#3 = print_char::ch#2 [phi:print_uchar::@1->print_char#1] -- register_copy 
    jsr print_char
    // print_uchar::@return
    // }
    // [35] return 
    rts
}
  // print_ln
// Print a newline
print_ln: {
    // [37] phi from print_ln print_ln::@1 to print_ln::@1 [phi:print_ln/print_ln::@1->print_ln::@1]
    // [37] phi print_line_cursor#11 = print_line_cursor#21 [phi:print_ln/print_ln::@1->print_ln::@1#0] -- register_copy 
    // print_ln::@1
  __b1:
    // print_line_cursor + $28
    // [38] print_line_cursor#0 = print_line_cursor#11 + $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z print_line_cursor
    sta.z print_line_cursor
    bcc !+
    inc.z print_line_cursor+1
  !:
    // while (print_line_cursor<print_char_cursor)
    // [39] if(print_line_cursor#0<print_char_cursor#30) goto print_ln::@1 -- pbuz1_lt_pbuz2_then_la1 
    lda.z print_line_cursor+1
    cmp.z print_char_cursor+1
    bcc __b1
    bne !+
    lda.z print_line_cursor
    cmp.z print_char_cursor
    bcc __b1
  !:
    // print_ln::@return
    // }
    // [40] return 
    rts
}
  // memset
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// void * memset(void *str, char c, unsigned int num)
memset: {
    .const c = ' '
    .const num = $3e8
    .label str = print_screen
    .label end = str+num
    .label dst = 2
    // [42] phi from memset to memset::@1 [phi:memset->memset::@1]
    // [42] phi memset::dst#2 = (char *)memset::str#0 [phi:memset->memset::@1#0] -- pbuz1=pbuc1 
    lda #<str
    sta.z dst
    lda #>str
    sta.z dst+1
    // memset::@1
  __b1:
    // for(char* dst = str; dst!=end; dst++)
    // [43] if(memset::dst#2!=memset::end#0) goto memset::@2 -- pbuz1_neq_pbuc1_then_la1 
    lda.z dst+1
    cmp #>end
    bne __b2
    lda.z dst
    cmp #<end
    bne __b2
    // memset::@return
    // }
    // [44] return 
    rts
    // memset::@2
  __b2:
    // *dst = c
    // [45] *memset::dst#2 = memset::c#0 -- _deref_pbuz1=vbuc1 
    lda #c
    ldy #0
    sta (dst),y
    // for(char* dst = str; dst!=end; dst++)
    // [46] memset::dst#1 = ++ memset::dst#2 -- pbuz1=_inc_pbuz1 
    inc.z dst
    bne !+
    inc.z dst+1
  !:
    // [42] phi from memset::@2 to memset::@1 [phi:memset::@2->memset::@1]
    // [42] phi memset::dst#2 = memset::dst#1 [phi:memset::@2->memset::@1#0] -- register_copy 
    jmp __b1
}
  // print_char
// Print a single char
// void print_char(__register(A) char ch)
print_char: {
    // *(print_char_cursor++) = ch
    // [48] *print_char_cursor#29 = print_char::ch#3 -- _deref_pbuz1=vbuaa 
    ldy #0
    sta (print_char_cursor),y
    // *(print_char_cursor++) = ch;
    // [49] print_char_cursor#30 = ++ print_char_cursor#29 -- pbuz1=_inc_pbuz1 
    inc.z print_char_cursor
    bne !+
    inc.z print_char_cursor+1
  !:
    // print_char::@return
    // }
    // [50] return 
    rts
}
  // File Data
.segment Data
  print_hextab: .text "0123456789abcdef"
  files: .fill 2*$a, 0

