#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 */
scalar_t__ cos(double);
int const log(int);
int const log_add(double, double);
int log_conv(scalar_t__);
scalar_t__ sin(double);
void lsp2sp(double *lsp, const int m, double *x, const int l, const int gain) {
  int i, p;
  double w, eq1, eq2, ap = 0.0;
  for (p = 0; p < l; p++) {
    eq1 = 0.0;
    eq2 = 0.0;
    w = p * (3.1415926535897932384626433832795 / (l - 1));
    if (m % 2 == 0) {
      for (i = 0; i < m / 2; i++) {
        eq1 += 2 * log_conv(cos(w) - cos(lsp[2 * i + gain]));
        eq2 += 2 * log_conv(cos(w) - cos(lsp[2 * i + 1 + gain]));
      }
      eq1 += 2 * log_conv(cos(w / 2));
      eq2 += 2 * log_conv(sin(w / 2));
      ap = m * log(2) + log_add(eq1, eq2);
    } else {
      for (i = 0; i < (m + 1) / 2; i++)
        eq1 += 2 * log_conv(cos(w) - cos(lsp[2 * i + gain]));
      for (i = 0; i < (m - 1) / 2; i++)
        eq2 += 2 * log_conv(cos(w) - cos(lsp[2 * i + 1 + gain]));
      eq2 += 2 * log_conv(sin(w));
      ap = (m - 1) * log(2) + log_add(eq1, eq2);
    }
    x[p] = -0.5 * ap;
    if (gain == 1)
      x[p] += lsp[0];
  }
}


