#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 const fabs(double);
void gauleg(double x1, double x2, double *x, double *w, int n) {
  const double pi = 3.141592653589793238462643383279502884197;
  const double eps = 3.0E-14;
  int m = (n + 1) / 2;
  double xm = 0.5 * (x2 + x1);
  double xl = 0.5 * (x2 - x1);
  int i;
  for (i = 1; i <= m; ++i) {
    double z = cos(pi * (i - 0.25) / (n + 0.5));
    double pp;
    int dobreak = 0;
    while (1) {
      double p1 = 1.0, p2 = 0.0;
      double z1 = z;
      int j;
      for (j = 1; j <= n; ++j) {
        double p3 = p2;
        p2 = p1;
        p1 = ((2 * j - 1) * z * p2 - (j - 1) * p3) / j;
      }
      pp = n * (z * p1 - p2) / (z * z - 1);
      z = z1 - p1 / pp;
      if (dobreak)
        break;
      if (fabs(z - z1) <= eps)
        dobreak = 1;
    }
    x[i - 1] = xm - xl * z;
    x[n - i] = xm + xl * z;
    w[i - 1] = w[n - i] = 2 * xl / ((1 - z * z) * pp * pp);
  }
}


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  0xec8(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3c(%rbp)
movsd  -0x10(%rbp),%xmm1
addsd  -0x8(%rbp),%xmm1
movsd  0xe83(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
movsd  0xe68(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jg     145a <gauleg+0x33a>
cvtsi2sdl -0x54(%rbp),%xmm1
movsd  0xe57(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe43(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  0xe22(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x6c(%rbp)
movsd  0xe21(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movl   $0x1,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     12bc <gauleg+0x19c>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x8c(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm2
mov    -0x8c(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  -0x98(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x8c(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    1223 <gauleg+0x103>
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm3
movsd  -0x80(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd1f(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x78(%rbp),%xmm1
divsd  -0x68(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
cmpl   $0x0,-0x6c(%rbp)
je     1340 <gauleg+0x220>
jmp    1373 <gauleg+0x253>
movsd  -0x60(%rbp),%xmm0
subsd  -0x88(%rbp),%xmm0
ff
call   1030 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xcab(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     136e <gauleg+0x24e>
movl   $0x1,-0x6c(%rbp)
jmp    11f7 <gauleg+0xd7>
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xc4c(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xc0a(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  -0x68(%rbp),%xmm1
mulsd  -0x68(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11a8 <gauleg+0x88>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gauleg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
test   %edx,%edx
jle    131e <gauleg+0x20e>
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,0x18(%rsp)
subsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
lea    0x1(%rbx),%eax
shr    $0x1f,%eax
add    %ebx,%eax
add    $0x1,%eax
sar    %eax
cvtsi2sd %edx,%xmm6
movsd  0xe93(%rip),%xmm0
addsd  %xmm6,%xmm0
movsd  %xmm0,0x8(%rsp)
movapd 0xeb1(%rip),%xmm0
xorpd  %xmm2,%xmm0
movapd %xmm0,0x30(%rsp)
movapd %xmm2,0x40(%rsp)
addsd  %xmm2,%xmm2
movapd %xmm2,0x20(%rsp)
mov    %edx,%r12d
cmp    $0x2,%eax
mov    $0x1,%r13d
cmovge %eax,%r13d
add    $0x1,%r13d
mov    $0x1,%ebp
movsd  %xmm6,0x10(%rsp)
jmp    122e <gauleg+0x11e>
nopw   0x0(%rax,%rax,1)
movapd 0x30(%rsp),%xmm0
mulsd  %xmm3,%xmm0
movsd  0x18(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%r15,%rbp,8)
movapd 0x40(%rsp),%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
mov    %r12,%rax
sub    %rbp,%rax
movsd  %xmm0,(%r15,%rax,8)
mulsd  %xmm3,%xmm3
movapd %xmm8,%xmm0
subsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
movapd 0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rax,8)
movsd  %xmm1,-0x8(%r14,%rbp,8)
add    $0x1,%rbp
cmp    %r13,%rbp
je     131e <gauleg+0x20e>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
addsd  0xdcb(%rip),%xmm0
mulsd  0xdcb(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
call   1030 <cos@plt>
movsd  0xdcf(%rip),%xmm9
movapd 0xddf(%rip),%xmm5
movsd  0xdb7(%rip),%xmm7
movsd  0xda6(%rip),%xmm8
movsd  0x10(%rsp),%xmm6
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
xorpd  %xmm2,%xmm2
mov    $0x1,%ecx
xor    %edx,%edx
movapd %xmm8,%xmm1
movapd %xmm1,%xmm3
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm4,%xmm4
cvtsi2sd %edx,%xmm4
add    $0x1,%edx
mulsd  %xmm2,%xmm4
mulsd  %xmm3,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %edx,%xmm2
subsd  %xmm4,%xmm1
divsd  %xmm2,%xmm1
add    $0x2,%ecx
movapd %xmm3,%xmm2
cmp    %edx,%ebx
jne    1290 <gauleg+0x180>
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
test   %eax,%eax
jne    11c0 <gauleg+0xb0>
movapd %xmm3,%xmm1
subsd  %xmm0,%xmm1
andpd  %xmm5,%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm9
setae  %al
movapd %xmm3,%xmm0
jmp    1280 <gauleg+0x170>
add    $0x58,%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 double
%12 = alloca double
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca double
%18 = alloca double
%19 = alloca i32
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca i32
%24 = 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 0x400921FB54442D18, double* %11
store double 3.000000e-14, double* %12
%25 = load i32, i32* %10
%26 = add nsw i32 %25, 1
%27 = sdiv i32 %26, 2
store i32 %27, i32* %13
%28 = load double, double* %7
%29 = load double, double* %6
%30 = fadd double %28, %29
%31 = fmul double 5.000000e-01, %30
store double %31, double* %14
%32 = load double, double* %7
%33 = load double, double* %6
%34 = fsub double %32, %33
%35 = fmul double 5.000000e-01, %34
store double %35, double* %15
store i32 1, i32* %16
br label %36
36: ; preds = %151, %5
%37 = load i32, i32* %16
%38 = load i32, i32* %13
%39 = icmp sle i32 %37, %38
br i1 %39, label %40, label %154
40: ; preds = %36
%41 = load i32, i32* %16
%42 = sitofp i32 %41 to double
%43 = fsub double %42, 2.500000e-01
%44 = fmul double 0x400921FB54442D18, %43
%45 = load i32, i32* %10
%46 = sitofp i32 %45 to double
%47 = fadd double %46, 5.000000e-01
%48 = fdiv double %44, %47
%49 = call double @cos(double %48)
store double %49, double* %17
store i32 0, i32* %19
br label %50
50: ; preds = %40, %107
store double 1.000000e+00, double* %20
store double 0.000000e+00, double* %21
%51 = load double, double* %17
store double %51, double* %22
store i32 1, i32* %23
br label %52
52: ; preds = %76, %50
%53 = load i32, i32* %23
%54 = load i32, i32* %10
%55 = icmp sle i32 %53, %54
br i1 %55, label %56, label %79
56: ; preds = %52
%57 = load double, double* %21
store double %57, double* %24
%58 = load double, double* %20
store double %58, double* %21
%59 = load i32, i32* %23
%60 = mul nsw i32 2, %59
%61 = sub nsw i32 %60, 1
%62 = sitofp i32 %61 to double
%63 = load double, double* %17
%64 = fmul double %62, %63
%65 = load double, double* %21
%66 = load i32, i32* %23
%67 = sub nsw i32 %66, 1
%68 = sitofp i32 %67 to double
%69 = load double, double* %24
%70 = fmul double %68, %69
%71 = fneg double %70
%72 = call double @llvm.fmuladd.f64(double %64, double %65, double %71)
%73 = load i32, i32* %23
%74 = sitofp i32 %73 to double
%75 = fdiv double %72, %74
store double %75, double* %20
br label %76
76: ; preds = %56
%77 = load i32, i32* %23
%78 = add nsw i32 %77, 1
store i32 %78, i32* %23
br label %52
79: ; preds = %52
%80 = load i32, i32* %10
%81 = sitofp i32 %80 to double
%82 = load double, double* %17
%83 = load double, double* %20
%84 = load double, double* %21
%85 = fneg double %84
%86 = call double @llvm.fmuladd.f64(double %82, double %83, double %85)
%87 = fmul double %81, %86
%88 = load double, double* %17
%89 = load double, double* %17
%90 = call double @llvm.fmuladd.f64(double %88, double %89, double -1.000000e+00)
%91 = fdiv double %87, %90
store double %91, double* %18
%92 = load double, double* %22
%93 = load double, double* %20
%94 = load double, double* %18
%95 = fdiv double %93, %94
%96 = fsub double %92, %95
store double %96, double* %17
%97 = load i32, i32* %19
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %100
99: ; preds = %79
br label %108
100: ; preds = %79
%101 = load double, double* %17
%102 = load double, double* %22
%103 = fsub double %101, %102
%104 = call double @fabs(double %103)
%105 = fcmp ole double %104, 3.000000e-14
br i1 %105, label %106, label %107
106: ; preds = %100
store i32 1, i32* %19
br label %107
107: ; preds = %106, %100
br label %50
108: ; preds = %99
%109 = load double, double* %14
%110 = load double, double* %15
%111 = load double, double* %17
%112 = fneg double %110
%113 = call double @llvm.fmuladd.f64(double %112, double %111, double %109)
%114 = load double*, double** %8
%115 = load i32, i32* %16
%116 = sub nsw i32 %115, 1
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double, double* %114, i64 %117
store double %113, double* %118
%119 = load double, double* %14
%120 = load double, double* %15
%121 = load double, double* %17
%122 = call double @llvm.fmuladd.f64(double %120, double %121, double %119)
%123 = load double*, double** %8
%124 = load i32, i32* %10
%125 = load i32, i32* %16
%126 = sub nsw i32 %124, %125
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds double, double* %123, i64 %127
store double %122, double* %128
%129 = load double, double* %15
%130 = fmul double 2.000000e+00, %129
%131 = load double, double* %17
%132 = load double, double* %17
%133 = fneg double %131
%134 = call double @llvm.fmuladd.f64(double %133, double %132, double 1.000000e+00)
%135 = load double, double* %18
%136 = fmul double %134, %135
%137 = load double, double* %18
%138 = fmul double %136, %137
%139 = fdiv double %130, %138
%140 = load double*, double** %9
%141 = load i32, i32* %10
%142 = load i32, i32* %16
%143 = sub nsw i32 %141, %142
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double, double* %140, i64 %144
store double %139, double* %145
%146 = load double*, double** %9
%147 = load i32, i32* %16
%148 = sub nsw i32 %147, 1
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds double, double* %146, i64 %149
store double %139, double* %150
br label %151
151: ; preds = %108
%152 = load i32, i32* %16
%153 = add nsw i32 %152, 1
store i32 %153, i32* %16
br label %36
154: ; preds = %36
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 = icmp slt i32 %4, 1
br i1 %10, label %80, label %11
11: ; preds = %5
%12 = add nuw i32 %4, 1
%13 = sdiv i32 %12, 2
%14 = sitofp i32 %4 to double
%15 = fadd double %14, 5.000000e-01
%16 = fneg double %9
%17 = fmul double %9, 2.000000e+00
%18 = zext i32 %4 to i64
%19 = call i32 @llvm.smax.i32(i32 %13, i32 1)
%20 = add nuw nsw i32 %19, 1
%21 = zext i32 %20 to i64
br label %22
22: ; preds = %11, %64
%23 = phi i64 [ 1, %11 ], [ %78, %64 ]
%24 = trunc i64 %23 to i32
%25 = sitofp i32 %24 to double
%26 = fadd double %25, -2.500000e-01
%27 = fmul double %26, 0x400921FB54442D18
%28 = fdiv double %27, %15
%29 = tail call double @cos(double %28)
br label %30
30: ; preds = %22, %59
%31 = phi i32 [ 0, %22 ], [ %63, %59 ]
%32 = phi double [ %29, %22 ], [ %57, %59 ]
br label %33
33: ; preds = %30, %33
%34 = phi i32 [ %48, %33 ], [ 1, %30 ]
%35 = phi double [ %36, %33 ], [ 0.000000e+00, %30 ]
%36 = phi double [ %47, %33 ], [ 1.000000e+00, %30 ]
%37 = shl nuw nsw i32 %34, 1
%38 = add nsw i32 %37, -1
%39 = sitofp i32 %38 to double
%40 = fmul double %32, %39
%41 = add nsw i32 %34, -1
%42 = sitofp i32 %41 to double
%43 = fneg double %35
%44 = fmul double %43, %42
%45 = tail call double @llvm.fmuladd.f64(double %40, double %36, double %44)
%46 = sitofp i32 %34 to double
%47 = fdiv double %45, %46
%48 = add nuw i32 %34, 1
%49 = icmp eq i32 %34, %4
br i1 %49, label %50, label %33
50: ; preds = %33
%51 = fneg double %36
%52 = tail call double @llvm.fmuladd.f64(double %32, double %47, double %51)
%53 = fmul double %52, %14
%54 = tail call double @llvm.fmuladd.f64(double %32, double %32, double -1.000000e+00)
%55 = fdiv double %53, %54
%56 = fdiv double %47, %55
%57 = fsub double %32, %56
%58 = icmp eq i32 %31, 0
br i1 %58, label %59, label %64
59: ; preds = %50
%60 = fsub double %57, %32
%61 = tail call double @llvm.fabs.f64(double %60)
%62 = fcmp ole double %61, 3.000000e-14
%63 = zext i1 %62 to i32
br label %30
64: ; preds = %50
%65 = tail call double @llvm.fmuladd.f64(double %16, double %57, double %7)
%66 = add nsw i64 %23, -1
%67 = getelementptr inbounds double, double* %2, i64 %66
store double %65, double* %67
%68 = tail call double @llvm.fmuladd.f64(double %9, double %57, double %7)
%69 = sub nsw i64 %18, %23
%70 = getelementptr inbounds double, double* %2, i64 %69
store double %68, double* %70
%71 = fneg double %57
%72 = tail call double @llvm.fmuladd.f64(double %71, double %57, double 1.000000e+00)
%73 = fmul double %55, %72
%74 = fmul double %55, %73
%75 = fdiv double %17, %74
%76 = getelementptr inbounds double, double* %3, i64 %69
store double %75, double* %76
%77 = getelementptr inbounds double, double* %3, i64 %66
store double %75, double* %77
%78 = add nuw nsw i64 %23, 1
%79 = icmp eq i64 %78, %21
br i1 %79, label %80, label %22
80: ; preds = %64, %5
ret void
}