#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 */

/* Variables and functions */
int rand();
int /*<<< orphan*/ troom(int, int, int, int, int, int);
void treasureroom(int lv) {
  int tx, ty, xsize, ysize;
  for (tx = 1 + ((int)(rand() % (10)) + 1); tx < 67 - 10; tx += 10) {
    if ((lv == (16 - 1)) || (lv == (16 + 5 - 1)) ||
        (((int)(rand() % (10)) + 1) <= 2)) {
      xsize = ((int)(rand() % (6)) + 1) + 3;
      ysize = ((int)(rand() % (3)) + 1) + 3;
      ty = ((int)(rand() % (17 - 9)) + 1) + 1;
      if ((lv == (16 - 1)) || (lv == (16 + 5 - 1))) {
        troom(lv, xsize, ysize, (tx = tx + ((int)(rand() % (67 - 24)) + 1)), ty,
              ((int)(rand() % (3)) + 1) + 6);
      } else {
        troom(lv, xsize, ysize, tx, ty, ((int)(rand() % (9)) + 1));
      }
    }
  }
}


x86 assembly (clang, -O0):
<treasureroom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x39,-0x8(%rbp)
jge    12b4 <treasureroom+0x194>
cmpl   $0xf,-0x4(%rbp)
je     117e <treasureroom+0x5e>
cmpl   $0x14,-0x4(%rbp)
je     117e <treasureroom+0x5e>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
cmp    $0x2,%edx
jg     12a1 <treasureroom+0x181>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x1,%eax
add    $0x3,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x1,%eax
add    $0x3,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xf,-0x4(%rbp)
je     11e0 <treasureroom+0xc0>
cmpl   $0x14,-0x4(%rbp)
jne    1251 <treasureroom+0x131>
mov    -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x2b,%ecx
cltd
idiv   %ecx
mov    -0x2c(%rbp),%eax
add    $0x1,%edx
add    %edx,%eax
mov    %eax,-0x20(%rbp)
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x3,%r9d
cltd
idiv   %r9d
mov    %edx,%r9d
mov    -0x18(%rbp),%edx
add    $0x1,%r9d
add    $0x6,%r9d
call   1030 <troom@plt>
jmp    129c <treasureroom+0x17c>
mov    -0x4(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    -0x40(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    $0x9,%r9d
cltd
idiv   %r9d
mov    %edx,%r9d
mov    -0x30(%rbp),%edx
add    $0x1,%r9d
call   1030 <troom@plt>
jmp    12a1 <treasureroom+0x181>
jmp    12a6 <treasureroom+0x186>
mov    -0x8(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x8(%rbp)
jmp    1145 <treasureroom+0x25>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<treasureroom>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r13d
add    $0x2,%r13d
mov    %ebx,0x4(%rsp)
jmp    11fb <treasureroom+0xdb>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x2fa0be83,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
imul   $0x2b,%ecx,%ecx
sub    %ecx,%eax
add    %eax,%r13d
add    $0x1,%r13d
mov    $0x7,%ebx
movl   $0x3,(%rsp)
mov    0x10(%rsp),%rax
add    %eax,%r15d
add    $0x4,%r15d
mov    0x8(%rsp),%rax
add    %eax,%r12d
add    $0x4,%r12d
add    %r14d,%ebp
add    $0x2,%ebp
xor    %eax,%eax
call   1040 <rand@plt>
cltd
idivl  (%rsp)
add    %edx,%ebx
mov    0x4(%rsp),%edi
mov    %r15d,%esi
mov    %r12d,%edx
mov    %r13d,%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
mov    %edi,%ebx
call   1030 <troom@plt>
lea    0xa(%r13),%eax
cmp    $0x2f,%r13d
mov    %eax,%r13d
jge    12c1 <treasureroom+0x1a1>
cmp    $0xf,%ebx
je     1230 <treasureroom+0x110>
cmp    $0x14,%ebx
je     1230 <treasureroom+0x110>
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
jg     11ea <treasureroom+0xca>
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x10(%rsp)
cltq
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,2),%r15d
neg    %r15d
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x8(%rsp)
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%r12d
neg    %r12d
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ebp
lea    0x7(%rbp),%r14d
test   %eax,%eax
cmovns %eax,%r14d
and    $0xfffffff8,%r14d
neg    %r14d
cmp    $0x14,%ebx
je     1170 <treasureroom+0x50>
cmp    $0xf,%ebx
je     1170 <treasureroom+0x50>
mov    $0x1,%ebx
movl   $0x9,(%rsp)
jmp    11a5 <treasureroom+0x85>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @treasureroom(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 10
%9 = add nsw i32 %8, 1
%10 = add nsw i32 1, %9
store i32 %10, i32* %3
br label %11
11: ; preds = %70, %1
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 57
br i1 %13, label %14, label %73
14: ; preds = %11
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 15
br i1 %16, label %25, label %17
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 20
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 10
%23 = add nsw i32 %22, 1
%24 = icmp sle i32 %23, 2
br i1 %24, label %25, label %69
25: ; preds = %20, %17, %14
%26 = call i32 (...) @rand()
%27 = srem i32 %26, 6
%28 = add nsw i32 %27, 1
%29 = add nsw i32 %28, 3
store i32 %29, i32* %5
%30 = call i32 (...) @rand()
%31 = srem i32 %30, 3
%32 = add nsw i32 %31, 1
%33 = add nsw i32 %32, 3
store i32 %33, i32* %6
%34 = call i32 (...) @rand()
%35 = srem i32 %34, 8
%36 = add nsw i32 %35, 1
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
%38 = load i32, i32* %2
%39 = icmp eq i32 %38, 15
br i1 %39, label %43, label %40
40: ; preds = %25
%41 = load i32, i32* %2
%42 = icmp eq i32 %41, 20
br i1 %42, label %43, label %58
43: ; preds = %40, %25
%44 = load i32, i32* %2
%45 = load i32, i32* %5
%46 = load i32, i32* %6
%47 = load i32, i32* %3
%48 = call i32 (...) @rand()
%49 = srem i32 %48, 43
%50 = add nsw i32 %49, 1
%51 = add nsw i32 %47, %50
store i32 %51, i32* %3
%52 = load i32, i32* %4
%53 = call i32 (...) @rand()
%54 = srem i32 %53, 3
%55 = add nsw i32 %54, 1
%56 = add nsw i32 %55, 6
%57 = call i32 @troom(i32 %44, i32 %45, i32 %46, i32 %51, i32 %52, i32 %56)
br label %68
58: ; preds = %40
%59 = load i32, i32* %2
%60 = load i32, i32* %5
%61 = load i32, i32* %6
%62 = load i32, i32* %3
%63 = load i32, i32* %4
%64 = call i32 (...) @rand()
%65 = srem i32 %64, 9
%66 = add nsw i32 %65, 1
%67 = call i32 @troom(i32 %59, i32 %60, i32 %61, i32 %62, i32 %63, i32 %66)
br label %68
68: ; preds = %58, %43
br label %69
69: ; preds = %68, %20
br label %70
70: ; preds = %69
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 10
store i32 %72, i32* %3
br label %11
73: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @treasureroom(i32 %0) {
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 10
%4 = add nsw i32 %3, 2
br label %5
5: ; preds = %1, %34
%6 = phi i32 [ %36, %34 ], [ %4, %1 ]
switch i32 %0, label %7 [
i32 20, label %11
i32 15, label %11
]
7: ; preds = %5
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 10
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %34
11: ; preds = %5, %5, %7
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 6
%14 = add nsw i32 %13, 4
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 3
%17 = add nsw i32 %16, 4
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 8
%20 = add nsw i32 %19, 2
switch i32 %0, label %26 [
i32 20, label %21
i32 15, label %21
]
21: ; preds = %11, %11
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 43
%24 = add nsw i32 %6, 1
%25 = add i32 %24, %23
br label %26
26: ; preds = %11, %21
%27 = phi i32 [ 3, %21 ], [ 9, %11 ]
%28 = phi i32 [ 7, %21 ], [ 1, %11 ]
%29 = phi i32 [ %25, %21 ], [ %6, %11 ]
%30 = tail call i32 (...) @rand()
%31 = srem i32 %30, %27
%32 = add nsw i32 %31, %28
%33 = tail call i32 @troom(i32 %0, i32 %14, i32 %17, i32 %29, i32 %20, i32 %32)
br label %34
34: ; preds = %26, %7
%35 = phi i32 [ %6, %7 ], [ %29, %26 ]
%36 = add nsw i32 %35, 10
%37 = icmp slt i32 %35, 47
br i1 %37, label %5, label %38
38: ; preds = %34
ret void
}