#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 Random(int);
int GetKlingons(int diff) {
  int dice;
  dice = Random(diff);
  if (dice < 2)
    return 5;
  if (dice < 9)
    return 5;
  if (dice < 24)
    return 4;
  if (dice < 49)
    return 3;
  if (dice < 99)
    return 2;
  if (dice < 209)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<GetKlingons>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <Random@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    113c <GetKlingons+0x2c>
movl   $0x5,-0x4(%rbp)
jmp    11b4 <GetKlingons+0xa4>
cmpl   $0x9,-0xc(%rbp)
jge    1152 <GetKlingons+0x42>
movl   $0x5,-0x4(%rbp)
jmp    11b4 <GetKlingons+0xa4>
cmpl   $0x18,-0xc(%rbp)
jge    1168 <GetKlingons+0x58>
movl   $0x4,-0x4(%rbp)
jmp    11b4 <GetKlingons+0xa4>
cmpl   $0x31,-0xc(%rbp)
jge    117e <GetKlingons+0x6e>
movl   $0x3,-0x4(%rbp)
jmp    11b4 <GetKlingons+0xa4>
cmpl   $0x63,-0xc(%rbp)
jge    1194 <GetKlingons+0x84>
movl   $0x2,-0x4(%rbp)
jmp    11b4 <GetKlingons+0xa4>
cmpl   $0xd1,-0xc(%rbp)
jge    11ad <GetKlingons+0x9d>
movl   $0x1,-0x4(%rbp)
jmp    11b4 <GetKlingons+0xa4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetKlingons>:
push   %rax
call   1030 <Random@plt>
mov    %eax,%ecx
mov    $0x5,%eax
cmp    $0x9,%ecx
jl     114b <GetKlingons+0x3b>
mov    $0x4,%eax
cmp    $0x18,%ecx
jb     114b <GetKlingons+0x3b>
mov    $0x3,%eax
cmp    $0x31,%ecx
jb     114b <GetKlingons+0x3b>
mov    $0x2,%eax
cmp    $0x63,%ecx
jb     114b <GetKlingons+0x3b>
xor    %eax,%eax
cmp    $0xd1,%ecx
setb   %al
pop    %rcx
ret

LLVM IR (-O0):
define i32 @GetKlingons(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i32 @Random(i32 %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 5, i32* %2
br label %31
10: ; preds = %1
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 9
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 5, i32* %2
br label %31
14: ; preds = %10
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 24
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 4, i32* %2
br label %31
18: ; preds = %14
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 49
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 3, i32* %2
br label %31
22: ; preds = %18
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 99
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 2, i32* %2
br label %31
26: ; preds = %22
%27 = load i32, i32* %4
%28 = icmp slt i32 %27, 209
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 1, i32* %2
br label %31
30: ; preds = %26
store i32 0, i32* %2
br label %31
31: ; preds = %30, %29, %25, %21, %17, %13, %9
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @GetKlingons(i32 %0) {
%2 = tail call i32 @Random(i32 %0)
%3 = icmp slt i32 %2, 9
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = icmp ult i32 %2, 24
br i1 %5, label %13, label %6
6: ; preds = %4
%7 = icmp ult i32 %2, 49
br i1 %7, label %13, label %8
8: ; preds = %6
%9 = icmp ult i32 %2, 99
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = icmp ult i32 %2, 209
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %10, %8, %6, %4, %1
%14 = phi i32 [ 5, %1 ], [ 4, %4 ], [ 3, %6 ], [ 2, %8 ], [ %12, %10 ]
ret i32 %14
}