1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-18 04:08:58 +00:00
kickc/src/test/ref/index-sizeof-reuse.log

1252 lines
63 KiB
Plaintext
Raw Normal View History

CONTROL FLOW GRAPH SSA
(void()) main()
main: scope:[main] from __start
asm { sei }
(signed byte) main::v#0 ← (signed byte) -1
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@2
(signed byte) main::v#3 ← phi( main/(signed byte) main::v#0 main::@2/(signed byte) main::v#1 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
(bool~) main::$0 ← (byte) main::i#2 < (number) $19
if((bool~) main::$0) goto main::@2
to:main::@3
main::@2: scope:[main] from main::@1
(signed byte) main::v#2 ← phi( main::@1/(signed byte) main::v#3 )
(byte) main::i#3 ← phi( main::@1/(byte) main::i#2 )
(byte~) main::$9 ← (byte) main::i#3 * (const byte) SIZEOF_STRUCT_ENTITY
*((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$9) ← (signed byte)(byte) main::i#3
(byte~) main::$10 ← (byte) main::i#3 * (const byte) SIZEOF_STRUCT_ENTITY
*((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$10) ← (signed byte) main::v#2
(byte~) main::$11 ← (byte) main::i#3 * (const byte) SIZEOF_STRUCT_ENTITY
*((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$11) ← (byte) main::i#3
(signed byte~) main::$1 ← - (signed byte) main::v#2
(signed byte) main::v#1 ← (signed byte~) main::$1
(byte) main::i#1 ← ++ (byte) main::i#3
to:main::@1
main::@3: scope:[main] from main::@1 main::@8
(bool~) main::$20 ← (number) 0 != (number) 1
if((bool~) main::$20) goto main::@4
to:main::@return
main::@4: scope:[main] from main::@3 main::@4
(bool~) main::$2 ← *((const nomodify byte*) VIC_RASTER) != (number) $ff
if((bool~) main::$2) goto main::@4
to:main::@5
main::@5: scope:[main] from main::@4
*((const nomodify byte*) VIC_BG_COLOR) ← (number) 0
(byte*) main::line#0 ← (const nomodify byte*) SCREEN
(byte) main::i1#0 ← (byte) 0
to:main::@6
main::@6: scope:[main] from main::@5 main::@9
(byte*) main::line#4 ← phi( main::@5/(byte*) main::line#0 main::@9/(byte*) main::line#1 )
(byte) main::i1#2 ← phi( main::@5/(byte) main::i1#0 main::@9/(byte) main::i1#1 )
(bool~) main::$3 ← (byte) main::i1#2 < (number) $19
if((bool~) main::$3) goto main::@7
to:main::@8
main::@7: scope:[main] from main::@6
(byte*) main::line#2 ← phi( main::@6/(byte*) main::line#4 )
(byte) main::i1#3 ← phi( main::@6/(byte) main::i1#2 )
(byte~) main::$12 ← (byte) main::i1#3 * (const byte) SIZEOF_STRUCT_ENTITY
*((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$12)) ← (byte) ' '
(byte~) main::$13 ← (byte) main::i1#3 * (const byte) SIZEOF_STRUCT_ENTITY
*((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$13) ← *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$13) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$13)
(byte~) main::$14 ← (byte) main::i1#3 * (const byte) SIZEOF_STRUCT_ENTITY
(bool~) main::$4 ← *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$14) < (number) 0
(byte~) main::$15 ← (byte) main::i1#3 * (const byte) SIZEOF_STRUCT_ENTITY
(bool~) main::$5 ← *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$15) > (number) $27
(bool~) main::$6 ← (bool~) main::$4 || (bool~) main::$5
(bool~) main::$7 ← ! (bool~) main::$6
if((bool~) main::$7) goto main::@9
to:main::@10
main::@8: scope:[main] from main::@6
*((const nomodify byte*) VIC_BG_COLOR) ← (number) $f
to:main::@3
main::@9: scope:[main] from main::@10 main::@7
(byte*) main::line#3 ← phi( main::@10/(byte*) main::line#5 main::@7/(byte*) main::line#2 )
(byte) main::i1#4 ← phi( main::@10/(byte) main::i1#5 main::@7/(byte) main::i1#3 )
(byte~) main::$16 ← (byte) main::i1#4 * (const byte) SIZEOF_STRUCT_ENTITY
*((byte*) main::line#3 + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$16)) ← *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$16)
(byte*) main::line#1 ← (byte*) main::line#3 + (number) $28
(byte) main::i1#1 ← ++ (byte) main::i1#4
to:main::@6
main::@10: scope:[main] from main::@7
(byte*) main::line#5 ← phi( main::@7/(byte*) main::line#2 )
(byte) main::i1#5 ← phi( main::@7/(byte) main::i1#3 )
(byte~) main::$17 ← (byte) main::i1#5 * (const byte) SIZEOF_STRUCT_ENTITY
(signed byte~) main::$8 ← - *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$17)
(byte~) main::$18 ← (byte) main::i1#5 * (const byte) SIZEOF_STRUCT_ENTITY
*((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) ← (signed byte~) main::$8
(byte~) main::$19 ← (byte) main::i1#5 * (const byte) SIZEOF_STRUCT_ENTITY
*((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$19) ← *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$19) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$19)
to:main::@9
main::@return: scope:[main] from main::@3
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
(byte) Entity::symbol
(signed byte) Entity::x_pos
(signed byte) Entity::x_vel
(const byte) OFFSET_STRUCT_ENTITY_SYMBOL = (byte) 2
(const byte) OFFSET_STRUCT_ENTITY_X_POS = (byte) 0
(const byte) OFFSET_STRUCT_ENTITY_X_VEL = (byte) 1
(const nomodify byte*) SCREEN = (byte*)(number) $400
(const byte) SIZEOF_STRUCT_ENTITY = (byte) 3
(const nomodify byte*) VIC_BG_COLOR = (byte*)(number) $d020
(const nomodify byte*) VIC_RASTER = (byte*)(number) $d012
(void()) __start()
(label) __start::@1
(label) __start::@return
(const struct Entity*) entities[(number) $19] = { fill( $19, 0) }
(void()) main()
(bool~) main::$0
(signed byte~) main::$1
(byte~) main::$10
(byte~) main::$11
(byte~) main::$12
(byte~) main::$13
(byte~) main::$14
(byte~) main::$15
(byte~) main::$16
(byte~) main::$17
(byte~) main::$18
(byte~) main::$19
(bool~) main::$2
(bool~) main::$20
(bool~) main::$3
(bool~) main::$4
(bool~) main::$5
(bool~) main::$6
(bool~) main::$7
(signed byte~) main::$8
(byte~) main::$9
(label) main::@1
(label) main::@10
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@7
(label) main::@8
(label) main::@9
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) main::i1
(byte) main::i1#0
(byte) main::i1#1
(byte) main::i1#2
(byte) main::i1#3
(byte) main::i1#4
(byte) main::i1#5
(byte*) main::line
(byte*) main::line#0
(byte*) main::line#1
(byte*) main::line#2
(byte*) main::line#3
(byte*) main::line#4
(byte*) main::line#5
(signed byte) main::v
(signed byte) main::v#0
(signed byte) main::v#1
(signed byte) main::v#2
(signed byte) main::v#3
Adding number conversion cast (unumber) $19 in (bool~) main::$0 ← (byte) main::i#2 < (number) $19
Adding number conversion cast (unumber) $ff in (bool~) main::$2 ← *((const nomodify byte*) VIC_RASTER) != (number) $ff
Adding number conversion cast (unumber) 0 in *((const nomodify byte*) VIC_BG_COLOR) ← (number) 0
Adding number conversion cast (unumber) $19 in (bool~) main::$3 ← (byte) main::i1#2 < (number) $19
Adding number conversion cast (snumber) 0 in (bool~) main::$4 ← *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$14) < (number) 0
Adding number conversion cast (snumber) $27 in (bool~) main::$5 ← *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$15) > (number) $27
Adding number conversion cast (unumber) $f in *((const nomodify byte*) VIC_BG_COLOR) ← (number) $f
Adding number conversion cast (unumber) $28 in (byte*) main::line#1 ← (byte*) main::line#3 + (number) $28
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((const nomodify byte*) VIC_BG_COLOR) ← (unumber)(number) 0
Inlining cast *((const nomodify byte*) VIC_BG_COLOR) ← (unumber)(number) $f
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53266
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $19
Simplifying constant integer cast $ff
Simplifying constant integer cast 0
Simplifying constant integer cast $19
Simplifying constant integer cast 0
Simplifying constant integer cast $27
Simplifying constant integer cast $f
Simplifying constant integer cast $28
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $19
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $19
Finalized signed number type (signed byte) 0
Finalized signed number type (signed byte) $27
Finalized unsigned number type (byte) $f
Finalized unsigned number type (byte) $28
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::i#2 = main::i#3
Alias main::v#2 = main::v#3
Alias main::v#1 = main::$1
Alias main::i1#2 = main::i1#3 main::i1#5
Alias main::line#2 = main::line#4 main::line#5
Successful SSA optimization Pass2AliasElimination
Alias main::i1#2 = main::i1#4
Alias main::line#2 = main::line#3
Successful SSA optimization Pass2AliasElimination
Identified duplicate assignment right side [9] (byte~) main::$10 ← (byte) main::i#2 * (const byte) SIZEOF_STRUCT_ENTITY
Identified duplicate assignment right side [11] (byte~) main::$11 ← (byte) main::i#2 * (const byte) SIZEOF_STRUCT_ENTITY
Identified duplicate assignment right side [29] (byte~) main::$13 ← (byte) main::i1#2 * (const byte) SIZEOF_STRUCT_ENTITY
Identified duplicate assignment right side [31] (byte~) main::$14 ← (byte) main::i1#2 * (const byte) SIZEOF_STRUCT_ENTITY
Identified duplicate assignment right side [33] (byte~) main::$15 ← (byte) main::i1#2 * (const byte) SIZEOF_STRUCT_ENTITY
Identified duplicate assignment right side [47] (byte~) main::$18 ← (byte) main::i1#2 * (const byte) SIZEOF_STRUCT_ENTITY
Identified duplicate assignment right side [49] (byte~) main::$19 ← (byte) main::i1#2 * (const byte) SIZEOF_STRUCT_ENTITY
Successful SSA optimization Pass2DuplicateRValueIdentification
Simple Condition (bool~) main::$0 [5] if((byte) main::i#2<(byte) $19) goto main::@2
Simple Condition (bool~) main::$20 [15] if((number) 0!=(number) 1) goto main::@4
Simple Condition (bool~) main::$2 [17] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@4
Simple Condition (bool~) main::$3 [23] if((byte) main::i1#2<(byte) $19) goto main::@7
Successful SSA optimization Pass2ConditionalJumpSimplification
Rewriting ! if()-condition to reversed if() [33] (bool~) main::$7 ← ! (bool~) main::$6
Rewriting || if()-condition to two if()s [32] (bool~) main::$6 ← (bool~) main::$4 || (bool~) main::$5
Successful SSA optimization Pass2ConditionalAndOrRewriting
Constant (const signed byte) main::v#0 = -1
Constant (const byte) main::i#0 = 0
Constant (const byte*) main::line#0 = SCREEN
Constant (const byte) main::i1#0 = 0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [15] if((number) 0!=(number) 1) goto main::@4
Successful SSA optimization Pass2ConstantIfs
Simplifying expression containing zero (signed byte*)entities in [7] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$9) ← (signed byte)(byte) main::i#2
Simplifying expression containing zero (signed byte*)entities in [25] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$12)) ← (byte) ' '
Simplifying expression containing zero (signed byte*)entities in [27] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$13) ← *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$13) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$13)
Simplifying expression containing zero (signed byte*)entities in [27] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$13) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$13)
Simplifying expression containing zero (signed byte*)entities in [29] (bool~) main::$4 ← *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$14) < (signed byte) 0
Simplifying expression containing zero (signed byte*)entities in [31] (bool~) main::$5 ← *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$15) > (signed byte) $27
Simplifying expression containing zero (signed byte*)entities in [37] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$16)) ← *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$16)
Simplifying expression containing zero (signed byte*)entities in [45] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$19) ← *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$19) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$19)
Simplifying expression containing zero (signed byte*)entities in [45] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_POS + (byte~) main::$19) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$19) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$19)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant (const byte) OFFSET_STRUCT_ENTITY_X_POS
Successful SSA optimization PassNEliminateUnusedVars
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
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 main::$10 = main::$9 main::$11
Alias main::$13 = main::$12 main::$14 main::$15
Alias main::$18 = main::$17 main::$19
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$4 [18] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) 0) goto main::@10
Simple Condition (bool~) main::$5 [28] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)>(signed byte) $27) goto main::@10
Successful SSA optimization Pass2ConditionalJumpSimplification
Negating conditional jump and destination [28] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<=(signed byte) $27) goto main::@9
Successful SSA optimization Pass2ConditionalJumpSequenceImprovement
Rewriting conditional comparison [28] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<=(signed byte) $27) goto main::@9
Adding number conversion cast (snumber) $27+1 in if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) $27+(number) 1) goto main::@9
Adding number conversion cast (snumber) 1 in if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(snumber)(signed byte) $27+(number) 1) goto main::@9
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast (signed byte) $27+(snumber)(number) 1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized signed number type (signed byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift and addition[3] (byte~) main::$10 ← (byte) main::i#2 * (const byte) SIZEOF_STRUCT_ENTITY
Rewriting multiplication to use shift and addition[13] (byte~) main::$13 ← (byte) main::i1#2 * (const byte) SIZEOF_STRUCT_ENTITY
Rewriting multiplication to use shift and addition[18] (byte~) main::$16 ← (byte) main::i1#2 * (const byte) SIZEOF_STRUCT_ENTITY
Rewriting multiplication to use shift and addition[22] (byte~) main::$18 ← (byte) main::i1#2 * (const byte) SIZEOF_STRUCT_ENTITY
Inlining constant with var siblings (const signed byte) main::v#0
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte*) main::line#0
Inlining constant with var siblings (const byte) main::i1#0
Constant inlined main::i#0 = (byte) 0
Constant inlined main::i1#0 = (byte) 0
Constant inlined main::line#0 = (const nomodify byte*) SCREEN
Constant inlined main::v#0 = (signed byte) -1
Successful SSA optimization Pass2ConstantInlining
Alias main::$10 = main::$22
Alias main::$13 = main::$24
Alias main::$16 = main::$26
Alias main::$18 = main::$28
Successful SSA optimization Pass2AliasElimination
Eliminating unused constant (const byte) SIZEOF_STRUCT_ENTITY
Successful SSA optimization PassNEliminateUnusedVars
Adding NOP phi() at start of main::@3
CALL GRAPH
Created 4 initial phi equivalence classes
Coalesced [25] main::i1#6 ← main::i1#1
Coalesced [26] main::line#6 ← main::line#1
Coalesced [34] main::i#4 ← main::i#1
Coalesced [35] main::v#4 ← main::v#1
Coalesced down to 4 phi equivalence classes
Culled Empty Block (label) main::@3
Renumbering block main::@4 to main::@3
Renumbering block main::@5 to main::@4
Renumbering block main::@6 to main::@5
Renumbering block main::@7 to main::@6
Renumbering block main::@8 to main::@7
Renumbering block main::@9 to main::@8
Renumbering block main::@10 to main::@9
Renumbering block main::@11 to main::@10
FINAL CONTROL FLOW GRAPH
(void()) main()
main: scope:[main] from
asm { sei }
to:main::@1
main::@1: scope:[main] from main main::@2
[1] (signed byte) main::v#2 ← phi( main/(signed byte) -1 main::@2/(signed byte) main::v#1 )
[1] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
[2] if((byte) main::i#2<(byte) $19) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@1 main::@3 main::@7
[3] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@3
to:main::@4
main::@4: scope:[main] from main::@3
[4] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0
to:main::@5
main::@5: scope:[main] from main::@4 main::@8
[5] (byte*) main::line#2 ← phi( main::@4/(const nomodify byte*) SCREEN main::@8/(byte*) main::line#1 )
[5] (byte) main::i1#2 ← phi( main::@4/(byte) 0 main::@8/(byte) main::i1#1 )
[6] if((byte) main::i1#2<(byte) $19) goto main::@6
to:main::@7
main::@7: scope:[main] from main::@5
[7] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f
to:main::@3
main::@6: scope:[main] from main::@5
[8] (byte~) main::$23 ← (byte) main::i1#2 << (byte) 1
[9] (byte~) main::$13 ← (byte~) main::$23 + (byte) main::i1#2
[10] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$13)) ← (byte) ' '
[11] *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$13)
[12] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) 0) goto main::@9
to:main::@10
main::@10: scope:[main] from main::@6
[13] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) $27+(signed byte) 1) goto main::@8
to:main::@9
main::@9: scope:[main] from main::@10 main::@6
[14] (byte~) main::$27 ← (byte) main::i1#2 << (byte) 1
[15] (byte~) main::$18 ← (byte~) main::$27 + (byte) main::i1#2
[16] (signed byte~) main::$8 ← - *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18)
[17] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) ← (signed byte~) main::$8
[18] *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18)
to:main::@8
main::@8: scope:[main] from main::@10 main::@9
[19] (byte~) main::$25 ← (byte) main::i1#2 << (byte) 1
[20] (byte~) main::$16 ← (byte~) main::$25 + (byte) main::i1#2
[21] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$16)) ← *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$16)
[22] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28
[23] (byte) main::i1#1 ← ++ (byte) main::i1#2
to:main::@5
main::@2: scope:[main] from main::@1
[24] (byte~) main::$21 ← (byte) main::i#2 << (byte) 1
[25] (byte~) main::$10 ← (byte~) main::$21 + (byte) main::i#2
[26] *((signed byte*)(const struct Entity*) entities + (byte~) main::$10) ← (signed byte)(byte) main::i#2
[27] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$10) ← (signed byte) main::v#2
[28] *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$10) ← (byte) main::i#2
[29] (signed byte) main::v#1 ← - (signed byte) main::v#2
[30] (byte) main::i#1 ← ++ (byte) main::i#2
to:main::@1
VARIABLE REGISTER WEIGHTS
(byte) Entity::symbol
(signed byte) Entity::x_pos
(signed byte) Entity::x_vel
(void()) main()
(byte~) main::$10 14.666666666666666
(byte~) main::$13 176.75
(byte~) main::$16 303.0
(byte~) main::$18 201.99999999999997
(byte~) main::$21 22.0
(byte~) main::$23 202.0
(byte~) main::$25 202.0
(byte~) main::$27 202.0
(signed byte~) main::$8 202.0
(byte) main::i
(byte) main::i#1 22.0
(byte) main::i#2 8.25
(byte) main::i1
(byte) main::i1#1 202.0
(byte) main::i1#2 53.470588235294116
(byte*) main::line
(byte*) main::line#1 101.0
(byte*) main::line#2 25.25
(signed byte) main::v
(signed byte) main::v#1 11.0
(signed byte) main::v#2 4.714285714285714
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ main::v#2 main::v#1 ]
[ main::i1#2 main::i1#1 ]
[ main::line#2 main::line#1 ]
Added variable main::$23 to live range equivalence class [ main::$23 ]
Added variable main::$13 to live range equivalence class [ main::$13 ]
Added variable main::$27 to live range equivalence class [ main::$27 ]
Added variable main::$18 to live range equivalence class [ main::$18 ]
Added variable main::$8 to live range equivalence class [ main::$8 ]
Added variable main::$25 to live range equivalence class [ main::$25 ]
Added variable main::$16 to live range equivalence class [ main::$16 ]
Added variable main::$21 to live range equivalence class [ main::$21 ]
Added variable main::$10 to live range equivalence class [ main::$10 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::v#2 main::v#1 ]
[ main::i1#2 main::i1#1 ]
[ main::line#2 main::line#1 ]
[ main::$23 ]
[ main::$13 ]
[ main::$27 ]
[ main::$18 ]
[ main::$8 ]
[ main::$25 ]
[ main::$16 ]
[ main::$21 ]
[ main::$10 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[1]:3 [ main::v#2 main::v#1 ]
Allocated zp[1]:4 [ main::i1#2 main::i1#1 ]
Allocated zp[2]:5 [ main::line#2 main::line#1 ]
Allocated zp[1]:7 [ main::$23 ]
Allocated zp[1]:8 [ main::$13 ]
Allocated zp[1]:9 [ main::$27 ]
Allocated zp[1]:10 [ main::$18 ]
Allocated zp[1]:11 [ main::$8 ]
Allocated zp[1]:12 [ main::$25 ]
Allocated zp[1]:13 [ main::$16 ]
Allocated zp[1]:14 [ main::$21 ]
Allocated zp[1]:15 [ main::$10 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Test that the multiplication of a idx*sizeof(element) is reused inside loops
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.const OFFSET_STRUCT_ENTITY_X_VEL = 1
.const OFFSET_STRUCT_ENTITY_SYMBOL = 2
.label VIC_RASTER = $d012
.label VIC_BG_COLOR = $d020
.label SCREEN = $400
// main
main: {
.label __8 = $b
.label __10 = $f
.label __13 = 8
.label __16 = $d
.label __18 = $a
// Initialize velocities
.label v = 3
.label i = 2
// Move the entities
.label line = 5
.label i1 = 4
.label __21 = $e
.label __23 = 7
.label __25 = $c
.label __27 = 9
// asm { sei }
sei
// [1] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [1] phi (signed byte) main::v#2 = (signed byte) -1 [phi:main->main::@1#0] -- vbsz1=vbsc1
lda #-1
sta.z v
// [1] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1
lda #0
sta.z i
jmp __b1
// main::@1
__b1:
// [2] if((byte) main::i#2<(byte) $19) goto main::@2 -- vbuz1_lt_vbuc1_then_la1
lda.z i
cmp #$19
bcc __b2
jmp __b3
// Wait for raster refresh
// main::@3
__b3:
// [3] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@3 -- _deref_pbuc1_neq_vbuc2_then_la1
lda #$ff
cmp VIC_RASTER
bne __b3
jmp __b4
// main::@4
__b4:
// [4] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta VIC_BG_COLOR
// [5] phi from main::@4 to main::@5 [phi:main::@4->main::@5]
__b5_from___b4:
// [5] phi (byte*) main::line#2 = (const nomodify byte*) SCREEN [phi:main::@4->main::@5#0] -- pbuz1=pbuc1
lda #<SCREEN
sta.z line
lda #>SCREEN
sta.z line+1
// [5] phi (byte) main::i1#2 = (byte) 0 [phi:main::@4->main::@5#1] -- vbuz1=vbuc1
lda #0
sta.z i1
jmp __b5
// main::@5
__b5:
// [6] if((byte) main::i1#2<(byte) $19) goto main::@6 -- vbuz1_lt_vbuc1_then_la1
lda.z i1
cmp #$19
bcc __b6
jmp __b7
// main::@7
__b7:
// [7] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f -- _deref_pbuc1=vbuc2
lda #$f
sta VIC_BG_COLOR
jmp __b3
// main::@6
__b6:
// [8] (byte~) main::$23 ← (byte) main::i1#2 << (byte) 1 -- vbuz1=vbuz2_rol_1
lda.z i1
asl
sta.z __23
// [9] (byte~) main::$13 ← (byte~) main::$23 + (byte) main::i1#2 -- vbuz1=vbuz2_plus_vbuz3
lda.z __23
clc
adc.z i1
sta.z __13
// [10] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$13)) ← (byte) ' ' -- pbuz1_derefidx_(pbsc1_derefidx_vbuz2)=vbuc2
// Delete old symbol
lda #' '
ldx.z __13
ldy entities,x
sta (line),y
// [11] *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$13) -- pbsc1_derefidx_vbuz1=pbsc1_derefidx_vbuz1_plus_pbsc2_derefidx_vbuz1
// Move by velocity
ldy.z __13
clc
lda entities,y
adc entities+OFFSET_STRUCT_ENTITY_X_VEL,y
sta entities,y
// [12] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) 0) goto main::@9 -- pbsc1_derefidx_vbuz1_lt_0_then_la1
ldy.z __13
lda entities,y
cmp #0
bmi __b9
jmp __b10
// main::@10
__b10:
// [13] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) $27+(signed byte) 1) goto main::@8 -- pbsc1_derefidx_vbuz1_lt_vbsc2_then_la1
ldy.z __13
lda entities,y
sec
sbc #$27+1
bvc !+
eor #$80
!:
bmi __b8
jmp __b9
// main::@9
__b9:
// [14] (byte~) main::$27 ← (byte) main::i1#2 << (byte) 1 -- vbuz1=vbuz2_rol_1
lda.z i1
asl
sta.z __27
// [15] (byte~) main::$18 ← (byte~) main::$27 + (byte) main::i1#2 -- vbuz1=vbuz2_plus_vbuz3
lda.z __27
clc
adc.z i1
sta.z __18
// [16] (signed byte~) main::$8 ← - *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) -- vbsz1=_neg_pbsc1_derefidx_vbuz2
ldy.z __18
lda entities+OFFSET_STRUCT_ENTITY_X_VEL,y
eor #$ff
clc
adc #1
sta.z __8
// [17] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) ← (signed byte~) main::$8 -- pbsc1_derefidx_vbuz1=vbsz2
lda.z __8
ldy.z __18
sta entities+OFFSET_STRUCT_ENTITY_X_VEL,y
// [18] *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) -- pbsc1_derefidx_vbuz1=pbsc1_derefidx_vbuz1_plus_pbsc2_derefidx_vbuz1
ldy.z __18
clc
lda entities,y
adc entities+OFFSET_STRUCT_ENTITY_X_VEL,y
sta entities,y
jmp __b8
// main::@8
__b8:
// [19] (byte~) main::$25 ← (byte) main::i1#2 << (byte) 1 -- vbuz1=vbuz2_rol_1
lda.z i1
asl
sta.z __25
// [20] (byte~) main::$16 ← (byte~) main::$25 + (byte) main::i1#2 -- vbuz1=vbuz2_plus_vbuz3
lda.z __25
clc
adc.z i1
sta.z __16
// [21] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$16)) ← *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$16) -- pbuz1_derefidx_(pbsc1_derefidx_vbuz2)=pbuc2_derefidx_vbuz2
// Draw symbol
ldx.z __16
lda entities+OFFSET_STRUCT_ENTITY_SYMBOL,x
ldy entities,x
sta (line),y
// [22] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1
// Next line
lda #$28
clc
adc.z line
sta.z line
bcc !+
inc.z line+1
!:
// [23] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuz1=_inc_vbuz1
inc.z i1
// [5] phi from main::@8 to main::@5 [phi:main::@8->main::@5]
__b5_from___b8:
// [5] phi (byte*) main::line#2 = (byte*) main::line#1 [phi:main::@8->main::@5#0] -- register_copy
// [5] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@8->main::@5#1] -- register_copy
jmp __b5
// main::@2
__b2:
// [24] (byte~) main::$21 ← (byte) main::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1
lda.z i
asl
sta.z __21
// [25] (byte~) main::$10 ← (byte~) main::$21 + (byte) main::i#2 -- vbuz1=vbuz2_plus_vbuz3
lda.z __21
clc
adc.z i
sta.z __10
// [26] *((signed byte*)(const struct Entity*) entities + (byte~) main::$10) ← (signed byte)(byte) main::i#2 -- pbsc1_derefidx_vbuz1=vbsz2
lda.z i
ldy.z __10
sta entities,y
// [27] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$10) ← (signed byte) main::v#2 -- pbsc1_derefidx_vbuz1=vbsz2
lda.z v
ldy.z __10
sta entities+OFFSET_STRUCT_ENTITY_X_VEL,y
// [28] *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$10) ← (byte) main::i#2 -- pbuc1_derefidx_vbuz1=vbuz2
lda.z i
ldy.z __10
sta entities+OFFSET_STRUCT_ENTITY_SYMBOL,y
// [29] (signed byte) main::v#1 ← - (signed byte) main::v#2 -- vbsz1=_neg_vbsz1
lda.z v
eor #$ff
clc
adc #1
sta.z v
// [30] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
__b1_from___b2:
// [1] phi (signed byte) main::v#2 = (signed byte) main::v#1 [phi:main::@2->main::@1#0] -- register_copy
// [1] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#1] -- register_copy
jmp __b1
}
// File Data
entities: .fill 3*$19, 0
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [3] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@3 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [4] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [7] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f [ ] ( [ ] { } ) always clobbers reg byte a
Statement [8] (byte~) main::$23 ← (byte) main::i1#2 << (byte) 1 [ main::i1#2 main::line#2 main::$23 ] ( [ main::i1#2 main::line#2 main::$23 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:4 [ main::i1#2 main::i1#1 ]
Statement [9] (byte~) main::$13 ← (byte~) main::$23 + (byte) main::i1#2 [ main::i1#2 main::line#2 main::$13 ] ( [ main::i1#2 main::line#2 main::$13 ] { } ) always clobbers reg byte a
Statement [10] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$13)) ← (byte) ' ' [ main::i1#2 main::line#2 main::$13 ] ( [ main::i1#2 main::line#2 main::$13 ] { } ) always clobbers reg byte a reg byte y
Removing always clobbered register reg byte y as potential for zp[1]:4 [ main::i1#2 main::i1#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:8 [ main::$13 ]
Removing always clobbered register reg byte y as potential for zp[1]:8 [ main::$13 ]
Statement [11] *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$13) [ main::i1#2 main::line#2 main::$13 ] ( [ main::i1#2 main::line#2 main::$13 ] { } ) always clobbers reg byte a
Statement [12] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) 0) goto main::@9 [ main::i1#2 main::line#2 main::$13 ] ( [ main::i1#2 main::line#2 main::$13 ] { } ) always clobbers reg byte a
Statement [13] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) $27+(signed byte) 1) goto main::@8 [ main::i1#2 main::line#2 ] ( [ main::i1#2 main::line#2 ] { } ) always clobbers reg byte a
Statement [14] (byte~) main::$27 ← (byte) main::i1#2 << (byte) 1 [ main::i1#2 main::line#2 main::$27 ] ( [ main::i1#2 main::line#2 main::$27 ] { } ) always clobbers reg byte a
Statement [15] (byte~) main::$18 ← (byte~) main::$27 + (byte) main::i1#2 [ main::i1#2 main::line#2 main::$18 ] ( [ main::i1#2 main::line#2 main::$18 ] { } ) always clobbers reg byte a
Statement [16] (signed byte~) main::$8 ← - *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) [ main::i1#2 main::line#2 main::$18 main::$8 ] ( [ main::i1#2 main::line#2 main::$18 main::$8 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:10 [ main::$18 ]
Statement [18] *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) [ main::i1#2 main::line#2 ] ( [ main::i1#2 main::line#2 ] { } ) always clobbers reg byte a
Statement [19] (byte~) main::$25 ← (byte) main::i1#2 << (byte) 1 [ main::i1#2 main::line#2 main::$25 ] ( [ main::i1#2 main::line#2 main::$25 ] { } ) always clobbers reg byte a
Statement [20] (byte~) main::$16 ← (byte~) main::$25 + (byte) main::i1#2 [ main::i1#2 main::line#2 main::$16 ] ( [ main::i1#2 main::line#2 main::$16 ] { } ) always clobbers reg byte a
Statement [21] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$16)) ← *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$16) [ main::i1#2 main::line#2 ] ( [ main::i1#2 main::line#2 ] { } ) always clobbers reg byte a reg byte y
Statement [22] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 [ main::i1#2 main::line#1 ] ( [ main::i1#2 main::line#1 ] { } ) always clobbers reg byte a
Statement [24] (byte~) main::$21 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::v#2 main::$21 ] ( [ main::i#2 main::v#2 main::$21 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:3 [ main::v#2 main::v#1 ]
Statement [25] (byte~) main::$10 ← (byte~) main::$21 + (byte) main::i#2 [ main::i#2 main::v#2 main::$10 ] ( [ main::i#2 main::v#2 main::$10 ] { } ) always clobbers reg byte a
Statement [26] *((signed byte*)(const struct Entity*) entities + (byte~) main::$10) ← (signed byte)(byte) main::i#2 [ main::i#2 main::v#2 main::$10 ] ( [ main::i#2 main::v#2 main::$10 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:15 [ main::$10 ]
Statement [27] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$10) ← (signed byte) main::v#2 [ main::i#2 main::v#2 main::$10 ] ( [ main::i#2 main::v#2 main::$10 ] { } ) always clobbers reg byte a
Statement [28] *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$10) ← (byte) main::i#2 [ main::i#2 main::v#2 ] ( [ main::i#2 main::v#2 ] { } ) always clobbers reg byte a
Statement [29] (signed byte) main::v#1 ← - (signed byte) main::v#2 [ main::i#2 main::v#1 ] ( [ main::i#2 main::v#1 ] { } ) always clobbers reg byte a
Statement [3] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@3 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [4] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [7] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f [ ] ( [ ] { } ) always clobbers reg byte a
Statement [8] (byte~) main::$23 ← (byte) main::i1#2 << (byte) 1 [ main::i1#2 main::line#2 main::$23 ] ( [ main::i1#2 main::line#2 main::$23 ] { } ) always clobbers reg byte a
Statement [9] (byte~) main::$13 ← (byte~) main::$23 + (byte) main::i1#2 [ main::i1#2 main::line#2 main::$13 ] ( [ main::i1#2 main::line#2 main::$13 ] { } ) always clobbers reg byte a
Statement [10] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$13)) ← (byte) ' ' [ main::i1#2 main::line#2 main::$13 ] ( [ main::i1#2 main::line#2 main::$13 ] { } ) always clobbers reg byte a reg byte y
Statement [11] *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$13) [ main::i1#2 main::line#2 main::$13 ] ( [ main::i1#2 main::line#2 main::$13 ] { } ) always clobbers reg byte a
Statement [12] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) 0) goto main::@9 [ main::i1#2 main::line#2 main::$13 ] ( [ main::i1#2 main::line#2 main::$13 ] { } ) always clobbers reg byte a
Statement [13] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) $27+(signed byte) 1) goto main::@8 [ main::i1#2 main::line#2 ] ( [ main::i1#2 main::line#2 ] { } ) always clobbers reg byte a
Statement [14] (byte~) main::$27 ← (byte) main::i1#2 << (byte) 1 [ main::i1#2 main::line#2 main::$27 ] ( [ main::i1#2 main::line#2 main::$27 ] { } ) always clobbers reg byte a
Statement [15] (byte~) main::$18 ← (byte~) main::$27 + (byte) main::i1#2 [ main::i1#2 main::line#2 main::$18 ] ( [ main::i1#2 main::line#2 main::$18 ] { } ) always clobbers reg byte a
Statement [16] (signed byte~) main::$8 ← - *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) [ main::i1#2 main::line#2 main::$18 main::$8 ] ( [ main::i1#2 main::line#2 main::$18 main::$8 ] { } ) always clobbers reg byte a
Statement [18] *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) [ main::i1#2 main::line#2 ] ( [ main::i1#2 main::line#2 ] { } ) always clobbers reg byte a
Statement [19] (byte~) main::$25 ← (byte) main::i1#2 << (byte) 1 [ main::i1#2 main::line#2 main::$25 ] ( [ main::i1#2 main::line#2 main::$25 ] { } ) always clobbers reg byte a
Statement [20] (byte~) main::$16 ← (byte~) main::$25 + (byte) main::i1#2 [ main::i1#2 main::line#2 main::$16 ] ( [ main::i1#2 main::line#2 main::$16 ] { } ) always clobbers reg byte a
Statement [21] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$16)) ← *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$16) [ main::i1#2 main::line#2 ] ( [ main::i1#2 main::line#2 ] { } ) always clobbers reg byte a reg byte y
Statement [22] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 [ main::i1#2 main::line#1 ] ( [ main::i1#2 main::line#1 ] { } ) always clobbers reg byte a
Statement [24] (byte~) main::$21 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::v#2 main::$21 ] ( [ main::i#2 main::v#2 main::$21 ] { } ) always clobbers reg byte a
Statement [25] (byte~) main::$10 ← (byte~) main::$21 + (byte) main::i#2 [ main::i#2 main::v#2 main::$10 ] ( [ main::i#2 main::v#2 main::$10 ] { } ) always clobbers reg byte a
Statement [26] *((signed byte*)(const struct Entity*) entities + (byte~) main::$10) ← (signed byte)(byte) main::i#2 [ main::i#2 main::v#2 main::$10 ] ( [ main::i#2 main::v#2 main::$10 ] { } ) always clobbers reg byte a
Statement [27] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$10) ← (signed byte) main::v#2 [ main::i#2 main::v#2 main::$10 ] ( [ main::i#2 main::v#2 main::$10 ] { } ) always clobbers reg byte a
Statement [28] *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$10) ← (byte) main::i#2 [ main::i#2 main::v#2 ] ( [ main::i#2 main::v#2 ] { } ) always clobbers reg byte a
Statement [29] (signed byte) main::v#1 ← - (signed byte) main::v#2 [ main::i#2 main::v#1 ] ( [ main::i#2 main::v#1 ] { } ) always clobbers reg byte a
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y ,
Potential registers zp[1]:3 [ main::v#2 main::v#1 ] : zp[1]:3 , reg byte x , reg byte y ,
Potential registers zp[1]:4 [ main::i1#2 main::i1#1 ] : zp[1]:4 , reg byte x ,
Potential registers zp[2]:5 [ main::line#2 main::line#1 ] : zp[2]:5 ,
Potential registers zp[1]:7 [ main::$23 ] : zp[1]:7 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:8 [ main::$13 ] : zp[1]:8 , reg byte x ,
Potential registers zp[1]:9 [ main::$27 ] : zp[1]:9 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:10 [ main::$18 ] : zp[1]:10 , reg byte x , reg byte y ,
Potential registers zp[1]:11 [ main::$8 ] : zp[1]:11 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:12 [ main::$25 ] : zp[1]:12 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:13 [ main::$16 ] : zp[1]:13 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:14 [ main::$21 ] : zp[1]:14 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:15 [ main::$10 ] : zp[1]:15 , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 303: zp[1]:13 [ main::$16 ] 255.47: zp[1]:4 [ main::i1#2 main::i1#1 ] 202: zp[1]:7 [ main::$23 ] 202: zp[1]:9 [ main::$27 ] 202: zp[1]:11 [ main::$8 ] 202: zp[1]:12 [ main::$25 ] 202: zp[1]:10 [ main::$18 ] 176.75: zp[1]:8 [ main::$13 ] 126.25: zp[2]:5 [ main::line#2 main::line#1 ] 30.25: zp[1]:2 [ main::i#2 main::i#1 ] 22: zp[1]:14 [ main::$21 ] 15.71: zp[1]:3 [ main::v#2 main::v#1 ] 14.67: zp[1]:15 [ main::$10 ]
Uplift Scope [Entity]
Uplift Scope []
Uplifting [main] best 25607 combination reg byte a [ main::$16 ] zp[1]:4 [ main::i1#2 main::i1#1 ] reg byte a [ main::$23 ] reg byte a [ main::$27 ] zp[1]:11 [ main::$8 ] zp[1]:12 [ main::$25 ] zp[1]:10 [ main::$18 ] zp[1]:8 [ main::$13 ] zp[2]:5 [ main::line#2 main::line#1 ] zp[1]:2 [ main::i#2 main::i#1 ] zp[1]:14 [ main::$21 ] zp[1]:3 [ main::v#2 main::v#1 ] zp[1]:15 [ main::$10 ]
Limited combination testing to 100 combinations of 1327104 possible.
Uplifting [Entity] best 25607 combination
Uplifting [] best 25607 combination
Attempting to uplift remaining variables inzp[1]:4 [ main::i1#2 main::i1#1 ]
Uplifting [main] best 25607 combination zp[1]:4 [ main::i1#2 main::i1#1 ]
Attempting to uplift remaining variables inzp[1]:11 [ main::$8 ]
Uplifting [main] best 25007 combination reg byte a [ main::$8 ]
Attempting to uplift remaining variables inzp[1]:12 [ main::$25 ]
Uplifting [main] best 24407 combination reg byte a [ main::$25 ]
Attempting to uplift remaining variables inzp[1]:10 [ main::$18 ]
Uplifting [main] best 23407 combination reg byte x [ main::$18 ]
Attempting to uplift remaining variables inzp[1]:8 [ main::$13 ]
Uplifting [main] best 22107 combination reg byte x [ main::$13 ]
Attempting to uplift remaining variables inzp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [main] best 21977 combination reg byte x [ main::i#2 main::i#1 ]
Attempting to uplift remaining variables inzp[1]:14 [ main::$21 ]
Uplifting [main] best 21957 combination reg byte a [ main::$21 ]
Attempting to uplift remaining variables inzp[1]:3 [ main::v#2 main::v#1 ]
Uplifting [main] best 21957 combination zp[1]:3 [ main::v#2 main::v#1 ]
Attempting to uplift remaining variables inzp[1]:15 [ main::$10 ]
Uplifting [main] best 21857 combination reg byte y [ main::$10 ]
Allocated (was zp[1]:3) zp[1]:2 [ main::v#2 main::v#1 ]
Allocated (was zp[1]:4) zp[1]:3 [ main::i1#2 main::i1#1 ]
Allocated (was zp[2]:5) zp[2]:4 [ main::line#2 main::line#1 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Test that the multiplication of a idx*sizeof(element) is reused inside loops
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.const OFFSET_STRUCT_ENTITY_X_VEL = 1
.const OFFSET_STRUCT_ENTITY_SYMBOL = 2
.label VIC_RASTER = $d012
.label VIC_BG_COLOR = $d020
.label SCREEN = $400
// main
main: {
// Initialize velocities
.label v = 2
// Move the entities
.label line = 4
.label i1 = 3
// asm { sei }
sei
// [1] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [1] phi (signed byte) main::v#2 = (signed byte) -1 [phi:main->main::@1#0] -- vbsz1=vbsc1
lda #-1
sta.z v
// [1] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1
ldx #0
jmp __b1
// main::@1
__b1:
// [2] if((byte) main::i#2<(byte) $19) goto main::@2 -- vbuxx_lt_vbuc1_then_la1
cpx #$19
bcc __b2
jmp __b3
// Wait for raster refresh
// main::@3
__b3:
// [3] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@3 -- _deref_pbuc1_neq_vbuc2_then_la1
lda #$ff
cmp VIC_RASTER
bne __b3
jmp __b4
// main::@4
__b4:
// [4] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta VIC_BG_COLOR
// [5] phi from main::@4 to main::@5 [phi:main::@4->main::@5]
__b5_from___b4:
// [5] phi (byte*) main::line#2 = (const nomodify byte*) SCREEN [phi:main::@4->main::@5#0] -- pbuz1=pbuc1
lda #<SCREEN
sta.z line
lda #>SCREEN
sta.z line+1
// [5] phi (byte) main::i1#2 = (byte) 0 [phi:main::@4->main::@5#1] -- vbuz1=vbuc1
lda #0
sta.z i1
jmp __b5
// main::@5
__b5:
// [6] if((byte) main::i1#2<(byte) $19) goto main::@6 -- vbuz1_lt_vbuc1_then_la1
lda.z i1
cmp #$19
bcc __b6
jmp __b7
// main::@7
__b7:
// [7] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f -- _deref_pbuc1=vbuc2
lda #$f
sta VIC_BG_COLOR
jmp __b3
// main::@6
__b6:
// [8] (byte~) main::$23 ← (byte) main::i1#2 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i1
asl
// [9] (byte~) main::$13 ← (byte~) main::$23 + (byte) main::i1#2 -- vbuxx=vbuaa_plus_vbuz1
clc
adc.z i1
tax
// [10] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$13)) ← (byte) ' ' -- pbuz1_derefidx_(pbsc1_derefidx_vbuxx)=vbuc2
// Delete old symbol
lda #' '
ldy entities,x
sta (line),y
// [11] *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$13) -- pbsc1_derefidx_vbuxx=pbsc1_derefidx_vbuxx_plus_pbsc2_derefidx_vbuxx
// Move by velocity
clc
lda entities,x
adc entities+OFFSET_STRUCT_ENTITY_X_VEL,x
sta entities,x
// [12] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) 0) goto main::@9 -- pbsc1_derefidx_vbuxx_lt_0_then_la1
lda entities,x
cmp #0
bmi __b9
jmp __b10
// main::@10
__b10:
// [13] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) $27+(signed byte) 1) goto main::@8 -- pbsc1_derefidx_vbuxx_lt_vbsc2_then_la1
lda entities,x
sec
sbc #$27+1
bvc !+
eor #$80
!:
bmi __b8
jmp __b9
// main::@9
__b9:
// [14] (byte~) main::$27 ← (byte) main::i1#2 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i1
asl
// [15] (byte~) main::$18 ← (byte~) main::$27 + (byte) main::i1#2 -- vbuxx=vbuaa_plus_vbuz1
clc
adc.z i1
tax
// [16] (signed byte~) main::$8 ← - *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) -- vbsaa=_neg_pbsc1_derefidx_vbuxx
lda entities+OFFSET_STRUCT_ENTITY_X_VEL,x
eor #$ff
clc
adc #1
// [17] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) ← (signed byte~) main::$8 -- pbsc1_derefidx_vbuxx=vbsaa
sta entities+OFFSET_STRUCT_ENTITY_X_VEL,x
// [18] *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) -- pbsc1_derefidx_vbuxx=pbsc1_derefidx_vbuxx_plus_pbsc2_derefidx_vbuxx
clc
lda entities,x
adc entities+OFFSET_STRUCT_ENTITY_X_VEL,x
sta entities,x
jmp __b8
// main::@8
__b8:
// [19] (byte~) main::$25 ← (byte) main::i1#2 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i1
asl
// [20] (byte~) main::$16 ← (byte~) main::$25 + (byte) main::i1#2 -- vbuaa=vbuaa_plus_vbuz1
clc
adc.z i1
// [21] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$16)) ← *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$16) -- pbuz1_derefidx_(pbsc1_derefidx_vbuaa)=pbuc2_derefidx_vbuaa
// Draw symbol
tax
lda entities+OFFSET_STRUCT_ENTITY_SYMBOL,x
ldy entities,x
sta (line),y
// [22] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1
// Next line
lda #$28
clc
adc.z line
sta.z line
bcc !+
inc.z line+1
!:
// [23] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuz1=_inc_vbuz1
inc.z i1
// [5] phi from main::@8 to main::@5 [phi:main::@8->main::@5]
__b5_from___b8:
// [5] phi (byte*) main::line#2 = (byte*) main::line#1 [phi:main::@8->main::@5#0] -- register_copy
// [5] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@8->main::@5#1] -- register_copy
jmp __b5
// main::@2
__b2:
// [24] (byte~) main::$21 ← (byte) main::i#2 << (byte) 1 -- vbuaa=vbuxx_rol_1
txa
asl
// [25] (byte~) main::$10 ← (byte~) main::$21 + (byte) main::i#2 -- vbuyy=vbuaa_plus_vbuxx
stx.z $ff
clc
adc.z $ff
tay
// [26] *((signed byte*)(const struct Entity*) entities + (byte~) main::$10) ← (signed byte)(byte) main::i#2 -- pbsc1_derefidx_vbuyy=vbsxx
txa
sta entities,y
// [27] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$10) ← (signed byte) main::v#2 -- pbsc1_derefidx_vbuyy=vbsz1
lda.z v
sta entities+OFFSET_STRUCT_ENTITY_X_VEL,y
// [28] *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$10) ← (byte) main::i#2 -- pbuc1_derefidx_vbuyy=vbuxx
txa
sta entities+OFFSET_STRUCT_ENTITY_SYMBOL,y
// [29] (signed byte) main::v#1 ← - (signed byte) main::v#2 -- vbsz1=_neg_vbsz1
lda.z v
eor #$ff
clc
adc #1
sta.z v
// [30] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
inx
// [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
__b1_from___b2:
// [1] phi (signed byte) main::v#2 = (signed byte) main::v#1 [phi:main::@2->main::@1#0] -- register_copy
// [1] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#1] -- register_copy
jmp __b1
}
// File Data
entities: .fill 3*$19, 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b3
Removing instruction jmp __b4
Removing instruction jmp __b5
Removing instruction jmp __b7
Removing instruction jmp __b10
Removing instruction jmp __b9
Removing instruction jmp __b8
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from_main:
Removing instruction __b4:
Removing instruction __b5_from___b4:
Removing instruction __b7:
Removing instruction __b10:
Removing instruction __b5_from___b8:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5UnusedLabelElimination
Fixing long branch [21] bcc __b2 to bcs
FINAL SYMBOL TABLE
(byte) Entity::symbol
(signed byte) Entity::x_pos
(signed byte) Entity::x_vel
(const byte) OFFSET_STRUCT_ENTITY_SYMBOL = (byte) 2
(const byte) OFFSET_STRUCT_ENTITY_X_VEL = (byte) 1
(const nomodify byte*) SCREEN = (byte*) 1024
(const nomodify byte*) VIC_BG_COLOR = (byte*) 53280
(const nomodify byte*) VIC_RASTER = (byte*) 53266
(const struct Entity*) entities[(number) $19] = { fill( $19, 0) }
(void()) main()
(byte~) main::$10 reg byte y 14.666666666666666
(byte~) main::$13 reg byte x 176.75
(byte~) main::$16 reg byte a 303.0
(byte~) main::$18 reg byte x 201.99999999999997
(byte~) main::$21 reg byte a 22.0
(byte~) main::$23 reg byte a 202.0
(byte~) main::$25 reg byte a 202.0
(byte~) main::$27 reg byte a 202.0
(signed byte~) main::$8 reg byte a 202.0
(label) main::@1
(label) main::@10
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@7
(label) main::@8
(label) main::@9
(byte) main::i
(byte) main::i#1 reg byte x 22.0
(byte) main::i#2 reg byte x 8.25
(byte) main::i1
(byte) main::i1#1 i1 zp[1]:3 202.0
(byte) main::i1#2 i1 zp[1]:3 53.470588235294116
(byte*) main::line
(byte*) main::line#1 line zp[2]:4 101.0
(byte*) main::line#2 line zp[2]:4 25.25
(signed byte) main::v
(signed byte) main::v#1 v zp[1]:2 11.0
(signed byte) main::v#2 v zp[1]:2 4.714285714285714
reg byte x [ main::i#2 main::i#1 ]
zp[1]:2 [ main::v#2 main::v#1 ]
zp[1]:3 [ main::i1#2 main::i1#1 ]
zp[2]:4 [ main::line#2 main::line#1 ]
reg byte a [ main::$23 ]
reg byte x [ main::$13 ]
reg byte a [ main::$27 ]
reg byte x [ main::$18 ]
reg byte a [ main::$8 ]
reg byte a [ main::$25 ]
reg byte a [ main::$16 ]
reg byte a [ main::$21 ]
reg byte y [ main::$10 ]
FINAL ASSEMBLER
Score: 20027
// File Comments
// Test that the multiplication of a idx*sizeof(element) is reused inside loops
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.const OFFSET_STRUCT_ENTITY_X_VEL = 1
.const OFFSET_STRUCT_ENTITY_SYMBOL = 2
.label VIC_RASTER = $d012
.label VIC_BG_COLOR = $d020
.label SCREEN = $400
// main
main: {
// Initialize velocities
.label v = 2
// Move the entities
.label line = 4
.label i1 = 3
// asm
// asm { sei }
sei
// [1] phi from main to main::@1 [phi:main->main::@1]
// [1] phi (signed byte) main::v#2 = (signed byte) -1 [phi:main->main::@1#0] -- vbsz1=vbsc1
lda #-1
sta.z v
// [1] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1
ldx #0
// main::@1
__b1:
// for(char i=0;i<NUM_ENTITIES;i++)
// [2] if((byte) main::i#2<(byte) $19) goto main::@2 -- vbuxx_lt_vbuc1_then_la1
cpx #$19
bcs !__b2+
jmp __b2
!__b2:
// Wait for raster refresh
// main::@3
__b3:
// while(*VIC_RASTER!=0xff)
// [3] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@3 -- _deref_pbuc1_neq_vbuc2_then_la1
lda #$ff
cmp VIC_RASTER
bne __b3
// main::@4
// *VIC_BG_COLOR = 0
// [4] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta VIC_BG_COLOR
// [5] phi from main::@4 to main::@5 [phi:main::@4->main::@5]
// [5] phi (byte*) main::line#2 = (const nomodify byte*) SCREEN [phi:main::@4->main::@5#0] -- pbuz1=pbuc1
lda #<SCREEN
sta.z line
lda #>SCREEN
sta.z line+1
// [5] phi (byte) main::i1#2 = (byte) 0 [phi:main::@4->main::@5#1] -- vbuz1=vbuc1
lda #0
sta.z i1
// main::@5
__b5:
// for(char i=0;i<NUM_ENTITIES;i++)
// [6] if((byte) main::i1#2<(byte) $19) goto main::@6 -- vbuz1_lt_vbuc1_then_la1
lda.z i1
cmp #$19
bcc __b6
// main::@7
// *VIC_BG_COLOR = 15
// [7] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f -- _deref_pbuc1=vbuc2
lda #$f
sta VIC_BG_COLOR
jmp __b3
// main::@6
__b6:
// line[entities[i].x_pos] = ' '
// [8] (byte~) main::$23 ← (byte) main::i1#2 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i1
asl
// [9] (byte~) main::$13 ← (byte~) main::$23 + (byte) main::i1#2 -- vbuxx=vbuaa_plus_vbuz1
clc
adc.z i1
tax
// [10] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$13)) ← (byte) ' ' -- pbuz1_derefidx_(pbsc1_derefidx_vbuxx)=vbuc2
// Delete old symbol
lda #' '
ldy entities,x
sta (line),y
// entities[i].x_pos += entities[i].x_vel
// [11] *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$13) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$13) -- pbsc1_derefidx_vbuxx=pbsc1_derefidx_vbuxx_plus_pbsc2_derefidx_vbuxx
// Move by velocity
clc
lda entities,x
adc entities+OFFSET_STRUCT_ENTITY_X_VEL,x
sta entities,x
// if(entities[i].x_pos<0 || entities[i].x_pos>39)
// [12] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) 0) goto main::@9 -- pbsc1_derefidx_vbuxx_lt_0_then_la1
lda entities,x
cmp #0
bmi __b9
// main::@10
// [13] if(*((signed byte*)(const struct Entity*) entities + (byte~) main::$13)<(signed byte) $27+(signed byte) 1) goto main::@8 -- pbsc1_derefidx_vbuxx_lt_vbsc2_then_la1
lda entities,x
sec
sbc #$27+1
bvc !+
eor #$80
!:
bmi __b8
// main::@9
__b9:
// -entities[i].x_vel
// [14] (byte~) main::$27 ← (byte) main::i1#2 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i1
asl
// [15] (byte~) main::$18 ← (byte~) main::$27 + (byte) main::i1#2 -- vbuxx=vbuaa_plus_vbuz1
clc
adc.z i1
tax
// [16] (signed byte~) main::$8 ← - *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) -- vbsaa=_neg_pbsc1_derefidx_vbuxx
lda entities+OFFSET_STRUCT_ENTITY_X_VEL,x
eor #$ff
clc
adc #1
// entities[i].x_vel = -entities[i].x_vel
// [17] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) ← (signed byte~) main::$8 -- pbsc1_derefidx_vbuxx=vbsaa
sta entities+OFFSET_STRUCT_ENTITY_X_VEL,x
// entities[i].x_pos += entities[i].x_vel
// [18] *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) ← *((signed byte*)(const struct Entity*) entities + (byte~) main::$18) + *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$18) -- pbsc1_derefidx_vbuxx=pbsc1_derefidx_vbuxx_plus_pbsc2_derefidx_vbuxx
clc
lda entities,x
adc entities+OFFSET_STRUCT_ENTITY_X_VEL,x
sta entities,x
// main::@8
__b8:
// line[entities[i].x_pos] = entities[i].symbol
// [19] (byte~) main::$25 ← (byte) main::i1#2 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i1
asl
// [20] (byte~) main::$16 ← (byte~) main::$25 + (byte) main::i1#2 -- vbuaa=vbuaa_plus_vbuz1
clc
adc.z i1
// [21] *((byte*) main::line#2 + *((signed byte*)(const struct Entity*) entities + (byte~) main::$16)) ← *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$16) -- pbuz1_derefidx_(pbsc1_derefidx_vbuaa)=pbuc2_derefidx_vbuaa
// Draw symbol
tax
lda entities+OFFSET_STRUCT_ENTITY_SYMBOL,x
ldy entities,x
sta (line),y
// line +=40
// [22] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1
// Next line
lda #$28
clc
adc.z line
sta.z line
bcc !+
inc.z line+1
!:
// for(char i=0;i<NUM_ENTITIES;i++)
// [23] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuz1=_inc_vbuz1
inc.z i1
// [5] phi from main::@8 to main::@5 [phi:main::@8->main::@5]
// [5] phi (byte*) main::line#2 = (byte*) main::line#1 [phi:main::@8->main::@5#0] -- register_copy
// [5] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@8->main::@5#1] -- register_copy
jmp __b5
// main::@2
__b2:
// entities[i].x_pos = (signed char)i
// [24] (byte~) main::$21 ← (byte) main::i#2 << (byte) 1 -- vbuaa=vbuxx_rol_1
txa
asl
// [25] (byte~) main::$10 ← (byte~) main::$21 + (byte) main::i#2 -- vbuyy=vbuaa_plus_vbuxx
stx.z $ff
clc
adc.z $ff
tay
// [26] *((signed byte*)(const struct Entity*) entities + (byte~) main::$10) ← (signed byte)(byte) main::i#2 -- pbsc1_derefidx_vbuyy=vbsxx
txa
sta entities,y
// entities[i].x_vel = v
// [27] *((signed byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_X_VEL + (byte~) main::$10) ← (signed byte) main::v#2 -- pbsc1_derefidx_vbuyy=vbsz1
lda.z v
sta entities+OFFSET_STRUCT_ENTITY_X_VEL,y
// entities[i].symbol = i
// [28] *((byte*)(const struct Entity*) entities+(const byte) OFFSET_STRUCT_ENTITY_SYMBOL + (byte~) main::$10) ← (byte) main::i#2 -- pbuc1_derefidx_vbuyy=vbuxx
txa
sta entities+OFFSET_STRUCT_ENTITY_SYMBOL,y
// v = -v
// [29] (signed byte) main::v#1 ← - (signed byte) main::v#2 -- vbsz1=_neg_vbsz1
lda.z v
eor #$ff
clc
adc #1
sta.z v
// for(char i=0;i<NUM_ENTITIES;i++)
// [30] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
inx
// [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
// [1] phi (signed byte) main::v#2 = (signed byte) main::v#1 [phi:main::@2->main::@1#0] -- register_copy
// [1] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#1] -- register_copy
jmp __b1
}
// File Data
entities: .fill 3*$19, 0