Setting inferred volatile on symbol affected by address-of: fgetc::channel in asm { ldxchannel jsrCHKIN jsrGETIN staret jsrCLRCHN  }
Setting inferred volatile on symbol affected by address-of: fgetc::ret in asm { ldxchannel jsrCHKIN jsrGETIN staret jsrCLRCHN  }
Eliminating unused variable with no statement main::$0

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  fgetc::channel = 7
  call fgetc
  fgetc::return#0 = fgetc::return#2
  to:main::@1
main::@1: scope:[main]  from main
  fgetc::return#3 = phi( main/fgetc::return#0 )
  main::x#0 = fgetc::return#3
  *main::SCREEN = main::x#0
  to:main::@return
main::@return: scope:[main]  from main::@1
  return 
  to:@return

char fgetc(volatile char channel)
fgetc: scope:[fgetc]  from main
  fgetc::ret = 0
  asm { ldxchannel jsrCHKIN jsrGETIN staret jsrCLRCHN  }
  fgetc::return#1 = fgetc::ret
  to:fgetc::@return
fgetc::@return: scope:[fgetc]  from fgetc
  fgetc::return#4 = phi( fgetc/fgetc::return#1 )
  fgetc::return#2 = fgetc::return#4
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  call main
  to:__start::@1
__start::@1: scope:[__start]  from __start
  to:__start::@return
__start::@return: scope:[__start]  from __start::@1
  return 
  to:@return

SYMBOL TABLE SSA
__constant char * const CHKIN = (char *)$1000
__constant char * const CLRCHN = (char *)$1006
__constant char * const GETIN = (char *)$1003
void __start()
char fgetc(volatile char channel)
__loadstore volatile char fgetc::channel
__loadstore volatile char fgetc::ret
char fgetc::return
char fgetc::return#0
char fgetc::return#1
char fgetc::return#2
char fgetc::return#3
char fgetc::return#4
void main()
__constant char * const main::SCREEN = (char *)$1009
char main::x
char main::x#0

Adding number conversion cast (unumber) 7 in fgetc::channel = 7
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast fgetc::channel = (unumber)7
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 4105
Simplifying constant pointer cast (char *) 4096
Simplifying constant pointer cast (char *) 4099
Simplifying constant pointer cast (char *) 4102
Simplifying constant integer cast 7
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 7
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias candidate removed (volatile)fgetc::return#1 = fgetc::ret fgetc::return#4 fgetc::return#2 
Alias fgetc::return#0 = fgetc::return#3 
Successful SSA optimization Pass2AliasElimination
Alias candidate removed (volatile)fgetc::return#1 = fgetc::ret fgetc::return#4 fgetc::return#2 
Identical Phi Values fgetc::return#4 fgetc::return#1
Successful SSA optimization Pass2IdenticalPhiElimination
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Alias candidate removed (volatile)fgetc::return#1 = fgetc::ret fgetc::return#2 
Alias candidate removed (volatile)fgetc::return#1 = fgetc::ret fgetc::return#2 
Alias candidate removed (volatile)fgetc::return#1 = fgetc::ret fgetc::return#2 
CALL GRAPH
Calls in [main] to fgetc:1 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] fgetc::channel = 7
  [1] call fgetc
  [2] fgetc::return#0 = fgetc::return#2
  to:main::@1
main::@1: scope:[main]  from main
  [3] main::x#0 = fgetc::return#0
  [4] *main::SCREEN = main::x#0
  to:main::@return
main::@return: scope:[main]  from main::@1
  [5] return 
  to:@return

char fgetc(volatile char channel)
fgetc: scope:[fgetc]  from main
  [6] fgetc::ret = 0
  asm { ldxchannel jsrCHKIN jsrGETIN staret jsrCLRCHN  }
  [8] fgetc::return#1 = fgetc::ret
  to:fgetc::@return
fgetc::@return: scope:[fgetc]  from fgetc
  [9] fgetc::return#2 = fgetc::return#1
  [10] return 
  to:@return


