#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct timeval {
  int tv_usec;
  int tv_sec;
};
struct timespec {
  int tv_nsec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ addaces(int *, int *, int);
int /*<<< orphan*/ addslave(int *);
int /*<<< orphan*/ blackqueen(int *, int *, int *, int *, int *, int *, int *,
                              int *, int *, int *, int *, int *, int);
int checkfullinv(int *);
int /*<<< orphan*/ dropinv(int *, int);
int /*<<< orphan*/ genie(int *, int *, int *, int *, int *, int *, int *, int *,
                         int *, int *, int *, int *, int, int);
int /*<<< orphan*/ getint(int *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ hebrac(int *, int *, int *, int *, int *, int *, int *,
                          int *, int *, int *, int *, int *, int,
                          int /*<<< orphan*/, int);
int /*<<< orphan*/ nameitem(char *, int);
int /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ redqueen(int *, int *, int *, int *, int *, int *, int *,
                            int *, int *, int *, int *, int *, int,
                            int /*<<< orphan*/, int);
int /*<<< orphan*/ shiftarray(int *);
int /*<<< orphan*/ srand(int);
void treasure(int *hpmax, int *hpnow, int *aces, int *inv, int *slave,
              int *future, int *map, int *loot, int *vision, int *end, int *pos,
              int *antimag, int rec, int stat, int combat) {
  struct timespec a;
  a.tv_sec = 0;
  a.tv_nsec = 1000;
  nanosleep(&a, NULL);
  struct timeval t1;
  gettimeofday(&t1, NULL);
  srand(t1.tv_usec * t1.tv_sec);
  int r, n;
  if (stat == 0) {
    if (*future >= 0) {
      r = *future;
      shiftarray(future);
    } else
      r = rand() % 54;
  } else
    r = *(loot + *pos);
  if (r == -1) {
    printf("This room is empty...\n");
    return;
  }
  if (stat == 1) {
    printf(
        "Do you want to take the treasure in this room?\n[0]: No\n[1]: Yes\n");
    getint(&n);
    if (n == 0)
      return;
  }
  if (r >= 52)
    hebrac(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end, pos,
           antimag, rec, 0, combat);
  else if (r % 13 == 12) {
    if (rec == 0)
      genie(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end, pos,
            antimag, r, combat);
    else {
      printf("An empty lantern...");
    }
  } else if (r % 13 == 11) {
    if (r >= 25)
      blackqueen(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end,
                 pos, antimag, 1);
    else
      redqueen(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end,
               pos, antimag, rec, 0, combat);
  } else if (r % 13 == 10)
    addslave(slave);
  else if (r % 13 == 0)
    addaces(hpmax, aces, r);
  else {
    int n = checkfullinv(inv);
    char s[20];
    if (n >= 0) {
      *(inv + n) = r;
      nameitem(s, r);
      printf("You received %s!\n", s);
    } else {
      dropinv(inv, r);
    }
  }
  if (stat == 1) {
    *(loot + *pos) = -1;
    *(vision + *pos) = 2;
  }
}


x86 assembly (clang, -O0):
<treasure>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    0x50(%rbp),%eax
mov    0x48(%rbp),%eax
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
mov    %r8,-0x50(%rbp)
mov    %r9,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movl   $0x3e8,-0x68(%rbp)
lea    -0x68(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <nanosleep@plt>
lea    -0x70(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x70(%rbp),%edi
imul   -0x6c(%rbp),%edi
call   1070 <srand@plt>
cmpl   $0x0,0x48(%rbp)
jne    12c7 <treasure+0xc7>
mov    -0x58(%rbp),%rax
cmpl   $0x0,(%rax)
jl     12b0 <treasure+0xb0>
mov    -0x58(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x58(%rbp),%rdi
call   10b0 <shiftarray@plt>
jmp    12c2 <treasure+0xc2>
mov    $0x0,%al
call   1120 <rand@plt>
mov    $0x36,%ecx
cltd
idiv   %ecx
mov    %edx,-0x74(%rbp)
jmp    12d8 <treasure+0xd8>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x74(%rbp)
cmpl   $0xffffffff,-0x74(%rbp)
jne    12f5 <treasure+0xf5>
lea    0xd17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    162e <treasure+0x42e>
cmpl   $0x1,0x48(%rbp)
jne    132a <treasure+0x12a>
lea    0xd11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x78(%rbp),%rdi
call   1060 <getint@plt>
cmpl   $0x0,-0x78(%rbp)
jne    1325 <treasure+0x125>
jmp    162e <treasure+0x42e>
jmp    132a <treasure+0x12a>
cmpl   $0x34,-0x74(%rbp)
jl     13b1 <treasure+0x1b1>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    0x10(%rbp),%r13
mov    0x18(%rbp),%r12
mov    0x20(%rbp),%r15
mov    0x28(%rbp),%r14
mov    0x30(%rbp),%rbx
mov    0x38(%rbp),%r11
mov    0x40(%rbp),%r10d
mov    0x50(%rbp),%eax
mov    %eax,-0x94(%rbp)
xor    %eax,%eax
mov    -0x94(%rbp),%eax
mov    %r13,(%rsp)
mov    %r12,0x8(%rsp)
mov    %r15,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10d,0x30(%rsp)
movl   $0x0,0x38(%rsp)
mov    %eax,0x40(%rsp)
call   10e0 <hebrac@plt>
jmp    1600 <treasure+0x400>
mov    -0x74(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0xc,%edx
jne    1449 <treasure+0x249>
cmpl   $0x0,0x40(%rbp)
jne    1436 <treasure+0x236>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    0x10(%rbp),%r13
mov    0x18(%rbp),%r12
mov    0x20(%rbp),%r15
mov    0x28(%rbp),%r14
mov    0x30(%rbp),%rbx
mov    0x38(%rbp),%r11
mov    -0x74(%rbp),%r10d
mov    0x50(%rbp),%eax
mov    %r13,(%rsp)
mov    %r12,0x8(%rsp)
mov    %r15,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10d,0x30(%rsp)
mov    %eax,0x38(%rsp)
call   1110 <genie@plt>
jmp    1444 <treasure+0x244>
lea    0xc1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    15fb <treasure+0x3fb>
mov    -0x74(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0xb,%edx
jne    1543 <treasure+0x343>
cmpl   $0x19,-0x74(%rbp)
jl     14c6 <treasure+0x2c6>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    0x10(%rbp),%r15
mov    0x18(%rbp),%r14
mov    0x20(%rbp),%rbx
mov    0x28(%rbp),%r11
mov    0x30(%rbp),%r10
mov    0x38(%rbp),%rax
mov    %r15,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
movl   $0x1,0x30(%rsp)
call   1100 <blackqueen@plt>
jmp    153e <treasure+0x33e>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    0x10(%rbp),%r13
mov    0x18(%rbp),%r12
mov    0x20(%rbp),%r15
mov    0x28(%rbp),%r14
mov    0x30(%rbp),%rbx
mov    0x38(%rbp),%r11
mov    0x40(%rbp),%r10d
mov    0x50(%rbp),%eax
mov    %eax,-0x98(%rbp)
xor    %eax,%eax
mov    -0x98(%rbp),%eax
mov    %r13,(%rsp)
mov    %r12,0x8(%rsp)
mov    %r15,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10d,0x30(%rsp)
movl   $0x0,0x38(%rsp)
mov    %eax,0x40(%rsp)
call   10f0 <redqueen@plt>
jmp    15f6 <treasure+0x3f6>
mov    -0x74(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0xa,%edx
jne    1565 <treasure+0x365>
mov    -0x50(%rbp),%rdi
call   10a0 <addslave@plt>
jmp    15f1 <treasure+0x3f1>
mov    -0x74(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    158e <treasure+0x38e>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x74(%rbp),%edx
call   10d0 <addaces@plt>
jmp    15ec <treasure+0x3ec>
mov    -0x48(%rbp),%rdi
call   10c0 <checkfullinv@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jl     15db <treasure+0x3db>
mov    -0x74(%rbp),%edx
mov    -0x48(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
lea    -0x90(%rbp),%rdi
mov    -0x74(%rbp),%esi
call   1090 <nameitem@plt>
lea    -0x90(%rbp),%rsi
lea    0xa9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    15e7 <treasure+0x3e7>
mov    -0x48(%rbp),%rdi
mov    -0x74(%rbp),%esi
call   1080 <dropinv@plt>
jmp    15ec <treasure+0x3ec>
jmp    15f1 <treasure+0x3f1>
jmp    15f6 <treasure+0x3f6>
jmp    15fb <treasure+0x3fb>
jmp    1600 <treasure+0x400>
cmpl   $0x1,0x48(%rbp)
jne    162e <treasure+0x42e>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    0x20(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0x2,(%rax,%rcx,4)
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<treasure>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,%r13
mov    %r8,0x8(%rsp)
mov    %rcx,0x10(%rsp)
mov    %rdx,(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,%rbx
mov    0xc8(%rsp),%r14d
mov    0xb0(%rsp),%rbp
mov    0x98(%rsp),%r12
movq   $0x0,0x38(%rsp)
movl   $0x3e8,0x30(%rsp)
lea    0x30(%rsp),%rdi
xor    %esi,%esi
call   1050 <nanosleep@plt>
lea    0x28(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0x2c(%rsp),%edi
imul   0x28(%rsp),%edi
call   1080 <srand@plt>
test   %r14d,%r14d
je     12c8 <treasure+0xb8>
movslq 0x0(%rbp),%rax
mov    (%r12,%rax,4),%r15d
cmp    $0xffffffff,%r15d
je     13db <treasure+0x1cb>
cmp    $0x1,%r14d
jne    12dd <treasure+0xcd>
lea    0xdb0(%rip),%rdi
call   1030 <puts@plt>
lea    0x24(%rsp),%rdi
call   1070 <getint@plt>
mov    $0x1,%r14b
cmpl   $0x0,0x24(%rsp)
jne    12e0 <treasure+0xd0>
jmp    1512 <treasure+0x302>
mov    0x0(%r13),%r15d
test   %r15d,%r15d
js     13aa <treasure+0x19a>
mov    %r13,%rdi
call   10c0 <shiftarray@plt>
xor    %r14d,%r14d
mov    %rbx,%rdi
mov    0xd0(%rsp),%r10d
mov    0xc0(%rsp),%r11d
mov    0xb8(%rsp),%rbp
mov    0xa8(%rsp),%rax
mov    0xa0(%rsp),%rbx
mov    0x90(%rsp),%rsi
cmp    $0x34,%r15d
jl     1362 <treasure+0x152>
sub    $0x8,%rsp
mov    %rsi,%r15
mov    0x20(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%r8
mov    %r13,%r9
push   %r10
push   $0x0
push   %r11
push   %rbp
push   0xd8(%rsp)
push   %rax
push   %rbx
push   %r12
push   %r15
call   10f0 <hebrac@plt>
add    $0x50,%rsp
test   %r14b,%r14b
jne    14f5 <treasure+0x2e5>
jmp    1512 <treasure+0x302>
movslq %r15d,%rcx
imul   $0x4ec4ec4f,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%edx
mov    %r15d,%ecx
sub    %edx,%ecx
cmp    $0xc,%ecx
ja     13ec <treasure+0x1dc>
lea    0xc70(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    (%rsp),%rsi
mov    %r15d,%edx
call   10e0 <addaces@plt>
jmp    14e8 <treasure+0x2d8>
xor    %r14d,%r14d
xor    %eax,%eax
call   1130 <rand@plt>
movslq %eax,%r15
imul   $0x4bda12f7,%r15,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x24,%rax
add    %ecx,%eax
imul   $0x36,%eax,%eax
sub    %eax,%r15d
cmp    $0xffffffff,%r15d
jne    12e0 <treasure+0xd0>
lea    0xcb8(%rip),%rdi
call   1030 <puts@plt>
jmp    1512 <treasure+0x302>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   10d0 <checkfullinv@plt>
test   %eax,%eax
js     14dd <treasure+0x2cd>
mov    %eax,%eax
mov    %r15d,(%rbx,%rax,4)
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15d,%esi
call   10a0 <nameitem@plt>
lea    0xc2a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    14e8 <treasure+0x2d8>
mov    0x8(%rsp),%rdi
call   10b0 <addslave@plt>
jmp    14e8 <treasure+0x2d8>
sub    $0x8,%rsp
cmp    $0x19,%r15d
jl     149b <treasure+0x28b>
mov    %rsi,%r10
mov    0x20(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%r8
mov    %r13,%r9
push   $0x1
push   %rbp
push   0xc8(%rsp)
push   %rax
mov    0xc8(%rsp),%rbx
push   %rbx
push   %r12
push   %r10
call   1110 <blackqueen@plt>
jmp    1559 <treasure+0x349>
test   %r11d,%r11d
je     1521 <treasure+0x311>
lea    0xba2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    14e8 <treasure+0x2d8>
mov    %rax,%rbx
mov    %rsi,%rax
mov    0x20(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%r8
mov    %r13,%r9
push   %r10
push   $0x0
push   %r11
push   %rbp
push   0xd8(%rsp)
push   %rbx
mov    0xd8(%rsp),%rbx
push   %rbx
push   %r12
push   %rax
call   1100 <redqueen@plt>
jmp    1350 <treasure+0x140>
mov    %rbx,%rdi
mov    %r15d,%esi
call   1090 <dropinv@plt>
mov    0xa0(%rsp),%rbx
test   %r14b,%r14b
je     1512 <treasure+0x302>
mov    0xb0(%rsp),%rcx
movslq (%rcx),%rax
movl   $0xffffffff,(%r12,%rax,4)
ff
movslq (%rcx),%rax
movl   $0x2,(%rbx,%rax,4)
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r11
mov    0x18(%rsp),%rsi
mov    (%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    0x8(%rsp),%r8
mov    %r13,%r9
push   %r10
push   %r15
push   %rbp
push   0xc8(%rsp)
push   %rax
mov    0xc8(%rsp),%rbx
push   %rbx
push   %r12
push   %r11
call   1120 <genie@plt>
add    $0x40,%rsp
test   %r14b,%r14b
jne    14f5 <treasure+0x2e5>
jmp    1512 <treasure+0x302>

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
%struct.timeval = type { i32, i32 }
@.str = [23 x i8] c"This room is empty...\0A\00"
@.str.1 = [65 x i8] c"Do you want to take the treasure in this room?\0A[0]: No\0A[1]: Yes\0A\00"
@.str.2 = [20 x i8] c"An empty lantern...\00"
@.str.3 = [18 x i8] c"You received %s!\0A\00"
define void @treasure(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32 %12, i32 %13, i32 %14) {
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i32*
%23 = alloca i32*
%24 = alloca i32*
%25 = alloca i32*
%26 = alloca i32*
%27 = alloca i32*
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca %struct.timespec
%32 = alloca %struct.timeval
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
%36 = alloca [20 x i8]
store i32* %0, i32** %16
store i32* %1, i32** %17
store i32* %2, i32** %18
store i32* %3, i32** %19
store i32* %4, i32** %20
store i32* %5, i32** %21
store i32* %6, i32** %22
store i32* %7, i32** %23
store i32* %8, i32** %24
store i32* %9, i32** %25
store i32* %10, i32** %26
store i32* %11, i32** %27
store i32 %12, i32* %28
store i32 %13, i32* %29
store i32 %14, i32* %30
%37 = getelementptr inbounds %struct.timespec, %struct.timespec* %31, i32 0, i32 1
store i64 0, i64* %37
%38 = getelementptr inbounds %struct.timespec, %struct.timespec* %31, i32 0, i32 0
store i32 1000, i32* %38
%39 = call i32 @nanosleep(%struct.timespec* %31, i32* null)
%40 = call i32 @gettimeofday(%struct.timeval* %32, i32* null)
%41 = getelementptr inbounds %struct.timeval, %struct.timeval* %32, i32 0, i32 0
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.timeval, %struct.timeval* %32, i32 0, i32 1
%44 = load i32, i32* %43
%45 = mul nsw i32 %42, %44
%46 = call i32 @srand(i32 %45)
%47 = load i32, i32* %29
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %62
49: ; preds = %15
%50 = load i32*, i32** %21
%51 = load i32, i32* %50
%52 = icmp sge i32 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = load i32*, i32** %21
%55 = load i32, i32* %54
store i32 %55, i32* %33
%56 = load i32*, i32** %21
%57 = call i32 @shiftarray(i32* %56)
br label %61
58: ; preds = %49
%59 = call i32 (...) @rand()
%60 = srem i32 %59, 54
store i32 %60, i32* %33
br label %61
61: ; preds = %58, %53
br label %69
62: ; preds = %15
%63 = load i32*, i32** %23
%64 = load i32*, i32** %26
%65 = load i32, i32* %64
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %63, i64 %66
%68 = load i32, i32* %67
store i32 %68, i32* %33
br label %69
69: ; preds = %62, %61
%70 = load i32, i32* %33
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %222
74: ; preds = %69
%75 = load i32, i32* %29
%76 = icmp eq i32 %75, 1
br i1 %76, label %77, label %84
77: ; preds = %74
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
%79 = call i32 @getint(i32* %34)
%80 = load i32, i32* %34
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %83
82: ; preds = %77
br label %222
83: ; preds = %77
br label %84
84: ; preds = %83, %74
%85 = load i32, i32* %33
%86 = icmp sge i32 %85, 52
br i1 %86, label %87, label %103
87: ; preds = %84
%88 = load i32*, i32** %16
%89 = load i32*, i32** %17
%90 = load i32*, i32** %18
%91 = load i32*, i32** %19
%92 = load i32*, i32** %20
%93 = load i32*, i32** %21
%94 = load i32*, i32** %22
%95 = load i32*, i32** %23
%96 = load i32*, i32** %24
%97 = load i32*, i32** %25
%98 = load i32*, i32** %26
%99 = load i32*, i32** %27
%100 = load i32, i32* %28
%101 = load i32, i32* %30
%102 = call i32 @hebrac(i32* %88, i32* %89, i32* %90, i32* %91, i32* %92, i32* %93, i32* %94, i32* %95, i32* %96, i32* %97, i32* %98, i32* %99, i32 %100, i32 0, i32 %101)
br label %208
103: ; preds = %84
%104 = load i32, i32* %33
%105 = srem i32 %104, 13
%106 = icmp eq i32 %105, 12
br i1 %106, label %107, label %129
107: ; preds = %103
%108 = load i32, i32* %28
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %126
110: ; preds = %107
%111 = load i32*, i32** %16
%112 = load i32*, i32** %17
%113 = load i32*, i32** %18
%114 = load i32*, i32** %19
%115 = load i32*, i32** %20
%116 = load i32*, i32** %21
%117 = load i32*, i32** %22
%118 = load i32*, i32** %23
%119 = load i32*, i32** %24
%120 = load i32*, i32** %25
%121 = load i32*, i32** %26
%122 = load i32*, i32** %27
%123 = load i32, i32* %33
%124 = load i32, i32* %30
%125 = call i32 @genie(i32* %111, i32* %112, i32* %113, i32* %114, i32* %115, i32* %116, i32* %117, i32* %118, i32* %119, i32* %120, i32* %121, i32* %122, i32 %123, i32 %124)
br label %128
126: ; preds = %107
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %128
128: ; preds = %126, %110
br label %207
129: ; preds = %103
%130 = load i32, i32* %33
%131 = srem i32 %130, 13
%132 = icmp eq i32 %131, 11
br i1 %132, label %133, label %167
133: ; preds = %129
%134 = load i32, i32* %33
%135 = icmp sge i32 %134, 25
br i1 %135, label %136, label %150
136: ; preds = %133
%137 = load i32*, i32** %16
%138 = load i32*, i32** %17
%139 = load i32*, i32** %18
%140 = load i32*, i32** %19
%141 = load i32*, i32** %20
%142 = load i32*, i32** %21
%143 = load i32*, i32** %22
%144 = load i32*, i32** %23
%145 = load i32*, i32** %24
%146 = load i32*, i32** %25
%147 = load i32*, i32** %26
%148 = load i32*, i32** %27
%149 = call i32 @blackqueen(i32* %137, i32* %138, i32* %139, i32* %140, i32* %141, i32* %142, i32* %143, i32* %144, i32* %145, i32* %146, i32* %147, i32* %148, i32 1)
br label %166
150: ; preds = %133
%151 = load i32*, i32** %16
%152 = load i32*, i32** %17
%153 = load i32*, i32** %18
%154 = load i32*, i32** %19
%155 = load i32*, i32** %20
%156 = load i32*, i32** %21
%157 = load i32*, i32** %22
%158 = load i32*, i32** %23
%159 = load i32*, i32** %24
%160 = load i32*, i32** %25
%161 = load i32*, i32** %26
%162 = load i32*, i32** %27
%163 = load i32, i32* %28
%164 = load i32, i32* %30
%165 = call i32 @redqueen(i32* %151, i32* %152, i32* %153, i32* %154, i32* %155, i32* %156, i32* %157, i32* %158, i32* %159, i32* %160, i32* %161, i32* %162, i32 %163, i32 0, i32 %164)
br label %166
166: ; preds = %150, %136
br label %206
167: ; preds = %129
%168 = load i32, i32* %33
%169 = srem i32 %168, 13
%170 = icmp eq i32 %169, 10
br i1 %170, label %171, label %174
171: ; preds = %167
%172 = load i32*, i32** %20
%173 = call i32 @addslave(i32* %172)
br label %205
174: ; preds = %167
%175 = load i32, i32* %33
%176 = srem i32 %175, 13
%177 = icmp eq i32 %176, 0
br i1 %177, label %178, label %183
178: ; preds = %174
%179 = load i32*, i32** %16
%180 = load i32*, i32** %18
%181 = load i32, i32* %33
%182 = call i32 @addaces(i32* %179, i32* %180, i32 %181)
br label %204
183: ; preds = %174
%184 = load i32*, i32** %19
%185 = call i32 @checkfullinv(i32* %184)
store i32 %185, i32* %35
%186 = load i32, i32* %35
%187 = icmp sge i32 %186, 0
br i1 %187, label %188, label %199
188: ; preds = %183
%189 = load i32, i32* %33
%190 = load i32*, i32** %19
%191 = load i32, i32* %35
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds i32, i32* %190, i64 %192
store i32 %189, i32* %193
%194 = getelementptr inbounds [20 x i8], [20 x i8]* %36, i64 0, i64 0
%195 = load i32, i32* %33
%196 = call i32 @nameitem(i8* %194, i32 %195)
%197 = getelementptr inbounds [20 x i8], [20 x i8]* %36, i64 0, i64 0
%198 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %197)
br label %203
199: ; preds = %183
%200 = load i32*, i32** %19
%201 = load i32, i32* %33
%202 = call i32 @dropinv(i32* %200, i32 %201)
br label %203
203: ; preds = %199, %188
br label %204
204: ; preds = %203, %178
br label %205
205: ; preds = %204, %171
br label %206
206: ; preds = %205, %166
br label %207
207: ; preds = %206, %128
br label %208
208: ; preds = %207, %87
%209 = load i32, i32* %29
%210 = icmp eq i32 %209, 1
br i1 %210, label %211, label %222
211: ; preds = %208
%212 = load i32*, i32** %23
%213 = load i32*, i32** %26
%214 = load i32, i32* %213
%215 = sext i32 %214 to i64
%216 = getelementptr inbounds i32, i32* %212, i64 %215
store i32 -1, i32* %216
%217 = load i32*, i32** %24
%218 = load i32*, i32** %26
%219 = load i32, i32* %218
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds i32, i32* %217, i64 %220
store i32 2, i32* %221
br label %222
222: ; preds = %72, %82, %211, %208
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
%struct.timeval = type { i32, i32 }
@.str.2 = [20 x i8] c"An empty lantern...\00"
@.str.3 = [18 x i8] c"You received %s!\0A\00"
@str = [64 x i8] c"Do you want to take the treasure in this room?\0A[0]: No\0A[1]: Yes\00"
@str.4 = [22 x i8] c"This room is empty...\00"
define void @treasure(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32 %12, i32 %13, i32 %14) {
%16 = alloca %struct.timespec
%17 = alloca %struct.timeval
%18 = alloca i32
%19 = alloca [20 x i8]
%20 = bitcast %struct.timespec* %16 to i8*
%21 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i64 0, i32 1
store i64 0, i64* %21
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i64 0, i32 0
store i32 1000, i32* %22
%23 = call i32 @nanosleep(%struct.timespec* %16, i32* null)
%24 = bitcast %struct.timeval* %17 to i8*
%25 = call i32 @gettimeofday(%struct.timeval* %17, i32* null)
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i64 0, i32 0
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i64 0, i32 1
%29 = load i32, i32* %28
%30 = mul nsw i32 %29, %27
%31 = call i32 @srand(i32 %30)
%32 = bitcast i32* %18 to i8*
%33 = icmp eq i32 %13, 0
br i1 %33, label %34, label %39
34: ; preds = %15
%35 = load i32, i32* %5
%36 = icmp sgt i32 %35, -1
br i1 %36, label %37, label %45
37: ; preds = %34
%38 = call i32 @shiftarray(i32* %5)
br label %58
39: ; preds = %15
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %7, i64 %41
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, -1
br i1 %44, label %49, label %51
45: ; preds = %34
%46 = call i32 (...) @rand()
%47 = srem i32 %46, 54
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %58
49: ; preds = %45, %39
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
br label %102
51: ; preds = %39
%52 = icmp eq i32 %13, 1
br i1 %52, label %53, label %58
53: ; preds = %51
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str, i64 0, i64 0))
%55 = call i32 @getint(i32* %18)
%56 = load i32, i32* %18
%57 = icmp eq i32 %56, 0
br i1 %57, label %102, label %58
58: ; preds = %45, %37, %53, %51
%59 = phi i1 [ false, %37 ], [ true, %53 ], [ false, %51 ], [ false, %45 ]
%60 = phi i32 [ %35, %37 ], [ %43, %53 ], [ %43, %51 ], [ %47, %45 ]
%61 = icmp sgt i32 %60, 51
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = call i32 @hebrac(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32 %12, i32 0, i32 %14)
br label %94
64: ; preds = %58
%65 = srem i32 %60, 13
switch i32 %65, label %82 [
i32 12, label %66
i32 11, label %72
i32 10, label %78
i32 0, label %80
]
66: ; preds = %64
%67 = icmp eq i32 %12, 0
br i1 %67, label %68, label %70
68: ; preds = %66
%69 = call i32 @genie(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32 %60, i32 %14)
br label %94
70: ; preds = %66
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %94
72: ; preds = %64
%73 = icmp sgt i32 %60, 24
br i1 %73, label %74, label %76
74: ; preds = %72
%75 = call i32 @blackqueen(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32 1)
br label %94
76: ; preds = %72
%77 = call i32 @redqueen(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32 %12, i32 0, i32 %14)
br label %94
78: ; preds = %64
%79 = call i32 @addslave(i32* %4)
br label %94
80: ; preds = %64
%81 = call i32 @addaces(i32* %0, i32* %2, i32 %60)
br label %94
82: ; preds = %64
%83 = call i32 @checkfullinv(i32* %3)
%84 = getelementptr inbounds [20 x i8], [20 x i8]* %19, i64 0, i64 0
%85 = icmp sgt i32 %83, -1
br i1 %85, label %86, label %91
86: ; preds = %82
%87 = zext i32 %83 to i64
%88 = getelementptr inbounds i32, i32* %3, i64 %87
store i32 %60, i32* %88
%89 = call i32 @nameitem(i8* %84, i32 %60)
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %84)
br label %93
91: ; preds = %82
%92 = call i32 @dropinv(i32* %3, i32 %60)
br label %93
93: ; preds = %91, %86
br label %94
94: ; preds = %70, %68, %78, %93, %80, %74, %76, %62
br i1 %59, label %95, label %102
95: ; preds = %94
%96 = load i32, i32* %10
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i32, i32* %7, i64 %97
store i32 -1, i32* %98
%99 = load i32, i32* %10
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i32, i32* %8, i64 %100
store i32 2, i32* %101
br label %102
102: ; preds = %94, %95, %53, %49
ret void
}