#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 EXIT_SUCCESS;
int /*<<< orphan*/ clock();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int main(void) {
  int trials;
  int j;
  int d1, d2;
  int outcomes[13];
  int n_dice;
  n_dice = 2;
  for (j = 0; j < 13; j++) {
    outcomes[j] = 0;
  }
  srand(clock());
  printf("\nEnter number of trials: ");
  scanf("%d", &trials);
  for (j = 0; j < trials; ++j) {
    outcomes[(d1 = (rand() % 6 + 1)) + (d2 = (rand() % 6 + 1))]++;
  }
  printf("probability\n");
  for (j = 2; j < n_dice * 6 + 1; ++j) {
    printf("j = %d p = %lf\n", j, (double)(outcomes[j]) / (double)trials);
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x54(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xd,-0xc(%rbp)
jge    1191 <main+0x41>
movslq -0xc(%rbp),%rax
movl   $0x0,-0x50(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <main+0x1d>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121d <main+0xcd>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x58(%rbp)
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    -0x58(%rbp),%eax
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
add    %edx,%eax
cltq
mov    -0x50(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c4 <main+0x74>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
imul   $0x6,-0x54(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1276 <main+0x126>
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rax
cvtsi2sdl -0x50(%rbp,%rax,4),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xdc9(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1232 <main+0xe2>
mov    0x2d63(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
xorps  %xmm1,%xmm1
movaps %xmm1,0x70(%rsp)
movaps %xmm1,0x60(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm1,0x50(%rsp)
movl   $0x0,0x80(%rsp)
xor    %eax,%eax
call   1040 <clock@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe68(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    126c <main+0x10c>
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%r14
imul   $0x2aaaaaab,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%r14d
xor    %eax,%eax
call   1080 <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
sub    %ecx,%eax
add    %r14d,%eax
add    $0x2,%eax
cltq
addl   $0x1,0x50(%rsp,%rax,4)
add    $0x1,%ebx
cmp    0xc(%rsp),%ebx
jl     11d0 <main+0x70>
movdqu 0x58(%rsp),%xmm0
movdqu 0x68(%rsp),%xmm1
cvtdq2pd %xmm1,%xmm2
movaps %xmm2,0x20(%rsp)
cvtdq2pd %xmm0,%xmm2
movaps %xmm2,0x40(%rsp)
pshufd $0xee,%xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
movaps %xmm1,0x30(%rsp)
pshufd $0xee,%xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
jmp    1284 <main+0x124>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
lea    0xda2(%rip),%rdi
call   1030 <puts@plt>
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
movapd 0x40(%rsp),%xmm0
divsd  %xmm1,%xmm0
lea    0xd73(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rsp),%xmm0
movapd 0x40(%rsp),%xmm1
unpckhpd %xmm1,%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
movapd 0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
unpckhpd %xmm1,%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
movapd 0x20(%rsp),%xmm0
divsd  %xmm1,%xmm0
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rsp),%xmm0
movapd 0x20(%rsp),%xmm1
unpckhpd %xmm1,%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
movapd 0x30(%rsp),%xmm0
divsd  %xmm1,%xmm0
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rsp),%xmm0
movapd 0x30(%rsp),%xmm1
unpckhpd %xmm1,%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x78(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
divsd  %xmm1,%xmm0
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x7c(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
divsd  %xmm1,%xmm0
mov    %rbx,%rdi
mov    $0xb,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x80(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
divsd  %xmm1,%xmm0
mov    %rbx,%rdi
mov    $0xc,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2ba0(%rip),%rax
mov    (%rax),%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\0AEnter number of trials: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"probability\0A\00"
@.str.3 = [16 x i8] c"j = %d p = %lf\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [13 x i32]
%7 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %7
store i32 0, i32* %3
br label %8
8: ; preds = %15, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 13
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 %13
store i32 0, i32* %14
br label %15
15: ; preds = %11
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %8
18: ; preds = %8
%19 = call i32 (...) @clock()
%20 = call i32 @srand(i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %23
23: ; preds = %39, %18
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %42
27: ; preds = %23
%28 = call i32 (...) @rand()
%29 = srem i32 %28, 6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
%31 = call i32 (...) @rand()
%32 = srem i32 %31, 6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
%34 = add nsw i32 %30, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = add nsw i32 %37, 1
store i32 %38, i32* %36
br label %39
39: ; preds = %27
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %23
42: ; preds = %23
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %44
44: ; preds = %61, %42
%45 = load i32, i32* %3
%46 = load i32, i32* %7
%47 = mul nsw i32 %46, 6
%48 = add nsw i32 %47, 1
%49 = icmp slt i32 %45, %48
br i1 %49, label %50, label %64
50: ; preds = %44
%51 = load i32, i32* %3
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = sitofp i32 %55 to double
%57 = load i32, i32* %2
%58 = sitofp i32 %57 to double
%59 = fdiv double %56, %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %51, double %59)
br label %61
61: ; preds = %50
%62 = load i32, i32* %3
%63 = add nsw i32 %62, 1
store i32 %63, i32* %3
br label %44
64: ; preds = %44
%65 = load i32, i32* @EXIT_SUCCESS
ret i32 %65
}

LLVM IR (-O2):
@.str = [26 x i8] c"\0AEnter number of trials: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [16 x i8] c"j = %d p = %lf\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [12 x i8] c"probability\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [13 x i32]
%3 = bitcast [13 x i32]* %2 to i8*
%4 = bitcast i32* %1 to i8*
%5 = tail call i32 (...) @clock()
%6 = tail call i32 @srand(i32 %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %31
11: ; preds = %0, %11
%12 = phi i32 [ %23, %11 ], [ 0, %0 ]
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 6
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 6
%17 = add nsw i32 %14, 2
%18 = add nsw i32 %17, %16
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
store i32 %22, i32* %20
%23 = add nuw nsw i32 %12, 1
%24 = load i32, i32* %1
%25 = icmp slt i32 %23, %24
br i1 %25, label %11, label %26
26: ; preds = %11
%27 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 2
%28 = bitcast i32* %27 to <8 x i32>*
%29 = load <8 x i32>, <8 x i32>* %28
%30 = sitofp <8 x i32> %29 to <8 x double>
br label %31
31: ; preds = %26, %0
%32 = phi <8 x double> [ %30, %26 ], [ zeroinitializer, %0 ]
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%34 = load i32, i32* %1
%35 = sitofp i32 %34 to double
%36 = extractelement <8 x double> %32, i64 0
%37 = fdiv double %36, %35
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 2, double %37)
%39 = load i32, i32* %1
%40 = sitofp i32 %39 to double
%41 = extractelement <8 x double> %32, i64 1
%42 = fdiv double %41, %40
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 3, double %42)
%44 = load i32, i32* %1
%45 = sitofp i32 %44 to double
%46 = extractelement <8 x double> %32, i64 2
%47 = fdiv double %46, %45
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 4, double %47)
%49 = load i32, i32* %1
%50 = sitofp i32 %49 to double
%51 = extractelement <8 x double> %32, i64 3
%52 = fdiv double %51, %50
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 5, double %52)
%54 = load i32, i32* %1
%55 = sitofp i32 %54 to double
%56 = extractelement <8 x double> %32, i64 4
%57 = fdiv double %56, %55
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 6, double %57)
%59 = load i32, i32* %1
%60 = sitofp i32 %59 to double
%61 = extractelement <8 x double> %32, i64 5
%62 = fdiv double %61, %60
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 7, double %62)
%64 = load i32, i32* %1
%65 = sitofp i32 %64 to double
%66 = extractelement <8 x double> %32, i64 6
%67 = fdiv double %66, %65
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 8, double %67)
%69 = load i32, i32* %1
%70 = sitofp i32 %69 to double
%71 = extractelement <8 x double> %32, i64 7
%72 = fdiv double %71, %70
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 9, double %72)
%74 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 10
%75 = load i32, i32* %74
%76 = sitofp i32 %75 to double
%77 = load i32, i32* %1
%78 = sitofp i32 %77 to double
%79 = fdiv double %76, %78
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 10, double %79)
%81 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 11
%82 = load i32, i32* %81
%83 = sitofp i32 %82 to double
%84 = load i32, i32* %1
%85 = sitofp i32 %84 to double
%86 = fdiv double %83, %85
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 11, double %86)
%88 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 12
%89 = load i32, i32* %88
%90 = sitofp i32 %89 to double
%91 = load i32, i32* %1
%92 = sitofp i32 %91 to double
%93 = fdiv double %90, %92
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 12, double %93)
%95 = load i32, i32* @EXIT_SUCCESS
ret i32 %95
}