VARIABLE REGISTER WEIGHTS
char fgetc(volatile char channel)
__loadstore volatile char fgetc::channel // 1.0
__loadstore volatile char fgetc::ret // 11.0
char fgetc::return
char fgetc::return#0 // 4.0
char fgetc::return#1 // 22.0
char fgetc::return#2 // 4.333333333333333
void main()
char main::x
char main::x#0 // 4.0

Initial phi equivalence classes
Added variable fgetc::channel to live range equivalence class [ fgetc::channel ]
Added variable fgetc::return#0 to live range equivalence class [ fgetc::return#0 ]
Added variable main::x#0 to live range equivalence class [ main::x#0 ]
Added variable fgetc::ret to live range equivalence class [ fgetc::ret ]
Added variable fgetc::return#1 to live range equivalence class [ fgetc::return#1 ]
Added variable fgetc::return#2 to live range equivalence class [ fgetc::return#2 ]
Complete equivalence classes
[ fgetc::channel ]
[ fgetc::return#0 ]
[ main::x#0 ]
[ fgetc::ret ]
[ fgetc::return#1 ]
[ fgetc::return#2 ]
Allocated zp[1]:2 [ fgetc::return#1 ]
Allocated zp[1]:3 [ fgetc::ret ]
Allocated zp[1]:4 [ fgetc::return#2 ]
Allocated zp[1]:5 [ fgetc::return#0 ]
Allocated zp[1]:6 [ main::x#0 ]
Allocated zp[1]:7 [ fgetc::channel ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] fgetc::channel = 7 [ fgetc::channel ] (  [ fgetc::channel ] { { fgetc::return#0 = fgetc::return#2 } }  ) always clobbers reg byte a 
Statement [6] fgetc::ret = 0 [ fgetc::channel fgetc::ret ] ( fgetc:1 [ fgetc::channel fgetc::ret ] { { fgetc::return#0 = fgetc::return#2 } }  ) always clobbers reg byte a 
Statement asm { ldxchannel jsrCHKIN jsrGETIN staret jsrCLRCHN  } always clobbers reg byte a reg byte x reg byte y 
Potential registers zp[1]:7 [ fgetc::channel ] : zp[1]:7 , 
Potential registers zp[1]:5 [ fgetc::return#0 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:6 [ main::x#0 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ fgetc::ret ] : zp[1]:3 , 
Potential registers zp[1]:2 [ fgetc::return#1 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ fgetc::return#2 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [fgetc] 22: zp[1]:2 [ fgetc::return#1 ] 11: zp[1]:3 [ fgetc::ret ] 4.33: zp[1]:4 [ fgetc::return#2 ] 4: zp[1]:5 [ fgetc::return#0 ] 1: zp[1]:7 [ fgetc::channel ] 
Uplift Scope [main] 4: zp[1]:6 [ main::x#0 ] 
Uplift Scope [] 

Uplifting [fgetc] best 76 combination reg byte a [ fgetc::return#1 ] zp[1]:3 [ fgetc::ret ] reg byte a [ fgetc::return#2 ] reg byte a [ fgetc::return#0 ] zp[1]:7 [ fgetc::channel ] 
Uplifting [main] best 70 combination reg byte a [ main::x#0 ] 
Uplifting [] best 70 combination 
Attempting to uplift remaining variables inzp[1]:3 [ fgetc::ret ]
Uplifting [fgetc] best 70 combination zp[1]:3 [ fgetc::ret ] 
Attempting to uplift remaining variables inzp[1]:7 [ fgetc::channel ]
Uplifting [fgetc] best 70 combination zp[1]:7 [ fgetc::channel ] 
Allocated (was zp[1]:3) zp[1]:2 [ fgetc::ret ]
Allocated (was zp[1]:7) zp[1]:3 [ fgetc::channel ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Demonstrates inline ASM using a variable (res)
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-asm-uses-1.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 CHKIN = $1000
  .label GETIN = $1003
  .label CLRCHN = $1006
.segment Code
  // main
main: {
    .label SCREEN = $1009
    // [0] fgetc::channel = 7 -- vbuz1=vbuc1 
    lda #7
    sta.z fgetc.channel
    // [1] call fgetc
    jsr fgetc
    // [2] fgetc::return#0 = fgetc::return#2
    jmp __b1
    // main::@1
  __b1:
    // [3] main::x#0 = fgetc::return#0
    // [4] *main::SCREEN = main::x#0 -- _deref_pbuc1=vbuaa 
    sta SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [5] return 
    rts
}
  // fgetc
// __register(A) char fgetc(__zp(3) volatile char channel)
fgetc: {
    .label channel = 3
    .label ret = 2
    // [6] fgetc::ret = 0 -- vbuz1=vbuc1 
    lda #0
    sta.z ret
    // asm { ldxchannel jsrCHKIN jsrGETIN staret jsrCLRCHN  }
    ldx channel
    jsr CHKIN
    jsr GETIN
    sta ret
    jsr CLRCHN
    // [8] fgetc::return#1 = fgetc::ret -- vbuaa=vbuz1 
    lda.z ret
    jmp __breturn
    // fgetc::@return
  __breturn:
    // [9] fgetc::return#2 = fgetc::return#1
    // [10] return 
    rts
}
  // File Data

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

FINAL SYMBOL TABLE
__constant char * const CHKIN = (char *) 4096
__constant char * const CLRCHN = (char *) 4102
__constant char * const GETIN = (char *) 4099
char fgetc(volatile char channel)
__loadstore volatile char fgetc::channel // zp[1]:3 1.0
__loadstore volatile char fgetc::ret // zp[1]:2 11.0
char fgetc::return
char fgetc::return#0 // reg byte a 4.0
char fgetc::return#1 // reg byte a 22.0
char fgetc::return#2 // reg byte a 4.333333333333333
void main()
__constant char * const main::SCREEN = (char *) 4105
char main::x
char main::x#0 // reg byte a 4.0

zp[1]:3 [ fgetc::channel ]
reg byte a [ fgetc::return#0 ]
reg byte a [ main::x#0 ]
zp[1]:2 [ fgetc::ret ]
reg byte a [ fgetc::return#1 ]
reg byte a [ fgetc::return#2 ]


FINAL ASSEMBLER
Score: 61

  // File Comments
// Demonstrates inline ASM using a variable (res)
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-asm-uses-1.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 CHKIN = $1000
  .label GETIN = $1003
  .label CLRCHN = $1006
.segment Code
  // main
main: {
    .label SCREEN = $1009
    // char x = fgetc(7)
    // [0] fgetc::channel = 7 -- vbuz1=vbuc1 
    lda #7
    sta.z fgetc.channel
    // [1] call fgetc
    jsr fgetc
    // [2] fgetc::return#0 = fgetc::return#2
    // main::@1
    // [3] main::x#0 = fgetc::return#0
    // *SCREEN = x
    // [4] *main::SCREEN = main::x#0 -- _deref_pbuc1=vbuaa 
    sta SCREEN
    // main::@return
    // }
    // [5] return 
    rts
}
  // fgetc
// __register(A) char fgetc(__zp(3) volatile char channel)
fgetc: {
    .label channel = 3
    .label ret = 2
    // char ret
    // [6] fgetc::ret = 0 -- vbuz1=vbuc1 
    lda #0
    sta.z ret
    // asm
    // asm { ldxchannel jsrCHKIN jsrGETIN staret jsrCLRCHN  }
    ldx channel
    jsr CHKIN
    jsr GETIN
    sta ret
    jsr CLRCHN
    // return ret;
    // [8] fgetc::return#1 = fgetc::ret -- vbuaa=vbuz1 
    lda.z ret
    // fgetc::@return
    // }
    // [9] fgetc::return#2 = fgetc::return#1
    // [10] return 
    rts
}
  // File Data

