Fixing pointer increment (struct fileentry*) main::file ← ++ (struct fileentry*) main::file
Identified constant variable (struct fileentry*) filesEnd
Identified constant variable (struct fileentry*) dir
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) @1
Culled Empty Block (label) PrintName::@1

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

(void()) main()
main: scope:[main]  from @2
  (struct fileentry*) main::file#0 ← (struct fileentry*) 0
  to:main::@1
main::@1: scope:[main]  from main main::@7
  (struct fileentry*) main::file#2 ← phi( main/(struct fileentry*) main::file#0 main::@7/(struct fileentry*) main::file#1 )
  (bool~) main::$0 ← (struct fileentry*) main::file#2 != (const struct fileentry*) filesEnd
  if((bool~) main::$0) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  (struct fileentry*) main::file#3 ← phi( main::@1/(struct fileentry*) main::file#2 )
  (struct fileentry*) PrintName::file#0 ← (struct fileentry*) main::file#3
  call PrintName 
  to:main::@7
main::@7: scope:[main]  from main::@2
  (struct fileentry*) main::file#4 ← phi( main::@2/(struct fileentry*) main::file#3 )
  (struct fileentry*) main::file#1 ← (struct fileentry*) main::file#4 + (const byte) SIZEOF_STRUCT_FILEENTRY
  to:main::@1
main::@return: scope:[main]  from main::@1
  return 
  to:@return

(void()) PrintName((struct fileentry*) PrintName::file)
PrintName: scope:[PrintName]  from main::@2
  (struct fileentry*) PrintName::file#1 ← phi( main::@2/(struct fileentry*) PrintName::file#0 )
  (bool~) PrintName::$0 ← (struct fileentry*) PrintName::file#1 == (const struct fileentry*) dir
  (bool~) PrintName::$1 ← ! (bool~) PrintName::$0
  if((bool~) PrintName::$1) goto PrintName::@return
  to:PrintName::@2
PrintName::@2: scope:[PrintName]  from PrintName
  *((byte*)(number) $c7) ← (number) 1
  to:PrintName::@return
PrintName::@return: scope:[PrintName]  from PrintName PrintName::@2
  return 
  to:@return
@2: scope:[]  from @begin
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(void()) PrintName((struct fileentry*) PrintName::file)
(bool~) PrintName::$0
(bool~) PrintName::$1
(label) PrintName::@2
(label) PrintName::@return
(struct fileentry*) PrintName::file
(struct fileentry*) PrintName::file#0
(struct fileentry*) PrintName::file#1
(const byte) SIZEOF_STRUCT_FILEENTRY = (byte) 2
(const struct fileentry*) dir = (struct fileentry*) 0
(byte) fileentry::bError
(byte) fileentry::bFlag
(const struct fileentry*) filesEnd = (struct fileentry*) 0
(void()) main()
(bool~) main::$0
(label) main::@1
(label) main::@2
(label) main::@7
(label) main::@return
(struct fileentry*) main::file
(struct fileentry*) main::file#0
(struct fileentry*) main::file#1
(struct fileentry*) main::file#2
(struct fileentry*) main::file#3
(struct fileentry*) main::file#4

Adding number conversion cast (unumber) 1 in *((byte*)(number) $c7) ← (number) 1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((byte*)(number) $c7) ← (unumber)(number) 1
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 1
Simplifying constant pointer cast (byte*) 199
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [12] (bool~) PrintName::$1 ← (struct fileentry*) PrintName::file#1 != (const struct fileentry*) dir from [11] (bool~) PrintName::$0 ← (struct fileentry*) PrintName::file#1 == (const struct fileentry*) dir
Successful SSA optimization Pass2UnaryNotSimplification
Alias (struct fileentry*) main::file#2 = (struct fileentry*) main::file#3 (struct fileentry*) main::file#4 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (struct fileentry*) PrintName::file#1 (struct fileentry*) PrintName::file#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$0 [3] if((struct fileentry*) main::file#2!=(const struct fileentry*) filesEnd) goto main::@2
Simple Condition (bool~) PrintName::$1 [13] if((struct fileentry*) PrintName::file#0!=(const struct fileentry*) dir) goto PrintName::@return
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const struct fileentry*) main::file#0 = (struct fileentry*) 0
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const struct fileentry*) main::file#0
Constant inlined main::file#0 = (struct fileentry*) 0
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to PrintName:10 

