#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);
double rand();
double sqrt(double);
double Norm(double miu, double sigma) {
  double x;
  double u1 = rand() * 1.0 / RAND_MAX;
  double u2 = rand() * 1.0 / RAND_MAX;
  x = miu + sigma * sqrt(-2.0 * (log(u1))) * cos(2.0 * 3.1415926 * u2);
  return x;
}


x86 assembly (clang, -O0):
<Norm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
movsd  0xeaf(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2e7c(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
movsd  0xe8c(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2e59(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe47(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe1d(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Norm>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    0x2e8a(%rip),%rbx
divsd  (%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
divsd  (%rbx),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <log@plt>
mulsd  0xe74(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     119c <Norm+0x5c>
sqrtsd %xmm0,%xmm0
jmp    11a1 <Norm+0x61>
call   1050 <sqrt@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xe4f(%rip),%xmm0
call   1030 <cos@plt>
mulsd  (%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define double @Norm(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store double %1, double* %4
%8 = call double (...) @rand()
%9 = fmul double %8, 1.000000e+00
%10 = load double, double* @RAND_MAX
%11 = fdiv double %9, %10
store double %11, double* %6
%12 = call double (...) @rand()
%13 = fmul double %12, 1.000000e+00
%14 = load double, double* @RAND_MAX
%15 = fdiv double %13, %14
store double %15, double* %7
%16 = load double, double* %3
%17 = load double, double* %4
%18 = load double, double* %6
%19 = call double @log(double %18)
%20 = fmul double -2.000000e+00, %19
%21 = call double @sqrt(double %20)
%22 = fmul double %17, %21
%23 = load double, double* %7
%24 = fmul double 0x401921FB4D12D84A, %23
%25 = call double @cos(double %24)
%26 = call double @llvm.fmuladd.f64(double %22, double %25, double %16)
store double %26, double* %5
%27 = load double, double* %5
ret double %27
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define double @Norm(double %0, double %1) {
%3 = tail call double (...) @rand()
%4 = load double, double* @RAND_MAX
%5 = fdiv double %3, %4
%6 = tail call double (...) @rand()
%7 = load double, double* @RAND_MAX
%8 = fdiv double %6, %7
%9 = tail call double @log(double %5)
%10 = fmul double %9, -2.000000e+00
%11 = tail call double @sqrt(double %10)
%12 = fmul double %11, %1
%13 = fmul double %8, 0x401921FB4D12D84A
%14 = tail call double @cos(double %13)
%15 = tail call double @llvm.fmuladd.f64(double %12, double %14, double %0)
ret double %15
}