#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);
void count_freq(FILE *fout, int (*pdist)(int), double lcutoff, double rcutoff) {
  int i;
  int freq[(1 << 17)];
  int rand_nr;
  double range = rcutoff - lcutoff;
  for (i = 0; i < (1 << 17); i++)
    freq[i] = 0.0;
  for (i = 0; i < (1 << 13); i++) {
    rand_nr = pdist((1 << 10));
    if ((rand_nr < lcutoff) || (rand_nr > rcutoff))
      continue;
    freq[(int)((rand_nr - lcutoff) * (1 << 17) / range)]++;
  }
  for (i = 0; i < (1 << 17); i++) {
    if (freq[i] != 0) {
      fprintf(fout, "%.12f %.12f\n",
              lcutoff + (double)(range * i) / (double)(1 << 17),
              (double)freq[i] / (double)(1 << 13));
    }
  }
}


x86 assembly (clang, -O0):
<count_freq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80040,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x80040(%rbp)
ff
movl   $0x0,-0x24(%rbp)
cmpl   $0x20000,-0x24(%rbp)
jge    1170 <count_freq+0x60>
movslq -0x24(%rbp),%rax
movl   $0x0,-0x80030(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1146 <count_freq+0x36>
movl   $0x0,-0x24(%rbp)
cmpl   $0x2000,-0x24(%rbp)
jge    1207 <count_freq+0xf7>
mov    $0x400,%edi
call   *-0x10(%rbp)
mov    %eax,-0x80034(%rbp)
cvtsi2sdl -0x80034(%rbp),%xmm1
ff
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     11bc <count_freq+0xac>
cvtsi2sdl -0x80034(%rbp),%xmm0
ff
ucomisd -0x20(%rbp),%xmm0
jbe    11c1 <count_freq+0xb1>
jmp    11f9 <count_freq+0xe9>
cvtsi2sdl -0x80034(%rbp),%xmm0
ff
subsd  -0x18(%rbp),%xmm0
movsd  0xe32(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x80040(%rbp),%xmm0
ff
cvttsd2si %xmm0,%eax
cltq
mov    -0x80030(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x80030(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1177 <count_freq+0x67>
movl   $0x0,-0x24(%rbp)
cmpl   $0x20000,-0x24(%rbp)
jge    128f <count_freq+0x17f>
movslq -0x24(%rbp),%rax
cmpl   $0x0,-0x80030(%rbp,%rax,4)
je     127c <count_freq+0x16c>
mov    -0x8(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x80040(%rbp),%xmm1
ff
cvtsi2sdl -0x24(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdb9(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movslq -0x24(%rbp),%rax
cvtsi2sdl -0x80030(%rbp,%rax,4),%xmm1
f7 ff
movsd  0xd94(%rip),%xmm2
divsd  %xmm2,%xmm1
lea    0xd99(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1281 <count_freq+0x171>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120e <count_freq+0xfe>
add    $0x80040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_freq>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x80028,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x20(%rsp),%rdi
mov    $0x80000,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    $0x2000,%ebp
jmp    1175 <count_freq+0x55>
nopl   0x0(%rax)
add    $0xffffffff,%ebp
je     11b8 <count_freq+0x98>
mov    $0x400,%edi
call   *%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1170 <count_freq+0x50>
ucomisd 0x10(%rsp),%xmm0
ja     1170 <count_freq+0x50>
subsd  0x8(%rsp),%xmm0
mulsd  0xe5b(%rip),%xmm0
divsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%eax
cltq
addl   $0x1,0x20(%rsp,%rax,4)
jmp    1170 <count_freq+0x50>
xor    %ebx,%ebx
lea    0xe57(%rip),%r15
jmp    11dd <count_freq+0xbd>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    $0x20000,%rbx
je     121c <count_freq+0xfc>
mov    0x20(%rsp,%rbx,4),%eax
test   %eax,%eax
je     11d0 <count_freq+0xb0>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x18(%rsp),%xmm0
mulsd  0xe0e(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xe01(%rip),%xmm1
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
jmp    11d0 <count_freq+0xb0>
add    $0x80028,%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, i32 (i32)* %1, double %2, double %3) {
%5 = alloca i32*
%6 = alloca i32 (i32)*
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca [131072 x i32]
%11 = alloca i32
%12 = alloca double
store i32* %0, i32** %5
store i32 (i32)* %1, i32 (i32)** %6
store double %2, double* %7
store double %3, double* %8
%13 = load double, double* %8
%14 = load double, double* %7
%15 = fsub double %13, %14
store double %15, double* %12
store i32 0, i32* %9
br label %16
16: ; preds = %23, %4
%17 = load i32, i32* %9
%18 = icmp slt i32 %17, 131072
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [131072 x i32], [131072 x i32]* %10, i64 0, i64 %21
store i32 0, i32* %22
br label %23
23: ; preds = %19
%24 = load i32, i32* %9
%25 = add nsw i32 %24, 1
store i32 %25, i32* %9
br label %16
26: ; preds = %16
store i32 0, i32* %9
br label %27
27: ; preds = %56, %26
%28 = load i32, i32* %9
%29 = icmp slt i32 %28, 8192
br i1 %29, label %30, label %59
30: ; preds = %27
%31 = load i32 (i32)*, i32 (i32)** %6
%32 = call i32 %31(i32 1024)
store i32 %32, i32* %11
%33 = load i32, i32* %11
%34 = sitofp i32 %33 to double
%35 = load double, double* %7
%36 = fcmp olt double %34, %35
br i1 %36, label %42, label %37
37: ; preds = %30
%38 = load i32, i32* %11
%39 = sitofp i32 %38 to double
%40 = load double, double* %8
%41 = fcmp ogt double %39, %40
br i1 %41, label %42, label %43
42: ; preds = %37, %30
br label %56
43: ; preds = %37
%44 = load i32, i32* %11
%45 = sitofp i32 %44 to double
%46 = load double, double* %7
%47 = fsub double %45, %46
%48 = fmul double %47, 1.310720e+05
%49 = load double, double* %12
%50 = fdiv double %48, %49
%51 = fptosi double %50 to i32
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [131072 x i32], [131072 x i32]* %10, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = add nsw i32 %54, 1
store i32 %55, i32* %53
br label %56
56: ; preds = %43, %42
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
br label %27
59: ; preds = %27
store i32 0, i32* %9
br label %60
60: ; preds = %86, %59
%61 = load i32, i32* %9
%62 = icmp slt i32 %61, 131072
br i1 %62, label %63, label %89
63: ; preds = %60
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [131072 x i32], [131072 x i32]* %10, i64 0, i64 %65
%67 = load i32, i32* %66
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %85
69: ; preds = %63
%70 = load i32*, i32** %5
%71 = load double, double* %7
%72 = load double, double* %12
%73 = load i32, i32* %9
%74 = sitofp i32 %73 to double
%75 = fmul double %72, %74
%76 = fdiv double %75, 1.310720e+05
%77 = fadd double %71, %76
%78 = load i32, i32* %9
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [131072 x i32], [131072 x i32]* %10, i64 0, i64 %79
%81 = load i32, i32* %80
%82 = sitofp i32 %81 to double
%83 = fdiv double %82, 8.192000e+03
%84 = call i32 @fprintf(i32* %70, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %77, double %83)
br label %85
85: ; preds = %69, %63
br label %86
86: ; preds = %85
%87 = load i32, i32* %9
%88 = add nsw i32 %87, 1
store i32 %88, i32* %9
br label %60
89: ; preds = %60
ret void
}

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