Fixing pointer addition (struct Setting*~) main::$2 ← (const struct Setting*) settings + (byte) main::len
Fixing pointer increment (struct Setting*) main::setting ← ++ (struct Setting*) main::setting
Replacing struct member reference *((struct Setting*) main::setting).off with member unwinding reference *((byte*~) main::$7)
Replacing struct member reference *((struct Setting*) main::setting).id with member unwinding reference *((byte*~) main::$8)
Warning! Adding boolean cast to non-boolean sub-expression *((byte*~) main::$7)
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@8

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

(void()) main()
main: scope:[main]  from @1
  (byte) main::idx#0 ← (byte) 0
  (byte~) main::$0 ← sizeof  (const struct Setting*) settings
  (byte~) main::$1 ← (byte~) main::$0 / (const byte) SIZEOF_STRUCT_SETTING
  (byte) main::len#0 ← (byte~) main::$1
  (struct Setting*) main::setting#0 ← (const struct Setting*) settings
  to:main::@1
main::@1: scope:[main]  from main main::@4
  (byte) main::idx#4 ← phi( main/(byte) main::idx#0 main::@4/(byte) main::idx#5 )
  (struct Setting*) main::setting#2 ← phi( main/(struct Setting*) main::setting#0 main::@4/(struct Setting*) main::setting#1 )
  (byte) main::len#1 ← phi( main/(byte) main::len#0 main::@4/(byte) main::len#2 )
  (byte~) main::$6 ← (byte) main::len#1 * (const byte) SIZEOF_STRUCT_SETTING
  (struct Setting*~) main::$2 ← (const struct Setting*) settings + (byte~) main::$6
  (bool~) main::$3 ← (struct Setting*) main::setting#2 < (struct Setting*~) main::$2
  if((bool~) main::$3) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  (byte) main::len#3 ← phi( main::@1/(byte) main::len#1 )
  (byte) main::idx#3 ← phi( main::@1/(byte) main::idx#4 )
  (struct Setting*) main::setting#3 ← phi( main::@1/(struct Setting*) main::setting#2 )
  (byte*~) main::$7 ← (byte*)(struct Setting*) main::setting#3 + (const byte) OFFSET_STRUCT_SETTING_OFF
  (bool~) main::$9 ← (number) 0 != *((byte*~) main::$7)
  (bool~) main::$4 ← ! (bool~) main::$9
  (bool~) main::$5 ← ! (bool~) main::$4
  if((bool~) main::$5) goto main::@4
  to:main::@7
main::@4: scope:[main]  from main::@2 main::@7
  (byte) main::idx#5 ← phi( main::@2/(byte) main::idx#3 main::@7/(byte) main::idx#1 )
  (byte) main::len#2 ← phi( main::@2/(byte) main::len#3 main::@7/(byte) main::len#4 )
  (struct Setting*) main::setting#4 ← phi( main::@2/(struct Setting*) main::setting#3 main::@7/(struct Setting*) main::setting#5 )
  (struct Setting*) main::setting#1 ← (struct Setting*) main::setting#4 + (const byte) SIZEOF_STRUCT_SETTING
  to:main::@1