x86 assembly (clang, -O0):
<lsp2sp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    14e9 <lsp2sp+0x399>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm2
movsd  0xe51(%rip),%xmm1
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    132d <lsp2sp+0x1dd>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
cmp    %ecx,%eax
jge    1290 <lsp2sp+0x140>
movsd  -0x30(%rbp),%xmm0
call   1060 <cos@plt>
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1060 <cos@plt>
mov    -0x60(%rbp),%rdi
sub    %rax,%rdi
call   1030 <log_conv@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1060 <cos@plt>
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1060 <cos@plt>
mov    -0x58(%rbp),%rdi
sub    %rax,%rdi
call   1030 <log_conv@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d7 <lsp2sp+0x87>
movsd  -0x30(%rbp),%xmm0
movsd  0xd6b(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <cos@plt>
mov    %rax,%rdi
call   1030 <log_conv@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xd3c(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <sin@plt>
mov    %rax,%rdi
call   1030 <log_conv@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    $0x2,%edi
call   1070 <log@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x64(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1050 <log_add@plt>
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1498 <lsp2sp+0x348>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    %ecx,%eax
jge    13a8 <lsp2sp+0x258>
movsd  -0x30(%rbp),%xmm0
call   1060 <cos@plt>
mov    %rax,-0x78(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1060 <cos@plt>
mov    -0x78(%rbp),%rdi
sub    %rax,%rdi
call   1030 <log_conv@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1334 <lsp2sp+0x1e4>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x7c(%rbp),%eax
cmp    %ecx,%eax
jge    142c <lsp2sp+0x2dc>
movsd  -0x30(%rbp),%xmm0
call   1060 <cos@plt>
mov    %rax,-0x88(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1060 <cos@plt>
mov    -0x88(%rbp),%rdi
sub    %rax,%rdi
call   1030 <log_conv@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    13af <lsp2sp+0x25f>
movsd  -0x30(%rbp),%xmm0
call   1040 <sin@plt>
mov    %rax,%rdi
call   1030 <log_conv@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x90(%rbp)
mov    $0x2,%edi
call   1070 <log@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x8c(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1050 <log_add@plt>
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xb70(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x1,-0x20(%rbp)
jne    14d6 <lsp2sp+0x386>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    14db <lsp2sp+0x38b>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117c <lsp2sp+0x2c>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lsp2sp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
test   %ecx,%ecx
jle    14d8 <lsp2sp+0x388>
mov    %rdx,%r12
mov    %esi,%r14d
mov    %rdi,%r13
lea    -0x1(%rcx),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe7f(%rip),%xmm1
lea    0x1(%r14),%eax
shr    $0x1f,%eax
lea    (%r14,%rax,1),%edx
add    $0x1,%edx
sar    %edx
lea    -0x1(%r14),%eax
mov    %eax,0x2c(%rsp)
shr    $0x1f,%eax
lea    (%r14,%rax,1),%esi
add    $0xffffffff,%esi
sar    %esi
mov    %r14d,%eax
shr    $0x1f,%eax
add    %r14d,%eax
sar    %eax
mov    %rax,0x50(%rsp)
cmp    $0x2,%edx
mov    $0x1,%eax
cmovl  %eax,%edx
divsd  %xmm0,%xmm1
movsd  %xmm1,0x70(%rsp)
cmp    $0x2,%esi
cmovl  %eax,%esi
mov    %rsi,0x58(%rsp)
movslq %r8d,%rax
mov    %ecx,%ecx
mov    %rcx,0x68(%rsp)
lea    (%rdi,%rax,8),%r15
shl    $0x4,%rdx
mov    %rdx,0x80(%rsp)
add    $0x1,%eax
mov    %rax,0x38(%rsp)
xor    %eax,%eax
mov    %r14,0x40(%rsp)
mov    %r15,0x48(%rsp)
mov    %r8d,0xc(%rsp)
mov    %r12,0x60(%rsp)
jmp    1224 <lsp2sp+0xd4>
nop
add    $0x1,%rax
cmp    0x68(%rsp),%rax
mov    0x48(%rsp),%r15
je     14d8 <lsp2sp+0x388>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x70(%rsp),%xmm0
test   $0x1,%r14b
mov    %rax,0x78(%rsp)
jne    1360 <lsp2sp+0x210>
xorpd  %xmm1,%xmm1
cmp    $0x2,%r14d
jl     12fd <lsp2sp+0x1ad>
xorpd  %xmm1,%xmm1
mov    0x50(%rsp),%r14
mov    0x48(%rsp),%r15
mov    0x38(%rsp),%r12
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
movapd %xmm1,0x10(%rsp)
call   1060 <cos@plt>
mov    %rax,%rbp
movsd  (%r15),%xmm0
call   1060 <cos@plt>
sub    %rax,%rbp
mov    %rbp,%rdi
call   1030 <log_conv@plt>
mov    %eax,%ebp
movsd  (%rsp),%xmm0
call   1060 <cos@plt>
mov    %rax,%rbx
movslq %r12d,%r12
movsd  0x0(%r13,%r12,8),%xmm0
call   1060 <cos@plt>
sub    %rax,%rbx
mov    %rbx,%rdi
call   1030 <log_conv@plt>
movd   %ebp,%xmm0
movd   %eax,%xmm1
punpckldq %xmm1,%xmm0
paddd  %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
movapd 0x10(%rsp),%xmm1
addpd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movsd  (%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
add    $0x2,%r12d
add    $0x10,%r15
add    $0xffffffffffffffff,%r14
jne    1270 <lsp2sp+0x120>
movapd %xmm1,0x10(%rsp)
mulsd  0xcfd(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1060 <cos@plt>
mov    %rax,%rdi
call   1030 <log_conv@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x10(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
unpckhpd %xmm1,%xmm1
movapd %xmm1,0x10(%rsp)
mov    0x40(%rsp),%r14
mov    %r14d,%r15d
mov    0xc(%rsp),%ebp
mov    0x60(%rsp),%r12
movsd  (%rsp),%xmm0
jmp    1461 <lsp2sp+0x311>
nopl   0x0(%rax,%rax,1)
xorpd  %xmm1,%xmm1
test   %r14d,%r14d
movsd  %xmm0,(%rsp)
jle    13cf <lsp2sp+0x27f>
xorpd  %xmm1,%xmm1
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm1,0x30(%rsp)
movsd  (%rsp),%xmm0
call   1060 <cos@plt>
mov    %rax,%rbx
movsd  (%r15,%rbp,1),%xmm0
call   1060 <cos@plt>
sub    %rax,%rbx
mov    %rbx,%rdi
call   1030 <log_conv@plt>
movsd  0x30(%rsp),%xmm1
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
add    $0x10,%rbp
cmp    %rbp,0x80(%rsp)
jne    1380 <lsp2sp+0x230>
cmp    $0x3,%r14d
movsd  %xmm1,0x30(%rsp)
jl     1450 <lsp2sp+0x300>
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
mov    0x58(%rsp),%r14
mov    0x38(%rsp),%rbp
nop
movsd  (%rsp),%xmm0
call   1060 <cos@plt>
mov    %rax,%rbx
movslq %ebp,%rbp
movsd  0x0(%r13,%rbp,8),%xmm0
call   1060 <cos@plt>
sub    %rax,%rbx
mov    %rbx,%rdi
call   1030 <log_conv@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movsd  (%rsp),%xmm0
add    $0x2,%ebp
add    $0xffffffffffffffff,%r14
jne    13f0 <lsp2sp+0x2a0>
mov    0x2c(%rsp),%r15d
mov    0x40(%rsp),%r14
mov    0xc(%rsp),%ebp
jmp    1461 <lsp2sp+0x311>
xchg   %ax,%ax
mov    0x2c(%rsp),%r15d
mov    0xc(%rsp),%ebp
xorps  %xmm2,%xmm2
movaps %xmm2,0x10(%rsp)
call   1040 <sin@plt>
mov    %rax,%rdi
call   1030 <log_conv@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x2,%edi
call   1070 <log@plt>
mov    %eax,%ebx
imul   %r15d,%ebx
movsd  0x30(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1050 <log_add@plt>
add    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xb5d(%rip),%xmm0
mov    0x78(%rsp),%rax
movsd  %xmm0,(%r12,%rax,8)
cmp    $0x1,%ebp
jne    1210 <lsp2sp+0xc0>
addsd  0x0(%r13),%xmm0
movsd  %xmm0,(%r12,%rax,8)
jmp    1210 <lsp2sp+0xc0>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @lsp2sp(double* %0, i32 %1, double* %2, i32 %3, i32 %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double* %0, double** %6
store i32 %1, i32* %7
store double* %2, double** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store double 0.000000e+00, double* %16
store i32 0, i32* %12
br label %17
17: ; preds = %196, %5
%18 = load i32, i32* %12
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %199
21: ; preds = %17
store double 0.000000e+00, double* %14
store double 0.000000e+00, double* %15
%22 = load i32, i32* %12
%23 = sitofp i32 %22 to double
%24 = load i32, i32* %9
%25 = sub nsw i32 %24, 1
%26 = sitofp i32 %25 to double
%27 = fdiv double 0x400921FB54442D18, %26
%28 = fmul double %23, %27
store double %28, double* %13
%29 = load i32, i32* %7
%30 = srem i32 %29, 2
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %102
32: ; preds = %21
store i32 0, i32* %11
br label %33
33: ; preds = %74, %32
%34 = load i32, i32* %11
%35 = load i32, i32* %7
%36 = sdiv i32 %35, 2
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %77
38: ; preds = %33
%39 = load double, double* %13
%40 = call i64 @cos(double %39)
%41 = load double*, double** %6
%42 = load i32, i32* %11
%43 = mul nsw i32 2, %42
%44 = load i32, i32* %10
%45 = add nsw i32 %43, %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %41, i64 %46
%48 = load double, double* %47
%49 = call i64 @cos(double %48)
%50 = sub nsw i64 %40, %49
%51 = call i32 @log_conv(i64 %50)
%52 = mul nsw i32 2, %51
%53 = sitofp i32 %52 to double
%54 = load double, double* %14
%55 = fadd double %54, %53
store double %55, double* %14
%56 = load double, double* %13
%57 = call i64 @cos(double %56)
%58 = load double*, double** %6
%59 = load i32, i32* %11
%60 = mul nsw i32 2, %59
%61 = add nsw i32 %60, 1
%62 = load i32, i32* %10
%63 = add nsw i32 %61, %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %58, i64 %64
%66 = load double, double* %65
%67 = call i64 @cos(double %66)
%68 = sub nsw i64 %57, %67
%69 = call i32 @log_conv(i64 %68)
%70 = mul nsw i32 2, %69
%71 = sitofp i32 %70 to double
%72 = load double, double* %15
%73 = fadd double %72, %71
store double %73, double* %15
br label %74
74: ; preds = %38
%75 = load i32, i32* %11
%76 = add nsw i32 %75, 1
store i32 %76, i32* %11
br label %33
77: ; preds = %33
%78 = load double, double* %13
%79 = fdiv double %78, 2.000000e+00
%80 = call i64 @cos(double %79)
%81 = call i32 @log_conv(i64 %80)
%82 = mul nsw i32 2, %81
%83 = sitofp i32 %82 to double
%84 = load double, double* %14
%85 = fadd double %84, %83
store double %85, double* %14
%86 = load double, double* %13
%87 = fdiv double %86, 2.000000e+00
%88 = call i64 @sin(double %87)
%89 = call i32 @log_conv(i64 %88)
%90 = mul nsw i32 2, %89
%91 = sitofp i32 %90 to double
%92 = load double, double* %15
%93 = fadd double %92, %91
store double %93, double* %15
%94 = load i32, i32* %7
%95 = call i32 @log(i32 2)
%96 = mul nsw i32 %94, %95
%97 = load double, double* %14
%98 = load double, double* %15
%99 = call i32 @log_add(double %97, double %98)
%100 = add nsw i32 %96, %99
%101 = sitofp i32 %100 to double
store double %101, double* %16
br label %176
102: ; preds = %21
store i32 0, i32* %11
br label %103
103: ; preds = %127, %102
%104 = load i32, i32* %11
%105 = load i32, i32* %7
%106 = add nsw i32 %105, 1
%107 = sdiv i32 %106, 2
%108 = icmp slt i32 %104, %107
br i1 %108, label %109, label %130
109: ; preds = %103
%110 = load double, double* %13
%111 = call i64 @cos(double %110)
%112 = load double*, double** %6
%113 = load i32, i32* %11
%114 = mul nsw i32 2, %113
%115 = load i32, i32* %10
%116 = add nsw i32 %114, %115
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double, double* %112, i64 %117
%119 = load double, double* %118
%120 = call i64 @cos(double %119)
%121 = sub nsw i64 %111, %120
%122 = call i32 @log_conv(i64 %121)
%123 = mul nsw i32 2, %122
%124 = sitofp i32 %123 to double
%125 = load double, double* %14
%126 = fadd double %125, %124
store double %126, double* %14
br label %127
127: ; preds = %109
%128 = load i32, i32* %11
%129 = add nsw i32 %128, 1
store i32 %129, i32* %11
br label %103
130: ; preds = %103
store i32 0, i32* %11
br label %131
131: ; preds = %156, %130
%132 = load i32, i32* %11
%133 = load i32, i32* %7
%134 = sub nsw i32 %133, 1
%135 = sdiv i32 %134, 2
%136 = icmp slt i32 %132, %135
br i1 %136, label %137, label %159
137: ; preds = %131
%138 = load double, double* %13
%139 = call i64 @cos(double %138)
%140 = load double*, double** %6
%141 = load i32, i32* %11
%142 = mul nsw i32 2, %141
%143 = add nsw i32 %142, 1
%144 = load i32, i32* %10
%145 = add nsw i32 %143, %144
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds double, double* %140, i64 %146
%148 = load double, double* %147
%149 = call i64 @cos(double %148)
%150 = sub nsw i64 %139, %149
%151 = call i32 @log_conv(i64 %150)
%152 = mul nsw i32 2, %151
%153 = sitofp i32 %152 to double
%154 = load double, double* %15
%155 = fadd double %154, %153
store double %155, double* %15
br label %156
156: ; preds = %137
%157 = load i32, i32* %11
%158 = add nsw i32 %157, 1
store i32 %158, i32* %11
br label %131
159: ; preds = %131
%160 = load double, double* %13
%161 = call i64 @sin(double %160)
%162 = call i32 @log_conv(i64 %161)
%163 = mul nsw i32 2, %162
%164 = sitofp i32 %163 to double
%165 = load double, double* %15
%166 = fadd double %165, %164
store double %166, double* %15
%167 = load i32, i32* %7
%168 = sub nsw i32 %167, 1
%169 = call i32 @log(i32 2)
%170 = mul nsw i32 %168, %169
%171 = load double, double* %14
%172 = load double, double* %15
%173 = call i32 @log_add(double %171, double %172)
%174 = add nsw i32 %170, %173
%175 = sitofp i32 %174 to double
store double %175, double* %16
br label %176
176: ; preds = %159, %77
%177 = load double, double* %16
%178 = fmul double -5.000000e-01, %177
%179 = load double*, double** %8
%180 = load i32, i32* %12
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds double, double* %179, i64 %181
store double %178, double* %182
%183 = load i32, i32* %10
%184 = icmp eq i32 %183, 1
br i1 %184, label %185, label %195
185: ; preds = %176
%186 = load double*, double** %6
%187 = getelementptr inbounds double, double* %186, i64 0
%188 = load double, double* %187
%189 = load double*, double** %8
%190 = load i32, i32* %12
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds double, double* %189, i64 %191
%193 = load double, double* %192
%194 = fadd double %193, %188
store double %194, double* %192
br label %195
195: ; preds = %185, %176
br label %196
196: ; preds = %195
%197 = load i32, i32* %12
%198 = add nsw i32 %197, 1
store i32 %198, i32* %12
br label %17
199: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @lsp2sp(double* nocapture %0, i32 %1, double* nocapture writeonly %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %133
7: ; preds = %5
%8 = add nsw i32 %3, -1
%9 = sitofp i32 %8 to double
%10 = fdiv double 0x400921FB54442D18, %9
%11 = and i32 %1, 1
%12 = icmp eq i32 %11, 0
%13 = add nsw i32 %1, 1
%14 = sdiv i32 %13, 2
%15 = icmp sgt i32 %1, 0
%16 = add nsw i32 %1, -1
%17 = sdiv i32 %16, 2
%18 = icmp sgt i32 %1, 2
%19 = add i32 %4, 1
%20 = sdiv i32 %1, 2
%21 = icmp sgt i32 %1, 1
%22 = icmp eq i32 %4, 1
%23 = sext i32 %4 to i64
%24 = call i32 @llvm.smax.i32(i32 %14, i32 1)
%25 = call i32 @llvm.smax.i32(i32 %17, i32 1)
%26 = zext i32 %3 to i64
%27 = zext i32 %24 to i64
%28 = zext i32 %25 to i64
%29 = zext i32 %20 to i64
br label %30
30: ; preds = %7, %130
%31 = phi i64 [ 0, %7 ], [ %131, %130 ]
%32 = trunc i64 %31 to i32
%33 = sitofp i32 %32 to double
%34 = fmul double %10, %33
br i1 %12, label %36, label %35
35: ; preds = %30
br i1 %15, label %76, label %74
36: ; preds = %30
br i1 %21, label %37, label %64
37: ; preds = %36, %37
%38 = phi i64 [ %62, %37 ], [ 0, %36 ]
%39 = phi <2 x double> [ %61, %37 ], [ zeroinitializer, %36 ]
%40 = tail call i64 @cos(double %34)
%41 = shl nuw nsw i64 %38, 1
%42 = add nsw i64 %41, %23
%43 = getelementptr inbounds double, double* %0, i64 %42
%44 = load double, double* %43
%45 = tail call i64 @cos(double %44)
%46 = sub nsw i64 %40, %45
%47 = tail call i32 @log_conv(i64 %46)
%48 = tail call i64 @cos(double %34)
%49 = trunc i64 %41 to i32
%50 = add i32 %19, %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %0, i64 %51
%53 = load double, double* %52
%54 = tail call i64 @cos(double %53)
%55 = sub nsw i64 %48, %54
%56 = tail call i32 @log_conv(i64 %55)
%57 = insertelement <2 x i32> poison, i32 %47, i64 0
%58 = insertelement <2 x i32> %57, i32 %56, i64 1
%59 = shl nsw <2 x i32> %58, <i32 1, i32 1>
%60 = sitofp <2 x i32> %59 to <2 x double>
%61 = fadd <2 x double> %39, %60
%62 = add nuw nsw i64 %38, 1
%63 = icmp eq i64 %62, %29
br i1 %63, label %64, label %37
64: ; preds = %37, %36
%65 = phi <2 x double> [ zeroinitializer, %36 ], [ %61, %37 ]
%66 = fmul double %34, 5.000000e-01
%67 = tail call i64 @cos(double %66)
%68 = tail call i32 @log_conv(i64 %67)
%69 = shl nsw i32 %68, 1
%70 = sitofp i32 %69 to double
%71 = extractelement <2 x double> %65, i64 0
%72 = fadd double %71, %70
%73 = extractelement <2 x double> %65, i64 1
br label %110
74: ; preds = %76, %35
%75 = phi double [ 0.000000e+00, %35 ], [ %89, %76 ]
br i1 %18, label %92, label %110
76: ; preds = %35, %76
%77 = phi i64 [ %90, %76 ], [ 0, %35 ]
%78 = phi double [ %89, %76 ], [ 0.000000e+00, %35 ]
%79 = tail call i64 @cos(double %34)
%80 = shl nuw nsw i64 %77, 1
%81 = add nsw i64 %80, %23
%82 = getelementptr inbounds double, double* %0, i64 %81
%83 = load double, double* %82
%84 = tail call i64 @cos(double %83)
%85 = sub nsw i64 %79, %84
%86 = tail call i32 @log_conv(i64 %85)
%87 = shl nsw i32 %86, 1
%88 = sitofp i32 %87 to double
%89 = fadd double %78, %88
%90 = add nuw nsw i64 %77, 1
%91 = icmp eq i64 %90, %27
br i1 %91, label %74, label %76
92: ; preds = %74, %92
%93 = phi i64 [ %108, %92 ], [ 0, %74 ]
%94 = phi double [ %107, %92 ], [ 0.000000e+00, %74 ]
%95 = tail call i64 @cos(double %34)
%96 = trunc i64 %93 to i32
%97 = shl i32 %96, 1
%98 = add i32 %19, %97
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %0, i64 %99
%101 = load double, double* %100
%102 = tail call i64 @cos(double %101)
%103 = sub nsw i64 %95, %102
%104 = tail call i32 @log_conv(i64 %103)
%105 = shl nsw i32 %104, 1
%106 = sitofp i32 %105 to double
%107 = fadd double %94, %106
%108 = add nuw nsw i64 %93, 1
%109 = icmp eq i64 %108, %28
br i1 %109, label %110, label %92
110: ; preds = %92, %74, %64
%111 = phi double [ %66, %64 ], [ %34, %74 ], [ %34, %92 ]
%112 = phi double [ %73, %64 ], [ 0.000000e+00, %74 ], [ %107, %92 ]
%113 = phi i32 [ %1, %64 ], [ %16, %74 ], [ %16, %92 ]
%114 = phi double [ %72, %64 ], [ %75, %74 ], [ %75, %92 ]
%115 = tail call i64 @sin(double %111)
%116 = tail call i32 @log_conv(i64 %115)
%117 = shl nsw i32 %116, 1
%118 = sitofp i32 %117 to double
%119 = fadd double %112, %118
%120 = tail call i32 @log(i32 2)
%121 = mul nsw i32 %120, %113
%122 = tail call i32 @log_add(double %114, double %119)
%123 = add nsw i32 %121, %122
%124 = sitofp i32 %123 to double
%125 = fmul double %124, -5.000000e-01
%126 = getelementptr inbounds double, double* %2, i64 %31
store double %125, double* %126
br i1 %22, label %127, label %130
127: ; preds = %110
%128 = load double, double* %0
%129 = fadd double %125, %128
store double %129, double* %126
br label %130
130: ; preds = %110, %127
%131 = add nuw nsw i64 %31, 1
%132 = icmp eq i64 %131, %26
br i1 %132, label %133, label %30
133: ; preds = %130, %5
ret void
}