#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 get_rand_level_buf_size(int level) {
  int size;
  switch (level) {
  case 3:
    size = rand() % (1024 * 1024) +
           (4 * 1024 + 4 * 4 * 1024 + 2 * (32 * 1024) + 4 * 1 * 1024);
    break;
  case 2:
    size =
        rand() % (1024 * 1024) + ((4 * 1024 + 2 * (32 * 1024)) + 4 * 1 * 1024);
    break;
  case 1:
  default:
    size =
        rand() % (1024 * 1024) + ((4 * 1024 + 2 * (8 * 1024)) + 4 * 1 * 1024);
  }
  return size;
}


x86 assembly (clang, -O0):
<get_rand_level_buf_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     118b <get_rand_level_buf_size+0x7b>
jmp    112f <get_rand_level_buf_size+0x1f>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     116e <get_rand_level_buf_size+0x5e>
jmp    1140 <get_rand_level_buf_size+0x30>
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
jne    1190 <get_rand_level_buf_size+0x80>
jmp    1151 <get_rand_level_buf_size+0x41>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x100000,%ecx
cltd
idiv   %ecx
add    $0x16000,%edx
mov    %edx,-0x8(%rbp)
jmp    11a8 <get_rand_level_buf_size+0x98>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x100000,%ecx
cltd
idiv   %ecx
add    $0x12000,%edx
mov    %edx,-0x8(%rbp)
jmp    11a8 <get_rand_level_buf_size+0x98>
jmp    1190 <get_rand_level_buf_size+0x80>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x100000,%ecx
cltd
idiv   %ecx
add    $0x6000,%edx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rand_level_buf_size>:
push   %rbx
cmp    $0x2,%edi
mov    $0x12000,%eax
mov    $0x6000,%ecx
cmove  %eax,%ecx
cmp    $0x3,%edi
mov    $0x16000,%ebx
cmovne %ecx,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
lea    0xfffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfff00000,%ecx
sub    %ecx,%eax
add    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @get_rand_level_buf_size(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %14 [
i32 3, label %5
i32 2, label %9
i32 1, label %13
]
5: ; preds = %1
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 1048576
%8 = add nsw i32 %7, 90112
store i32 %8, i32* %3
br label %18
9: ; preds = %1
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 1048576
%12 = add nsw i32 %11, 73728
store i32 %12, i32* %3
br label %18
13: ; preds = %1
br label %14
14: ; preds = %1, %13
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 1048576
%17 = add nsw i32 %16, 24576
store i32 %17, i32* %3
br label %18
18: ; preds = %14, %9, %5
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
define i32 @get_rand_level_buf_size(i32 %0) {
%2 = icmp eq i32 %0, 2
%3 = select i1 %2, i32 73728, i32 24576
%4 = icmp eq i32 %0, 3
%5 = select i1 %4, i32 90112, i32 %3
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 1048576
%8 = add nsw i32 %7, %5
ret i32 %8
}