#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, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void throw(int total) {
  int count = 0;
  int dice1, dice2;
  srand(time(NULL));
  while (dice1 + dice2 != total) {
    count = count + 1;
    dice1 = rand() % 6 + 1;
    dice2 = rand() % 6 + 1;
    printf("Result of throw %d:  %d + %d\n", count, dice1, dice2);
  }
  printf("You got your total in %d throws!\n", count);
}


x86 assembly (clang, -O0):
<throw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     11c0 <throw+0x80>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1162 <throw+0x22>
mov    -0x8(%rbp),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<throw>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xea0(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r12d
add    $0x1,%r12d
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
add    %r12d,%ebx
cmp    %r15d,%ebx
jne    1170 <throw+0x30>
lea    0xe35(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Result of throw %d: %d + %d\0A\00"
@.str.1 = [34 x i8] c"You got your total in %d throws!\0A\00"
define void @throw(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
br label %8
8: ; preds = %14, %1
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = add nsw i32 %9, %10
%12 = load i32, i32* %2
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %8
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24, i32 %25)
br label %8
27: ; preds = %8
%28 = load i32, i32* %3
%29 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %28)
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"Result of throw %d: %d + %d\0A\00"
@.str.1 = [34 x i8] c"You got your total in %d throws!\0A\00"
define void @throw(i32 %0) {
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
br label %4
4: ; preds = %1, %4
%5 = phi i32 [ %6, %4 ], [ 0, %1 ]
%6 = add nuw nsw i32 %5, 1
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 6
%9 = add nsw i32 %8, 1
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 6
%12 = add nsw i32 %11, 1
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %9, i32 %12)
%14 = add nsw i32 %12, %9
%15 = icmp eq i32 %14, %0
br i1 %15, label %16, label %4
16: ; preds = %4
%17 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %6)
ret void
}