#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(double);
double log(double);
scalar_t__ rand();
double sin(double);
double sqrt(double);
void brnd(double sig, double m, double *x, double *y) {
  double r1, r2, r3;
  r1 = (double)rand() / RAND_MAX;
  while (r1 == 0.0) {
    r1 = (double)rand() / RAND_MAX;
  }
  r2 = (double)rand() / RAND_MAX;
  *x = sig * sqrt(-2.0 * log(r1)) * cos(2.0 * 3.14159 * r2) + m;
  *y = sig * sqrt(-2.0 * log(r1)) * sin(2.0 * 3.14159 * r2) + m;
}


x86 assembly (clang, -O0):
<brnd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e6b(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11bf <brnd+0x6f>
jp     11bf <brnd+0x6f>
mov    $0x0,%al
call   1070 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e37(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1186 <brnd+0x36>
mov    $0x0,%al
call   1070 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e16(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe0e(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xde4(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  0xda6(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd7c(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<brnd>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2e67(%rip),%rbx
divsd  (%rbx),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11bf <brnd+0x6f>
jp     11bf <brnd+0x6f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%rbx),%xmm0
ucomisd 0xe55(%rip),%xmm0
jne    11bf <brnd+0x6f>
jnp    11a0 <brnd+0x50>
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%rbx),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <log@plt>
mulsd  0xe0f(%rip),%xmm0
ucomisd 0xe17(%rip),%xmm0
jb     1201 <brnd+0xb1>
sqrtsd %xmm0,%xmm0
jmp    1206 <brnd+0xb6>
call   1060 <sqrt@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xde8(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1040 <cos@plt>
mulsd  0x28(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r15)
movsd  0x18(%rsp),%xmm0
call   1050 <log@plt>
mulsd  0xdb1(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     125f <brnd+0x10f>
sqrtsd %xmm0,%xmm0
jmp    1264 <brnd+0x114>
call   1060 <sqrt@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r14)
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define void @brnd(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
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
%12 = call i64 (...) @rand()
%13 = sitofp i64 %12 to double
%14 = load double, double* @RAND_MAX
%15 = fdiv double %13, %14
store double %15, double* %9
br label %16
16: ; preds = %19, %4
%17 = load double, double* %9
%18 = fcmp oeq double %17, 0.000000e+00
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = call i64 (...) @rand()
%21 = sitofp i64 %20 to double
%22 = load double, double* @RAND_MAX
%23 = fdiv double %21, %22
store double %23, double* %9
br label %16
24: ; preds = %16
%25 = call i64 (...) @rand()
%26 = sitofp i64 %25 to double
%27 = load double, double* @RAND_MAX
%28 = fdiv double %26, %27
store double %28, double* %10
%29 = load double, double* %5
%30 = load double, double* %9
%31 = call double @log(double %30)
%32 = fmul double -2.000000e+00, %31
%33 = call double @sqrt(double %32)
%34 = fmul double %29, %33
%35 = load double, double* %10
%36 = fmul double 6.283180e+00, %35
%37 = call double @cos(double %36)
%38 = load double, double* %6
%39 = call double @llvm.fmuladd.f64(double %34, double %37, double %38)
%40 = load double*, double** %7
store double %39, double* %40
%41 = load double, double* %5
%42 = load double, double* %9
%43 = call double @log(double %42)
%44 = fmul double -2.000000e+00, %43
%45 = call double @sqrt(double %44)
%46 = fmul double %41, %45
%47 = load double, double* %10
%48 = fmul double 6.283180e+00, %47
%49 = call double @sin(double %48)
%50 = load double, double* %6
%51 = call double @llvm.fmuladd.f64(double %46, double %49, double %50)
%52 = load double*, double** %8
store double %51, double* %52
ret void
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define void @brnd(double %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = tail call i64 (...) @rand()
%6 = sitofp i64 %5 to double
%7 = load double, double* @RAND_MAX
%8 = fdiv double %6, %7
%9 = fcmp oeq double %8, 0.000000e+00
br i1 %9, label %10, label %16
10: ; preds = %4, %10
%11 = tail call i64 (...) @rand()
%12 = sitofp i64 %11 to double
%13 = load double, double* @RAND_MAX
%14 = fdiv double %12, %13
%15 = fcmp oeq double %14, 0.000000e+00
br i1 %15, label %10, label %16
16: ; preds = %10, %4
%17 = phi double [ %8, %4 ], [ %14, %10 ]
%18 = tail call i64 (...) @rand()
%19 = sitofp i64 %18 to double
%20 = load double, double* @RAND_MAX
%21 = fdiv double %19, %20
%22 = tail call double @log(double %17)
%23 = fmul double %22, -2.000000e+00
%24 = tail call double @sqrt(double %23)
%25 = fmul double %24, %0
%26 = fmul double %21, 6.283180e+00
%27 = tail call double @cos(double %26)
%28 = tail call double @llvm.fmuladd.f64(double %25, double %27, double %1)
store double %28, double* %2
%29 = tail call double @log(double %17)
%30 = fmul double %29, -2.000000e+00
%31 = tail call double @sqrt(double %30)
%32 = fmul double %31, %0
%33 = tail call double @sin(double %26)
%34 = tail call double @llvm.fmuladd.f64(double %32, double %33, double %1)
store double %34, double* %3
ret void
}