main::@7: scope:[main]  from main::@2
  (byte) main::len#4 ← phi( main::@2/(byte) main::len#3 )
  (byte) main::idx#2 ← phi( main::@2/(byte) main::idx#3 )
  (struct Setting*) main::setting#5 ← phi( main::@2/(struct Setting*) main::setting#3 )
  (byte*~) main::$8 ← (byte*)(struct Setting*) main::setting#5 + (const byte) OFFSET_STRUCT_SETTING_ID
  *((const byte*) SCREEN + (byte) main::idx#2) ← *((byte*~) main::$8)
  (byte) main::idx#1 ← ++ (byte) main::idx#2
  to:main::@4
main::@return: scope:[main]  from main::@1
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(const byte) OFFSET_STRUCT_SETTING_ID = (byte) 1
(const byte) OFFSET_STRUCT_SETTING_OFF = (byte) 0
(const byte*) SCREEN = (byte*)(number) $400
(const byte) SIZEOF_STRUCT_SETTING = (byte) 2
(byte) Setting::id
(byte) Setting::off
(void()) main()
(byte~) main::$0
(byte~) main::$1
(struct Setting*~) main::$2
(bool~) main::$3
(bool~) main::$4
(bool~) main::$5
(byte~) main::$6
(byte*~) main::$7
(byte*~) main::$8
(bool~) main::$9
(label) main::@1
(label) main::@2
(label) main::@4
(label) main::@7
(label) main::@return
(byte) main::idx
(byte) main::idx#0
(byte) main::idx#1
(byte) main::idx#2
(byte) main::idx#3
(byte) main::idx#4
(byte) main::idx#5
(byte) main::len
(byte) main::len#0
(byte) main::len#1
(byte) main::len#2
(byte) main::len#3
(byte) main::len#4
(struct Setting*) main::setting
(struct Setting*) main::setting#0
(struct Setting*) main::setting#1
(struct Setting*) main::setting#2
(struct Setting*) main::setting#3
(struct Setting*) main::setting#4
(struct Setting*) main::setting#5
(const struct Setting*) settings[]  = { { off: (byte) 0, id: (byte) 'a' }, { off: (byte) 1, id: (byte) 'b' }, { off: (byte) 0, id: (byte) 'c' } }

Adding number conversion cast (unumber) 0 in (bool~) main::$9 ← (number) 0 != *((byte*~) main::$7)
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [13] (bool~) main::$4 ← (byte) 0 == *((byte*~) main::$7) from [12] (bool~) main::$9 ← (byte) 0 != *((byte*~) main::$7)
Inversing boolean not [14] (bool~) main::$5 ← (byte) 0 != *((byte*~) main::$7) from [13] (bool~) main::$4 ← (byte) 0 == *((byte*~) main::$7)
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte) main::len#0 = (byte~) main::$1 
Alias (struct Setting*) main::setting#2 = (struct Setting*) main::setting#3 (struct Setting*) main::setting#5 
Alias (byte) main::idx#2 = (byte) main::idx#3 (byte) main::idx#4 
Alias (byte) main::len#1 = (byte) main::len#3 (byte) main::len#4 
Successful SSA optimization Pass2AliasElimination
Alias (struct Setting*) main::setting#2 = (struct Setting*) main::setting#4 
Alias (byte) main::len#1 = (byte) main::len#2 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) main::len#1 (byte) main::len#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$3 [8] if((struct Setting*) main::setting#2<(struct Setting*~) main::$2) goto main::@2
Simple Condition (bool~) main::$5 [11] if((byte) 0!=*((byte*~) main::$7)) goto main::@4
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [1] (byte~) main::$0 ← sizeof  (const struct Setting*) settings
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#0 = 0
Constant (const byte) main::$0 = sizeof settings
Constant (const struct Setting*) main::setting#0 = settings
Successful SSA optimization Pass2ConstantIdentification
Converting *(pointer+n) to pointer[n] [11] if((byte) 0!=*((byte*~) main::$7)) goto main::@4  -- *((byte*)main::setting#2 + OFFSET_STRUCT_SETTING_OFF)
Converting *(pointer+n) to pointer[n] [15] *((const byte*) SCREEN + (byte) main::idx#2) ← *((byte*~) main::$8)  -- *((byte*)main::setting#2 + OFFSET_STRUCT_SETTING_ID)
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero (byte*)main::setting#2 in [9] (byte*~) main::$7 ← (byte*)(struct Setting*) main::setting#2 + (const byte) OFFSET_STRUCT_SETTING_OFF
Simplifying expression containing zero (byte*)main::setting#2 in [11] if((byte) 0!=*((byte*)(struct Setting*) main::setting#2 + (const byte) OFFSET_STRUCT_SETTING_OFF)) goto main::@4
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte*~) main::$7 and assignment [5] (byte*~) main::$7 ← (byte*)(struct Setting*) main::setting#2
Eliminating unused variable (byte*~) main::$8 and assignment [9] (byte*~) main::$8 ← (byte*)(struct Setting*) main::setting#2 + (const byte) OFFSET_STRUCT_SETTING_ID
Eliminating unused constant (const byte) OFFSET_STRUCT_SETTING_OFF
Successful SSA optimization PassNEliminateUnusedVars
Resolving array sizeof() sizeof (const struct Setting*) settings
Successful SSA optimization PassNSizeOfSimplification
Constant right-side identified [0] (byte) main::len#0 ← (const byte) main::$0 / (const byte) SIZEOF_STRUCT_SETTING
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::len#0 = main::$0/SIZEOF_STRUCT_SETTING
Successful SSA optimization Pass2ConstantIdentification
Adding number conversion cast (unumber) 3 in 
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 3
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [1] (byte~) main::$6 ← (const byte) main::len#0 * (const byte) SIZEOF_STRUCT_SETTING
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$6 = main::len#0*SIZEOF_STRUCT_SETTING
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [1] (struct Setting*~) main::$2 ← (const struct Setting*) settings + (const byte) main::$6
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const struct Setting*) main::$2 = settings+main::$6
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) main::idx#0
Inlining constant with var siblings (const struct Setting*) main::setting#0
Constant inlined main::$6 = (const byte) main::len#0*(const byte) SIZEOF_STRUCT_SETTING
Constant inlined main::idx#0 = (byte) 0
Constant inlined main::setting#0 = (const struct Setting*) settings
Constant inlined main::$2 = (const struct Setting*) settings+(const byte) main::len#0*(const byte) SIZEOF_STRUCT_SETTING
Constant inlined main::$0 = (byte) 3*(const byte) SIZEOF_STRUCT_SETTING
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@9(between main::@2 and main::@4)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2 

