#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*/ hist_book(int, double, double);
int hist_create(char *, int, double, double);
int /*<<< orphan*/ hist_plot(int);
double random_dist_flat();
double random_dist_gaus(double);
int main() {
  int i, h_index[2];
  double value;
  h_index[0] = hist_create("Gaus", 20, -3.0, 3.0);
  h_index[1] = hist_create("Flat", 20, 0.0, 1.0);
  for (i = 0; i < 10000; i++) {
    value = random_dist_gaus(1.0);
    hist_book(h_index[0], value, 1.0);
    value = random_dist_flat();
    hist_book(h_index[1], value, 1.0);
  }
  hist_plot(h_index[0]);
  hist_plot(h_index[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x14,%esi
movsd  0xe95(%rip),%xmm0
movsd  0xe95(%rip),%xmm1
call   1040 <hist_create@plt>
mov    %eax,-0x10(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x14,%esi
xorps  %xmm0,%xmm0
movsd  0xe66(%rip),%xmm1
call   1040 <hist_create@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x2710,-0x8(%rbp)
jge    120c <main+0xbc>
movsd  0xe42(%rip),%xmm0
call   1060 <random_dist_gaus@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  0xe28(%rip),%xmm1
call   1030 <hist_book@plt>
mov    $0x0,%al
call   1050 <random_dist_flat@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  0xe07(%rip),%xmm1
call   1030 <hist_book@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a9 <main+0x59>
mov    -0x10(%rbp),%edi
call   1070 <hist_plot@plt>
mov    -0xc(%rbp),%edi
call   1070 <hist_plot@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xebd(%rip),%rdi
movsd  0xe9d(%rip),%xmm0
movsd  0xe9d(%rip),%xmm1
mov    $0x14,%esi
call   1040 <hist_create@plt>
mov    %eax,%r14d
lea    0xe9e(%rip),%rdi
movsd  0xe89(%rip),%xmm1
xorps  %xmm0,%xmm0
mov    $0x14,%esi
call   1040 <hist_create@plt>
mov    %eax,%ebp
mov    $0x2710,%ebx
nopl   0x0(%rax,%rax,1)
movsd  0xe68(%rip),%xmm0
call   1060 <random_dist_gaus@plt>
mov    %r14d,%edi
movsd  0xe58(%rip),%xmm1
call   1030 <hist_book@plt>
xor    %eax,%eax
call   1050 <random_dist_flat@plt>
mov    %ebp,%edi
movsd  0xe42(%rip),%xmm1
call   1030 <hist_book@plt>
add    $0xffffffff,%ebx
jne    11a0 <main+0x50>
mov    %r14d,%edi
call   1070 <hist_plot@plt>
mov    %ebp,%edi
call   1070 <hist_plot@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"Gaus\00"
@.str.1 = [5 x i8] c"Flat\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x i32]
%4 = alloca double
store i32 0, i32* %1
%5 = call i32 @hist_create(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 20, double -3.000000e+00, double 3.000000e+00)
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
store i32 %5, i32* %6
%7 = call i32 @hist_create(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 20, double 0.000000e+00, double 1.000000e+00)
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
store i32 %7, i32* %8
store i32 0, i32* %2
br label %9
9: ; preds = %23, %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 10000
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = call double @random_dist_gaus(double 1.000000e+00)
store double %13, double* %4
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%15 = load i32, i32* %14
%16 = load double, double* %4
%17 = call i32 @hist_book(i32 %15, double %16, double 1.000000e+00)
%18 = call double (...) @random_dist_flat()
store double %18, double* %4
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%20 = load i32, i32* %19
%21 = load double, double* %4
%22 = call i32 @hist_book(i32 %20, double %21, double 1.000000e+00)
br label %23
23: ; preds = %12
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %9
26: ; preds = %9
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%28 = load i32, i32* %27
%29 = call i32 @hist_plot(i32 %28)
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%31 = load i32, i32* %30
%32 = call i32 @hist_plot(i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"Gaus\00"
@.str.1 = [5 x i8] c"Flat\00"
define i32 @main() {
%1 = tail call i32 @hist_create(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 20, double -3.000000e+00, double 3.000000e+00)
%2 = tail call i32 @hist_create(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 20, double 0.000000e+00, double 1.000000e+00)
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %9, %3 ]
%5 = tail call double @random_dist_gaus(double 1.000000e+00)
%6 = tail call i32 @hist_book(i32 %1, double %5, double 1.000000e+00)
%7 = tail call double (...) @random_dist_flat()
%8 = tail call i32 @hist_book(i32 %2, double %7, double 1.000000e+00)
%9 = add nuw nsw i32 %4, 1
%10 = icmp eq i32 %9, 10000
br i1 %10, label %11, label %3
11: ; preds = %3
%12 = tail call i32 @hist_plot(i32 %1)
%13 = tail call i32 @hist_plot(i32 %2)
ret i32 0
}