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


x86 assembly (clang, -O0):
<random_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     11c9 <random_number+0xb9>
mov    -0x18(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1178 <random_number+0x68>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <random_number+0xb9>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <random_number+0xb9>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x4(%rbp)
jmp    11c9 <random_number+0xb9>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x4(%rbp)
jmp    11c9 <random_number+0xb9>
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    $0x3,%edi
ja     1154 <random_number+0x44>
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
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
mov    %ecx,%eax
not    %eax
and    $0x1,%eax
add    %ecx,%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

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

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