#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 random_number(unsigned parameter) {
  int burst = 0;
  int number_of_pages = 0;
  switch (parameter) {
  case 1:
    burst = rand() % 30;
    if (burst % 2 == 0)
      return burst + 1;
    else
      return burst;
  case 2:
  case 3:
    return (rand() % 10 + 1);
  case 4:
    return (rand() % 3);
  case 5:
    number_of_pages = rand() % 20;
    if (number_of_pages < 3)
      number_of_pages = 3;
    return (number_of_pages);
  case 6:
    return (rand() % 3);
  }
}


x86 assembly (clang, -O0):
<random_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     1202 <random_number+0xf2>
mov    -0x18(%rbp),%rax
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x1e,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1186 <random_number+0x76>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1202 <random_number+0xf2>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1202 <random_number+0xf2>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x4(%rbp)
jmp    1202 <random_number+0xf2>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
jmp    1202 <random_number+0xf2>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    11e5 <random_number+0xd5>
movl   $0x3,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1202 <random_number+0xf2>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_number>:
push   %rax
add    $0xffffffff,%edi
cmp    $0x5,%edi
ja     1178 <random_number+0x68>
lea    0xee0(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
call   1030 <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
add    %ecx,%eax
add    $0x1,%eax
pop    %rcx
ret
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
pop    %rcx
ret
pop    %rcx
ret
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x4,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %ecx,%esi
add    %eax,%esi
mov    %esi,%eax
not    %eax
and    $0x1,%eax
add    %esi,%eax
pop    %rcx
ret
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rax
add    %edx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ecx
cmp    $0x4,%ecx
mov    $0x3,%eax
cmovge %ecx,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @random_number(i32 %0) {
switch i32 %0, label %23 [
i32 1, label %2
i32 2, label %8
i32 3, label %8
i32 4, label %12
i32 5, label %15
i32 6, label %20
]
2: ; preds = %1
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 30
%5 = and i32 %4, 1
%6 = xor i32 %5, 1
%7 = add nsw i32 %6, %4
br label %23
8: ; preds = %1, %1
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 10
%11 = add nsw i32 %10, 1
br label %23
12: ; preds = %1
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 3
br label %23
15: ; preds = %1
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 20
%18 = icmp sgt i32 %17, 3
%19 = select i1 %18, i32 %17, i32 3
br label %23
20: ; preds = %1
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 3
br label %23
23: ; preds = %2, %1, %20, %15, %12, %8
%24 = phi i32 [ %22, %20 ], [ %19, %15 ], [ %14, %12 ], [ %11, %8 ], [ undef, %1 ], [ %7, %2 ]
ret i32 %24
}