#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 exp(double);
double log(double);
int /*<<< orphan*/ math_gauss_quad_coefficients(int, double const **,
                                                double const **);
int /*<<< orphan*/ memcpy(double *, double const *, int);
void math_gauss_quad_initialise(int n, double xmin, double xmax, int logscale,
                                double *xGQ, double *wGQ) {
  const double *x, *w;
  math_gauss_quad_coefficients(n, &x, &w);
  memcpy(xGQ, x, n * sizeof(*xGQ));
  memcpy(wGQ, w, n * sizeof(*wGQ));
  if (logscale) {
    xmin = log(xmin);
    xmax = log(xmax);
    const double dx = xmax - xmin;
    int i;
    for (i = 0; i < n; i++) {
      const double xi = exp(xmin + dx * xGQ[i]);
      xGQ[i] = xi;
      wGQ[i] *= dx * xi;
    }
  } else {
    const double dx = xmax - xmin;
    int i;
    for (i = 0; i < n; i++) {
      xGQ[i] = xmin + dx * xGQ[i];
      wGQ[i] *= dx;
    }
  }
}


x86 assembly (clang, -O0):
<math_gauss_quad_initialise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1030 <math_gauss_quad_coefficients@plt>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rsi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1252 <math_gauss_quad_initialise+0x112>
movsd  -0x10(%rbp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    124d <math_gauss_quad_initialise+0x10d>
movsd  -0x10(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11dc <math_gauss_quad_initialise+0x9c>
jmp    12ca <math_gauss_quad_initialise+0x18a>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12c5 <math_gauss_quad_initialise+0x185>
movsd  -0x10(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x60(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x64(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1268 <math_gauss_quad_initialise+0x128>
jmp    12ca <math_gauss_quad_initialise+0x18a>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<math_gauss_quad_initialise>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%r14
mov    %rdx,%r13
mov    %esi,%r12d
movapd %xmm1,(%rsp)
movapd %xmm0,0x10(%rsp)
mov    %edi,%r15d
lea    0x30(%rsp),%rsi
lea    0x28(%rsp),%rdx
call   1030 <math_gauss_quad_coefficients@plt>
mov    0x30(%rsp),%rsi
lea    0x0(,%r15,8),%ebp
mov    %r13,%rdi
mov    %ebp,%edx
call   1040 <memcpy@plt>
mov    0x28(%rsp),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
call   1040 <memcpy@plt>
test   %r12d,%r12d
je     121d <math_gauss_quad_initialise+0xdd>
movaps 0x10(%rsp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x10(%rsp)
movapd (%rsp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,(%rsp)
test   %r15d,%r15d
jle    13cd <math_gauss_quad_initialise+0x28d>
movsd  (%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
movsd  0x0(%r13,%rbx,8),%xmm0
mulsd  (%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,0x0(%r13,%rbx,8)
mulsd  (%rsp),%xmm0
mulsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11e0 <math_gauss_quad_initialise+0xa0>
jmp    13cd <math_gauss_quad_initialise+0x28d>
test   %r15d,%r15d
movapd (%rsp),%xmm3
movapd 0x10(%rsp),%xmm4
jle    13cd <math_gauss_quad_initialise+0x28d>
subsd  %xmm4,%xmm3
mov    %r15d,%eax
cmp    $0x1,%r15d
je     125f <math_gauss_quad_initialise+0x11f>
lea    (%r14,%rax,8),%rcx
cmp    %r13,%rcx
jbe    12fc <math_gauss_quad_initialise+0x1bc>
lea    0x0(,%rax,8),%rcx
add    %r13,%rcx
cmp    %r14,%rcx
jbe    12fc <math_gauss_quad_initialise+0x1bc>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
test   $0x1,%al
je     1295 <math_gauss_quad_initialise+0x155>
movsd  0x0(%r13,%rcx,8),%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
movsd  %xmm0,0x0(%r13,%rcx,8)
movsd  (%r14,%rcx,8),%xmm0
mulsd  %xmm3,%xmm0
movsd  %xmm0,(%r14,%rcx,8)
or     $0x1,%rcx
add    %rax,%rdx
je     13cd <math_gauss_quad_initialise+0x28d>
xchg   %ax,%ax
movsd  0x0(%r13,%rcx,8),%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
movsd  %xmm0,0x0(%r13,%rcx,8)
movsd  (%r14,%rcx,8),%xmm0
mulsd  %xmm3,%xmm0
movsd  %xmm0,(%r14,%rcx,8)
movsd  0x8(%r13,%rcx,8),%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
movsd  %xmm0,0x8(%r13,%rcx,8)
movsd  0x8(%r14,%rcx,8),%xmm0
mulsd  %xmm3,%xmm0
movsd  %xmm0,0x8(%r14,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%rax
jne    12a0 <math_gauss_quad_initialise+0x160>
jmp    13cd <math_gauss_quad_initialise+0x28d>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
movapd %xmm3,%xmm0
unpcklpd %xmm3,%xmm0
movapd %xmm4,%xmm1
unpcklpd %xmm4,%xmm1
lea    -0x2(%rcx),%rdx
mov    %rdx,%rsi
shr    %rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     13dc <math_gauss_quad_initialise+0x29c>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movupd 0x0(%r13,%rdx,8),%xmm2
mulpd  %xmm0,%xmm2
addpd  %xmm1,%xmm2
movupd %xmm2,0x0(%r13,%rdx,8)
movupd (%r14,%rdx,8),%xmm2
mulpd  %xmm0,%xmm2
movupd %xmm2,(%r14,%rdx,8)
movupd 0x10(%r13,%rdx,8),%xmm2
mulpd  %xmm0,%xmm2
addpd  %xmm1,%xmm2
movupd %xmm2,0x10(%r13,%rdx,8)
movupd 0x10(%r14,%rdx,8),%xmm2
mulpd  %xmm0,%xmm2
movupd %xmm2,0x10(%r14,%rdx,8)
add    $0x4,%rdx
add    $0xfffffffffffffffe,%rdi
jne    1340 <math_gauss_quad_initialise+0x200>
test   $0x1,%sil
je     13c4 <math_gauss_quad_initialise+0x284>
movupd 0x0(%r13,%rdx,8),%xmm2
mulpd  %xmm0,%xmm2
addpd  %xmm1,%xmm2
movupd %xmm2,0x0(%r13,%rdx,8)
movupd (%r14,%rdx,8),%xmm1
mulpd  %xmm0,%xmm1
movupd %xmm1,(%r14,%rdx,8)
cmp    %rax,%rcx
jne    1261 <math_gauss_quad_initialise+0x121>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edx,%edx
test   $0x1,%sil
jne    139e <math_gauss_quad_initialise+0x25e>
jmp    13c4 <math_gauss_quad_initialise+0x284>

LLVM IR (-O0):
define void @math_gauss_quad_initialise(i32 %0, double %1, double %2, i32 %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double
%16 = alloca i32
%17 = alloca double
%18 = alloca double
%19 = alloca i32
store i32 %0, i32* %7
store double %1, double* %8
store double %2, double* %9
store i32 %3, i32* %10
store double* %4, double** %11
store double* %5, double** %12
%20 = load i32, i32* %7
%21 = call i32 @math_gauss_quad_coefficients(i32 %20, double** %13, double** %14)
%22 = load double*, double** %11
%23 = load double*, double** %13
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 8
%27 = trunc i64 %26 to i32
%28 = call i32 @memcpy(double* %22, double* %23, i32 %27)
%29 = load double*, double** %12
%30 = load double*, double** %14
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = mul i64 %32, 8
%34 = trunc i64 %33 to i32
%35 = call i32 @memcpy(double* %29, double* %30, i32 %34)
%36 = load i32, i32* %10
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %78
38: ; preds = %6
%39 = load double, double* %8
%40 = call double @log(double %39)
store double %40, double* %8
%41 = load double, double* %9
%42 = call double @log(double %41)
store double %42, double* %9
%43 = load double, double* %9
%44 = load double, double* %8
%45 = fsub double %43, %44
store double %45, double* %15
store i32 0, i32* %16
br label %46
46: ; preds = %74, %38
%47 = load i32, i32* %16
%48 = load i32, i32* %7
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %77
50: ; preds = %46
%51 = load double, double* %8
%52 = load double, double* %15
%53 = load double*, double** %11
%54 = load i32, i32* %16
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = call double @llvm.fmuladd.f64(double %52, double %57, double %51)
%59 = call double @exp(double %58)
store double %59, double* %17
%60 = load double, double* %17
%61 = load double*, double** %11
%62 = load i32, i32* %16
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds double, double* %61, i64 %63
store double %60, double* %64
%65 = load double, double* %15
%66 = load double, double* %17
%67 = fmul double %65, %66
%68 = load double*, double** %12
%69 = load i32, i32* %16
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
%72 = load double, double* %71
%73 = fmul double %72, %67
store double %73, double* %71
br label %74
74: ; preds = %50
%75 = load i32, i32* %16
%76 = add nsw i32 %75, 1
store i32 %76, i32* %16
br label %46
77: ; preds = %46
br label %110
78: ; preds = %6
%79 = load double, double* %9
%80 = load double, double* %8
%81 = fsub double %79, %80
store double %81, double* %18
store i32 0, i32* %19
br label %82
82: ; preds = %106, %78
%83 = load i32, i32* %19
%84 = load i32, i32* %7
%85 = icmp slt i32 %83, %84
br i1 %85, label %86, label %109
86: ; preds = %82
%87 = load double, double* %8
%88 = load double, double* %18
%89 = load double*, double** %11
%90 = load i32, i32* %19
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %89, i64 %91
%93 = load double, double* %92
%94 = call double @llvm.fmuladd.f64(double %88, double %93, double %87)
%95 = load double*, double** %11
%96 = load i32, i32* %19
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double, double* %95, i64 %97
store double %94, double* %98
%99 = load double, double* %18
%100 = load double*, double** %12
%101 = load i32, i32* %19
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double, double* %100, i64 %102
%104 = load double, double* %103
%105 = fmul double %104, %99
store double %105, double* %103
br label %106
106: ; preds = %86
%107 = load i32, i32* %19
%108 = add nsw i32 %107, 1
store i32 %108, i32* %19
br label %82
109: ; preds = %82
br label %110
110: ; preds = %109, %77
ret void
}

LLVM IR (-O2):
define void @math_gauss_quad_initialise(i32 %0, double %1, double %2, i32 %3, double* %4, double* %5) {
%7 = alloca double*
%8 = alloca double*
%9 = bitcast double** %7 to i8*
%10 = bitcast double** %8 to i8*
%11 = call i32 @math_gauss_quad_coefficients(i32 %0, double** %7, double** %8)
%12 = load double*, double** %7
%13 = shl i32 %0, 3
%14 = call i32 @memcpy(double* %4, double* %12, i32 %13)
%15 = load double*, double** %8
%16 = call i32 @memcpy(double* %5, double* %15, i32 %13)
%17 = icmp eq i32 %3, 0
br i1 %17, label %37, label %18
18: ; preds = %6
%19 = call double @log(double %1)
%20 = call double @log(double %2)
%21 = fsub double %20, %19
%22 = icmp sgt i32 %0, 0
br i1 %22, label %23, label %139
23: ; preds = %18
%24 = zext i32 %0 to i64
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ 0, %23 ], [ %35, %25 ]
%27 = getelementptr inbounds double, double* %4, i64 %26
%28 = load double, double* %27
%29 = call double @llvm.fmuladd.f64(double %21, double %28, double %19)
%30 = call double @exp(double %29)
store double %30, double* %27
%31 = fmul double %21, %30
%32 = getelementptr inbounds double, double* %5, i64 %26
%33 = load double, double* %32
%34 = fmul double %31, %33
store double %34, double* %32
%35 = add nuw nsw i64 %26, 1
%36 = icmp eq i64 %35, %24
br i1 %36, label %139, label %25
37: ; preds = %6
%38 = fsub double %2, %1
%39 = icmp sgt i32 %0, 0
br i1 %39, label %40, label %139
40: ; preds = %37
%41 = zext i32 %0 to i64
%42 = icmp eq i32 %0, 1
br i1 %42, label %105, label %43
43: ; preds = %40
%44 = getelementptr double, double* %4, i64 %41
%45 = getelementptr double, double* %5, i64 %41
%46 = icmp ugt double* %45, %4
%47 = icmp ugt double* %44, %5
%48 = and i1 %46, %47
br i1 %48, label %105, label %49
49: ; preds = %43
%50 = and i64 %41, 4294967294
%51 = insertelement <2 x double> poison, double %38, i64 0
%52 = shufflevector <2 x double> %51, <2 x double> poison, <2 x i32> zeroinitializer
%53 = insertelement <2 x double> poison, double %1, i64 0
%54 = shufflevector <2 x double> %53, <2 x double> poison, <2 x i32> zeroinitializer
%55 = add nsw i64 %50, -2
%56 = lshr exact i64 %55, 1
%57 = add nuw i64 %56, 1
%58 = and i64 %57, 1
%59 = icmp eq i64 %55, 0
br i1 %59, label %89, label %60
60: ; preds = %49
%61 = and i64 %57, -2
br label %62
62: ; preds = %62, %60
%63 = phi i64 [ 0, %60 ], [ %86, %62 ]
%64 = phi i64 [ 0, %60 ], [ %87, %62 ]
%65 = getelementptr inbounds double, double* %4, i64 %63
%66 = bitcast double* %65 to <2 x double>*
%67 = load <2 x double>, <2 x double>* %66
%68 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %52, <2 x double> %67, <2 x double> %54)
%69 = bitcast double* %65 to <2 x double>*
store <2 x double> %68, <2 x double>* %69
%70 = getelementptr inbounds double, double* %5, i64 %63
%71 = bitcast double* %70 to <2 x double>*
%72 = load <2 x double>, <2 x double>* %71
%73 = fmul <2 x double> %52, %72
%74 = bitcast double* %70 to <2 x double>*
store <2 x double> %73, <2 x double>* %74
%75 = or i64 %63, 2
%76 = getelementptr inbounds double, double* %4, i64 %75
%77 = bitcast double* %76 to <2 x double>*
%78 = load <2 x double>, <2 x double>* %77
%79 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %52, <2 x double> %78, <2 x double> %54)
%80 = bitcast double* %76 to <2 x double>*
store <2 x double> %79, <2 x double>* %80
%81 = getelementptr inbounds double, double* %5, i64 %75
%82 = bitcast double* %81 to <2 x double>*
%83 = load <2 x double>, <2 x double>* %82
%84 = fmul <2 x double> %52, %83
%85 = bitcast double* %81 to <2 x double>*
store <2 x double> %84, <2 x double>* %85
%86 = add nuw i64 %63, 4
%87 = add nuw i64 %64, 2
%88 = icmp eq i64 %87, %61
br i1 %88, label %89, label %62
89: ; preds = %62, %49
%90 = phi i64 [ 0, %49 ], [ %86, %62 ]
%91 = icmp eq i64 %58, 0
br i1 %91, label %103, label %92
92: ; preds = %89
%93 = getelementptr inbounds double, double* %4, i64 %90
%94 = bitcast double* %93 to <2 x double>*
%95 = load <2 x double>, <2 x double>* %94
%96 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %52, <2 x double> %95, <2 x double> %54)
%97 = bitcast double* %93 to <2 x double>*
store <2 x double> %96, <2 x double>* %97
%98 = getelementptr inbounds double, double* %5, i64 %90
%99 = bitcast double* %98 to <2 x double>*
%100 = load <2 x double>, <2 x double>* %99
%101 = fmul <2 x double> %52, %100
%102 = bitcast double* %98 to <2 x double>*
store <2 x double> %101, <2 x double>* %102
br label %103
103: ; preds = %89, %92
%104 = icmp eq i64 %50, %41
br i1 %104, label %139, label %105
105: ; preds = %43, %40, %103
%106 = phi i64 [ 0, %43 ], [ 0, %40 ], [ %50, %103 ]
%107 = xor i64 %106, -1
%108 = and i64 %41, 1
%109 = icmp eq i64 %108, 0
br i1 %109, label %118, label %110
110: ; preds = %105
%111 = getelementptr inbounds double, double* %4, i64 %106
%112 = load double, double* %111
%113 = call double @llvm.fmuladd.f64(double %38, double %112, double %1)
store double %113, double* %111
%114 = getelementptr inbounds double, double* %5, i64 %106
%115 = load double, double* %114
%116 = fmul double %38, %115
store double %116, double* %114
%117 = or i64 %106, 1
br label %118
118: ; preds = %110, %105
%119 = phi i64 [ %106, %105 ], [ %117, %110 ]
%120 = sub nsw i64 0, %41
%121 = icmp eq i64 %107, %120
br i1 %121, label %139, label %122
122: ; preds = %118, %122
%123 = phi i64 [ %137, %122 ], [ %119, %118 ]
%124 = getelementptr inbounds double, double* %4, i64 %123
%125 = load double, double* %124
%126 = call double @llvm.fmuladd.f64(double %38, double %125, double %1)
store double %126, double* %124
%127 = getelementptr inbounds double, double* %5, i64 %123
%128 = load double, double* %127
%129 = fmul double %38, %128
store double %129, double* %127
%130 = add nuw nsw i64 %123, 1
%131 = getelementptr inbounds double, double* %4, i64 %130
%132 = load double, double* %131
%133 = call double @llvm.fmuladd.f64(double %38, double %132, double %1)
store double %133, double* %131
%134 = getelementptr inbounds double, double* %5, i64 %130
%135 = load double, double* %134
%136 = fmul double %38, %135
store double %136, double* %134
%137 = add nuw nsw i64 %123, 2
%138 = icmp eq i64 %137, %41
br i1 %138, label %139, label %122
139: ; preds = %25, %118, %122, %103, %18, %37
ret void
}