#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 */
scalar_t__ RAND_MAX;
scalar_t__ rand();
int round(float);
int generate_gaussian_number(int lower_bound, int higher_bound) {
  float x = 0, rndm;
  int range = higher_bound - lower_bound;
  int i, reps = 20;
  for (i = 0; i < reps; i++) {
    rndm = ((float)rand()) / ((float)RAND_MAX);
    x += rndm;
  }
  x /= reps;
  x *= range;
  x += lower_bound;
  return (round(x));
}


x86 assembly (clang, -O0):
<generate_gaussian_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x14,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1197 <generate_gaussian_number+0x77>
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    0x2e7c(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114d <generate_gaussian_number+0x2d>
cvtsi2ssl -0x1c(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <round@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_gaussian_number>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r14d
xorps  %xmm0,%xmm0
mov    $0x14,%ebx
mov    0x2eac(%rip),%rbp
nopl   0x0(%rax)
movss  %xmm0,0x4(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssq 0x0(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x4(%rsp),%xmm0
add    $0xffffffff,%ebx
jne    1140 <generate_gaussian_number+0x20>
sub    %r14d,%r15d
divss  0xe78(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %r15d,%xmm1
mulss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
addss  %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <round@plt>

LLVM IR (-O0):
@RAND_MAX = global i64 0
define i32 @generate_gaussian_number(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store float 0.000000e+00, float* %5
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = sub nsw i32 %10, %11
store i32 %12, i32* %7
store i32 20, i32* %9
store i32 0, i32* %8
br label %13
13: ; preds = %26, %2
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = call i64 (...) @rand()
%19 = sitofp i64 %18 to float
%20 = load i64, i64* @RAND_MAX
%21 = sitofp i64 %20 to float
%22 = fdiv float %19, %21
store float %22, float* %6
%23 = load float, float* %6
%24 = load float, float* %5
%25 = fadd float %24, %23
store float %25, float* %5
br label %26
26: ; preds = %17
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %13
29: ; preds = %13
%30 = load i32, i32* %9
%31 = sitofp i32 %30 to float
%32 = load float, float* %5
%33 = fdiv float %32, %31
store float %33, float* %5
%34 = load i32, i32* %7
%35 = sitofp i32 %34 to float
%36 = load float, float* %5
%37 = fmul float %36, %35
store float %37, float* %5
%38 = load i32, i32* %3
%39 = sitofp i32 %38 to float
%40 = load float, float* %5
%41 = fadd float %40, %39
store float %41, float* %5
%42 = load float, float* %5
%43 = call i32 @round(float %42)
ret i32 %43
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define i32 @generate_gaussian_number(i32 %0, i32 %1) {
br label %3
3: ; preds = %2, %3
%4 = phi float [ 0.000000e+00, %2 ], [ %11, %3 ]
%5 = phi i32 [ 0, %2 ], [ %12, %3 ]
%6 = tail call i64 (...) @rand()
%7 = sitofp i64 %6 to float
%8 = load i64, i64* @RAND_MAX
%9 = sitofp i64 %8 to float
%10 = fdiv float %7, %9
%11 = fadd float %4, %10
%12 = add nuw nsw i32 %5, 1
%13 = icmp eq i32 %12, 20
br i1 %13, label %14, label %3
14: ; preds = %3
%15 = sub nsw i32 %1, %0
%16 = fdiv float %11, 2.000000e+01
%17 = sitofp i32 %15 to float
%18 = fmul float %16, %17
%19 = sitofp i32 %0 to float
%20 = fadd float %18, %19
%21 = tail call i32 @round(float %20)
ret i32 %21
}