#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;
scalar_t__ RAND_MAX;
double cos(int);
double log(double);
int /*<<< orphan*/ printf(char *, double, double);
scalar_t__ rand();
double sin(int);
double sqrt(double);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main() {
  double mu = 0;
  double sigma = 1;
  srand((unsigned)time(NULL));
  double u1 = ((double)rand() / (double)RAND_MAX);
  double u2 = ((double)rand() / (double)RAND_MAX);
  double z0 = sqrt(-2.0 * log(u1)) * cos(2 * M_PI * u2);
  double z1 = sqrt(-2.0 * log(u1)) * sin(2 * M_PI * u2);
  printf("%f %f\n", z0 * sigma + mu, z1 * sigma + mu);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe69(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   10a0 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e19(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2df8(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1080 <log@plt>
movaps %xmm0,%xmm1
movsd  0xdf5(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1090 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1080 <log@plt>
movaps %xmm0,%xmm1
movsd  0xda3(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1090 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm3
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
lea    0xd41(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
cvtsi2sd %rax,%xmm1
mov    0x2e3a(%rip),%rbx
cvtsi2sdq (%rbx),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdq (%rbx),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1080 <log@plt>
mulsd  0xe17(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11f9 <main+0x79>
sqrtsd %xmm0,%xmm0
jmp    11fe <main+0x7e>
call   1090 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x2ddd(%rip),%rbx
mov    (%rbx),%eax
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1080 <log@plt>
mulsd  0xdbc(%rip),%xmm0
ucomisd 0xdbc(%rip),%xmm0
jb     1254 <main+0xd4>
sqrtsd %xmm0,%xmm0
jmp    1259 <main+0xd9>
call   1090 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
mov    (%rbx),%eax
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1050 <sin@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movsd  0x10(%rsp),%xmm0
addsd  %xmm2,%xmm0
addsd  %xmm2,%xmm1
lea    0xd70(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
@M_PI = global i32 0
@.str = [7 x i8] c"%f %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 1.000000e+00, double* %3
%8 = call i64 @time(i32* null)
%9 = trunc i64 %8 to i32
%10 = call i32 @srand(i32 %9)
%11 = call i64 (...) @rand()
%12 = sitofp i64 %11 to double
%13 = load i64, i64* @RAND_MAX
%14 = sitofp i64 %13 to double
%15 = fdiv double %12, %14
store double %15, double* %4
%16 = call i64 (...) @rand()
%17 = sitofp i64 %16 to double
%18 = load i64, i64* @RAND_MAX
%19 = sitofp i64 %18 to double
%20 = fdiv double %17, %19
store double %20, double* %5
%21 = load double, double* %4
%22 = call double @log(double %21)
%23 = fmul double -2.000000e+00, %22
%24 = call double @sqrt(double %23)
%25 = load i32, i32* @M_PI
%26 = mul nsw i32 2, %25
%27 = sitofp i32 %26 to double
%28 = load double, double* %5
%29 = fmul double %27, %28
%30 = fptosi double %29 to i32
%31 = call double @cos(i32 %30)
%32 = fmul double %24, %31
store double %32, double* %6
%33 = load double, double* %4
%34 = call double @log(double %33)
%35 = fmul double -2.000000e+00, %34
%36 = call double @sqrt(double %35)
%37 = load i32, i32* @M_PI
%38 = mul nsw i32 2, %37
%39 = sitofp i32 %38 to double
%40 = load double, double* %5
%41 = fmul double %39, %40
%42 = fptosi double %41 to i32
%43 = call double @sin(i32 %42)
%44 = fmul double %36, %43
store double %44, double* %7
%45 = load double, double* %6
%46 = load double, double* %3
%47 = load double, double* %2
%48 = call double @llvm.fmuladd.f64(double %45, double %46, double %47)
%49 = load double, double* %7
%50 = load double, double* %3
%51 = load double, double* %2
%52 = call double @llvm.fmuladd.f64(double %49, double %50, double %51)
%53 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %48, double %52)
ret i32 0
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
@M_PI = global i32 0
@.str = [7 x i8] c"%f %f\0A\00"
define i32 @main() {
%1 = tail call i64 @time(i32* null)
%2 = trunc i64 %1 to i32
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i64 (...) @rand()
%5 = sitofp i64 %4 to double
%6 = load i64, i64* @RAND_MAX
%7 = sitofp i64 %6 to double
%8 = fdiv double %5, %7
%9 = tail call i64 (...) @rand()
%10 = sitofp i64 %9 to double
%11 = load i64, i64* @RAND_MAX
%12 = sitofp i64 %11 to double
%13 = fdiv double %10, %12
%14 = tail call double @log(double %8)
%15 = fmul double %14, -2.000000e+00
%16 = tail call double @sqrt(double %15)
%17 = load i32, i32* @M_PI
%18 = shl nsw i32 %17, 1
%19 = sitofp i32 %18 to double
%20 = fmul double %13, %19
%21 = fptosi double %20 to i32
%22 = tail call double @cos(i32 %21)
%23 = fmul double %16, %22
%24 = tail call double @log(double %8)
%25 = fmul double %24, -2.000000e+00
%26 = tail call double @sqrt(double %25)
%27 = load i32, i32* @M_PI
%28 = shl nsw i32 %27, 1
%29 = sitofp i32 %28 to double
%30 = fmul double %13, %29
%31 = fptosi double %30 to i32
%32 = tail call double @sin(i32 %31)
%33 = fmul double %26, %32
%34 = fadd double %23, 0.000000e+00
%35 = fadd double %33, 0.000000e+00
%36 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %34, double %35)
ret i32 0
}