#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 */
double RAND_MAX;
double cos(int);
int log(double);
double rand();
double sqrt(int);
int price(double center, double sigma) {
  double a, b;
  int ai;
  a = 1.0 * rand() / RAND_MAX;
  b = 1.0 * rand() / RAND_MAX;
  if (0 == a) {
    a = 0.001;
  }
  if (0 == b) {
    b = 0.001;
  }
  a = sqrt(-2 * log(a)) * cos(2 * 3.14159 * b);
  a = center + a * sigma;
  ai = (int)a;
  return ai;
}


x86 assembly (clang, -O0):
<price>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xe9c(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2e79(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xe76(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2e53(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    11bf <price+0x7f>
jp     11bf <price+0x7f>
movsd  0xe4e(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    11e0 <price+0xa0>
jp     11e0 <price+0xa0>
movsd  0xe2d(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
imul   $0xfffffffe,%eax,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe0e(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<price>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <rand@plt>
movaps %xmm0,0x20(%rsp)
mov    0x2e81(%rip),%rbp
movsd  0x0(%rbp),%xmm0
movapd %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movapd %xmm0,%xmm1
unpcklpd 0x20(%rsp),%xmm1
movsd  0x0(%rbp),%xmm0
unpcklpd (%rsp),%xmm0
divpd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
cmpeqpd %xmm1,%xmm0
movmskpd %xmm0,%ebp
test   $0x2,%bpl
movapd %xmm1,(%rsp)
jne    11b2 <price+0x72>
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
jmp    11ba <price+0x7a>
movsd  0xe46(%rip),%xmm0
call   1040 <log@plt>
lea    (%rax,%rax,1),%edi
neg    %edi
call   1050 <sqrt@plt>
movapd (%rsp),%xmm1
mulsd  0xe32(%rip),%xmm1
cvttsd2si %xmm1,%edi
movsd  %xmm0,(%rsp)
test   $0x1,%bpl
cmovne %ebx,%edi
call   1030 <cos@plt>
mulsd  (%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define i32 @price(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double %0, double* %3
store double %1, double* %4
%8 = call double (...) @rand()
%9 = fmul double 1.000000e+00, %8
%10 = load double, double* @RAND_MAX
%11 = fdiv double %9, %10
store double %11, double* %5
%12 = call double (...) @rand()
%13 = fmul double 1.000000e+00, %12
%14 = load double, double* @RAND_MAX
%15 = fdiv double %13, %14
store double %15, double* %6
%16 = load double, double* %5
%17 = fcmp oeq double 0.000000e+00, %16
br i1 %17, label %18, label %19
18: ; preds = %2
store double 1.000000e-03, double* %5
br label %19
19: ; preds = %18, %2
%20 = load double, double* %6
%21 = fcmp oeq double 0.000000e+00, %20
br i1 %21, label %22, label %23
22: ; preds = %19
store double 1.000000e-03, double* %6
br label %23
23: ; preds = %22, %19
%24 = load double, double* %5
%25 = call i32 @log(double %24)
%26 = mul nsw i32 -2, %25
%27 = call double @sqrt(i32 %26)
%28 = load double, double* %6
%29 = fmul double 6.283180e+00, %28
%30 = fptosi double %29 to i32
%31 = call double @cos(i32 %30)
%32 = fmul double %27, %31
store double %32, double* %5
%33 = load double, double* %3
%34 = load double, double* %5
%35 = load double, double* %4
%36 = call double @llvm.fmuladd.f64(double %34, double %35, double %33)
store double %36, double* %5
%37 = load double, double* %5
%38 = fptosi double %37 to i32
store i32 %38, i32* %7
%39 = load i32, i32* %7
ret i32 %39
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define i32 @price(double %0, double %1) {
%3 = tail call double (...) @rand()
%4 = load double, double* @RAND_MAX
%5 = tail call double (...) @rand()
%6 = load double, double* @RAND_MAX
%7 = insertelement <2 x double> poison, double %5, i64 0
%8 = insertelement <2 x double> %7, double %3, i64 1
%9 = insertelement <2 x double> poison, double %6, i64 0
%10 = insertelement <2 x double> %9, double %4, i64 1
%11 = fdiv <2 x double> %8, %10
%12 = fcmp oeq <2 x double> %11, zeroinitializer
%13 = extractelement <2 x i1> %12, i64 1
%14 = extractelement <2 x double> %11, i64 1
%15 = select i1 %13, double 1.000000e-03, double %14
%16 = tail call i32 @log(double %15)
%17 = mul nsw i32 %16, -2
%18 = tail call double @sqrt(i32 %17)
%19 = extractelement <2 x double> %11, i64 0
%20 = fmul double %19, 6.283180e+00
%21 = extractelement <2 x i1> %12, i64 0
%22 = fptosi double %20 to i32
%23 = select i1 %21, i32 0, i32 %22
%24 = tail call double @cos(i32 %23)
%25 = fmul double %18, %24
%26 = tail call double @llvm.fmuladd.f64(double %25, double %1, double %0)
%27 = fptosi double %26 to i32
ret i32 %27
}