#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 const);
double fabs(double);
void gauleg(double x1, double x2, double x[], double w[], int n) {
  int m, j, i;
  double z1, z, xm, xl, pp, p3, p2, p1;
  double const pi = 3.14159265359;
  double *x_low, *x_high, *w_low, *w_high;
  m = (n + 1) / 2;
  xm = 0.5 * (x2 + x1);
  xl = 0.5 * (x2 - x1);
  x_low = x;
  x_high = x + n - 1;
  w_low = w;
  w_high = w + n - 1;
  for (i = 1; i <= m; i++) {
    z = cos(pi * (i - 0.25) / (n + 0.5));
    do {
      p1 = 1.0;
      p2 = 0.0;
      for (j = 1; j <= n; j++) {
        p3 = p2;
        p2 = p1;
        p1 = ((2.0 * j - 1.0) * z * p2 - (j - 1.0) * p3) / j;
      }
      pp = n * (z * p1 - p2) / (z * z - 1.0);
      z1 = z;
      z = z1 - p1 / pp;
    } while (fabs(z - z1) > 1.0E-10);
    *(x_low++) = xm - xl * z;
    *(x_high--) = xm + xl * z;
    *w_low = 2.0 * xl / ((1.0 - z * z) * pp * pp);
    *(w_high--) = *(w_low++);
  }
}


