// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movq %rdi, %rbx
movsd 0x18(%rdi), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x20(%rdi), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x28(%rdi), %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x38(%rdi), %rax
xorl %ecx, %ecx
movsd 0x2708(%rip), %xmm0     # 0x78d0
movsd 0x2710(%rip), %xmm1     # 0x78e0
movsd 0x26f0(%rip), %xmm2     # 0x78c8
movsd 0x26c7(%rip), %xmm8     # 0x78a8
movsd 0x26ff(%rip), %xmm3     # 0x78e8
movsd 0x26e7(%rip), %xmm4     # 0x78d8
movl $0x8, %edx
movzwl -0x6(%rax,%rdx), %esi
testl %esi, %esi
je 0x52da
movq (%rax,%rdx), %rdi
leaq 0x1(%rdi), %r8
movq %r8, (%rax,%rdx)
cmpq $-0x1, %rdi
jl 0x52da
xorpd %xmm5, %xmm5
cmpl $0x47, %esi
jg 0x5242
cmpl $0x42, %esi
jg 0x525f
testl %esi, %esi
je 0x52da
cmpl $0x2b, %esi
jne 0x52a5
xorpd %xmm6, %xmm6
xorpd %xmm7, %xmm7
movapd %xmm0, %xmm5
jmp 0x52ad
cmpl $0x52, %esi
jg 0x5273
cmpl $0x48, %esi
je 0x5283
cmpl $0x4d, %esi
jne 0x52a5
movapd %xmm0, %xmm6
xorpd %xmm7, %xmm7
movapd %xmm4, %xmm5
jmp 0x52ad
cmpl $0x43, %esi
je 0x528d
cmpl $0x46, %esi
jne 0x52a5
xorpd %xmm6, %xmm6
movapd %xmm2, %xmm7
jmp 0x52ad
cmpl $0x53, %esi
je 0x529b
cmpl $0x57, %esi
jne 0x52a5
movapd %xmm4, %xmm6
jmp 0x52a9
xorpd %xmm6, %xmm6
movapd %xmm3, %xmm7
jmp 0x5295
movapd %xmm1, %xmm6
movapd %xmm1, %xmm7
movapd %xmm1, %xmm5
jmp 0x52ad
xorpd %xmm6, %xmm6
movapd %xmm3, %xmm7
jmp 0x52ad
xorpd %xmm6, %xmm6
xorpd %xmm7, %xmm7
divsd %xmm8, %xmm6
addsd 0x20(%rbx), %xmm6
movsd %xmm6, 0x20(%rbx)
divsd %xmm8, %xmm7
addsd 0x28(%rbx), %xmm7
movsd %xmm7, 0x28(%rbx)
divsd %xmm8, %xmm5
addsd 0x18(%rbx), %xmm5
movsd %xmm5, 0x18(%rbx)
addq $0x180, %rdx            # imm = 0x180
cmpq $0x5a08, %rdx           # imm = 0x5A08
jne 0x51f6
incq %rcx
addq $0x10, %rax
cmpq $0x18, %rcx
jne 0x51f1
movsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x20(%rbx), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x28(%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x2c8(%rbx), %r14
movl $0x10, %r15d
cmpl $0x0, 0xc(%r14)
je 0x533f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4f64
addq $0x10, %r14
decq %r15
jne 0x532d
movss 0x2480(%rip), %xmm1     # 0x77d0
xorps %xmm0, %xmm0
callq 0x5af3
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x40(%rbx), %xmm1
divsd 0x253c(%rip), %xmm1     # 0x78a8
ucomisd %xmm0, %xmm1
jbe 0x5408
movss 0x258e(%rip), %xmm1     # 0x790c
xorps %xmm0, %xmm0
callq 0x5af3
movss %xmm0, 0xc(%rsp)
callq 0x1060
mulss 0x2457(%rip), %xmm0     # 0x77f0
addss 0x2557(%rip), %xmm0     # 0x78f8
movss %xmm0, 0x8(%rsp)
movss 0xc(%rsp), %xmm0
callq 0x1100
mulss 0x2432(%rip), %xmm0     # 0x77ec
addss 0x253a(%rip), %xmm0     # 0x78fc
xorl %eax, %eax
cmpb $0x0, 0x48(%rbx,%rax)
je 0x53d9
addq $0x28, %rax
cmpq $0x280, %rax            # imm = 0x280
jne 0x53c4
jmp 0x5408
movb $0x1, %cl
movb %cl, 0x48(%rbx,%rax)
movss 0x8(%rsp), %xmm1
movss %xmm1, 0x4c(%rbx,%rax)
movss %xmm0, 0x50(%rbx,%rax)
xorl %edx, %edx
movq %rdx, 0x54(%rbx,%rax)
movw $0x67, 0x5c(%rbx,%rax)
movq %rdx, 0x60(%rbx,%rax)
movb %cl, 0x68(%rbx,%rax)
leaq 0x48(%rbx), %r14
movl $0x10, %r15d
movsd 0x248e(%rip), %xmm3     # 0x78a8
cmpb $0x1, (%r14)
jne 0x565f
cvttss2si 0x4(%r14), %esi
movq 0x38(%rbx), %rdi
cvttss2si 0x8(%r14), %edx
callq 0x46b9
movl %eax, %ebp
cvttss2si 0x4(%r14), %esi
movq 0x38(%rbx), %rdi
cvttss2si 0x8(%r14), %edx
callq 0x46e7
movl %eax, %r12d
cvttss2si 0xc(%r14), %esi
movq 0x38(%rbx), %rdi
cvttss2si 0x10(%r14), %edx
callq 0x46b9
movl %eax, %r13d
cvttss2si 0xc(%r14), %esi
movq 0x38(%rbx), %rdi
cvttss2si 0x10(%r14), %edx
callq 0x46e7
movw %ax, 0x8(%rsp)
cmpb $0x0, 0x20(%r14)
movw %bp, 0xc(%rsp)
movzwl %bp, %ebp
jne 0x54b5
movsd 0x30(%rbx), %xmm0
ucomisd 0x244f(%rip), %xmm0     # 0x78f0
jae 0x54b5
movzwl %r13w, %eax
cmpl $0x2248, %eax           # imm = 0x2248
je 0x54d7
cmpl $0x20, %eax
je 0x54d7
jmp 0x54e2
cmpl $0x2248, %ebp           # imm = 0x2248
je 0x54c2
cmpl $0x20, %ebp
jne 0x54d2
movabsq $0x4140000041f00000, %rax # imm = 0x4140000041F00000
movq %rax, 0xc(%r14)
jmp 0x54e2
movb $0x0, 0x20(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5863
testw %r12w, %r12w
je 0x5531
movq 0x18(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x18(%r14)
cmpq $0x15180, %rax          # imm = 0x15180
movsd 0x23a6(%rip), %xmm3     # 0x78a8
jl 0x5649
movq $0x0, 0x18(%r14)
cvttss2si 0x4(%r14), %esi
cvttss2si 0x8(%r14), %edx
movq %rbx, %rdi
callq 0x4cb0
movsd 0x237c(%rip), %xmm3     # 0x78a8
jmp 0x5649
movq $0x0, 0x18(%r14)
movss 0xc(%r14), %xmm5
movss 0x10(%r14), %xmm4
subss 0x4(%r14), %xmm5
subss 0x8(%r14), %xmm4
movaps %xmm4, %xmm1
mulss %xmm4, %xmm1
movaps %xmm5, %xmm0
mulss %xmm5, %xmm0
addss %xmm1, %xmm0
ucomiss 0x227e(%rip), %xmm0     # 0x77e8
jb 0x5572
sqrtss %xmm0, %xmm0
jmp 0x558f
movss %xmm4, 0x14(%rsp)
movss %xmm5, 0x10(%rsp)
callq 0x11a0
movss 0x10(%rsp), %xmm5
movss 0x14(%rsp), %xmm4
movsd 0x2311(%rip), %xmm3     # 0x78a8
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd 0x231a(%rip), %xmm2     # 0x78c0
ucomisd %xmm1, %xmm2
jbe 0x55c1
cmpw $0x0, 0x8(%rsp)
je 0x55eb
movq 0xc(%r14), %rax
movq %rax, 0x4(%r14)
jmp 0x5649
cmpw $0x20, 0xc(%rsp)
je 0x55e1
movss 0x233f(%rip), %xmm1     # 0x7910
cmpl $0x25b2, %ebp           # imm = 0x25B2
je 0x5603
cmpl $0x2248, %ebp           # imm = 0x2248
jne 0x55fb
movss 0x2317(%rip), %xmm1     # 0x7900
jmp 0x5603
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5863
jmp 0x5524
movss 0x2311(%rip), %xmm1     # 0x7914
movsd 0x30(%rbx), %xmm2
ucomisd 0x22e0(%rip), %xmm2     # 0x78f0
jb 0x5619
xorps 0x2307(%rip), %xmm1     # 0x7920
divss 0x22e7(%rip), %xmm1     # 0x7908
mulss %xmm1, %xmm5
divss %xmm0, %xmm5
addss 0x4(%r14), %xmm5
movss %xmm5, 0x4(%r14)
mulss %xmm1, %xmm4
divss %xmm0, %xmm4
addss 0x8(%r14), %xmm4
movss %xmm4, 0x8(%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 0x541a
movsd 0x30(%rbx), %xmm0
ucomisd 0x2277(%rip), %xmm0     # 0x78f0
jb 0x569d
xorl %eax, %eax
cmpl $0x0, 0x1dcc(%rbx,%rax,4)
je 0x5692
incq %rax
cmpq $0x8, %rax
jne 0x567d
jmp 0x569d
movl $0x2, 0x1dcc(%rbx,%rax,4)
movsd 0x18(%rsp), %xmm0
subsd 0x30(%rsp), %xmm0
mulsd %xmm3, %xmm0
cvttsd2si %xmm0, %edx
movsd 0x20(%rsp), %xmm0
subsd 0x38(%rsp), %xmm0
mulsd %xmm3, %xmm0
cvttsd2si %xmm0, %ecx
movsd 0x28(%rsp), %xmm0
subsd 0x40(%rsp), %xmm0
mulsd %xmm3, %xmm0
cvttsd2si %xmm0, %eax
incq 0x8(%rbx)
shlq $0x20, %rcx
orq %rcx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq