#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 RAND_MAX;
double exp(double);
scalar_t__ rand();
double sqrt(int);
double white_noise(double ex, double sigma) {
  int i;
  double r;
  while (1) {
    r = (double)rand() / RAND_MAX;
    if (1.0 / sqrt(2 * M_PI * sigma) *
            exp(-(r - ex) * (r - ex) / 2.0 / sigma / sigma) >=
        (double)rand() / RAND_MAX)
      break;
  }
  return r;
}


x86 assembly (clang, -O0):
<white_noise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e8b(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe81(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe39(%rip),%xmm1
divsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
movsd  -0x28(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
mov    0x2ddd(%rip),%rax
divsd  (%rax),%xmm1
ucomisd %xmm1,%xmm0
jb     1216 <white_noise+0xe6>
jmp    121b <white_noise+0xeb>
jmp    1142 <white_noise+0x12>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<white_noise>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    0x2e96(%rip),%rbx
mov    0x2e97(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%rbx),%xmm0
movsd  %xmm0,(%rsp)
mov    (%r14),%eax
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movapd %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm0
mulsd  0xe50(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movapd 0xe30(%rip),%xmm1
unpcklpd %xmm0,%xmm1
movapd 0x20(%rsp),%xmm0
movhpd (%rbx),%xmm0
divpd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm0
mulsd  %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1160 <white_noise+0x30>
movsd  (%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
@M_PI = global i32 0
define double @white_noise(double %0, double %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call i64 (...) @rand()
%5 = sitofp i64 %4 to double
%6 = load double, double* @RAND_MAX
%7 = fdiv double %5, %6
%8 = load i32, i32* @M_PI
%9 = shl nsw i32 %8, 1
%10 = sitofp i32 %9 to double
%11 = fmul double %10, %1
%12 = fptosi double %11 to i32
%13 = tail call double @sqrt(i32 %12)
%14 = fsub double %7, %0
%15 = fneg double %14
%16 = fmul double %14, %15
%17 = fmul double %16, 5.000000e-01
%18 = fdiv double %17, %1
%19 = fdiv double %18, %1
%20 = tail call double @exp(double %19)
%21 = tail call i64 (...) @rand()
%22 = sitofp i64 %21 to double
%23 = load double, double* @RAND_MAX
%24 = insertelement <2 x double> <double 1.000000e+00, double poison>, double %22, i64 1
%25 = insertelement <2 x double> poison, double %13, i64 0
%26 = insertelement <2 x double> %25, double %23, i64 1
%27 = fdiv <2 x double> %24, %26
%28 = extractelement <2 x double> %27, i64 0
%29 = fmul double %28, %20
%30 = extractelement <2 x double> %27, i64 1
%31 = fcmp ult double %29, %30
br i1 %31, label %3, label %32
32: ; preds = %3
ret double %7
}