#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 M_PI;
double cos(int);
double drand48();
int log(double);
double sqrt(int);
double get_distributed_rand(double mean) {
  double a = drand48();
  double b = drand48();
  double z = sqrt(-2 * log(a)) * cos(2 * M_PI * b);
  double result = ((mean / 2) * z) + mean;
  if (result < 1) {
    result = 1;
  } else if (result > 100) {
    result = 99;
  }
  return result;
}


x86 assembly (clang, -O0):
<get_distributed_rand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1060 <drand48@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1060 <drand48@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
imul   $0xfffffffe,%eax,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe4d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe22(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11fb <get_distributed_rand+0xbb>
movsd  0xe0f(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1224 <get_distributed_rand+0xe4>
movsd  -0x28(%rbp),%xmm0
movsd  0xe08(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    121f <get_distributed_rand+0xdf>
movsd  0xdfe(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1224 <get_distributed_rand+0xe4>
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_distributed_rand>:
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1060 <drand48@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <drand48@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1040 <log@plt>
lea    (%rax,%rax,1),%edi
neg    %edi
call   1050 <sqrt@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
add    %eax,%eax
cvtsi2sd %eax,%xmm1
movsd  %xmm0,(%rsp)
mulsd  0x8(%rsp),%xmm1
cvttsd2si %xmm1,%edi
call   1030 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  0xe59(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movsd  0xe47(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     11dd <get_distributed_rand+0x9d>
ucomisd 0xe41(%rip),%xmm1
movapd %xmm1,%xmm0
jbe    11dd <get_distributed_rand+0x9d>
movsd  0xe3b(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @get_distributed_rand(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %2
%7 = call double (...) @drand48()
store double %7, double* %3
%8 = call double (...) @drand48()
store double %8, double* %4
%9 = load double, double* %3
%10 = call i32 @log(double %9)
%11 = mul nsw i32 -2, %10
%12 = call double @sqrt(i32 %11)
%13 = load i32, i32* @M_PI
%14 = mul nsw i32 2, %13
%15 = sitofp i32 %14 to double
%16 = load double, double* %4
%17 = fmul double %15, %16
%18 = fptosi double %17 to i32
%19 = call double @cos(i32 %18)
%20 = fmul double %12, %19
store double %20, double* %5
%21 = load double, double* %2
%22 = fdiv double %21, 2.000000e+00
%23 = load double, double* %5
%24 = load double, double* %2
%25 = call double @llvm.fmuladd.f64(double %22, double %23, double %24)
store double %25, double* %6
%26 = load double, double* %6
%27 = fcmp olt double %26, 1.000000e+00
br i1 %27, label %28, label %29
28: ; preds = %1
store double 1.000000e+00, double* %6
br label %34
29: ; preds = %1
%30 = load double, double* %6
%31 = fcmp ogt double %30, 1.000000e+02
br i1 %31, label %32, label %33
32: ; preds = %29
store double 9.900000e+01, double* %6
br label %33
33: ; preds = %32, %29
br label %34
34: ; preds = %33, %28
%35 = load double, double* %6
ret double %35
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @get_distributed_rand(double %0) {
%2 = tail call double (...) @drand48()
%3 = tail call double (...) @drand48()
%4 = tail call i32 @log(double %2)
%5 = mul nsw i32 %4, -2
%6 = tail call double @sqrt(i32 %5)
%7 = load i32, i32* @M_PI
%8 = shl nsw i32 %7, 1
%9 = sitofp i32 %8 to double
%10 = fmul double %3, %9
%11 = fptosi double %10 to i32
%12 = tail call double @cos(i32 %11)
%13 = fmul double %6, %12
%14 = fmul double %0, 5.000000e-01
%15 = tail call double @llvm.fmuladd.f64(double %14, double %13, double %0)
%16 = fcmp olt double %15, 1.000000e+00
br i1 %16, label %20, label %17
17: ; preds = %1
%18 = fcmp ogt double %15, 1.000000e+02
br i1 %18, label %19, label %20
19: ; preds = %17
br label %20
20: ; preds = %1, %17, %19
%21 = phi double [ 9.900000e+01, %19 ], [ %15, %17 ], [ 1.000000e+00, %1 ]
ret double %21
}