// File: /workspace/github_c_makefile_star2_O3/skeeto[P]goblin-com/src/game.c
// Function: game_step
yield_t
game_step(game_t *game)
{
    struct {
        double gold;
        double food;
        double wood;
    } init = {game->gold, game->food, game->wood};
    for (int y = 0; y < MAP_HEIGHT; y++) {
        for (int x = 0; x < MAP_WIDTH; x++) {
            uint16_t building = game->map->high[x][y].building;
            if (building != C_NONE) {
                if (++game->map->high[x][y].building_age >= 0)
                    building_process(game, building);
            }
        }
    }
    yield_t diff = {
        .gold = (game->gold - init.gold) * DAY,
        .food = (game->food - init.food) * DAY,
        .wood = (game->wood - init.wood) * DAY
    };

    for (unsigned i = 0; i < countof(game->squads); i++)
        if (game->squads[i].member_count > 0)
            squad_step(game, game->squads + i);

    if (rand_uniform(0, 1) < game->spawn_rate / DAY)
        invader_push(game, invader_generate());
    for (unsigned i = 0; i < countof(game->invaders); i++)
        if (game->invaders[i].active)
            invader_step(game, game->invaders + i);

    /* Generate events. */
    if (game->population >= GAME_WIN_POP)
        game_event_push(game, EVENT_WIN);

    game->time++;
    return diff;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movsd 0x18(%rdi), %xmm0
movsd 0x20(%rdi), %xmm9
movsd 0x28(%rdi), %xmm1
movq 0x38(%rdi), %rax
movapd %xmm0, 0x60(%rsp)
movapd %xmm0, %xmm11
movapd %xmm1, 0x50(%rsp)
unpcklpd %xmm1, %xmm11           # xmm11 = xmm11[0],xmm1[0]
xorl %ecx, %ecx
movsd 0x227c(%rip), %xmm0     # 0x79b8
movapd 0x220c(%rip), %xmm1     # 0x7950
xorpd %xmm2, %xmm2
movhpd 0x2288(%rip), %xmm2     # xmm2 = xmm2[0],mem[0]
movsd 0x2278(%rip), %xmm3     # 0x79d0
movapd 0x2200(%rip), %xmm4     # 0x7960
movapd 0x21d8(%rip), %xmm5     # 0x7940
movsd 0x2250(%rip), %xmm6     # 0x79c0
movsd 0x2240(%rip), %xmm7     # 0x79b8
movsd 0x223f(%rip), %xmm8     # 0x79c0
movsd %xmm9, 0x48(%rsp)
movapd %xmm9, %xmm12
movl $0x8, %edx
movzwl -0x6(%rax,%rdx), %esi
testl %esi, %esi
je 0x5853
movq (%rax,%rdx), %rdi
leaq 0x1(%rdi), %r8
movq %r8, (%rax,%rdx)
cmpq $-0x1, %rdi
jl 0x5853
xorpd %xmm10, %xmm10
xorpd %xmm9, %xmm9
cmpl $0x47, %esi
jle 0x57df
cmpl $0x52, %esi
jg 0x57f5
cmpl $0x48, %esi
je 0x580d
cmpl $0x4d, %esi
jne 0x5829
movapd %xmm7, %xmm9
movapd %xmm6, %xmm10
jmp 0x5829
cmpl $0x2b, %esi
je 0x5806
cmpl $0x43, %esi
je 0x581f
cmpl $0x46, %esi
jne 0x5829
movapd %xmm2, %xmm10
jmp 0x5829
cmpl $0x53, %esi
je 0x5814
cmpl $0x57, %esi
jne 0x5829
movapd %xmm8, %xmm9
jmp 0x5829
movapd %xmm0, %xmm10
jmp 0x5829
movapd %xmm5, %xmm10
jmp 0x5829
movhpd 0x21ab(%rip), %xmm10    # xmm10 = xmm10[0],mem[0]
jmp 0x5829
movapd %xmm3, %xmm9
movapd %xmm1, %xmm10
divsd 0x2166(%rip), %xmm9     # 0x7998
addsd %xmm9, %xmm12
movsd %xmm12, 0x20(%rbx)
divpd %xmm4, %xmm10
addpd %xmm10, %xmm11
movhpd %xmm11, 0x28(%rbx)
movlpd %xmm11, 0x18(%rbx)
addq $0x180, %rdx            # imm = 0x180
cmpq $0x5a08, %rdx           # imm = 0x5A08
jne 0x5792
incq %rcx
addq $0x10, %rax
cmpq $0x18, %rcx
jne 0x578d
leaq 0x2c8(%rbx), %r14
movl $0x10, %r15d
cmpl $0x0, 0xc(%r14)
je 0x58b3
movq %rbx, %rdi
movq %r14, %rsi
movapd %xmm11, 0x10(%rsp)
movsd %xmm12, 0x8(%rsp)
callq 0x5521
movsd 0x8(%rsp), %xmm12
movapd 0x10(%rsp), %xmm11
addq $0x10, %r14
decq %r15
jne 0x5885
movsd %xmm12, 0x8(%rsp)
movapd %xmm11, 0x10(%rsp)
movss 0x1f76(%rip), %xmm1     # 0x7848
xorpd %xmm0, %xmm0
callq 0x6073
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x40(%rbx), %xmm1
divsd 0x20a9(%rip), %xmm1     # 0x7998
ucomisd %xmm0, %xmm1
jbe 0x5974
movss 0x20f7(%rip), %xmm1     # 0x79f4
xorps %xmm0, %xmm0
callq 0x6073
movss %xmm0, 0x2c(%rsp)
callq 0x1060
movaps %xmm0, 0x30(%rsp)
movss 0x2c(%rsp), %xmm0
callq 0x1100
movaps 0x30(%rsp), %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movaps %xmm1, %xmm0
mulps 0x203e(%rip), %xmm0     # 0x7970
addps 0x1ff7(%rip), %xmm0     # 0x7930
xorl %eax, %eax
cmpb $0x0, 0x48(%rbx,%rax)
je 0x5950
addq $0x28, %rax
cmpq $0x280, %rax            # imm = 0x280
jne 0x593b
jmp 0x5974
movb $0x1, %cl
movb %cl, 0x48(%rbx,%rax)
movq %xmm0, %xmm0            # xmm0 = xmm0[0],zero
movdqu %xmm0, 0x4c(%rbx,%rax)
movw $0x67, 0x5c(%rbx,%rax)
movq $0x0, 0x60(%rbx,%rax)
movb %cl, 0x68(%rbx,%rax)
leaq 0x48(%rbx), %r14
movl $0x10, %r15d
movapd 0x10(%rsp), %xmm5
movsd 0x200c(%rip), %xmm6     # 0x7998
movsd 0x8(%rsp), %xmm7
cmpb $0x1, (%r14)
jne 0x5bb8
cvttss2si 0x4(%r14), %esi
movq 0x38(%rbx), %rdi
cvttss2si 0x8(%r14), %edx
callq 0x4cb3
movl %eax, %ebp
cvttss2si 0x4(%r14), %esi
movq 0x38(%rbx), %rdi
cvttss2si 0x8(%r14), %edx
callq 0x4ce1
movl %eax, %r12d
cvttss2si 0xc(%r14), %esi
movq 0x38(%rbx), %rdi
cvttss2si 0x10(%r14), %edx
callq 0x4cb3
movl %eax, %r13d
cvttss2si 0xc(%r14), %esi
movq 0x38(%rbx), %rdi
cvttss2si 0x10(%r14), %edx
callq 0x4ce1
cmpb $0x0, 0x20(%r14)
movw %bp, 0x30(%rsp)
movzwl %bp, %ebp
jne 0x5a29
movsd 0x30(%rbx), %xmm0
ucomisd 0x1fcc(%rip), %xmm0     # 0x79e0
jae 0x5a29
movzwl %r13w, %ecx
cmpl $0x2248, %ecx           # imm = 0x2248
je 0x5a4b
cmpl $0x20, %ecx
je 0x5a4b
jmp 0x5a5c
cmpl $0x2248, %ebp           # imm = 0x2248
je 0x5a36
cmpl $0x20, %ebp
jne 0x5a46
movsd 0x1ef2(%rip), %xmm0     # 0x7930
movsd %xmm0, 0xc(%r14)
jmp 0x5a5c
movb $0x0, 0x20(%r14)
movq %rbx, %rdi
movq %r14, %rsi
movl %eax, %r13d
callq 0x5dc7
movl %r13d, %eax
testw %r12w, %r12w
je 0x5ac3
movq 0x18(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x18(%r14)
cmpq $0x15180, %rax          # imm = 0x15180
movapd 0x10(%rsp), %xmm5
movsd 0x1f16(%rip), %xmm6     # 0x7998
movsd 0x8(%rsp), %xmm7
jl 0x5ba2
movq $0x0, 0x18(%r14)
cvttss2si 0x4(%r14), %esi
cvttss2si 0x8(%r14), %edx
movq %rbx, %rdi
callq 0x5283
movsd 0x8(%rsp), %xmm7
movsd 0x1ee0(%rip), %xmm6     # 0x7998
movapd 0x10(%rsp), %xmm5
jmp 0x5ba2
movq $0x0, 0x18(%r14)
movsd 0x4(%r14), %xmm0
movsd 0xc(%r14), %xmm3
movaps %xmm3, %xmm1
subps %xmm0, %xmm1
movaps %xmm1, %xmm2
mulps %xmm1, %xmm2
shufps $0x55, %xmm2, %xmm2     # xmm2 = xmm2[1,1,1,1]
movaps %xmm1, %xmm4
mulss %xmm1, %xmm4
addss %xmm2, %xmm4
xorps %xmm2, %xmm2
sqrtss %xmm4, %xmm2
xorps %xmm4, %xmm4
cvtss2sd %xmm2, %xmm4
movsd 0x1ea8(%rip), %xmm5     # 0x79b0
ucomisd %xmm4, %xmm5
movapd 0x10(%rsp), %xmm5
movsd 0x1e7e(%rip), %xmm6     # 0x7998
movsd 0x8(%rsp), %xmm7
jbe 0x5b2e
testw %ax, %ax
je 0x5b58
movlps %xmm3, 0x4(%r14)
jmp 0x5ba2
cmpw $0x20, 0x30(%rsp)
je 0x5b4e
movss 0x1eba(%rip), %xmm3     # 0x79f8
cmpl $0x25b2, %ebp           # imm = 0x25B2
je 0x5b70
cmpl $0x2248, %ebp           # imm = 0x2248
jne 0x5b68
movss 0x1e92(%rip), %xmm3     # 0x79e8
jmp 0x5b70
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5dc7
jmp 0x5aaa
movss 0x1e8c(%rip), %xmm3     # 0x79fc
movsd 0x30(%rbx), %xmm4
ucomisd 0x1e63(%rip), %xmm4     # 0x79e0
jb 0x5b86
xorps 0x1b3a(%rip), %xmm3     # 0x76c0
divss 0x1e62(%rip), %xmm3     # 0x79f0
unpcklps %xmm3, %xmm3            # xmm3 = xmm3[0,0,1,1]
mulps %xmm3, %xmm1
unpcklps %xmm2, %xmm2            # xmm2 = xmm2[0,0,1,1]
divps %xmm2, %xmm1
addps %xmm1, %xmm0
movlps %xmm0, 0x4(%r14)
cmpw $0x20, %bp
sete %al
cmpl $0x2248, %ebp           # imm = 0x2248
sete %cl
orb %al, %cl
movb %cl, 0x20(%r14)
addq $0x28, %r14
decq %r15
jne 0x5992
movsd 0x30(%rbx), %xmm0
ucomisd 0x1e0e(%rip), %xmm0     # 0x79e0
jb 0x5bf6
xorl %eax, %eax
cmpl $0x0, 0x1dcc(%rbx,%rax,4)
je 0x5beb
incq %rax
cmpq $0x8, %rax
jne 0x5bd6
jmp 0x5bf6
movl $0x2, 0x1dcc(%rbx,%rax,4)
subsd 0x48(%rsp), %xmm7
mulsd %xmm6, %xmm7
cvttsd2si %xmm7, %edx
movapd %xmm5, %xmm0
unpckhpd %xmm5, %xmm0            # xmm0 = xmm0[1],xmm5[1]
subsd 0x50(%rsp), %xmm0
mulsd %xmm6, %xmm0
cvttsd2si %xmm0, %ecx
subsd 0x60(%rsp), %xmm5
mulsd %xmm6, %xmm5
cvttsd2si %xmm5, %eax
incq 0x8(%rbx)
shlq $0x20, %rcx
orq %rcx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq