// File: /workspace/github_c_makefile_star2_O0/kobolt[P]curses-collection/cavescroll/cavescroll.c
// Function: generate_cave
static void generate_cave(void)
{
  int i;

  /* Shift entire cave. */
  for (i = 0; i < (CAVE_WIDTH - 1); i++) {
    cave[i].top    = cave[i + 1].top;
    cave[i].bottom = cave[i + 1].bottom;
  }

  objects_shift();

  /* Next top. */
  switch (random() % 5) {
  case 0:
    cave[CAVE_WIDTH - 1].top--;
    if (cave[CAVE_WIDTH - 1].top < CAVE_PADDING_TOP) {
      cave[CAVE_WIDTH - 1].top++;
    }
    break;
  case 1:
    cave[CAVE_WIDTH - 1].top++;
    if (cave[CAVE_WIDTH - 1].top >
      cave[CAVE_WIDTH - 1].bottom - CAVE_OPENING_MIN) {
      cave[CAVE_WIDTH - 1].top--;
    }
    break;
  }

  /* Next bottom. */
  switch (random() % 5) {
  case 0:
    cave[CAVE_WIDTH - 1].bottom++;
    if (cave[CAVE_WIDTH - 1].bottom > CAVE_HEIGHT - CAVE_PADDING_BOTTOM) {
      cave[CAVE_WIDTH - 1].bottom--;
    }
    break;
  case 1:
    cave[CAVE_WIDTH - 1].bottom--;
    if (cave[CAVE_WIDTH - 1].bottom <=
      cave[CAVE_WIDTH - 1].top + CAVE_OPENING_MIN) {
      cave[CAVE_WIDTH - 1].bottom++;
    }
    break;
  }

  /* Possible item. */
  switch (random() % 20) {
  case 0:
    object_spawn(GRAPHICS_MONEY);
    break;
  case 1:
    object_spawn(GRAPHICS_AMMO);
    break;
  case 2:
    object_spawn(GRAPHICS_ENEMY);
    break;
  default:
    break;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x4f, -0x4(%rbp)
jge 0x18a4
movl -0x4(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x389b(%rip), %rax      # 0x5100
movl (%rax,%rcx,8), %edx
movslq -0x4(%rbp), %rcx
leaq 0x388d(%rip), %rax      # 0x5100
movl %edx, (%rax,%rcx,8)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x387a(%rip), %rax      # 0x5100
movl 0x4(%rax,%rcx,8), %edx
movslq -0x4(%rbp), %rcx
leaq 0x386b(%rip), %rax      # 0x5100
movl %edx, 0x4(%rax,%rcx,8)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x184f
callq 0x1da0
callq 0x1100
movq %rax, -0x18(%rbp)
movabsq $0x6666666666666667, %rcx # imm = 0x6666666666666667
imulq %rcx
movq -0x18(%rbp), %rax
movq %rdx, %rcx
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq %rcx
addq %rdx, %rcx
leaq (%rcx,%rcx,4), %rcx
subq %rcx, %rax
movq %rax, -0x10(%rbp)
je 0x18ee
jmp 0x18e2
movq -0x10(%rbp), %rax
subq $0x1, %rax
je 0x1917
jmp 0x194a
movl 0x3a84(%rip), %eax      # 0x5378
addl $-0x1, %eax
movl %eax, 0x3a7b(%rip)      # 0x5378
cmpl $0x2, 0x3a74(%rip)      # 0x5378
jge 0x1915
movl 0x3a6c(%rip), %eax      # 0x5378
addl $0x1, %eax
movl %eax, 0x3a63(%rip)      # 0x5378
jmp 0x194a
movl 0x3a5b(%rip), %eax      # 0x5378
addl $0x1, %eax
movl %eax, 0x3a52(%rip)      # 0x5378
movl 0x3a4c(%rip), %eax      # 0x5378
movl 0x3a4a(%rip), %ecx      # 0x537c
subl $0x3, %ecx
cmpl %ecx, %eax
jle 0x1948
movl 0x3a39(%rip), %eax      # 0x5378
addl $-0x1, %eax
movl %eax, 0x3a30(%rip)      # 0x5378
jmp 0x194a
callq 0x1100
movq %rax, -0x28(%rbp)
movabsq $0x6666666666666667, %rcx # imm = 0x6666666666666667
imulq %rcx
movq -0x28(%rbp), %rax
movq %rdx, %rcx
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq %rcx
addq %rdx, %rcx
leaq (%rcx,%rcx,4), %rcx
subq %rcx, %rax
movq %rax, -0x20(%rbp)
je 0x198f
jmp 0x1983
movq -0x20(%rbp), %rax
subq $0x1, %rax
je 0x19b8
jmp 0x19eb
movl 0x39e7(%rip), %eax      # 0x537c
addl $0x1, %eax
movl %eax, 0x39de(%rip)      # 0x537c
cmpl $0x16, 0x39d7(%rip)     # 0x537c
jle 0x19b6
movl 0x39cf(%rip), %eax      # 0x537c
addl $-0x1, %eax
movl %eax, 0x39c6(%rip)      # 0x537c
jmp 0x19eb
movl 0x39be(%rip), %eax      # 0x537c
addl $-0x1, %eax
movl %eax, 0x39b5(%rip)      # 0x537c
movl 0x39af(%rip), %eax      # 0x537c
movl 0x39a5(%rip), %ecx      # 0x5378
addl $0x3, %ecx
cmpl %ecx, %eax
jg 0x19e9
movl 0x399c(%rip), %eax      # 0x537c
addl $0x1, %eax
movl %eax, 0x3993(%rip)      # 0x537c
jmp 0x19eb
callq 0x1100
movq %rax, -0x38(%rbp)
movabsq $0x6666666666666667, %rcx # imm = 0x6666666666666667
imulq %rcx
movq -0x38(%rbp), %rax
movq %rdx, %rcx
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x3, %rcx
addq %rdx, %rcx
shlq $0x2, %rcx
leaq (%rcx,%rcx,4), %rcx
subq %rcx, %rax
movq %rax, -0x30(%rbp)
je 0x1a41
jmp 0x1a29
movq -0x30(%rbp), %rax
subq $0x1, %rax
je 0x1a4d
jmp 0x1a35
movq -0x30(%rbp), %rax
subq $0x2, %rax
je 0x1a59
jmp 0x1a65
movl $0x24, %edi
callq 0x1730
jmp 0x1a67
movl $0x2b, %edi
callq 0x1730
jmp 0x1a67
movl $0x40, %edi
callq 0x1730
jmp 0x1a67
jmp 0x1a67
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)