#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 edisrnd(double *);
scalar_t__ malloc(int);
double *nordisrndsq(double u, double g, double *r, int n) {
  double *value, *vp, temp;
  int i, count;
  value = (double *)malloc(n * sizeof(double));
  for (count = 0, vp = value; count < n; count++, vp++) {
    for (i = 1, temp = .0; i <= 12; i++)
      temp = temp + edisrnd(r);
    *vp = u + g * (temp - 6.0);
  }
  return value;
}


x86 assembly (clang, -O0):
<nordisrndsq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f7 <nordisrndsq+0xd7>
movl   $0x1,-0x3c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
cmpl   $0xc,-0x3c(%rbp)
jg     11b2 <nordisrndsq+0x92>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <edisrnd@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1176 <nordisrndsq+0x56>
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  0xe37(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
jmp    115b <nordisrndsq+0x3b>
mov    -0x28(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nordisrndsq>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r15d
mov    %rdi,%rbx
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
lea    0x0(,%r15,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r14
test   %r15d,%r15d
jle    125d <nordisrndsq+0x13d>
mov    %r15d,%r15d
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  0xe98(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <edisrnd@plt>
addsd  (%rsp),%xmm0
addsd  0xdc2(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%r12,8)
add    $0x1,%r12
cmp    %r12d,%r15d
jne    1160 <nordisrndsq+0x40>
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double* @nordisrndsq(double %0, double %1, double* %2, i32 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
store i32 %3, i32* %8
%14 = load i32, i32* %8
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 8
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to double*
store double* %19, double** %9
store i32 0, i32* %13
%20 = load double*, double** %9
store double* %20, double** %10
br label %21
21: ; preds = %44, %4
%22 = load i32, i32* %13
%23 = load i32, i32* %8
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %49
25: ; preds = %21
store i32 1, i32* %12
store double 0.000000e+00, double* %11
br label %26
26: ; preds = %34, %25
%27 = load i32, i32* %12
%28 = icmp sle i32 %27, 12
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = load double, double* %11
%31 = load double*, double** %7
%32 = call double @edisrnd(double* %31)
%33 = fadd double %30, %32
store double %33, double* %11
br label %34
34: ; preds = %29
%35 = load i32, i32* %12
%36 = add nsw i32 %35, 1
store i32 %36, i32* %12
br label %26
37: ; preds = %26
%38 = load double, double* %5
%39 = load double, double* %6
%40 = load double, double* %11
%41 = fsub double %40, 6.000000e+00
%42 = call double @llvm.fmuladd.f64(double %39, double %41, double %38)
%43 = load double*, double** %10
store double %42, double* %43
br label %44
44: ; preds = %37
%45 = load i32, i32* %13
%46 = add nsw i32 %45, 1
store i32 %46, i32* %13
%47 = load double*, double** %10
%48 = getelementptr inbounds double, double* %47, i32 1
store double* %48, double** %10
br label %21
49: ; preds = %21
%50 = load double*, double** %9
ret double* %50
}

LLVM IR (-O2):
define double* @nordisrndsq(double %0, double %1, double* %2, i32 %3) {
%5 = shl i32 %3, 3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to double*
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %41
9: ; preds = %4, %9
%10 = phi i32 [ %38, %9 ], [ 0, %4 ]
%11 = phi double* [ %39, %9 ], [ %7, %4 ]
%12 = tail call double @edisrnd(double* %2)
%13 = fadd double %12, 0.000000e+00
%14 = tail call double @edisrnd(double* %2)
%15 = fadd double %13, %14
%16 = tail call double @edisrnd(double* %2)
%17 = fadd double %15, %16
%18 = tail call double @edisrnd(double* %2)
%19 = fadd double %17, %18
%20 = tail call double @edisrnd(double* %2)
%21 = fadd double %19, %20
%22 = tail call double @edisrnd(double* %2)
%23 = fadd double %21, %22
%24 = tail call double @edisrnd(double* %2)
%25 = fadd double %23, %24
%26 = tail call double @edisrnd(double* %2)
%27 = fadd double %25, %26
%28 = tail call double @edisrnd(double* %2)
%29 = fadd double %27, %28
%30 = tail call double @edisrnd(double* %2)
%31 = fadd double %29, %30
%32 = tail call double @edisrnd(double* %2)
%33 = fadd double %31, %32
%34 = tail call double @edisrnd(double* %2)
%35 = fadd double %33, %34
%36 = fadd double %35, -6.000000e+00
%37 = tail call double @llvm.fmuladd.f64(double %1, double %36, double %0)
store double %37, double* %11
%38 = add nuw nsw i32 %10, 1
%39 = getelementptr inbounds double, double* %11, i64 1
%40 = icmp eq i32 %38, %3
br i1 %40, label %41, label %9
41: ; preds = %9, %4
ret double* %7
}