#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 abs(double);
int /*<<< orphan*/ exit(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int, ...);
double sqrt(int);
void grib_invtrans_legendre(int L, double x, double *RI, double *TR,
                            double *TI) {
  int l, m;
  double y2;
  double f, of, fx, p0;
  double *pP, *oP, *pRI;
  if (abs(x) > 1.0) {
    printf("grib_legendreP: invalid x=%g must be abs(x)>0\n", x);
    exit(1);
  }
  if (L < 0) {
    printf("grib_legendreP: invalid L=%d must be >0\n", L);
    exit(1);
  }
  pP = (double *)malloc(sizeof(double) * (L + 1));
  if (!pP) {
    printf("unable to allocate %d bytes\n", (int)sizeof(double) * (L + 1));
    exit(1);
  }
  y2 = (1.0 - x * x);
  fx = 1;
  p0 = 1;
  oP = pP;
  pRI = RI;
  for (m = 0; m < L; m++) {
    pP[0] = sqrt((2 * m + 1) * p0);
    if (m & 1)
      pP[0] = -pP[0];
    TR[m] = pP[0] * *(pRI++);
    TI[m] = pP[0] * *(pRI++);
    printf("-- (%d,%d) %.20e %.20e\n", m, m, TR[m], pP[0]);
    of = sqrt(2 * m + 3);
    pP[1] = x * of * pP[0];
    TR[m] += pP[1] * *(pRI++);
    TI[m] += pP[1] * *(pRI++);
    printf("-- (%d,%d) %.20e %.20e\n", m + 1, m, TR[m], pP[1]);
    for (l = m + 2; l <= L; l++) {
      f = sqrt((4.0 * l * l - 1.0) / (l * l - m * m));
      pP[2] = (x * pP[1] - pP[0] / of) * f;
      TR[m] += pP[2] * *(pRI++);
      TI[m] += pP[2] * *(pRI++);
      printf("-- (%d,%d) %.20e %.20e\n", l, m, TR[m], pP[2]);
      of = f;
      pP++;
    }
    pP = oP;
    p0 *= y2 * fx / (fx + 1.0);
    fx += 2;
  }
  pP[0] = sqrt((2 * L + 1) * p0);
  if (L & 1)
    pP[0] = -pP[0];
  TR[L] = pP[0] * *(pRI++);
  TI[L] = pP[0] * *(pRI++);
  printf("-- (%d,%d) %.20e %.20e\n", L, L, TR[m], pP[0]);
}


