#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 cos(double);
double log(double);
int /*<<< orphan*/ ranlxd(double *, int);
double sin(double);
double sqrt(double);
void gauss_vector(double v[], int n) {
  int k;
  double r[2];
  double x1, x2, rho, y1, y2;
  for (k = 0;; k += 2) {
    ranlxd(r, 2);
    x1 = r[0];
    x2 = r[1];
    rho = -log(1.0 - x1);
    rho = sqrt(rho);
    x2 *= 6.2831853071796;
    y1 = rho * sin(x2);
    y2 = rho * cos(x2);
    if (n > k)
      v[k] = y1;
    if (n > (k + 1))
      v[k + 1] = y2;
    if (n <= (k + 2))
      return;
  }
}


x86 assembly (clang, -O0):
<gauss_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x2,%esi
call   1030 <ranlxd@plt>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe78(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1060 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe33(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    123f <gauss_vector+0xef>
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jle    1267 <gauss_vector+0x117>
movsd  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jg     127e <gauss_vector+0x12e>
add    $0x60,%rsp
pop    %rbp
ret
jmp    1283 <gauss_vector+0x133>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    1166 <gauss_vector+0x16>

x86 assembly (clang, -O2):
<gauss_vector>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %esi,%r12d
mov    %rdi,%r14
movslq %esi,%rbx
xor    %ebp,%ebp
lea    0x20(%rsp),%r15
jmp    1180 <gauss_vector+0x30>
xchg   %ax,%ax
add    $0x1,%rax
mov    %rax,%rbp
cmp    %r12d,%eax
jge    123f <gauss_vector+0xef>
mov    %r15,%rdi
mov    $0x2,%esi
call   1030 <ranlxd@plt>
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xe5f(%rip),%xmm0
subsd  0x20(%rsp),%xmm0
call   1060 <log@plt>
movsd  0xe54(%rip),%xmm1
ucomisd %xmm0,%xmm1
xorpd  0xe60(%rip),%xmm0
jb     11d0 <gauss_vector+0x80>
sqrtsd %xmm0,%xmm0
jmp    11d5 <gauss_vector+0x85>
nopl   0x0(%rax,%rax,1)
call   1070 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xe27(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
cmp    %rbx,%rbp
jge    121c <gauss_vector+0xcc>
movsd  0x18(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
movsd  %xmm1,(%r14,%rbp,8)
lea    0x1(%rbp),%rax
cmp    %rbx,%rax
jge    1170 <gauss_vector+0x20>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r14,%rbp,8)
jmp    1170 <gauss_vector+0x20>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @gauss_vector(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [2 x double]
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %12
12: ; preds = %63, %2
%13 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 0
%14 = call i32 @ranlxd(double* %13, i32 2)
%15 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 0
%16 = load double, double* %15
store double %16, double* %7
%17 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 1
%18 = load double, double* %17
store double %18, double* %8
%19 = load double, double* %7
%20 = fsub double 1.000000e+00, %19
%21 = call double @log(double %20)
%22 = fneg double %21
store double %22, double* %9
%23 = load double, double* %9
%24 = call double @sqrt(double %23)
store double %24, double* %9
%25 = load double, double* %8
%26 = fmul double %25, 0x401921FB54442D28
store double %26, double* %8
%27 = load double, double* %9
%28 = load double, double* %8
%29 = call double @sin(double %28)
%30 = fmul double %27, %29
store double %30, double* %10
%31 = load double, double* %9
%32 = load double, double* %8
%33 = call double @cos(double %32)
%34 = fmul double %31, %33
store double %34, double* %11
%35 = load i32, i32* %4
%36 = load i32, i32* %5
%37 = icmp sgt i32 %35, %36
br i1 %37, label %38, label %44
38: ; preds = %12
%39 = load double, double* %10
%40 = load double*, double** %3
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
store double %39, double* %43
br label %44
44: ; preds = %38, %12
%45 = load i32, i32* %4
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
%48 = icmp sgt i32 %45, %47
br i1 %48, label %49, label %56
49: ; preds = %44
%50 = load double, double* %11
%51 = load double*, double** %3
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %51, i64 %54
store double %50, double* %55
br label %56
56: ; preds = %49, %44
%57 = load i32, i32* %4
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 2
%60 = icmp sle i32 %57, %59
br i1 %60, label %61, label %62
61: ; preds = %56
ret void
62: ; preds = %56
br label %63
63: ; preds = %62
%64 = load i32, i32* %5
%65 = add nsw i32 %64, 2
store i32 %65, i32* %5
br label %12
}

LLVM IR (-O2):
define void @gauss_vector(double* nocapture writeonly %0, i32 %1) {
%3 = alloca [2 x double]
%4 = bitcast [2 x double]* %3 to i8*
%5 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 0
%6 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 1
%7 = sext i32 %1 to i64
br label %8
8: ; preds = %30, %2
%9 = phi i64 [ %31, %30 ], [ 0, %2 ]
%10 = call i32 @ranlxd(double* %5, i32 2)
%11 = load double, double* %5
%12 = load double, double* %6
%13 = fsub double 1.000000e+00, %11
%14 = call double @log(double %13)
%15 = fneg double %14
%16 = call double @sqrt(double %15)
%17 = fmul double %12, 0x401921FB54442D28
%18 = call double @sin(double %17)
%19 = call double @cos(double %17)
%20 = fmul double %16, %19
%21 = icmp slt i64 %9, %7
br i1 %21, label %22, label %25
22: ; preds = %8
%23 = fmul double %16, %18
%24 = getelementptr inbounds double, double* %0, i64 %9
store double %23, double* %24
br label %25
25: ; preds = %22, %8
%26 = or i64 %9, 1
%27 = icmp slt i64 %26, %7
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = getelementptr inbounds double, double* %0, i64 %26
store double %20, double* %29
br label %30
30: ; preds = %28, %25
%31 = add nuw i64 %9, 2
%32 = trunc i64 %31 to i32
%33 = icmp slt i32 %32, %1
br i1 %33, label %8, label %34
34: ; preds = %30
ret void
}