#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 acos(double);
double cos(double);
double log(double);
double randd1();
double sin(double);
double sqrt(double);
void gaussian(double m, double sigma, double *x1, double *x2) {
  double pi = 2 * acos(0.0);
  double r1 = randd1(), r2 = randd1();
  double s, mtheta;
  double t1, t2;
  s = sigma * sqrt(-2.0 * log(r1));
  mtheta = 2.0 * pi * r2;
  t1 = m + s * cos(mtheta);
  t2 = m + s * sin(mtheta);
  r1 = randd1();
  r2 = randd1();
  s = sigma * sqrt(-2.0 * log(r1));
  mtheta = 2.0 * pi * r2;
  t1 = m + s * cos(mtheta);
  t2 = m + s * sin(mtheta);
  *x1 = t1;
  *x2 = t2;
}


x86 assembly (clang, -O0):
<gaussian>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
xorps  %xmm0,%xmm0
call   1030 <acos@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1040 <randd1@plt>
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1040 <randd1@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
call   1070 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe3d(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe10(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0xa0(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
call   1050 <sin@plt>
movsd  -0x90(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    $0x0,%al
call   1040 <randd1@plt>
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1040 <randd1@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1070 <log@plt>
movaps %xmm0,%xmm1
movsd  0xd4a(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd20(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0x78(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1050 <sin@plt>
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gaussian>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
call   1030 <acos@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <randd1@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1040 <randd1@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <log@plt>
xorpd  %xmm1,%xmm1
mulsd  0xe40(%rip),%xmm0
ucomisd %xmm0,%xmm1
ja     12a7 <gaussian+0x147>
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
ucomisd 0xe1d(%rip),%xmm1
movapd %xmm1,%xmm0
jae    12bb <gaussian+0x15b>
movsd  0xe13(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    12bb <gaussian+0x15b>
xor    %eax,%eax
call   1040 <randd1@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <randd1@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1070 <log@plt>
mulsd  0xdce(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1242 <gaussian+0xe2>
sqrtsd %xmm0,%xmm0
jmp    1247 <gaussian+0xe7>
call   1080 <sqrt@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1060 <cos@plt>
mulsd  (%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
mulsd  (%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  %xmm1,(%rbx)
movsd  %xmm0,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
ucomisd %xmm1,%xmm0
jae    11ca <gaussian+0x6a>
call   1080 <sqrt@plt>
jmp    11ca <gaussian+0x6a>
movsd  %xmm0,(%rsp)
call   1060 <cos@plt>
movsd  (%rsp),%xmm0
call   1050 <sin@plt>
jmp    1207 <gaussian+0xa7>

LLVM IR (-O0):
define void @gaussian(double %0, double %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
%16 = call i32 @acos(double 0.000000e+00)
%17 = mul nsw i32 2, %16
%18 = sitofp i32 %17 to double
store double %18, double* %9
%19 = call double (...) @randd1()
store double %19, double* %10
%20 = call double (...) @randd1()
store double %20, double* %11
%21 = load double, double* %6
%22 = load double, double* %10
%23 = call double @log(double %22)
%24 = fmul double -2.000000e+00, %23
%25 = call double @sqrt(double %24)
%26 = fmul double %21, %25
store double %26, double* %12
%27 = load double, double* %9
%28 = fmul double 2.000000e+00, %27
%29 = load double, double* %11
%30 = fmul double %28, %29
store double %30, double* %13
%31 = load double, double* %5
%32 = load double, double* %12
%33 = load double, double* %13
%34 = call double @cos(double %33)
%35 = call double @llvm.fmuladd.f64(double %32, double %34, double %31)
store double %35, double* %14
%36 = load double, double* %5
%37 = load double, double* %12
%38 = load double, double* %13
%39 = call double @sin(double %38)
%40 = call double @llvm.fmuladd.f64(double %37, double %39, double %36)
store double %40, double* %15
%41 = call double (...) @randd1()
store double %41, double* %10
%42 = call double (...) @randd1()
store double %42, double* %11
%43 = load double, double* %6
%44 = load double, double* %10
%45 = call double @log(double %44)
%46 = fmul double -2.000000e+00, %45
%47 = call double @sqrt(double %46)
%48 = fmul double %43, %47
store double %48, double* %12
%49 = load double, double* %9
%50 = fmul double 2.000000e+00, %49
%51 = load double, double* %11
%52 = fmul double %50, %51
store double %52, double* %13
%53 = load double, double* %5
%54 = load double, double* %12
%55 = load double, double* %13
%56 = call double @cos(double %55)
%57 = call double @llvm.fmuladd.f64(double %54, double %56, double %53)
store double %57, double* %14
%58 = load double, double* %5
%59 = load double, double* %12
%60 = load double, double* %13
%61 = call double @sin(double %60)
%62 = call double @llvm.fmuladd.f64(double %59, double %61, double %58)
store double %62, double* %15
%63 = load double, double* %14
%64 = load double*, double** %7
store double %63, double* %64
%65 = load double, double* %15
%66 = load double*, double** %8
store double %65, double* %66
ret void
}

LLVM IR (-O2):
define void @gaussian(double %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = tail call i32 @acos(double 0.000000e+00)
%6 = shl nsw i32 %5, 1
%7 = sitofp i32 %6 to double
%8 = tail call double (...) @randd1()
%9 = tail call double (...) @randd1()
%10 = tail call double @log(double %8)
%11 = fmul double %10, -2.000000e+00
%12 = fcmp olt double %11, 0.000000e+00
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = tail call double @sqrt(double %11)
br label %15
15: ; preds = %4, %13
%16 = fmul double %7, 2.000000e+00
%17 = fmul double %9, %16
%18 = fcmp oeq double %17, 0xFFF0000000000000
%19 = fcmp oeq double %17, 0x7FF0000000000000
%20 = or i1 %19, %18
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = tail call double @cos(double %17)
%23 = tail call double @sin(double %17)
br label %24
24: ; preds = %15, %21
%25 = tail call double (...) @randd1()
%26 = tail call double (...) @randd1()
%27 = tail call double @log(double %25)
%28 = fmul double %27, -2.000000e+00
%29 = tail call double @sqrt(double %28)
%30 = fmul double %29, %1
%31 = fmul double %16, %26
%32 = tail call double @cos(double %31)
%33 = tail call double @llvm.fmuladd.f64(double %30, double %32, double %0)
%34 = tail call double @sin(double %31)
%35 = tail call double @llvm.fmuladd.f64(double %30, double %34, double %0)
store double %33, double* %2
store double %35, double* %3
ret void
}