#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 /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int die;
  srand(time(NULL));
  die = rand() % 7;
  if (die == 1) {
    printf("1!\n");
  } else if (die == 2) {
    printf("2!\n");
  } else if (die == 3) {
    printf("3!\n");
  } else if (die == 4) {
    printf("4!\n");
  } else if (die == 5) {
    printf("5!\n");
  } else if (die == 6) {
    printf("6!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    118c <main+0x4c>
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
jmp    1227 <main+0xe7>
cmpl   $0x2,-0x8(%rbp)
jne    11a7 <main+0x67>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
jmp    1222 <main+0xe2>
cmpl   $0x3,-0x8(%rbp)
jne    11c2 <main+0x82>
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
jmp    121d <main+0xdd>
cmpl   $0x4,-0x8(%rbp)
jne    11dd <main+0x9d>
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
jmp    1218 <main+0xd8>
cmpl   $0x5,-0x8(%rbp)
jne    11f8 <main+0xb8>
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
jmp    1213 <main+0xd3>
cmpl   $0x6,-0x8(%rbp)
jne    120e <main+0xce>
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
jmp    1213 <main+0xd3>
jmp    1218 <main+0xd8>
jmp    121d <main+0xdd>
jmp    1222 <main+0xe2>
jmp    1227 <main+0xe7>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rcx
imul   $0xffffffff92492493,%rcx,%rdx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0x2,%edx
add    %eax,%edx
lea    0x0(,%rdx,8),%eax
sub    %edx,%eax
not    %eax
add    %ecx,%eax
cmp    $0x5,%eax
ja     1197 <main+0x57>
cltq
lea    0xe89(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"1!\0A\00"
@.str.1 = [4 x i8] c"2!\0A\00"
@.str.2 = [4 x i8] c"3!\0A\00"
@.str.3 = [4 x i8] c"4!\0A\00"
@.str.4 = [4 x i8] c"5!\0A\00"
@.str.5 = [4 x i8] c"6!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @time(i32* null)
%4 = call i32 @srand(i32 %3)
%5 = call i32 (...) @rand()
%6 = srem i32 %5, 7
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %41
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %40
16: ; preds = %11
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %39
21: ; preds = %16
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 4
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %38
26: ; preds = %21
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 5
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %37
31: ; preds = %26
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 6
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34, %31
br label %37
37: ; preds = %36, %29
br label %38
38: ; preds = %37, %24
br label %39
39: ; preds = %38, %19
br label %40
40: ; preds = %39, %14
br label %41
41: ; preds = %40, %9
ret i32 0
}

LLVM IR (-O2):
@str = [3 x i8] c"6!\00"
@str.6 = [3 x i8] c"5!\00"
@str.7 = [3 x i8] c"4!\00"
@str.8 = [3 x i8] c"3!\00"
@str.9 = [3 x i8] c"2!\00"
@str.10 = [3 x i8] c"1!\00"
@reltable.main = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @str.10 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @str.9 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @str.8 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @str.7 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @str.6 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @str to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 7
%5 = add nsw i32 %4, -1
%6 = icmp ult i32 %5, 6
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.main to i8*), i64 %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
br label %12
12: ; preds = %0, %7
ret i32 0
}