#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, int);
void count_freq(FILE *fout, int (*pdist)(FILE *, int, int, double *),
                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 << 10); i++) {
    rand_nr = pdist(NULL, 512, 1024, NULL);
    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 %d\n",
              lcutoff + (double)(range * i) / (double)(1 << 17), freq[i]);
    }
  }
}


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   $0x400,-0x24(%rbp)
jge    1213 <count_freq+0x103>
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x200,%esi
mov    $0x400,%edx
mov    %rcx,%rdi
call   *-0x10(%rbp)
mov    %eax,-0x80034(%rbp)
cvtsi2sdl -0x80034(%rbp),%xmm1
ff
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     11c8 <count_freq+0xb8>
cvtsi2sdl -0x80034(%rbp),%xmm0
ff
ucomisd -0x20(%rbp),%xmm0
jbe    11cd <count_freq+0xbd>
jmp    1205 <count_freq+0xf5>
cvtsi2sdl -0x80034(%rbp),%xmm0
ff
subsd  -0x18(%rbp),%xmm0
movsd  0xe1e(%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    128d <count_freq+0x17d>
movslq -0x24(%rbp),%rax
cmpl   $0x0,-0x80030(%rbp,%rax,4)
je     127a <count_freq+0x16a>
mov    -0x8(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x80040(%rbp),%xmm1
ff
cvtsi2sdl -0x24(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xda5(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movslq -0x24(%rbp),%rax
mov    -0x80030(%rbp,%rax,4),%edx
lea    0xd93(%rip),%rsi
call   1030 <fprintf@plt>
jmp    127f <count_freq+0x16f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    121a <count_freq+0x10a>
add    $0x80040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_freq>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80020,%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    $0x400,%ebp
jmp    1175 <count_freq+0x55>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
je     11c1 <count_freq+0xa1>
xor    %edi,%edi
mov    $0x200,%esi
mov    $0x400,%edx
xor    %ecx,%ecx
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  0xe52(%rip),%xmm0
divsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%eax
cltq
addl   $0x1,0x20(%rsp,%rax,4)
jmp    1170 <count_freq+0x50>
xor    %ebp,%ebp
lea    0xe46(%rip),%rbx
jmp    11dd <count_freq+0xbd>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    $0x20000,%rbp
je     120d <count_freq+0xed>
mov    0x20(%rsp,%rbp,4),%edx
test   %edx,%edx
je     11d0 <count_freq+0xb0>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x18(%rsp),%xmm0
mulsd  0xe0e(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <fprintf@plt>
jmp    11d0 <count_freq+0xb0>
add    $0x80020,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%.12f %d\0A\00"
define void @count_freq(i32* %0, i32 (i32*, i32, i32, double*)* %1, double %2, double %3) {
%5 = alloca i32*
%6 = alloca i32 (i32*, i32, i32, double*)*
%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*, i32, i32, double*)* %1, i32 (i32*, i32, i32, double*)** %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, 1024
br i1 %29, label %30, label %59
30: ; preds = %27
%31 = load i32 (i32*, i32, i32, double*)*, i32 (i32*, i32, i32, double*)** %6
%32 = call i32 %31(i32* null, i32 512, i32 1024, double* null)
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 = %84, %59
%61 = load i32, i32* %9
%62 = icmp slt i32 %61, 131072
br i1 %62, label %63, label %87
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 %83
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 = call i32 @fprintf(i32* %70, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %77, i32 %81)
br label %83
83: ; preds = %69, %63
br label %84
84: ; preds = %83
%85 = load i32, i32* %9
%86 = add nsw i32 %85, 1
store i32 %86, i32* %9
br label %60
87: ; preds = %60
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%.12f %d\0A\00"
define void @count_freq(i32* nocapture %0, i32 (i32*, i32, i32, double*)* 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* null, i32 512, i32 1024, double* null)
%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, 1024
br i1 %26, label %27, label %8
27: ; preds = %24, %39
%28 = phi i64 [ %40, %39 ], [ 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 %39, 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 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %37, i32 %30)
br label %39
39: ; preds = %27, %32
%40 = add nuw nsw i64 %28, 1
%41 = icmp eq i64 %40, 131072
br i1 %41, label %42, label %27
42: ; preds = %39
ret void
}