// File: /workspace/github_c_makefile_star2_O0/kobolt[P]curses-collection/invaders/game.c
// Function: game_handle_bombs
int game_handle_bombs(void)
{
  int i, j, x, y, invader;

  if (game_state.bomb_pos_y >= 0) { /* Bomb is being dropped. */
    game_state.bomb_pos_y++;

    if (game_state.bomb_pos_y > GAME_MAP_HEIGHT) { /* Out of range. */
      game_state.bomb_pos_y = -1;
      return 0;
    }

    /* Check for collision against player. */
    if (game_state.bomb_pos_y == GAME_MAP_HEIGHT) {
      if ((game_state.bomb_pos_x >= game_state.player_pos - 2) && 
          (game_state.bomb_pos_x <= game_state.player_pos + 2)) {
        game_state.score -= 500;
        return 1;
      }
    }

    /* Check for collision with shields. */
    for (i = 0; i < GAME_SHIELDS; i++) {
      for (j = 0; j < GAME_SHIELD_PARTS; j++) {
        if (game_state.shield_intact[i][j]) {
          y = (i / 4 == 0) ? GAME_MAP_HEIGHT - 4 : GAME_MAP_HEIGHT - 5;
          x = 12 + ((i % 4) * 15) + j;
          if ((game_state.bomb_pos_y == y) &&
              (game_state.bomb_pos_x == x)) {
            game_state.shield_intact[i][j] = false;
            game_state.bomb_pos_y = -1;
          }
        }
      }
    }

  } else { /* Check if a new bomb should be dropped. */

    if (game_invaders_alive() == 0)
      return 0;

    /* Pick a random invader that's still alive. */
    do {
      invader = rand() % GAME_INVADERS;
    } while (! game_state.invader_alive[invader]);

    /* Check if anyone below that invader is still alive. */
    if (invader < 10) {
      if (game_state.invader_alive[invader + 20])
        invader += 20;
      else if (game_state.invader_alive[invader + 10])
        invader += 10;
    } else if (invader < 20) {
      if (game_state.invader_alive[invader + 10])
        invader += 10;
    }

    game_state.bomb_pos_y = game_state.invaders_pos_y + 
      ((invader / 10) * 4) + 2;
    game_state.bomb_pos_x = game_state.invaders_pos_x + 
      ((invader % 10) * 7) + 2;
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movswl 0x2ad7(%rip), %eax      # 0x5156
cmpl $0x0, %eax
jl 0x27f2
movw 0x2ac7(%rip), %ax       # 0x5156
addw $0x1, %ax
movw %ax, 0x2abc(%rip)       # 0x5156
movswl 0x2ab5(%rip), %eax      # 0x5156
cmpl $0x18, %eax
jle 0x26bb
movw $0xffff, 0x2aa7(%rip)   # imm = 0xFFFF
movl $0x0, -0x4(%rbp)
jmp 0x28fc
movswl 0x2a94(%rip), %eax      # 0x5156
cmpl $0x18, %eax
jne 0x2713
movswl 0x2a8a(%rip), %eax      # 0x5158
movswl 0x2a75(%rip), %ecx      # 0x514a
subl $0x2, %ecx
cmpl %ecx, %eax
jl 0x2711
movswl 0x2a75(%rip), %eax      # 0x5158
movswl 0x2a60(%rip), %ecx      # 0x514a
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x2711
movq 0x2a48(%rip), %rax      # 0x5140
subq $0x1f4, %rax            # imm = 0x1F4
movq %rax, 0x2a3b(%rip)      # 0x5140
movl $0x1, -0x4(%rbp)
jmp 0x28fc
jmp 0x2713
movl $0x0, -0x8(%rbp)
cmpl $0x8, -0x8(%rbp)
jge 0x27ed
movl $0x0, -0xc(%rbp)
cmpl $0xa, -0xc(%rbp)
jge 0x27dd
movslq -0x8(%rbp), %rcx
leaq 0x2a00(%rip), %rax      # 0x5140
addq $0x38, %rax
imulq $0xa, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0x27cd
movl -0x8(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %edx
movl $0x13, %eax
movl $0x14, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
imull $0xf, %edx, %eax
addl $0xc, %eax
addl -0xc(%rbp), %eax
movl %eax, -0x10(%rbp)
movswl 0x29c3(%rip), %eax      # 0x5156
cmpl -0x14(%rbp), %eax
jne 0x27cb
movswl 0x29b9(%rip), %eax      # 0x5158
cmpl -0x10(%rbp), %eax
jne 0x27cb
movslq -0x8(%rbp), %rcx
leaq 0x2991(%rip), %rax      # 0x5140
addq $0x38, %rax
imulq $0xa, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movw $0xffff, 0x298b(%rip)   # imm = 0xFFFF
jmp 0x27cd
jmp 0x27cf
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x272b
jmp 0x27df
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x271a
jmp 0x28f5
callq 0x20c0
cmpl $0x0, %eax
jne 0x2808
movl $0x0, -0x4(%rbp)
jmp 0x28fc
jmp 0x280a
callq 0x1170
movl $0x1e, %ecx
cltd
idivl %ecx
movl %edx, -0x18(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x291b(%rip), %rax      # 0x5140
movb 0x1a(%rax,%rcx), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x280a
cmpl $0xa, -0x18(%rbp)
jge 0x287b
movl -0x18(%rbp), %eax
addl $0x14, %eax
movslq %eax, %rcx
leaq 0x28fb(%rip), %rax      # 0x5140
testb $0x1, 0x1a(%rax,%rcx)
je 0x2857
movl -0x18(%rbp), %eax
addl $0x14, %eax
movl %eax, -0x18(%rbp)
jmp 0x2879
movl -0x18(%rbp), %eax
addl $0xa, %eax
movslq %eax, %rcx
leaq 0x28d9(%rip), %rax      # 0x5140
testb $0x1, 0x1a(%rax,%rcx)
je 0x2877
movl -0x18(%rbp), %eax
addl $0xa, %eax
movl %eax, -0x18(%rbp)
jmp 0x2879
jmp 0x28a5
cmpl $0x14, -0x18(%rbp)
jge 0x28a3
movl -0x18(%rbp), %eax
addl $0xa, %eax
movslq %eax, %rcx
leaq 0x28af(%rip), %rax      # 0x5140
testb $0x1, 0x1a(%rax,%rcx)
je 0x28a1
movl -0x18(%rbp), %eax
addl $0xa, %eax
movl %eax, -0x18(%rbp)
jmp 0x28a3
jmp 0x28a5
movswl 0x28a0(%rip), %eax      # 0x514c
movl %eax, -0x20(%rbp)
movl -0x18(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x20(%rbp), %eax
shll $0x2, %ecx
addl %ecx, %eax
addl $0x2, %eax
movw %ax, 0x2888(%rip)       # 0x5156
movswl 0x2879(%rip), %eax      # 0x514e
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl -0x1c(%rbp), %eax
imull $0x7, %edx, %ecx
addl %ecx, %eax
addl $0x2, %eax
movw %ax, 0x2863(%rip)       # 0x5158
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop