#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void count_freq(FILE *fout, double (*pdist)(void)) {
  int i;
  int freq[(1 << 12)];
  double rand_nr;
  srand(time(NULL));
  for (i = 0; i < (1 << 12); i++)
    freq[i] = 0.0;
  for (i = 0; i < (1 << 17); i++) {
    rand_nr = pdist();
    if ((rand_nr < -(10.0)) || (rand_nr > (10.0)))
      continue;
    freq[(int)(rand_nr / (2 * (10.0) / (1 << 12))) + (1 << 12) / 2]++;
  }
  for (i = 0; i < (1 << 12); i++) {
    fprintf(fout, "%.12f %.12f\n", (10.0) * (2.0 * i / (1 << 12) - 1.0),
            (double)(freq[i] * (1 << 12)) / (2.0 * (10.0) * (1 << 17)));
  }
}


x86 assembly (clang, -O0):
<count_freq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1000,-0x14(%rbp)
jge    1184 <count_freq+0x54>
movslq -0x14(%rbp),%rax
movl   $0x0,-0x4020(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115a <count_freq+0x2a>
movl   $0x0,-0x14(%rbp)
cmpl   $0x20000,-0x14(%rbp)
jge    1216 <count_freq+0xe6>
call   *-0x10(%rbp)
movsd  %xmm0,-0x4028(%rbp)
ff
movsd  0xe7d(%rip),%xmm0
ucomisd -0x4028(%rbp),%xmm0
ff
ja     11d3 <count_freq+0xa3>
movsd  -0x4028(%rbp),%xmm0
ff
movsd  0xe3f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d8 <count_freq+0xa8>
jmp    1208 <count_freq+0xd8>
movsd  -0x4028(%rbp),%xmm0
ff
movsd  0xe48(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x800,%eax
cltq
mov    -0x4020(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x4020(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118b <count_freq+0x5b>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1000,-0x14(%rbp)
jge    129b <count_freq+0x16b>
mov    -0x8(%rbp),%rdi
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xde5(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xdd1(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdbd(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xda9(%rip),%xmm0
mulsd  %xmm1,%xmm0
movslq -0x14(%rbp),%rax
mov    -0x4020(%rbp,%rax,4),%eax
shl    $0xc,%eax
cvtsi2sd %eax,%xmm1
movsd  0xd83(%rip),%xmm2
divsd  %xmm2,%xmm1
lea    0xdb0(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    121d <count_freq+0xed>
add    $0x4030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_freq>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x4008,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    %rsp,%rdi
mov    $0x4000,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    $0x20000,%ebp
jmp    1185 <count_freq+0x45>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
je     11bb <count_freq+0x7b>
call   *%rbx
movsd  0xe79(%rip),%xmm1
movsd  0xe69(%rip),%xmm2
ucomisd %xmm0,%xmm2
ja     1180 <count_freq+0x40>
ucomisd %xmm1,%xmm0
ja     1180 <count_freq+0x40>
divsd  0xe65(%rip),%xmm0
cvttsd2si %xmm0,%eax
cltq
addl   $0x1,0x2000(%rsp,%rax,4)
01
jmp    1180 <count_freq+0x40>
xor    %ebx,%ebx
lea    0xe6c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
addsd  %xmm0,%xmm0
mulsd  0xe35(%rip),%xmm0
addsd  0xe35(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    (%rsp,%rbx,4),%eax
shl    $0xc,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  0xe24(%rip),%xmm1
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <fprintf@plt>
movsd  0xdf1(%rip),%xmm1
add    $0x1,%rbx
cmp    $0x1000,%rbx
jne    11d0 <count_freq+0x90>
add    $0x4008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%.12f %.12f\0A\00"
define void @count_freq(i32* %0, double ()* %1) {
%3 = alloca i32*
%4 = alloca double ()*
%5 = alloca i32
%6 = alloca [4096 x i32]
%7 = alloca double
store i32* %0, i32** %3
store double ()* %1, double ()** %4
%8 = call i32 @time(i32* null)
%9 = call i32 @srand(i32 %8)
store i32 0, i32* %5
br label %10
10: ; preds = %17, %2
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 4096
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 %15
store i32 0, i32* %16
br label %17
17: ; preds = %13
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %10
20: ; preds = %10
store i32 0, i32* %5
br label %21
21: ; preds = %42, %20
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 131072
br i1 %23, label %24, label %45
24: ; preds = %21
%25 = load double ()*, double ()** %4
%26 = call double %25()
store double %26, double* %7
%27 = load double, double* %7
%28 = fcmp olt double %27, -1.000000e+01
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = load double, double* %7
%31 = fcmp ogt double %30, 1.000000e+01
br i1 %31, label %32, label %33
32: ; preds = %29, %24
br label %42
33: ; preds = %29
%34 = load double, double* %7
%35 = fdiv double %34, 0x3F74000000000000
%36 = fptosi double %35 to i32
%37 = add nsw i32 %36, 2048
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1
store i32 %41, i32* %39
br label %42
42: ; preds = %33, %32
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %21
45: ; preds = %21
store i32 0, i32* %5
br label %46
46: ; preds = %65, %45
%47 = load i32, i32* %5
%48 = icmp slt i32 %47, 4096
br i1 %48, label %49, label %68
49: ; preds = %46
%50 = load i32*, i32** %3
%51 = load i32, i32* %5
%52 = sitofp i32 %51 to double
%53 = fmul double 2.000000e+00, %52
%54 = fdiv double %53, 4.096000e+03
%55 = fsub double %54, 1.000000e+00
%56 = fmul double 1.000000e+01, %55
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = mul nsw i32 %60, 4096
%62 = sitofp i32 %61 to double
%63 = fdiv double %62, 2.621440e+06
%64 = call i32 @fprintf(i32* %50, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %56, double %63)
br label %65
65: ; preds = %49
%66 = load i32, i32* %5
%67 = add nsw i32 %66, 1
store i32 %67, i32* %5
br label %46
68: ; preds = %46
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%.12f %.12f\0A\00"
define void @count_freq(i32* nocapture %0, double ()* nocapture %1) {
%3 = alloca [4096 x i32]
%4 = bitcast [4096 x i32]* %3 to i8*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
br label %7
7: ; preds = %2, %21
%8 = phi i32 [ %22, %21 ], [ 0, %2 ]
%9 = tail call double %1()
%10 = fcmp olt double %9, -1.000000e+01
%11 = fcmp ogt double %9, 1.000000e+01
%12 = or i1 %10, %11
br i1 %12, label %21, label %13
13: ; preds = %7
%14 = fdiv double %9, 0x3F74000000000000
%15 = fptosi double %14 to i32
%16 = add nsw i32 %15, 2048
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = add nsw i32 %19, 1
store i32 %20, i32* %18
br label %21
21: ; preds = %7, %13
%22 = add nuw nsw i32 %8, 1
%23 = icmp eq i32 %22, 131072
br i1 %23, label %24, label %7
24: ; preds = %21, %24
%25 = phi i64 [ %38, %24 ], [ 0, %21 ]
%26 = trunc i64 %25 to i32
%27 = sitofp i32 %26 to double
%28 = fmul double %27, 2.000000e+00
%29 = fmul double %28, 0x3F30000000000000
%30 = fadd double %29, -1.000000e+00
%31 = fmul double %30, 1.000000e+01
%32 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 %25
%33 = load i32, i32* %32
%34 = shl nsw i32 %33, 12
%35 = sitofp i32 %34 to double
%36 = fdiv double %35, 2.621440e+06
%37 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %31, double %36)
%38 = add nuw nsw i64 %25, 1
%39 = icmp eq i64 %38, 4096
br i1 %39, label %40, label %24
40: ; preds = %24
ret void
}