x86 assembly (clang, -O0):
<grib_invtrans_legendre>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <abs@plt>
movsd  0xe82(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a5 <grib_invtrans_legendre+0x55>
cvttsd2si -0x10(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x0,-0x4(%rbp)
jge    11ca <grib_invtrans_legendre+0x7a>
mov    -0x4(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    120d <grib_invtrans_legendre+0xbd>
mov    -0x4(%rbp),%esi
add    $0x1,%esi
shl    $0x3,%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdc6(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xdb5(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xda8(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    15c9 <grib_invtrans_legendre+0x479>
mov    -0x30(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x58(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    -0x60(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     12d9 <grib_invtrans_legendre+0x189>
mov    -0x60(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x60(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x60(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x70(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x70(%rbp)
mulsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x70(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x70(%rbp)
mulsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x60(%rbp),%rax
movsd  (%rax),%xmm1
lea    0xd4a(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%edi
shl    $0x1,%edi
add    $0x3,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
mov    -0x60(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x60(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x60(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x70(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x70(%rbp)
movsd  (%rax),%xmm2
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x70(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x70(%rbp)
movsd  (%rax),%xmm2
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%esi
add    $0x1,%esi
mov    -0x30(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x60(%rbp),%rax
movsd  0x8(%rax),%xmm1
lea    0xc83(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     157c <grib_invtrans_legendre+0x42c>
cvtsi2sdl -0x2c(%rbp),%xmm1
movsd  0xbdd(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xbc0(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x2c(%rbp),%eax
imul   -0x2c(%rbp),%eax
mov    -0x30(%rbp),%ecx
imul   -0x30(%rbp),%ecx
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x60(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x60(%rbp),%rax
movsd  (%rax),%xmm1
divsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x60(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x60(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x70(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x70(%rbp)
movsd  (%rax),%xmm2
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x70(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x70(%rbp)
movsd  (%rax),%xmm2
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x60(%rbp),%rax
movsd  0x10(%rax),%xmm1
lea    0xb44(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x60(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x60(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1422 <grib_invtrans_legendre+0x2d2>
mov    -0x68(%rbp),%rax
mov    %rax,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  0xa6a(%rip),%xmm1
addsd  -0x50(%rbp),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xa57(%rip),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1274 <grib_invtrans_legendre+0x124>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x58(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    -0x60(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1622 <grib_invtrans_legendre+0x4d2>
mov    -0x60(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x60(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x60(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x70(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x70(%rbp)
mulsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x70(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x70(%rbp)
mulsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x60(%rbp),%rax
movsd  (%rax),%xmm1
lea    0xa01(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grib_invtrans_legendre>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %edi,%ebx
movsd  %xmm0,0x8(%rsp)
call   1030 <abs@plt>
ucomisd 0xe84(%rip),%xmm0
ja     1512 <grib_invtrans_legendre+0x3c2>
mov    %r14,0x18(%rsp)
test   %ebx,%ebx
js     1521 <grib_invtrans_legendre+0x3d1>
lea    0x8(,%rbx,8),%r14d
mov    %r14d,%edi
mov    %rbx,%r15
call   1050 <malloc@plt>
test   %rax,%rax
je     152c <grib_invtrans_legendre+0x3dc>
mov    %rax,%rbx
movsd  0xe4a(%rip),%xmm2
test   %r15d,%r15d
movsd  0x8(%rsp),%xmm0
je     148f <grib_invtrans_legendre+0x33f>
mulsd  %xmm0,%xmm0
subsd  %xmm0,%xmm2
mov    %r15d,%eax
mov    %rax,0x10(%rsp)
mov    %r15d,%edx
neg    %edx
mov    %rbx,%rax
add    $0x10,%rax
mov    %rax,0x38(%rsp)
movsd  0xe12(%rip),%xmm0
xor    %r14d,%r14d
movapd %xmm0,%xmm1
movapd %xmm0,%xmm3
mov    %r15,0x30(%rsp)
mov    %rbx,0x40(%rsp)
movsd  %xmm2,0x48(%rsp)
mov    %rdx,0x68(%rsp)
jmp    1258 <grib_invtrans_legendre+0x108>
mov    %rax,%r12
movsd  0x48(%rsp),%xmm0
movsd  0x58(%rsp),%xmm3
mulsd  %xmm3,%xmm0
movapd %xmm3,%xmm1
addsd  0xdd1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0x60(%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xdd3(%rip),%xmm3
mov    0x50(%rsp),%rax
mov    %rax,%r14
cmp    0x10(%rsp),%rax
je     1489 <grib_invtrans_legendre+0x339>
movsd  %xmm3,0x58(%rsp)
mov    %r12,%r15
lea    (%r14,%r14,1),%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm1,0x60(%rsp)
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
test   $0x1,%r14b
je     1290 <grib_invtrans_legendre+0x140>
xorpd  0xd90(%rip),%xmm0
lea    0xe0e(%rip),%rax
movsd  %xmm0,(%rbx)
mulsd  0x0(%rbp),%xmm0
mov    0x18(%rsp),%r12
movsd  %xmm0,(%r12,%r14,8)
movsd  (%rbx),%xmm0
mulsd  0x8(%rbp),%xmm0
mov    %r15,%r13
movsd  %xmm0,(%r15,%r14,8)
movsd  (%r12,%r14,8),%xmm0
movsd  (%rbx),%xmm1
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14d,%esi
mov    %r14d,%edx
mov    $0x2,%al
call   1040 <printf@plt>
lea    (%r14,%r14,1),%edi
add    $0x3,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,0x20(%rsp)
mulsd  0x8(%rsp),%xmm0
mulsd  (%rbx),%xmm0
movsd  %xmm0,0x8(%rbx)
mulsd  0x10(%rbp),%xmm0
addsd  (%r12,%r14,8),%xmm0
movsd  %xmm0,(%r12,%r14,8)
movsd  0x8(%rbx),%xmm0
mulsd  0x18(%rbp),%xmm0
add    $0x20,%rbp
addsd  0x0(%r13,%r14,8),%xmm0
movsd  %xmm0,0x0(%r13,%r14,8)
lea    0x1(%r14),%rsi
movsd  (%r12,%r14,8),%xmm0
movsd  0x8(%rbx),%xmm1
mov    %r15,%rdi
mov    %rsi,0x50(%rsp)
mov    %r14d,%edx
mov    $0x2,%al
call   1040 <printf@plt>
mov    %r13,%rax
lea    0x2(%r14),%r13d
mov    0x30(%rsp),%r15
cmp    %r15d,%r13d
jg     1210 <grib_invtrans_legendre+0xc0>
mov    %r14d,%ecx
imul   %r14d,%ecx
mov    %ecx,0x2c(%rsp)
mov    %r12,%rbx
mov    %rax,%r12
mov    0x38(%rsp),%r15
movsd  0xc8c(%rip),%xmm2
movsd  0xc8c(%rip),%xmm3
movsd  0x20(%rsp),%xmm0
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
mov    %r13d,%eax
imul   %r13d,%eax
sub    0x2c(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm3,%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,0x70(%rsp)
movsd  -0x10(%r15),%xmm2
divsd  0x20(%rsp),%xmm2
movsd  -0x8(%r15),%xmm1
mulsd  0x8(%rsp),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
mulsd  0x0(%rbp),%xmm1
addsd  (%rbx,%r14,8),%xmm1
movsd  %xmm1,(%rbx,%r14,8)
movsd  (%r15),%xmm0
mulsd  0x8(%rbp),%xmm0
addsd  (%r12,%r14,8),%xmm0
add    $0x10,%rbp
movsd  %xmm0,(%r12,%r14,8)
movsd  (%rbx,%r14,8),%xmm0
movsd  (%r15),%xmm1
lea    0xc70(%rip),%rdi
mov    %r13d,%esi
mov    %r14d,%edx
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xbc6(%rip),%xmm3
movsd  0xbb6(%rip),%xmm2
mov    0x68(%rsp),%rdx
lea    (%rdx,%r13,1),%eax
add    $0x1,%eax
mov    %r13d,%ecx
add    $0x1,%ecx
add    $0x8,%r15
mov    %ecx,%r13d
movsd  0x70(%rsp),%xmm0
cmp    $0x1,%eax
jne    1390 <grib_invtrans_legendre+0x240>
mov    0x30(%rsp),%r15
mov    0x40(%rsp),%rbx
jmp    1213 <grib_invtrans_legendre+0xc3>
movapd %xmm1,%xmm2
jmp    1496 <grib_invtrans_legendre+0x346>
xor    %eax,%eax
mov    %rax,0x10(%rsp)
lea    (%r15,%r15,1),%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    %r15,%rdx
test   $0x1,%dl
je     14c1 <grib_invtrans_legendre+0x371>
xorpd  0xb5f(%rip),%xmm0
mov    0x18(%rsp),%rcx
movsd  %xmm0,(%rbx)
mulsd  0x0(%rbp),%xmm0
movslq %edx,%rax
movsd  %xmm0,(%rcx,%rax,8)
movsd  (%rbx),%xmm0
mulsd  0x8(%rbp),%xmm0
movsd  %xmm0,(%r12,%rax,8)
mov    0x10(%rsp),%rax
movsd  (%rcx,%rax,8),%xmm0
movsd  (%rbx),%xmm1
lea    0xbaa(%rip),%rdi
mov    %edx,%esi
mov    $0x2,%al
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
cvttsd2si 0x8(%rsp),%esi
lea    0xb11(%rip),%rdi
jmp    1536 <grib_invtrans_legendre+0x3e6>
lea    0xb37(%rip),%rdi
mov    %ebx,%esi
jmp    1536 <grib_invtrans_legendre+0x3e6>
lea    0xb55(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"grib_legendreP: invalid x=%g must be abs(x)>0\0A\00"
@.str.1 = [41 x i8] c"grib_legendreP: invalid L=%d must be >0\0A\00"
@.str.2 = [29 x i8] c"unable to allocate %d bytes\0A\00"
@.str.3 = [24 x i8] c"-- (%d,%d) %.20e %.20e\0A\00"
define void @grib_invtrans_legendre(i32 %0, double %1, double* %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double*
%19 = alloca double*
%20 = alloca double*
store i32 %0, i32* %6
store double %1, double* %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%21 = load double, double* %7
%22 = call double @abs(double %21)
%23 = fcmp ogt double %22, 1.000000e+00
br i1 %23, label %24, label %29
24: ; preds = %5
%25 = load double, double* %7
%26 = fptosi double %25 to i32
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %5
%30 = load i32, i32* %6
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i32, i32* %6
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %29
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = mul i64 8, %39
%41 = trunc i64 %40 to i32
%42 = call i64 @malloc(i32 %41)
%43 = inttoptr i64 %42 to double*
store double* %43, double** %18
%44 = load double*, double** %18
%45 = icmp ne double* %44, null
br i1 %45, label %52, label %46
46: ; preds = %36
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
%49 = mul nsw i32 8, %48
%50 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %36
%53 = load double, double* %7
%54 = load double, double* %7
%55 = fneg double %53
%56 = call double @llvm.fmuladd.f64(double %55, double %54, double 1.000000e+00)
store double %56, double* %13
store double 1.000000e+00, double* %16
store double 1.000000e+00, double* %17
%57 = load double*, double** %18
store double* %57, double** %19
%58 = load double*, double** %8
store double* %58, double** %20
store i32 0, i32* %12
br label %59
59: ; preds = %259, %52
%60 = load i32, i32* %12
%61 = load i32, i32* %6
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %262
63: ; preds = %59
%64 = load i32, i32* %12
%65 = mul nsw i32 2, %64
%66 = add nsw i32 %65, 1
%67 = sitofp i32 %66 to double
%68 = load double, double* %17
%69 = fmul double %67, %68
%70 = fptosi double %69 to i32
%71 = call double @sqrt(i32 %70)
%72 = load double*, double** %18
%73 = getelementptr inbounds double, double* %72, i64 0
store double %71, double* %73
%74 = load i32, i32* %12
%75 = and i32 %74, 1
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %84
77: ; preds = %63
%78 = load double*, double** %18
%79 = getelementptr inbounds double, double* %78, i64 0
%80 = load double, double* %79
%81 = fneg double %80
%82 = load double*, double** %18
%83 = getelementptr inbounds double, double* %82, i64 0
store double %81, double* %83
br label %84
84: ; preds = %77, %63
%85 = load double*, double** %18
%86 = getelementptr inbounds double, double* %85, i64 0
%87 = load double, double* %86
%88 = load double*, double** %20
%89 = getelementptr inbounds double, double* %88, i32 1
store double* %89, double** %20
%90 = load double, double* %88
%91 = fmul double %87, %90
%92 = load double*, double** %9
%93 = load i32, i32* %12
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %92, i64 %94
store double %91, double* %95
%96 = load double*, double** %18
%97 = getelementptr inbounds double, double* %96, i64 0
%98 = load double, double* %97
%99 = load double*, double** %20
%100 = getelementptr inbounds double, double* %99, i32 1
store double* %100, double** %20
%101 = load double, double* %99
%102 = fmul double %98, %101
%103 = load double*, double** %10
%104 = load i32, i32* %12
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds double, double* %103, i64 %105
store double %102, double* %106
%107 = load i32, i32* %12
%108 = load i32, i32* %12
%109 = load double*, double** %9
%110 = load i32, i32* %12
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %109, i64 %111
%113 = load double, double* %112
%114 = load double*, double** %18
%115 = getelementptr inbounds double, double* %114, i64 0
%116 = load double, double* %115
%117 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %107, i32 %108, double %113, double %116)
%118 = load i32, i32* %12
%119 = mul nsw i32 2, %118
%120 = add nsw i32 %119, 3
%121 = call double @sqrt(i32 %120)
store double %121, double* %15
%122 = load double, double* %7
%123 = load double, double* %15
%124 = fmul double %122, %123
%125 = load double*, double** %18
%126 = getelementptr inbounds double, double* %125, i64 0
%127 = load double, double* %126
%128 = fmul double %124, %127
%129 = load double*, double** %18
%130 = getelementptr inbounds double, double* %129, i64 1
store double %128, double* %130
%131 = load double*, double** %18
%132 = getelementptr inbounds double, double* %131, i64 1
%133 = load double, double* %132
%134 = load double*, double** %20
%135 = getelementptr inbounds double, double* %134, i32 1
store double* %135, double** %20
%136 = load double, double* %134
%137 = load double*, double** %9
%138 = load i32, i32* %12
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds double, double* %137, i64 %139
%141 = load double, double* %140
%142 = call double @llvm.fmuladd.f64(double %133, double %136, double %141)
store double %142, double* %140
%143 = load double*, double** %18
%144 = getelementptr inbounds double, double* %143, i64 1
%145 = load double, double* %144
%146 = load double*, double** %20
%147 = getelementptr inbounds double, double* %146, i32 1
store double* %147, double** %20
%148 = load double, double* %146
%149 = load double*, double** %10
%150 = load i32, i32* %12
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds double, double* %149, i64 %151
%153 = load double, double* %152
%154 = call double @llvm.fmuladd.f64(double %145, double %148, double %153)
store double %154, double* %152
%155 = load i32, i32* %12
%156 = add nsw i32 %155, 1
%157 = load i32, i32* %12
%158 = load double*, double** %9
%159 = load i32, i32* %12
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds double, double* %158, i64 %160
%162 = load double, double* %161
%163 = load double*, double** %18
%164 = getelementptr inbounds double, double* %163, i64 1
%165 = load double, double* %164
%166 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %156, i32 %157, double %162, double %165)
%167 = load i32, i32* %12
%168 = add nsw i32 %167, 2
store i32 %168, i32* %11
br label %169
169: ; preds = %244, %84
%170 = load i32, i32* %11
%171 = load i32, i32* %6
%172 = icmp sle i32 %170, %171
br i1 %172, label %173, label %247
173: ; preds = %169
%174 = load i32, i32* %11
%175 = sitofp i32 %174 to double
%176 = fmul double 4.000000e+00, %175
%177 = load i32, i32* %11
%178 = sitofp i32 %177 to double
%179 = call double @llvm.fmuladd.f64(double %176, double %178, double -1.000000e+00)
%180 = load i32, i32* %11
%181 = load i32, i32* %11
%182 = mul nsw i32 %180, %181
%183 = load i32, i32* %12
%184 = load i32, i32* %12
%185 = mul nsw i32 %183, %184
%186 = sub nsw i32 %182, %185
%187 = sitofp i32 %186 to double
%188 = fdiv double %179, %187
%189 = fptosi double %188 to i32
%190 = call double @sqrt(i32 %189)
store double %190, double* %14
%191 = load double, double* %7
%192 = load double*, double** %18
%193 = getelementptr inbounds double, double* %192, i64 1
%194 = load double, double* %193
%195 = load double*, double** %18
%196 = getelementptr inbounds double, double* %195, i64 0
%197 = load double, double* %196
%198 = load double, double* %15
%199 = fdiv double %197, %198
%200 = fneg double %199
%201 = call double @llvm.fmuladd.f64(double %191, double %194, double %200)
%202 = load double, double* %14
%203 = fmul double %201, %202
%204 = load double*, double** %18
%205 = getelementptr inbounds double, double* %204, i64 2
store double %203, double* %205
%206 = load double*, double** %18
%207 = getelementptr inbounds double, double* %206, i64 2
%208 = load double, double* %207
%209 = load double*, double** %20
%210 = getelementptr inbounds double, double* %209, i32 1
store double* %210, double** %20
%211 = load double, double* %209
%212 = load double*, double** %9
%213 = load i32, i32* %12
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds double, double* %212, i64 %214
%216 = load double, double* %215
%217 = call double @llvm.fmuladd.f64(double %208, double %211, double %216)
store double %217, double* %215
%218 = load double*, double** %18
%219 = getelementptr inbounds double, double* %218, i64 2
%220 = load double, double* %219
%221 = load double*, double** %20
%222 = getelementptr inbounds double, double* %221, i32 1
store double* %222, double** %20
%223 = load double, double* %221
%224 = load double*, double** %10
%225 = load i32, i32* %12
%226 = sext i32 %225 to i64
%227 = getelementptr inbounds double, double* %224, i64 %226
%228 = load double, double* %227
%229 = call double @llvm.fmuladd.f64(double %220, double %223, double %228)
store double %229, double* %227
%230 = load i32, i32* %11
%231 = load i32, i32* %12
%232 = load double*, double** %9
%233 = load i32, i32* %12
%234 = sext i32 %233 to i64
%235 = getelementptr inbounds double, double* %232, i64 %234
%236 = load double, double* %235
%237 = load double*, double** %18
%238 = getelementptr inbounds double, double* %237, i64 2
%239 = load double, double* %238
%240 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %230, i32 %231, double %236, double %239)
%241 = load double, double* %14
store double %241, double* %15
%242 = load double*, double** %18
%243 = getelementptr inbounds double, double* %242, i32 1
store double* %243, double** %18
br label %244
244: ; preds = %173
%245 = load i32, i32* %11
%246 = add nsw i32 %245, 1
store i32 %246, i32* %11
br label %169
247: ; preds = %169
%248 = load double*, double** %19
store double* %248, double** %18
%249 = load double, double* %13
%250 = load double, double* %16
%251 = fmul double %249, %250
%252 = load double, double* %16
%253 = fadd double %252, 1.000000e+00
%254 = fdiv double %251, %253
%255 = load double, double* %17
%256 = fmul double %255, %254
store double %256, double* %17
%257 = load double, double* %16
%258 = fadd double %257, 2.000000e+00
store double %258, double* %16
br label %259
259: ; preds = %247
%260 = load i32, i32* %12
%261 = add nsw i32 %260, 1
store i32 %261, i32* %12
br label %59
262: ; preds = %59
%263 = load i32, i32* %6
%264 = mul nsw i32 2, %263
%265 = add nsw i32 %264, 1
%266 = sitofp i32 %265 to double
%267 = load double, double* %17
%268 = fmul double %266, %267
%269 = fptosi double %268 to i32
%270 = call double @sqrt(i32 %269)
%271 = load double*, double** %18
%272 = getelementptr inbounds double, double* %271, i64 0
store double %270, double* %272
%273 = load i32, i32* %6
%274 = and i32 %273, 1
%275 = icmp ne i32 %274, 0
br i1 %275, label %276, label %283
276: ; preds = %262
%277 = load double*, double** %18
%278 = getelementptr inbounds double, double* %277, i64 0
%279 = load double, double* %278
%280 = fneg double %279
%281 = load double*, double** %18
%282 = getelementptr inbounds double, double* %281, i64 0
store double %280, double* %282
br label %283
283: ; preds = %276, %262
%284 = load double*, double** %18
%285 = getelementptr inbounds double, double* %284, i64 0
%286 = load double, double* %285
%287 = load double*, double** %20
%288 = getelementptr inbounds double, double* %287, i32 1
store double* %288, double** %20
%289 = load double, double* %287
%290 = fmul double %286, %289
%291 = load double*, double** %9
%292 = load i32, i32* %6
%293 = sext i32 %292 to i64
%294 = getelementptr inbounds double, double* %291, i64 %293
store double %290, double* %294
%295 = load double*, double** %18
%296 = getelementptr inbounds double, double* %295, i64 0
%297 = load double, double* %296
%298 = load double*, double** %20
%299 = getelementptr inbounds double, double* %298, i32 1
store double* %299, double** %20
%300 = load double, double* %298
%301 = fmul double %297, %300
%302 = load double*, double** %10
%303 = load i32, i32* %6
%304 = sext i32 %303 to i64
%305 = getelementptr inbounds double, double* %302, i64 %304
store double %301, double* %305
%306 = load i32, i32* %6
%307 = load i32, i32* %6
%308 = load double*, double** %9
%309 = load i32, i32* %12
%310 = sext i32 %309 to i64
%311 = getelementptr inbounds double, double* %308, i64 %310
%312 = load double, double* %311
%313 = load double*, double** %18
%314 = getelementptr inbounds double, double* %313, i64 0
%315 = load double, double* %314
%316 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %306, i32 %307, double %312, double %315)
ret void
}

LLVM IR (-O2):
@.str = [47 x i8] c"grib_legendreP: invalid x=%g must be abs(x)>0\0A\00"
@.str.1 = [41 x i8] c"grib_legendreP: invalid L=%d must be >0\0A\00"
@.str.2 = [29 x i8] c"unable to allocate %d bytes\0A\00"
@.str.3 = [24 x i8] c"-- (%d,%d) %.20e %.20e\0A\00"
define void @grib_invtrans_legendre(i32 %0, double %1, double* nocapture %2, double* nocapture %3, double* nocapture %4) {
%6 = tail call double @abs(double %1)
%7 = fcmp ogt double %6, 1.000000e+00
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = fptosi double %1 to i32
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %5
%13 = icmp slt i32 %0, 0
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %12
%18 = shl i32 %0, 3
%19 = add i32 %18, 8
%20 = tail call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to double*
%22 = icmp eq i64 %20, 0
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %17
%27 = fneg double %1
%28 = tail call double @llvm.fmuladd.f64(double %27, double %1, double 1.000000e+00)
%29 = icmp eq i32 %0, 0
br i1 %29, label %133, label %30
30: ; preds = %26
%31 = getelementptr inbounds double, double* %21, i64 1
%32 = zext i32 %0 to i64
br label %33
33: ; preds = %30, %123
%34 = phi i64 [ 0, %30 ], [ %77, %123 ]
%35 = phi double* [ %2, %30 ], [ %124, %123 ]
%36 = phi double [ 1.000000e+00, %30 ], [ %128, %123 ]
%37 = phi double [ 1.000000e+00, %30 ], [ %129, %123 ]
%38 = shl nuw nsw i64 %34, 1
%39 = trunc i64 %38 to i32
%40 = or i32 %39, 1
%41 = sitofp i32 %40 to double
%42 = fmul double %36, %41
%43 = fptosi double %42 to i32
%44 = tail call double @sqrt(i32 %43)
%45 = trunc i64 %34 to i32
%46 = and i32 %45, 1
%47 = icmp eq i32 %46, 0
%48 = fneg double %44
%49 = select i1 %47, double %44, double %48
store double %49, double* %21
%50 = getelementptr inbounds double, double* %35, i64 1
%51 = load double, double* %35
%52 = fmul double %49, %51
%53 = getelementptr inbounds double, double* %3, i64 %34
store double %52, double* %53
%54 = load double, double* %21
%55 = getelementptr inbounds double, double* %35, i64 2
%56 = load double, double* %50
%57 = fmul double %54, %56
%58 = getelementptr inbounds double, double* %4, i64 %34
store double %57, double* %58
%59 = load double, double* %53
%60 = load double, double* %21
%61 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %45, i32 %45, double %59, double %60)
%62 = trunc i64 %38 to i32
%63 = add i32 %62, 3
%64 = tail call double @sqrt(i32 %63)
%65 = fmul double %64, %1
%66 = load double, double* %21
%67 = fmul double %65, %66
store double %67, double* %31
%68 = getelementptr inbounds double, double* %35, i64 3
%69 = load double, double* %55
%70 = load double, double* %53
%71 = tail call double @llvm.fmuladd.f64(double %67, double %69, double %70)
store double %71, double* %53
%72 = load double, double* %31
%73 = getelementptr inbounds double, double* %35, i64 4
%74 = load double, double* %68
%75 = load double, double* %58
%76 = tail call double @llvm.fmuladd.f64(double %72, double %74, double %75)
store double %76, double* %58
%77 = add nuw nsw i64 %34, 1
%78 = trunc i64 %77 to i32
%79 = load double, double* %53
%80 = load double, double* %31
%81 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %78, i32 %45, double %79, double %80)
%82 = trunc i64 %34 to i32
%83 = add i32 %82, 2
%84 = icmp sgt i32 %83, %0
br i1 %84, label %123, label %85
85: ; preds = %33
%86 = mul nsw i32 %45, %45
br label %87
87: ; preds = %85, %87
%88 = phi double* [ %73, %85 ], [ %114, %87 ]
%89 = phi i32 [ %83, %85 ], [ %121, %87 ]
%90 = phi double* [ %21, %85 ], [ %101, %87 ]
%91 = phi double [ %64, %85 ], [ %100, %87 ]
%92 = sitofp i32 %89 to double
%93 = fmul double %92, 4.000000e+00
%94 = tail call double @llvm.fmuladd.f64(double %93, double %92, double -1.000000e+00)
%95 = mul nsw i32 %89, %89
%96 = sub nsw i32 %95, %86
%97 = sitofp i32 %96 to double
%98 = fdiv double %94, %97
%99 = fptosi double %98 to i32
%100 = tail call double @sqrt(i32 %99)
%101 = getelementptr inbounds double, double* %90, i64 1
%102 = load double, double* %101
%103 = load double, double* %90
%104 = fneg double %103
%105 = fdiv double %104, %91
%106 = tail call double @llvm.fmuladd.f64(double %1, double %102, double %105)
%107 = fmul double %100, %106
%108 = getelementptr inbounds double, double* %90, i64 2
store double %107, double* %108
%109 = getelementptr inbounds double, double* %88, i64 1
%110 = load double, double* %88
%111 = load double, double* %53
%112 = tail call double @llvm.fmuladd.f64(double %107, double %110, double %111)
store double %112, double* %53
%113 = load double, double* %108
%114 = getelementptr inbounds double, double* %88, i64 2
%115 = load double, double* %109
%116 = load double, double* %58
%117 = tail call double @llvm.fmuladd.f64(double %113, double %115, double %116)
store double %117, double* %58
%118 = load double, double* %53
%119 = load double, double* %108
%120 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %89, i32 %45, double %118, double %119)
%121 = add i32 %89, 1
%122 = icmp eq i32 %89, %0
br i1 %122, label %123, label %87
123: ; preds = %87, %33
%124 = phi double* [ %73, %33 ], [ %114, %87 ]
%125 = fmul double %28, %37
%126 = fadd double %37, 1.000000e+00
%127 = fdiv double %125, %126
%128 = fmul double %36, %127
%129 = fadd double %37, 2.000000e+00
%130 = icmp eq i64 %77, %32
br i1 %130, label %131, label %33
131: ; preds = %123
%132 = zext i32 %0 to i64
br label %133
133: ; preds = %26, %131
%134 = phi i64 [ %132, %131 ], [ 0, %26 ]
%135 = phi double [ %128, %131 ], [ 1.000000e+00, %26 ]
%136 = phi double* [ %124, %131 ], [ %2, %26 ]
%137 = shl nsw i32 %0, 1
%138 = or i32 %137, 1
%139 = sitofp i32 %138 to double
%140 = fmul double %135, %139
%141 = fptosi double %140 to i32
%142 = tail call double @sqrt(i32 %141)
%143 = and i32 %0, 1
%144 = icmp eq i32 %143, 0
%145 = fneg double %142
%146 = select i1 %144, double %142, double %145
store double %146, double* %21
%147 = getelementptr inbounds double, double* %136, i64 1
%148 = load double, double* %136
%149 = fmul double %146, %148
%150 = sext i32 %0 to i64
%151 = getelementptr inbounds double, double* %3, i64 %150
store double %149, double* %151
%152 = load double, double* %21
%153 = load double, double* %147
%154 = fmul double %152, %153
%155 = getelementptr inbounds double, double* %4, i64 %150
store double %154, double* %155
%156 = getelementptr inbounds double, double* %3, i64 %134
%157 = load double, double* %156
%158 = load double, double* %21
%159 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %0, i32 %0, double %157, double %158)
ret void
}