#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 M_PI;
double asin(double);
double cos(double);
double fabs(double);
int /*<<< orphan*/ gauss_first_guess(long, double *);
double sqrt(double);
int grib_get_gaussian_latitudes(long trunc, double *lats) {
  long jlat, iter, legi;
  double rad2deg, convval, root, legfonc = 0;
  double mem1, mem2, conv;
  double precision = 1.0E-14;
  long nlat = trunc * 2;
  rad2deg = 180.0 / M_PI;
  convval = (1.0 - ((2.0 / M_PI) * (2.0 / M_PI)) * 0.25);
  gauss_first_guess(trunc, lats);
  for (jlat = 0; jlat < trunc; jlat++) {
    root =
        cos(lats[jlat] /
            sqrt(((((double)nlat) + 0.5) * (((double)nlat) + 0.5)) + convval));
    iter = 0;
    conv = 1;
    while (fabs(conv) >= precision) {
      mem2 = 1.0;
      mem1 = root;
      for (legi = 0; legi < nlat; legi++) {
        legfonc = ((2.0 * (legi + 1) - 1.0) * root * mem1 - legi * mem2) /
                  ((double)(legi + 1));
        mem2 = mem1;
        mem1 = legfonc;
      }
      conv = legfonc / ((((double)nlat) * (mem2 - root * legfonc)) /
                        (1.0 - (root * root)));
      root -= conv;
      if (iter++ > 10) {
        return -16;
      }
    }
    lats[jlat] = asin(root) * rad2deg;
    lats[nlat - 1 - jlat] = -lats[jlat];
  }
  if (nlat != (trunc * 2))
    lats[trunc + 1] = 0.0;
  return 0;
}