x86 assembly (clang, -O0):
<gauleg>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
addsd  -0x8(%rbp),%xmm1
movsd  0xea0(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
movsd  0xe85(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x88(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x98(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     1471 <gauleg+0x361>
cvtsi2sdl -0x30(%rbp),%xmm1
movsd  0xe25(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe11(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  0xdf8(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xdf6(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     12c6 <gauleg+0x1b6>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xdb9(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
cvtsi2sdl -0x2c(%rbp),%xmm1
movsd  0xd96(%rip),%xmm3
subsd  %xmm3,%xmm1
mulsd  -0x60(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1236 <gauleg+0x126>
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm3
movsd  -0x68(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd0d(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
divsd  -0x58(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movaps 0xced(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xcc9(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     121a <gauleg+0x10a>
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x80(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x80(%rbp)
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x88(%rbp)
movsd  %xmm0,(%rax)
movsd  0xc4e(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xc04(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x90(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x90(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x90(%rbp)
movsd  (%rax),%xmm0
mov    -0x98(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x98(%rbp)
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11d2 <gauleg+0xc2>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gauleg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
test   %edx,%edx
jle    1338 <gauleg+0x228>
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
movapd %xmm0,%xmm3
movapd %xmm1,%xmm2
addsd  %xmm1,%xmm3
movsd  0xebe(%rip),%xmm1
mulsd  %xmm1,%xmm3
movsd  %xmm3,0x20(%rsp)
subsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movslq %edx,%rax
lea    0x1(%rbx),%ecx
shr    $0x1f,%ecx
add    %ebx,%ecx
add    $0x1,%ecx
sar    %ecx
lea    (%rdi,%rax,8),%rbp
lea    (%rsi,%rax,8),%r13
cvtsi2sd %edx,%xmm6
movsd  0xe88(%rip),%xmm0
addsd  %xmm6,%xmm0
movsd  %xmm0,0x10(%rsp)
movapd 0xea6(%rip),%xmm0
xorpd  %xmm2,%xmm0
movapd %xmm0,0x40(%rsp)
movapd %xmm2,0x50(%rsp)
cmp    $0x2,%ecx
mov    $0x1,%r12d
cmovl  %r12d,%ecx
mov    %ecx,0xc(%rsp)
addsd  %xmm2,%xmm2
movapd %xmm2,0x30(%rsp)
neg    %ebx
movsd  0xe49(%rip),%xmm0
movsd  %xmm6,0x18(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xfffffffffffffff8,%r13
movsd  %xmm0,0x28(%rsp)
addsd  0xe2e(%rip),%xmm0
mulsd  0xe2e(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
call   1030 <cos@plt>
movsd  0xe2a(%rip),%xmm9
movapd 0xe3a(%rip),%xmm5
movsd  0xe12(%rip),%xmm7
movsd  0xdf1(%rip),%xmm8
movsd  0x18(%rsp),%xmm6
nopl   (%rax)
xorpd  %xmm3,%xmm3
mov    $0x1,%eax
movapd %xmm8,%xmm1
xchg   %ax,%ax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movapd %xmm2,%xmm4
addsd  %xmm7,%xmm4
mulsd  %xmm3,%xmm4
movapd %xmm1,%xmm3
movapd %xmm2,%xmm1
addsd  %xmm2,%xmm1
addsd  %xmm7,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm3,%xmm1
subsd  %xmm4,%xmm1
divsd  %xmm2,%xmm1
lea    (%rbx,%rax,1),%ecx
add    $0x1,%ecx
add    $0x1,%eax
cmp    $0x1,%ecx
jne    1230 <gauleg+0x120>
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm6,%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm7,%xmm3
divsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
movapd %xmm0,%xmm3
subsd  %xmm1,%xmm3
movapd %xmm3,%xmm1
subsd  %xmm0,%xmm1
andpd  %xmm5,%xmm1
ucomisd %xmm9,%xmm1
movapd %xmm3,%xmm0
ja     1220 <gauleg+0x110>
movapd 0x40(%rsp),%xmm0
mulsd  %xmm3,%xmm0
movsd  0x20(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r15)
add    $0x8,%r15
movapd 0x50(%rsp),%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
add    $0xfffffffffffffff8,%rbp
mulsd  %xmm3,%xmm3
movapd %xmm8,%xmm0
subsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
movapd 0x30(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x8,%r14
movsd  %xmm1,0x0(%r13)
movsd  0x28(%rsp),%xmm0
addsd  %xmm8,%xmm0
lea    0x1(%r12),%eax
cmp    0xc(%rsp),%r12d
mov    %eax,%r12d
jne    11d0 <gauleg+0xc0>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @gauleg(double %0, double %1, double* %2, double* %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double*
%24 = alloca double*
%25 = alloca double*
%26 = alloca double*
store double %0, double* %6
store double %1, double* %7
store double* %2, double** %8
store double* %3, double** %9
store i32 %4, i32* %10
store double 0x400921FB54442EEA, double* %22
%27 = load i32, i32* %10
%28 = add nsw i32 %27, 1
%29 = sdiv i32 %28, 2
store i32 %29, i32* %11
%30 = load double, double* %7
%31 = load double, double* %6
%32 = fadd double %30, %31
%33 = fmul double 5.000000e-01, %32
store double %33, double* %16
%34 = load double, double* %7
%35 = load double, double* %6
%36 = fsub double %34, %35
%37 = fmul double 5.000000e-01, %36
store double %37, double* %17
%38 = load double*, double** %8
store double* %38, double** %23
%39 = load double*, double** %8
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = getelementptr inbounds double, double* %42, i64 -1
store double* %43, double** %24
%44 = load double*, double** %9
store double* %44, double** %25
%45 = load double*, double** %9
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = getelementptr inbounds double, double* %48, i64 -1
store double* %49, double** %26
store i32 1, i32* %13
br label %50
50: ; preds = %147, %5
%51 = load i32, i32* %13
%52 = load i32, i32* %11
%53 = icmp sle i32 %51, %52
br i1 %53, label %54, label %150
54: ; preds = %50
%55 = load i32, i32* %13
%56 = sitofp i32 %55 to double
%57 = fsub double %56, 2.500000e-01
%58 = fmul double 0x400921FB54442EEA, %57
%59 = load i32, i32* %10
%60 = sitofp i32 %59 to double
%61 = fadd double %60, 5.000000e-01
%62 = fdiv double %58, %61
%63 = call double @cos(double %62)
store double %63, double* %15
br label %64
64: ; preds = %110, %54
store double 1.000000e+00, double* %21
store double 0.000000e+00, double* %20
store i32 1, i32* %12
br label %65
65: ; preds = %88, %64
%66 = load i32, i32* %12
%67 = load i32, i32* %10
%68 = icmp sle i32 %66, %67
br i1 %68, label %69, label %91
69: ; preds = %65
%70 = load double, double* %20
store double %70, double* %19
%71 = load double, double* %21
store double %71, double* %20
%72 = load i32, i32* %12
%73 = sitofp i32 %72 to double
%74 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %73, double -1.000000e+00)
%75 = load double, double* %15
%76 = fmul double %74, %75
%77 = load double, double* %20
%78 = load i32, i32* %12
%79 = sitofp i32 %78 to double
%80 = fsub double %79, 1.000000e+00
%81 = load double, double* %19
%82 = fmul double %80, %81
%83 = fneg double %82
%84 = call double @llvm.fmuladd.f64(double %76, double %77, double %83)
%85 = load i32, i32* %12
%86 = sitofp i32 %85 to double
%87 = fdiv double %84, %86
store double %87, double* %21
br label %88
88: ; preds = %69
%89 = load i32, i32* %12
%90 = add nsw i32 %89, 1
store i32 %90, i32* %12
br label %65
91: ; preds = %65
%92 = load i32, i32* %10
%93 = sitofp i32 %92 to double
%94 = load double, double* %15
%95 = load double, double* %21
%96 = load double, double* %20
%97 = fneg double %96
%98 = call double @llvm.fmuladd.f64(double %94, double %95, double %97)
%99 = fmul double %93, %98
%100 = load double, double* %15
%101 = load double, double* %15
%102 = call double @llvm.fmuladd.f64(double %100, double %101, double -1.000000e+00)
%103 = fdiv double %99, %102
store double %103, double* %18
%104 = load double, double* %15
store double %104, double* %14
%105 = load double, double* %14
%106 = load double, double* %21
%107 = load double, double* %18
%108 = fdiv double %106, %107
%109 = fsub double %105, %108
store double %109, double* %15
br label %110
110: ; preds = %91
%111 = load double, double* %15
%112 = load double, double* %14
%113 = fsub double %111, %112
%114 = call double @llvm.fabs.f64(double %113)
%115 = fcmp ogt double %114, 1.000000e-10
br i1 %115, label %64, label %116
116: ; preds = %110
%117 = load double, double* %16
%118 = load double, double* %17
%119 = load double, double* %15
%120 = fneg double %118
%121 = call double @llvm.fmuladd.f64(double %120, double %119, double %117)
%122 = load double*, double** %23
%123 = getelementptr inbounds double, double* %122, i32 1
store double* %123, double** %23
store double %121, double* %122
%124 = load double, double* %16
%125 = load double, double* %17
%126 = load double, double* %15
%127 = call double @llvm.fmuladd.f64(double %125, double %126, double %124)
%128 = load double*, double** %24
%129 = getelementptr inbounds double, double* %128, i32 -1
store double* %129, double** %24
store double %127, double* %128
%130 = load double, double* %17
%131 = fmul double 2.000000e+00, %130
%132 = load double, double* %15
%133 = load double, double* %15
%134 = fneg double %132
%135 = call double @llvm.fmuladd.f64(double %134, double %133, double 1.000000e+00)
%136 = load double, double* %18
%137 = fmul double %135, %136
%138 = load double, double* %18
%139 = fmul double %137, %138
%140 = fdiv double %131, %139
%141 = load double*, double** %25
store double %140, double* %141
%142 = load double*, double** %25
%143 = getelementptr inbounds double, double* %142, i32 1
store double* %143, double** %25
%144 = load double, double* %142
%145 = load double*, double** %26
%146 = getelementptr inbounds double, double* %145, i32 -1
store double* %146, double** %26
store double %144, double* %145
br label %147
147: ; preds = %116
%148 = load i32, i32* %13
%149 = add nsw i32 %148, 1
store i32 %149, i32* %13
br label %50
150: ; preds = %50
ret void
}

LLVM IR (-O2):
define void @gauleg(double %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3, i32 %4) {
%6 = fadd double %0, %1
%7 = fmul double %6, 5.000000e-01
%8 = fsub double %1, %0
%9 = fmul double %8, 5.000000e-01
%10 = sext i32 %4 to i64
%11 = icmp slt i32 %4, 1
br i1 %11, label %74, label %12
12: ; preds = %5
%13 = add nuw i32 %4, 1
%14 = sdiv i32 %13, 2
%15 = getelementptr inbounds double, double* %2, i64 %10
%16 = getelementptr inbounds double, double* %3, i64 %10
%17 = sitofp i32 %4 to double
%18 = fadd double %17, 5.000000e-01
%19 = fneg double %9
%20 = fmul double %9, 2.000000e+00
%21 = call i32 @llvm.smax.i32(i32 %14, i32 1)
br label %22
22: ; preds = %12, %61
%23 = phi double* [ %15, %12 ], [ %62, %61 ]
%24 = phi double* [ %16, %12 ], [ %28, %61 ]
%25 = phi double* [ %3, %12 ], [ %71, %61 ]
%26 = phi double* [ %2, %12 ], [ %64, %61 ]
%27 = phi i32 [ 1, %12 ], [ %72, %61 ]
%28 = getelementptr inbounds double, double* %24, i64 -1
%29 = sitofp i32 %27 to double
%30 = fadd double %29, -2.500000e-01
%31 = fmul double %30, 0x400921FB54442EEA
%32 = fdiv double %31, %18
%33 = tail call double @cos(double %32)
br label %34
34: ; preds = %22, %50
%35 = phi double [ %33, %22 ], [ %57, %50 ]
br label %36
36: ; preds = %34, %36
%37 = phi i32 [ %48, %36 ], [ 1, %34 ]
%38 = phi double [ %47, %36 ], [ 1.000000e+00, %34 ]
%39 = phi double [ %38, %36 ], [ 0.000000e+00, %34 ]
%40 = sitofp i32 %37 to double
%41 = tail call double @llvm.fmuladd.f64(double %40, double 2.000000e+00, double -1.000000e+00)
%42 = fmul double %35, %41
%43 = fadd double %40, -1.000000e+00
%44 = fneg double %43
%45 = fmul double %39, %44
%46 = tail call double @llvm.fmuladd.f64(double %42, double %38, double %45)
%47 = fdiv double %46, %40
%48 = add nuw i32 %37, 1
%49 = icmp eq i32 %37, %4
br i1 %49, label %50, label %36
50: ; preds = %36
%51 = fneg double %38
%52 = tail call double @llvm.fmuladd.f64(double %35, double %47, double %51)
%53 = fmul double %52, %17
%54 = tail call double @llvm.fmuladd.f64(double %35, double %35, double -1.000000e+00)
%55 = fdiv double %53, %54
%56 = fdiv double %47, %55
%57 = fsub double %35, %56
%58 = fsub double %57, %35
%59 = tail call double @llvm.fabs.f64(double %58)
%60 = fcmp ogt double %59, 1.000000e-10
br i1 %60, label %34, label %61
61: ; preds = %50
%62 = getelementptr inbounds double, double* %23, i64 -1
%63 = tail call double @llvm.fmuladd.f64(double %19, double %57, double %7)
%64 = getelementptr inbounds double, double* %26, i64 1
store double %63, double* %26
%65 = tail call double @llvm.fmuladd.f64(double %9, double %57, double %7)
store double %65, double* %62
%66 = fneg double %57
%67 = tail call double @llvm.fmuladd.f64(double %66, double %57, double 1.000000e+00)
%68 = fmul double %55, %67
%69 = fmul double %55, %68
%70 = fdiv double %20, %69
store double %70, double* %25
%71 = getelementptr inbounds double, double* %25, i64 1
store double %70, double* %28
%72 = add nuw nsw i32 %27, 1
%73 = icmp eq i32 %27, %21
br i1 %73, label %74, label %22
74: ; preds = %61, %5
ret void
}