#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(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main() {
  int d1, d2, loop;
  int td1 = 0;
  int td2 = 0;
  float ad1, ad2;
  int running_total = 0;
  td1 = 0;
  srand((unsigned)time(NULL));
  for (loop = 0; loop < 1000; loop++) {
    d1 = rand() % 6 + 1;
    d2 = rand() % 6 + 1;
    printf("You rolled %d and %d\n", d1, d2);
    td1 = td1 + d1;
    td2 += d2;
  }
  printf("//%d d1\n", td1);
  printf("//%d d2\n\n\n", td2);
  ad1 = (float)td1 / 1000;
  ad2 = (float)td2 / 1000;
  printf("The average roll for %d times was %.2f/%.2f\n", 1000, ad1, ad2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x3e8,-0x10(%rbp)
jge    11ed <main+0xad>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1182 <main+0x42>
mov    -0x14(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2ssl -0x14(%rbp),%xmm0
movss  0xde4(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm0
movss  0xdce(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdda(%rip),%rdi
mov    $0x3e8,%esi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x3e8,%ebp
xor    %r13d,%r13d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
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
mov    %eax,%ebx
sub    %ecx,%ebx
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
mov    %eax,%r15d
sub    %ecx,%r15d
neg    %ecx
lea    (%rax,%rcx,1),%edx
add    $0x1,%edx
lea    0xe2d(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %ebx,%r13d
add    $0x1,%r13d
add    %r15d,%r14d
add    $0x1,%r14d
add    $0xffffffff,%ebp
jne    1170 <main+0x30>
lea    0xe1b(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe13(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cvtsi2ss %r13d,%xmm0
movss  0xdd9(%rip),%xmm1
cvtsi2ss %r14d,%xmm2
divss  %xmm1,%xmm0
divss  %xmm1,%xmm2
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
lea    0xde8(%rip),%rdi
mov    $0x3e8,%esi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"You rolled %d and %d\0A\00"
@.str.1 = [9 x i8] c"//%d d1\0A\00"
@.str.2 = [11 x i8] c"//%d d2\0A\0A\0A\00"
@.str.3 = [45 x i8] c"The average roll for %d times was %.2f/%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %9
store i32 0, i32* %5
%10 = call i64 @time(i32* null)
%11 = trunc i64 %10 to i32
%12 = call i32 @srand(i32 %11)
store i32 0, i32* %4
br label %13
13: ; preds = %32, %0
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 1000
br i1 %15, label %16, label %35
16: ; preds = %13
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24)
%26 = load i32, i32* %5
%27 = load i32, i32* %2
%28 = add nsw i32 %26, %27
store i32 %28, i32* %5
%29 = load i32, i32* %3
%30 = load i32, i32* %6
%31 = add nsw i32 %30, %29
store i32 %31, i32* %6
br label %32
32: ; preds = %16
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %13
35: ; preds = %13
%36 = load i32, i32* %5
%37 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %6
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %5
%41 = sitofp i32 %40 to float
%42 = fdiv float %41, 1.000000e+03
store float %42, float* %7
%43 = load i32, i32* %6
%44 = sitofp i32 %43 to float
%45 = fdiv float %44, 1.000000e+03
store float %45, float* %8
%46 = load float, float* %7
%47 = fpext float %46 to double
%48 = load float, float* %8
%49 = fpext float %48 to double
%50 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 1000, double %47, double %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"You rolled %d and %d\0A\00"
@.str.1 = [9 x i8] c"//%d d1\0A\00"
@.str.2 = [11 x i8] c"//%d d2\0A\0A\0A\00"
@.str.3 = [45 x i8] c"The average roll for %d times was %.2f/%.2f\0A\00"
define i32 @main() {
%1 = tail call i64 @time(i32* null)
%2 = trunc i64 %1 to i32
%3 = tail call i32 @srand(i32 %2)
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %17, %4 ]
%6 = phi i32 [ 0, %0 ], [ %15, %4 ]
%7 = phi i32 [ 0, %0 ], [ %16, %4 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 6
%10 = add nsw i32 %9, 1
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 6
%13 = add nsw i32 %12, 1
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %13)
%15 = add nsw i32 %10, %6
%16 = add nsw i32 %13, %7
%17 = add nuw nsw i32 %5, 1
%18 = icmp eq i32 %17, 1000
br i1 %18, label %19, label %4
19: ; preds = %4
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%21 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%22 = sitofp i32 %15 to float
%23 = fdiv float %22, 1.000000e+03
%24 = sitofp i32 %16 to float
%25 = fdiv float %24, 1.000000e+03
%26 = fpext float %23 to double
%27 = fpext float %25 to double
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 1000, double %26, double %27)
ret i32 0
}