x86 assembly (clang, -O0):
<grib_get_gaussian_latitudes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xebd(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x78(%rbp)
movsd  0xe9c(%rip),%xmm0
mov    0x2e65(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe7c(%rip),%xmm0
mov    0x2e4d(%rip),%rax
divsd  (%rax),%xmm0
movsd  0xe69(%rip),%xmm1
mov    0x2e3a(%rip),%rax
divsd  (%rax),%xmm1
mulsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe2b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe27(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <gauss_first_guess@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1472 <grib_get_gaussian_latitudes+0x332>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
cvtsi2sdq -0x78(%rbp),%xmm0
movsd  0xdfb(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdq -0x78(%rbp),%xmm2
movsd  0xde9(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
divsd  %xmm1,%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x48(%rbp)
movq   $0x0,-0x28(%rbp)
movsd  0xd8d(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movaps 0xdb4(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x70(%rbp),%xmm0
jb     140c <grib_get_gaussian_latitudes+0x2cc>
movsd  0xd65(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x78(%rbp),%rax
jge    1354 <grib_get_gaussian_latitudes+0x214>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm0
movsd  0xd4f(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
cvtsi2sdq -0x30(%rbp),%xmm1
mulsd  -0x60(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
add    $0x1,%rax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12ba <grib_get_gaussian_latitudes+0x17a>
movsd  -0x50(%rbp),%xmm0
cvtsi2sdq -0x78(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm4
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm3
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm2
movsd  0xc4a(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
cmp    $0xa,%rax
jle    1407 <grib_get_gaussian_latitudes+0x2c7>
movl   $0xfffffff0,-0x4(%rbp)
jmp    149f <grib_get_gaussian_latitudes+0x35f>
jmp    1280 <grib_get_gaussian_latitudes+0x140>
movsd  -0x48(%rbp),%xmm0
call   1030 <asin@plt>
mulsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x78(%rbp),%rcx
sub    $0x1,%rcx
sub    -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11ff <grib_get_gaussian_latitudes+0xbf>
mov    -0x78(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x1,%rcx
cmp    %rcx,%rax
je     1498 <grib_get_gaussian_latitudes+0x358>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax,%rcx,8)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grib_get_gaussian_latitudes>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%r12
mov    %rdi,%r14
mov    0x2e8e(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <gauss_first_guess@plt>
test   %r14,%r14
jle    1355 <grib_get_gaussian_latitudes+0x215>
lea    (%r14,%r14,1),%r15
movsd  0xe82(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0xe72(%rip),%xmm0
divsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm0
mulsd  0xe6a(%rip),%xmm0
addsd  0xe6a(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r15,%xmm1
movsd  0xe62(%rip),%xmm2
movsd  %xmm1,0x28(%rsp)
addsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
cmp    $0x2,%r15
mov    $0x1,%ebx
cmovge %r15,%rbx
xor    %r13d,%r13d
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
xorpd  %xmm1,%xmm1
movsd  %xmm2,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
movsd  (%r12,%r13,8),%xmm3
ucomisd %xmm1,%xmm2
jae    121a <grib_get_gaussian_latitudes+0xda>
movsd  0x8(%rsp),%xmm0
movsd  %xmm3,0x10(%rsp)
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm3
divsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
call   1050 <cos@plt>
xor    %eax,%eax
movsd  0xde6(%rip),%xmm10
movapd %xmm10,%xmm1
movsd  0x28(%rsp),%xmm6
movapd 0xdfa(%rip),%xmm8
movsd  0xdd9(%rip),%xmm9
movsd  0xdd9(%rip),%xmm7
nopw   0x0(%rax,%rax,1)
andpd  %xmm8,%xmm1
ucomisd %xmm9,%xmm1
jb     1310 <grib_get_gaussian_latitudes+0x1d0>
movapd %xmm10,%xmm3
movapd %xmm0,%xmm1
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
xorps  %xmm4,%xmm4
cvtsi2sd %rcx,%xmm4
movapd %xmm1,%xmm2
lea    0x1(%rcx),%rdx
xorps  %xmm5,%xmm5
cvtsi2sd %rdx,%xmm5
movapd %xmm5,%xmm1
addsd  %xmm5,%xmm1
addsd  %xmm7,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm3,%xmm4
mulsd  %xmm2,%xmm1
subsd  %xmm4,%xmm1
divsd  %xmm5,%xmm1
movapd %xmm2,%xmm3
mov    %rdx,%rcx
cmp    %rdx,%rbx
jne    1280 <grib_get_gaussian_latitudes+0x140>
movapd %xmm0,%xmm3
mulsd  %xmm1,%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm6,%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm10,%xmm4
subsd  %xmm3,%xmm4
divsd  %xmm4,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
add    $0x1,%rax
cmp    $0xc,%rax
jne    1260 <grib_get_gaussian_latitudes+0x120>
jmp    1359 <grib_get_gaussian_latitudes+0x219>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1030 <asin@plt>
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r12,%r13,8)
xorpd  0xd27(%rip),%xmm0
mov    %r13,%rax
not    %rax
add    %r15,%rax
movlpd %xmm0,(%r12,%rax,8)
add    $0x1,%r13
cmp    %r14,%r13
movsd  0x8(%rsp),%xmm2
movsd  0x18(%rsp),%xmm0
xorpd  %xmm1,%xmm1
jne    11f7 <grib_get_gaussian_latitudes+0xb7>
xor    %eax,%eax
jmp    135e <grib_get_gaussian_latitudes+0x21e>
mov    $0xfffffff0,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define i32 @grib_get_gaussian_latitudes(i64 %0, double* %1) {
%3 = shl i64 %0, 1
%4 = load double, double* @M_PI
%5 = fdiv double 1.800000e+02, %4
%6 = fdiv double 2.000000e+00, %4
%7 = tail call i32 @gauss_first_guess(i64 %0, double* %1)
%8 = icmp sgt i64 %0, 0
br i1 %8, label %9, label %63
9: ; preds = %2
%10 = fneg double %6
%11 = fmul double %6, %10
%12 = tail call double @llvm.fmuladd.f64(double %11, double 2.500000e-01, double 1.000000e+00)
%13 = sitofp i64 %3 to double
%14 = fadd double %13, 5.000000e-01
%15 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %12)
%16 = call i64 @llvm.smax.i64(i64 %3, i64 1)
br label %17
17: ; preds = %9, %54
%18 = phi i64 [ 0, %9 ], [ %61, %54 ]
%19 = getelementptr inbounds double, double* %1, i64 %18
%20 = load double, double* %19
%21 = tail call double @sqrt(double %15)
%22 = fdiv double %20, %21
%23 = tail call double @cos(double %22)
br label %24
24: ; preds = %44, %17
%25 = phi i64 [ 0, %17 ], [ %52, %44 ]
%26 = phi double [ %23, %17 ], [ %51, %44 ]
%27 = phi double [ 1.000000e+00, %17 ], [ %50, %44 ]
%28 = tail call double @llvm.fabs.f64(double %27)
%29 = fcmp ult double %28, 0x3D06849B86A12B9B
br i1 %29, label %54, label %30
30: ; preds = %24, %30
%31 = phi double [ %32, %30 ], [ 1.000000e+00, %24 ]
%32 = phi double [ %42, %30 ], [ %26, %24 ]
%33 = phi i64 [ %34, %30 ], [ 0, %24 ]
%34 = add nuw nsw i64 %33, 1
%35 = sitofp i64 %34 to double
%36 = tail call double @llvm.fmuladd.f64(double %35, double 2.000000e+00, double -1.000000e+00)
%37 = fmul double %26, %36
%38 = sitofp i64 %33 to double
%39 = fneg double %31
%40 = fmul double %38, %39
%41 = tail call double @llvm.fmuladd.f64(double %37, double %32, double %40)
%42 = fdiv double %41, %35
%43 = icmp eq i64 %34, %16
br i1 %43, label %44, label %30
44: ; preds = %30
%45 = fneg double %26
%46 = tail call double @llvm.fmuladd.f64(double %45, double %42, double %32)
%47 = fmul double %46, %13
%48 = tail call double @llvm.fmuladd.f64(double %45, double %26, double 1.000000e+00)
%49 = fdiv double %47, %48
%50 = fdiv double %42, %49
%51 = fsub double %26, %50
%52 = add nuw nsw i64 %25, 1
%53 = icmp eq i64 %52, 12
br i1 %53, label %63, label %24
54: ; preds = %24
%55 = tail call double @asin(double %26)
%56 = fmul double %5, %55
store double %56, double* %19
%57 = fneg double %56
%58 = xor i64 %18, -1
%59 = add i64 %3, %58
%60 = getelementptr inbounds double, double* %1, i64 %59
store double %57, double* %60
%61 = add nuw nsw i64 %18, 1
%62 = icmp eq i64 %61, %0
br i1 %62, label %63, label %17
63: ; preds = %54, %44, %2
%64 = phi i32 [ 0, %2 ], [ -16, %44 ], [ 0, %54 ]
ret i32 %64
}