Created 1 initial phi equivalence classes
Coalesced [12] main::file#5 ← main::file#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @3
Renumbering block @2 to @1
Renumbering block main::@7 to main::@3
Renumbering block PrintName::@2 to PrintName::@1
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

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] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@3
  [5] (struct fileentry*) main::file#2 ← phi( main/(struct fileentry*) 0 main::@3/(struct fileentry*) main::file#1 )
  [6] if((struct fileentry*) main::file#2!=(const struct fileentry*) filesEnd) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@1
  [7] return 
  to:@return
main::@2: scope:[main]  from main::@1
  [8] (struct fileentry*) PrintName::file#0 ← (struct fileentry*) main::file#2
  [9] call PrintName 
  to:main::@3
main::@3: scope:[main]  from main::@2
  [10] (struct fileentry*) main::file#1 ← (struct fileentry*) main::file#2 + (const byte) SIZEOF_STRUCT_FILEENTRY
  to:main::@1

(void()) PrintName((struct fileentry*) PrintName::file)
PrintName: scope:[PrintName]  from main::@2
  [11] if((struct fileentry*) PrintName::file#0!=(const struct fileentry*) dir) goto PrintName::@return
  to:PrintName::@1
PrintName::@1: scope:[PrintName]  from PrintName
  [12] *((byte*) 199) ← (byte) 1
  to:PrintName::@return
PrintName::@return: scope:[PrintName]  from PrintName PrintName::@1
  [13] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) PrintName((struct fileentry*) PrintName::file)
(struct fileentry*) PrintName::file
(struct fileentry*) PrintName::file#0 13.0
(byte) fileentry::bError
(byte) fileentry::bFlag
(void()) main()
(struct fileentry*) main::file
(struct fileentry*) main::file#1 22.0
(struct fileentry*) main::file#2 11.0

Initial phi equivalence classes
[ main::file#2 main::file#1 ]
Added variable PrintName::file#0 to live range equivalence class [ PrintName::file#0 ]
Complete equivalence classes
[ main::file#2 main::file#1 ]
[ PrintName::file#0 ]
Allocated zp[2]:2 [ main::file#2 main::file#1 ]
Allocated zp[2]:4 [ PrintName::file#0 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const SIZEOF_STRUCT_FILEENTRY = 2
  .label filesEnd = 0
  .label dir = 0
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label file = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (struct fileentry*) main::file#2 = (struct fileentry*) 0 [phi:main->main::@1#0] -- pssz1=pssc1 
    lda #<0
    sta.z file
    lda #>0
    sta.z file+1
    jmp __b1
    // main::@1
  __b1:
    // [6] if((struct fileentry*) main::file#2!=(const struct fileentry*) filesEnd) goto main::@2 -- pssz1_neq_pssc1_then_la1 
    lda.z file+1
    cmp #>filesEnd
    bne __b2
    lda.z file
    cmp #<filesEnd
    bne __b2
    jmp __breturn
    // main::@return
  __breturn:
    // [7] return 
    rts
    // main::@2
  __b2:
    // [8] (struct fileentry*) PrintName::file#0 ← (struct fileentry*) main::file#2 -- pssz1=pssz2 
    lda.z file
    sta.z PrintName.file
    lda.z file+1
    sta.z PrintName.file+1
    // [9] call PrintName 
    jsr PrintName
    jmp __b3
    // main::@3
  __b3:
    // [10] (struct fileentry*) main::file#1 ← (struct fileentry*) main::file#2 + (const byte) SIZEOF_STRUCT_FILEENTRY -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_FILEENTRY
    clc
    adc.z file
    sta.z file
    bcc !+
    inc.z file+1
  !:
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (struct fileentry*) main::file#2 = (struct fileentry*) main::file#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b1
}
  // PrintName
// PrintName(struct fileentry* zp(4) file)
PrintName: {
    .label file = 4
    // [11] if((struct fileentry*) PrintName::file#0!=(const struct fileentry*) dir) goto PrintName::@return -- pssz1_neq_pssc1_then_la1 
    lda.z file+1
    cmp #>dir
    bne __breturn
    lda.z file
    cmp #<dir
    bne __breturn
    jmp __b1
    // PrintName::@1
  __b1:
    // [12] *((byte*) 199) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta $c7
    jmp __breturn
    // PrintName::@return
  __breturn:
    // [13] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] if((struct fileentry*) main::file#2!=(const struct fileentry*) filesEnd) goto main::@2 [ main::file#2 ] ( main:2 [ main::file#2 ] ) always clobbers reg byte a 
Statement [8] (struct fileentry*) PrintName::file#0 ← (struct fileentry*) main::file#2 [ main::file#2 PrintName::file#0 ] ( main:2 [ main::file#2 PrintName::file#0 ] ) always clobbers reg byte a 
Statement [10] (struct fileentry*) main::file#1 ← (struct fileentry*) main::file#2 + (const byte) SIZEOF_STRUCT_FILEENTRY [ main::file#1 ] ( main:2 [ main::file#1 ] ) always clobbers reg byte a 
Statement [11] if((struct fileentry*) PrintName::file#0!=(const struct fileentry*) dir) goto PrintName::@return [ ] ( main:2::PrintName:9 [ main::file#2 ] ) always clobbers reg byte a 
Statement [12] *((byte*) 199) ← (byte) 1 [ ] ( main:2::PrintName:9 [ main::file#2 ] ) always clobbers reg byte a 
Potential registers zp[2]:2 [ main::file#2 main::file#1 ] : zp[2]:2 , 
Potential registers zp[2]:4 [ PrintName::file#0 ] : zp[2]:4 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 33: zp[2]:2 [ main::file#2 main::file#1 ] 
Uplift Scope [PrintName] 13: zp[2]:4 [ PrintName::file#0 ] 
Uplift Scope [fileentry] 
Uplift Scope [] 

Uplifting [main] best 776 combination zp[2]:2 [ main::file#2 main::file#1 ] 
Uplifting [PrintName] best 776 combination zp[2]:4 [ PrintName::file#0 ] 
Uplifting [fileentry] best 776 combination 
Uplifting [] best 776 combination 
Coalescing zero page register [ zp[2]:2 [ main::file#2 main::file#1 ] ] with [ zp[2]:4 [ PrintName::file#0 ] ] - score: 1

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const SIZEOF_STRUCT_FILEENTRY = 2
  .label filesEnd = 0
  .label dir = 0
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label file = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (struct fileentry*) main::file#2 = (struct fileentry*) 0 [phi:main->main::@1#0] -- pssz1=pssc1 
    lda #<0
    sta.z file
    lda #>0
    sta.z file+1
    jmp __b1
    // main::@1
  __b1:
    // [6] if((struct fileentry*) main::file#2!=(const struct fileentry*) filesEnd) goto main::@2 -- pssz1_neq_pssc1_then_la1 
    lda.z file+1
    cmp #>filesEnd
    bne __b2
    lda.z file
    cmp #<filesEnd
    bne __b2
    jmp __breturn
    // main::@return
  __breturn:
    // [7] return 
    rts
    // main::@2
  __b2:
    // [8] (struct fileentry*) PrintName::file#0 ← (struct fileentry*) main::file#2
    // [9] call PrintName 
    jsr PrintName
    jmp __b3
    // main::@3
  __b3:
    // [10] (struct fileentry*) main::file#1 ← (struct fileentry*) main::file#2 + (const byte) SIZEOF_STRUCT_FILEENTRY -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_FILEENTRY
    clc
    adc.z file
    sta.z file
    bcc !+
    inc.z file+1
  !:
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (struct fileentry*) main::file#2 = (struct fileentry*) main::file#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b1
}
  // PrintName
// PrintName(struct fileentry* zp(2) file)
PrintName: {
    .label file = 2
    // [11] if((struct fileentry*) PrintName::file#0!=(const struct fileentry*) dir) goto PrintName::@return -- pssz1_neq_pssc1_then_la1 
    lda.z file+1
    cmp #>dir
    bne __breturn
    lda.z file
    cmp #<dir
    bne __breturn
    jmp __b1
    // PrintName::@1
  __b1:
    // [12] *((byte*) 199) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta $c7
    jmp __breturn
    // PrintName::@return
  __breturn:
    // [13] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b3
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #>0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b3:
Removing instruction __b1_from___b3:
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) PrintName((struct fileentry*) PrintName::file)
(label) PrintName::@1
(label) PrintName::@return
(struct fileentry*) PrintName::file
(struct fileentry*) PrintName::file#0 file zp[2]:2 13.0
(const byte) SIZEOF_STRUCT_FILEENTRY = (byte) 2
(const struct fileentry*) dir = (struct fileentry*) 0
(byte) fileentry::bError
(byte) fileentry::bFlag
(const struct fileentry*) filesEnd = (struct fileentry*) 0
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(struct fileentry*) main::file
(struct fileentry*) main::file#1 file zp[2]:2 22.0
(struct fileentry*) main::file#2 file zp[2]:2 11.0

zp[2]:2 [ main::file#2 main::file#1 PrintName::file#0 ]


FINAL ASSEMBLER
Score: 528

  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .const SIZEOF_STRUCT_FILEENTRY = 2
  .label filesEnd = 0
  .label dir = 0
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label file = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (struct fileentry*) main::file#2 = (struct fileentry*) 0 [phi:main->main::@1#0] -- pssz1=pssc1 
    lda #<0
    sta.z file
    sta.z file+1
    // main::@1
  __b1:
    // while(file != filesEnd)
    // [6] if((struct fileentry*) main::file#2!=(const struct fileentry*) filesEnd) goto main::@2 -- pssz1_neq_pssc1_then_la1 
    lda.z file+1
    cmp #>filesEnd
    bne __b2
    lda.z file
    cmp #<filesEnd
    bne __b2
    // main::@return
    // }
    // [7] return 
    rts
    // main::@2
  __b2:
    // PrintName(file)
    // [8] (struct fileentry*) PrintName::file#0 ← (struct fileentry*) main::file#2
    // [9] call PrintName 
    jsr PrintName
    // main::@3
    // ++file;
    // [10] (struct fileentry*) main::file#1 ← (struct fileentry*) main::file#2 + (const byte) SIZEOF_STRUCT_FILEENTRY -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_FILEENTRY
    clc
    adc.z file
    sta.z file
    bcc !+
    inc.z file+1
  !:
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [5] phi (struct fileentry*) main::file#2 = (struct fileentry*) main::file#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b1
}
  // PrintName
// PrintName(struct fileentry* zp(2) file)
PrintName: {
    .label file = 2
    // if (file == dir)
    // [11] if((struct fileentry*) PrintName::file#0!=(const struct fileentry*) dir) goto PrintName::@return -- pssz1_neq_pssc1_then_la1 
    lda.z file+1
    cmp #>dir
    bne __breturn
    lda.z file
    cmp #<dir
    bne __breturn
    // PrintName::@1
    // *(BYTE *)0xC7 = 1
    // [12] *((byte*) 199) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta $c7
    // PrintName::@return
  __breturn:
    // }
    // [13] return 
    rts
}
  // File Data

