// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x18(%rbp), %rax
movsd 0x28(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
cmpl $0x18, -0x34(%rbp)
jge 0x762f
movl $0x0, -0x38(%rbp)
cmpl $0x3c, -0x38(%rbp)
jge 0x761f
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x38(%rbp), %rcx
imulq $0x180, %rcx, %rcx      # imm = 0x180
addq %rcx, %rax
movslq -0x34(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movw 0x2(%rax), %ax
movw %ax, -0x3a(%rbp)
movzwl -0x3a(%rbp), %eax
cmpl $0x0, %eax
je 0x760f
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rcx
movslq -0x38(%rbp), %rax
imulq $0x180, %rax, %rax      # imm = 0x180
addq %rax, %rcx
movslq -0x34(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rcx
movq 0x8(%rcx), %rax
addq $0x1, %rax
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jl 0x760d
movq -0x18(%rbp), %rdi
movzwl -0x3a(%rbp), %esi
callq 0x7800
jmp 0x760f
jmp 0x7611
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x7591
jmp 0x7621
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x7580
movq -0x18(%rbp), %rax
movsd 0x18(%rax), %xmm0
subsd -0x30(%rbp), %xmm0
movsd 0x23bb(%rip), %xmm1     # 0x9a00
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xc(%rbp)
movq -0x18(%rbp), %rax
movsd 0x28(%rax), %xmm0
subsd -0x28(%rbp), %xmm0
movsd 0x239a(%rip), %xmm1     # 0x9a00
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x8(%rbp)
movq -0x18(%rbp), %rax
movsd 0x20(%rax), %xmm0
subsd -0x20(%rbp), %xmm0
movsd 0x2379(%rip), %xmm1     # 0x9a00
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x4(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpq $0x10, %rax
jae 0x76e7
movq -0x18(%rbp), %rax
addq $0x2c8, %rax            # imm = 0x2C8
movl -0x40(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jbe 0x76da
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x2c8, %rsi            # imm = 0x2C8
movl -0x40(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x71e0
jmp 0x76dc
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x7699
xorps %xmm0, %xmm0
movss 0x2262(%rip), %xmm1     # 0x9954
callq 0x8510
cvtss2sd %xmm0, %xmm1
movq -0x18(%rbp), %rax
movss 0x40(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x22f0(%rip), %xmm2     # 0x9a00
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x7754
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x7a50
movq -0x88(%rbp), %rdi
movq -0x48(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x68(%rbp), %xmm0
movups -0x58(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x79d0
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpq $0x10, %rax
jae 0x77a3
movq -0x18(%rbp), %rax
addq $0x48, %rax
movl -0x6c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
testb $0x1, (%rax)
je 0x7796
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x48, %rsi
movl -0x6c(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rsi
callq 0x7b00
jmp 0x7798
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x775b
movq -0x18(%rbp), %rax
movsd 0x30(%rax), %xmm0
movsd 0x2264(%rip), %xmm1     # 0x9a18
ucomisd %xmm1, %xmm0
jb 0x77c8
movq -0x18(%rbp), %rdi
movl $0x2, %esi
callq 0x74c0
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
incq %rcx
movq %rcx, 0x8(%rax)
movl -0x4(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0xc(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movl -0x78(%rbp), %edx
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)