Created 3 initial phi equivalence classes
Coalesced [12] main::idx#8 ← main::idx#1
Coalesced [15] main::setting#6 ← main::setting#1
Coalesced [16] main::idx#6 ← main::idx#5
Coalesced (already) [17] main::idx#7 ← main::idx#2
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@9
Renumbering block main::@4 to main::@3
Renumbering block main::@7 to main::@4
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] (byte) main::idx#2 ← phi( main/(byte) 0 main::@3/(byte) main::idx#5 )
  [5] (struct Setting*) main::setting#2 ← phi( main/(const struct Setting*) settings main::@3/(struct Setting*) main::setting#1 )
  [6] if((struct Setting*) main::setting#2<(const struct Setting*) settings+(const byte) main::len#0*(const byte) SIZEOF_STRUCT_SETTING) 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] if((byte) 0!=*((byte*)(struct Setting*) main::setting#2)) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@2
  [9] *((const byte*) SCREEN + (byte) main::idx#2) ← *((byte*)(struct Setting*) main::setting#2 + (const byte) OFFSET_STRUCT_SETTING_ID)
  [10] (byte) main::idx#1 ← ++ (byte) main::idx#2
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@4
  [11] (byte) main::idx#5 ← phi( main::@2/(byte) main::idx#2 main::@4/(byte) main::idx#1 )
  [12] (struct Setting*) main::setting#1 ← (struct Setting*) main::setting#2 + (const byte) SIZEOF_STRUCT_SETTING
  to:main::@1


VARIABLE REGISTER WEIGHTS
(byte) Setting::id
(byte) Setting::off
(void()) main()
(byte) main::idx
(byte) main::idx#1 22.0
(byte) main::idx#2 11.0
(byte) main::idx#5 16.5
(byte) main::len
(struct Setting*) main::setting
(struct Setting*) main::setting#1 22.0
(struct Setting*) main::setting#2 5.5

Initial phi equivalence classes
[ main::setting#2 main::setting#1 ]
[ main::idx#2 main::idx#5 main::idx#1 ]
Complete equivalence classes
[ main::setting#2 main::setting#1 ]
[ main::idx#2 main::idx#5 main::idx#1 ]
Allocated zp[2]:2 [ main::setting#2 main::setting#1 ]
Allocated zp[1]:4 [ main::idx#2 main::idx#5 main::idx#1 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Demonstrates problem with conditions using negated struct references
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .const SIZEOF_STRUCT_SETTING = 2
  .const OFFSET_STRUCT_SETTING_ID = 1
  // @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: {
    .const len = 3*SIZEOF_STRUCT_SETTING/SIZEOF_STRUCT_SETTING
    .label setting = 2
    .label idx = 4
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::idx#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z idx
    // [5] phi (struct Setting*) main::setting#2 = (const struct Setting*) settings [phi:main->main::@1#1] -- pssz1=pssc1 
    lda #<settings
    sta.z setting
    lda #>settings
    sta.z setting+1
    jmp __b1
    // main::@1
  __b1:
    // [6] if((struct Setting*) main::setting#2<(const struct Setting*) settings+(const byte) main::len#0*(const byte) SIZEOF_STRUCT_SETTING) goto main::@2 -- pssz1_lt_pssc1_then_la1 
    lda.z setting+1
    cmp #>settings+len*SIZEOF_STRUCT_SETTING
    bcc __b2
    bne !+
    lda.z setting
    cmp #<settings+len*SIZEOF_STRUCT_SETTING
    bcc __b2
  !:
    jmp __breturn
    // main::@return
  __breturn:
    // [7] return 
    rts
    // main::@2
  __b2:
    // [8] if((byte) 0!=*((byte*)(struct Setting*) main::setting#2)) goto main::@3 -- vbuc1_neq__deref_pbuz1_then_la1 
    ldy #0
    lda (setting),y
    cmp #0
    bne __b3_from___b2
    jmp __b4
    // main::@4
  __b4:
    // [9] *((const byte*) SCREEN + (byte) main::idx#2) ← *((byte*)(struct Setting*) main::setting#2 + (const byte) OFFSET_STRUCT_SETTING_ID) -- pbuc1_derefidx_vbuz1=pbuz2_derefidx_vbuc2 
    ldx.z idx
    ldy #OFFSET_STRUCT_SETTING_ID
    lda (setting),y
    sta SCREEN,x
    // [10] (byte) main::idx#1 ← ++ (byte) main::idx#2 -- vbuz1=_inc_vbuz1 
    inc.z idx
    // [11] phi from main::@2 main::@4 to main::@3 [phi:main::@2/main::@4->main::@3]
  __b3_from___b2:
  __b3_from___b4:
    // [11] phi (byte) main::idx#5 = (byte) main::idx#2 [phi:main::@2/main::@4->main::@3#0] -- register_copy 
    jmp __b3
    // main::@3
  __b3:
    // [12] (struct Setting*) main::setting#1 ← (struct Setting*) main::setting#2 + (const byte) SIZEOF_STRUCT_SETTING -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_SETTING
    clc
    adc.z setting
    sta.z setting
    bcc !+
    inc.z setting+1
  !:
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (byte) main::idx#2 = (byte) main::idx#5 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (struct Setting*) main::setting#2 = (struct Setting*) main::setting#1 [phi:main::@3->main::@1#1] -- register_copy 
    jmp __b1
}
  // File Data
  settings: .byte 0, 'a', 1, 'b', 0, 'c'

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] if((struct Setting*) main::setting#2<(const struct Setting*) settings+(const byte) main::len#0*(const byte) SIZEOF_STRUCT_SETTING) goto main::@2 [ main::setting#2 main::idx#2 ] ( main:2 [ main::setting#2 main::idx#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:4 [ main::idx#2 main::idx#5 main::idx#1 ]
Statement [8] if((byte) 0!=*((byte*)(struct Setting*) main::setting#2)) goto main::@3 [ main::setting#2 main::idx#2 ] ( main:2 [ main::setting#2 main::idx#2 ] ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte y as potential for zp[1]:4 [ main::idx#2 main::idx#5 main::idx#1 ]
Statement [9] *((const byte*) SCREEN + (byte) main::idx#2) ← *((byte*)(struct Setting*) main::setting#2 + (const byte) OFFSET_STRUCT_SETTING_ID) [ main::setting#2 main::idx#2 ] ( main:2 [ main::setting#2 main::idx#2 ] ) always clobbers reg byte a reg byte y 
Statement [12] (struct Setting*) main::setting#1 ← (struct Setting*) main::setting#2 + (const byte) SIZEOF_STRUCT_SETTING [ main::setting#1 main::idx#5 ] ( main:2 [ main::setting#1 main::idx#5 ] ) always clobbers reg byte a 
Statement [6] if((struct Setting*) main::setting#2<(const struct Setting*) settings+(const byte) main::len#0*(const byte) SIZEOF_STRUCT_SETTING) goto main::@2 [ main::setting#2 main::idx#2 ] ( main:2 [ main::setting#2 main::idx#2 ] ) always clobbers reg byte a 
Statement [8] if((byte) 0!=*((byte*)(struct Setting*) main::setting#2)) goto main::@3 [ main::setting#2 main::idx#2 ] ( main:2 [ main::setting#2 main::idx#2 ] ) always clobbers reg byte a reg byte y 
Statement [9] *((const byte*) SCREEN + (byte) main::idx#2) ← *((byte*)(struct Setting*) main::setting#2 + (const byte) OFFSET_STRUCT_SETTING_ID) [ main::setting#2 main::idx#2 ] ( main:2 [ main::setting#2 main::idx#2 ] ) always clobbers reg byte a reg byte y 
Statement [12] (struct Setting*) main::setting#1 ← (struct Setting*) main::setting#2 + (const byte) SIZEOF_STRUCT_SETTING [ main::setting#1 main::idx#5 ] ( main:2 [ main::setting#1 main::idx#5 ] ) always clobbers reg byte a 
Potential registers zp[2]:2 [ main::setting#2 main::setting#1 ] : zp[2]:2 , 
Potential registers zp[1]:4 [ main::idx#2 main::idx#5 main::idx#1 ] : zp[1]:4 , reg byte x , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 49.5: zp[1]:4 [ main::idx#2 main::idx#5 main::idx#1 ] 27.5: zp[2]:2 [ main::setting#2 main::setting#1 ] 
Uplift Scope [Setting] 
Uplift Scope [] 

Uplifting [main] best 903 combination reg byte x [ main::idx#2 main::idx#5 main::idx#1 ] zp[2]:2 [ main::setting#2 main::setting#1 ] 
Uplifting [Setting] best 903 combination 
Uplifting [] best 903 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Demonstrates problem with conditions using negated struct references
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .const SIZEOF_STRUCT_SETTING = 2
  .const OFFSET_STRUCT_SETTING_ID = 1
  // @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: {
    .const len = 3*SIZEOF_STRUCT_SETTING/SIZEOF_STRUCT_SETTING
    .label setting = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::idx#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi (struct Setting*) main::setting#2 = (const struct Setting*) settings [phi:main->main::@1#1] -- pssz1=pssc1 
    lda #<settings
    sta.z setting
    lda #>settings
    sta.z setting+1
    jmp __b1
    // main::@1
  __b1:
    // [6] if((struct Setting*) main::setting#2<(const struct Setting*) settings+(const byte) main::len#0*(const byte) SIZEOF_STRUCT_SETTING) goto main::@2 -- pssz1_lt_pssc1_then_la1 
    lda.z setting+1
    cmp #>settings+len*SIZEOF_STRUCT_SETTING
    bcc __b2
    bne !+
    lda.z setting
    cmp #<settings+len*SIZEOF_STRUCT_SETTING
    bcc __b2
  !:
    jmp __breturn
    // main::@return
  __breturn:
    // [7] return 
    rts
    // main::@2
  __b2:
    // [8] if((byte) 0!=*((byte*)(struct Setting*) main::setting#2)) goto main::@3 -- vbuc1_neq__deref_pbuz1_then_la1 
    ldy #0
    lda (setting),y
    cmp #0
    bne __b3_from___b2
    jmp __b4
    // main::@4
  __b4:
    // [9] *((const byte*) SCREEN + (byte) main::idx#2) ← *((byte*)(struct Setting*) main::setting#2 + (const byte) OFFSET_STRUCT_SETTING_ID) -- pbuc1_derefidx_vbuxx=pbuz1_derefidx_vbuc2 
    ldy #OFFSET_STRUCT_SETTING_ID
    lda (setting),y
    sta SCREEN,x
    // [10] (byte) main::idx#1 ← ++ (byte) main::idx#2 -- vbuxx=_inc_vbuxx 
    inx
    // [11] phi from main::@2 main::@4 to main::@3 [phi:main::@2/main::@4->main::@3]
  __b3_from___b2:
  __b3_from___b4:
    // [11] phi (byte) main::idx#5 = (byte) main::idx#2 [phi:main::@2/main::@4->main::@3#0] -- register_copy 
    jmp __b3
    // main::@3
  __b3:
    // [12] (struct Setting*) main::setting#1 ← (struct Setting*) main::setting#2 + (const byte) SIZEOF_STRUCT_SETTING -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_SETTING
    clc
    adc.z setting
    sta.z setting
    bcc !+
    inc.z setting+1
  !:
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (byte) main::idx#2 = (byte) main::idx#5 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (struct Setting*) main::setting#2 = (struct Setting*) main::setting#1 [phi:main::@3->main::@1#1] -- register_copy 
    jmp __b1
}
  // File Data
  settings: .byte 0, 'a', 1, 'b', 0, 'c'

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b4
Removing instruction jmp __b3
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b3_from___b2 with __b3
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b3_from___b2:
Removing instruction __b3_from___b4:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b4:
Removing instruction __b1_from___b3:
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
(const byte) OFFSET_STRUCT_SETTING_ID = (byte) 1
(const byte*) SCREEN = (byte*) 1024
(const byte) SIZEOF_STRUCT_SETTING = (byte) 2
(byte) Setting::id
(byte) Setting::off
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@return
(byte) main::idx
(byte) main::idx#1 reg byte x 22.0
(byte) main::idx#2 reg byte x 11.0
(byte) main::idx#5 reg byte x 16.5
(byte) main::len
(const byte) main::len#0 len = (byte) 3*(const byte) SIZEOF_STRUCT_SETTING/(const byte) SIZEOF_STRUCT_SETTING
(struct Setting*) main::setting
(struct Setting*) main::setting#1 setting zp[2]:2 22.0
(struct Setting*) main::setting#2 setting zp[2]:2 5.5
(const struct Setting*) settings[]  = { { off: (byte) 0, id: (byte) 'a' }, { off: (byte) 1, id: (byte) 'b' }, { off: (byte) 0, id: (byte) 'c' } }

zp[2]:2 [ main::setting#2 main::setting#1 ]
reg byte x [ main::idx#2 main::idx#5 main::idx#1 ]


FINAL ASSEMBLER
Score: 771

  // File Comments
// Demonstrates problem with conditions using negated struct references
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .const SIZEOF_STRUCT_SETTING = 2
  .const OFFSET_STRUCT_SETTING_ID = 1
  // @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: {
    .const len = 3*SIZEOF_STRUCT_SETTING/SIZEOF_STRUCT_SETTING
    .label setting = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::idx#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi (struct Setting*) main::setting#2 = (const struct Setting*) settings [phi:main->main::@1#1] -- pssz1=pssc1 
    lda #<settings
    sta.z setting
    lda #>settings
    sta.z setting+1
    // main::@1
  __b1:
    // for(struct Setting* setting = settings; setting<settings+len; setting++)
    // [6] if((struct Setting*) main::setting#2<(const struct Setting*) settings+(const byte) main::len#0*(const byte) SIZEOF_STRUCT_SETTING) goto main::@2 -- pssz1_lt_pssc1_then_la1 
    lda.z setting+1
    cmp #>settings+len*SIZEOF_STRUCT_SETTING
    bcc __b2
    bne !+
    lda.z setting
    cmp #<settings+len*SIZEOF_STRUCT_SETTING
    bcc __b2
  !:
    // main::@return
    // }
    // [7] return 
    rts
    // main::@2
  __b2:
    // if (! setting->off)
    // [8] if((byte) 0!=*((byte*)(struct Setting*) main::setting#2)) goto main::@3 -- vbuc1_neq__deref_pbuz1_then_la1 
    ldy #0
    lda (setting),y
    cmp #0
    bne __b3
    // main::@4
    // SCREEN[idx++] = setting->id
    // [9] *((const byte*) SCREEN + (byte) main::idx#2) ← *((byte*)(struct Setting*) main::setting#2 + (const byte) OFFSET_STRUCT_SETTING_ID) -- pbuc1_derefidx_vbuxx=pbuz1_derefidx_vbuc2 
    ldy #OFFSET_STRUCT_SETTING_ID
    lda (setting),y
    sta SCREEN,x
    // SCREEN[idx++] = setting->id;
    // [10] (byte) main::idx#1 ← ++ (byte) main::idx#2 -- vbuxx=_inc_vbuxx 
    inx
    // [11] phi from main::@2 main::@4 to main::@3 [phi:main::@2/main::@4->main::@3]
    // [11] phi (byte) main::idx#5 = (byte) main::idx#2 [phi:main::@2/main::@4->main::@3#0] -- register_copy 
    // main::@3
  __b3:
    // for(struct Setting* setting = settings; setting<settings+len; setting++)
    // [12] (struct Setting*) main::setting#1 ← (struct Setting*) main::setting#2 + (const byte) SIZEOF_STRUCT_SETTING -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_SETTING
    clc
    adc.z setting
    sta.z setting
    bcc !+
    inc.z setting+1
  !:
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [5] phi (byte) main::idx#2 = (byte) main::idx#5 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (struct Setting*) main::setting#2 = (struct Setting*) main::setting#1 [phi:main::@3->main::@1#1] -- register_copy 
    jmp __b1
}
  // File Data
  settings: .byte 0, 'a', 1, 'b', 0, 'c'

