#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);
double pow(double, double);
double sin(double);
double deriv2(double *param, int dimension, int functiontype, double x) {
  int i;
  double second_derivate = 0;
  switch (functiontype) {
  case 1: {
    int len1 = (dimension - 1);
    double D[len1];
    int len2 = (dimension - 2);
    double DD[len2];
    for (i = 0; i <= len1; i++) {
      D[i] = param[i + 1] * (i + 1);
    }
    for (i = 0; i <= len2; i++) {
      DD[i] = D[i + 1] * (i + 1);
    }
    for (i = 0; i <= len2; i++) {
      second_derivate += DD[i] * (pow(x, i));
    }
    break;
  }
  case 2: {
    double a = param[0];
    double b = param[1];
    double n = param[2];
    second_derivate =
        a * (pow(2.7182818284, x)) + b * n * (n - 1) * (pow(x, (n - 2)));
    break;
  }
  case 3: {
    double A = param[0];
    double m = param[1];
    double t = param[2];
    double B = param[3];
    double n = param[4];
    double p = param[5];
    second_derivate = -A * m * m * sin(m * x + t) - B * n * n * cos(n * x + p);
    break;
  }
  }
  return second_derivate;
}


x86 assembly (clang, -O0):
<deriv2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x9c(%rbp)
sub    $0x1,%eax
je     1191 <deriv2+0x61>
jmp    1169 <deriv2+0x39>
mov    -0x9c(%rbp),%eax
sub    $0x2,%eax
je     1306 <deriv2+0x1d6>
jmp    117d <deriv2+0x4d>
mov    -0x9c(%rbp),%eax
sub    $0x3,%eax
je     13c9 <deriv2+0x299>
jmp    14fc <deriv2+0x3cc>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
add    $0xfffffffe,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     1241 <deriv2+0x111>
mov    -0xb0(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movsd  (%rcx,%rdx,8),%xmm0
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
cvtsi2sd %ecx,%xmm1
mulsd  %xmm1,%xmm0
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f7 <deriv2+0xc7>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jg     1295 <deriv2+0x165>
mov    -0xa8(%rbp),%rax
mov    -0xb0(%rbp),%rcx
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movsd  (%rcx,%rdx,8),%xmm0
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
cvtsi2sd %ecx,%xmm1
mulsd  %xmm1,%xmm0
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1248 <deriv2+0x118>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jg     12fa <deriv2+0x1ca>
mov    -0xa8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0xb8(%rbp),%xmm0
ff
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    129c <deriv2+0x16c>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
jmp    14fc <deriv2+0x3cc>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x18(%rbp),%xmm1
movsd  0xcc7(%rip),%xmm0
call   1050 <pow@plt>
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  0xc9b(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  0xc71(%rip),%xmm2
subsd  %xmm2,%xmm1
call   1050 <pow@plt>
movsd  -0xd0(%rbp),%xmm1
ff
movsd  -0xc8(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xc0(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    14fc <deriv2+0x3cc>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x78(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x80(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
mulsd  -0x90(%rbp),%xmm0
ff
mulsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x18(%rbp),%xmm2
movsd  -0x98(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <cos@plt>
movsd  -0xe8(%rbp),%xmm1
ff
movsd  -0xe0(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xd8(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deriv2>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movapd %xmm0,%xmm9
cmp    $0x3,%edx
je     11b4 <deriv2+0x84>
cmp    $0x2,%edx
je     123e <deriv2+0x10e>
xorpd  %xmm2,%xmm2
cmp    $0x1,%edx
jne    159c <deriv2+0x46c>
mov    %rsp,%r14
lea    -0x1(%rsi),%r15d
mov    %rsp,%rax
lea    0xf(,%r15,8),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rax
mov    %rax,%rsp
lea    -0x2(%rsi),%ecx
mov    %rsp,%r12
lea    0xf(,%rcx,8),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r12
mov    %r12,%rsp
xorpd  %xmm2,%xmm2
test   %esi,%esi
jle    1599 <deriv2+0x469>
mov    %esi,%r8d
cmp    $0x4,%esi
jae    12c1 <deriv2+0x191>
xor    %edx,%edx
jmp    1360 <deriv2+0x230>
movsd  0x8(%rdi),%xmm0
movsd  0x20(%rdi),%xmm3
movsd  (%rdi),%xmm2
xorpd  0xe36(%rip),%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm2,-0x50(%rbp)
mulsd  %xmm9,%xmm0
addsd  0x10(%rdi),%xmm0
movapd %xmm3,%xmm2
movsd  %xmm3,-0x30(%rbp)
mulsd  %xmm3,%xmm9
addsd  0x28(%rdi),%xmm9
movsd  %xmm9,-0x38(%rbp)
movsd  0x18(%rdi),%xmm3
mulsd  %xmm2,%xmm3
movsd  %xmm3,-0x58(%rbp)
call   1030 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x58(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
subsd  %xmm1,%xmm0
jmp    15a0 <deriv2+0x470>
movsd  (%rdi),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0x10(%rdi),%xmm2
movsd  %xmm2,-0x60(%rbp)
movsd  0x8(%rdi),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xdd9(%rip),%xmm0
movsd  %xmm9,-0x38(%rbp)
movapd %xmm9,%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xdc4(%rip),%xmm0
movsd  -0x60(%rbp),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
addsd  0xdb1(%rip),%xmm1
movsd  -0x38(%rbp),%xmm0
call   1050 <pow@plt>
mulsd  -0x58(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
addsd  %xmm1,%xmm0
jmp    15a0 <deriv2+0x470>
mov    %r8d,%edx
and    $0xfffffffc,%edx
xor    %ebx,%ebx
movdqa 0xd3e(%rip),%xmm8
movdqa 0xd45(%rip),%xmm10
movdqa 0xd4d(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movq   %rbx,%xmm3
pshufd $0x44,%xmm3,%xmm4
movdqa %xmm4,%xmm5
por    %xmm8,%xmm5
por    %xmm10,%xmm3
paddq  %xmm1,%xmm4
movq   %xmm5,%rcx
movupd (%rdi,%rcx,8),%xmm6
movupd 0x10(%rdi,%rcx,8),%xmm7
pshufd $0xfa,%xmm5,%xmm5
movd   %ecx,%xmm0
movss  %xmm0,%xmm5
pshufd $0xee,%xmm4,%xmm0
punpckldq %xmm0,%xmm3
cvtdq2pd %xmm5,%xmm0
mulpd  %xmm6,%xmm0
cvtdq2pd %xmm3,%xmm3
mulpd  %xmm7,%xmm3
movapd %xmm0,(%rax,%rbx,8)
movapd %xmm3,0x10(%rax,%rbx,8)
add    $0x4,%rbx
cmp    %rbx,%rdx
jne    12f0 <deriv2+0x1c0>
cmp    %r8,%rdx
je     137e <deriv2+0x24e>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rdx),%rcx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  0x8(%rdi,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
mov    %rcx,%rdx
cmp    %rcx,%r8
jne    1360 <deriv2+0x230>
cmp    $0x2,%esi
jl     1599 <deriv2+0x469>
cmp    $0x4,%r15d
jae    1394 <deriv2+0x264>
xor    %ecx,%ecx
jmp    1430 <deriv2+0x300>
mov    %r15d,%ecx
and    $0xfffffffc,%ecx
xor    %edx,%edx
movdqa 0xc6b(%rip),%xmm8
movdqa 0xc72(%rip),%xmm10
movdqa 0xc7a(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
movq   %rdx,%xmm3
pshufd $0x44,%xmm3,%xmm4
movdqa %xmm4,%xmm5
por    %xmm8,%xmm5
por    %xmm10,%xmm3
paddq  %xmm1,%xmm4
movq   %xmm5,%rdi
movupd (%rax,%rdi,8),%xmm6
movupd 0x10(%rax,%rdi,8),%xmm7
pshufd $0xfa,%xmm5,%xmm5
movd   %edi,%xmm0
movss  %xmm0,%xmm5
pshufd $0xee,%xmm4,%xmm0
punpckldq %xmm0,%xmm3
cvtdq2pd %xmm5,%xmm0
mulpd  %xmm6,%xmm0
cvtdq2pd %xmm3,%xmm3
mulpd  %xmm7,%xmm3
movapd %xmm0,(%r12,%rdx,8)
movapd %xmm3,0x10(%r12,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%rcx
jne    13c0 <deriv2+0x290>
cmp    %r15,%rcx
je     144f <deriv2+0x31f>
nopl   (%rax)
lea    0x1(%rcx),%rdx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
mulsd  0x8(%rax,%rcx,8),%xmm0
movsd  %xmm0,(%r12,%rcx,8)
mov    %rdx,%rcx
cmp    %rdx,%r15
jne    1430 <deriv2+0x300>
cmp    $0x2,%esi
jl     1599 <deriv2+0x469>
movsd  %xmm9,-0x38(%rbp)
lea    -0x1(%r15),%rax
mov    %r15d,%r13d
and    $0x3,%r13d
cmp    $0x3,%rax
jae    147a <deriv2+0x34a>
xorpd  %xmm2,%xmm2
xor    %ebx,%ebx
jmp    1559 <deriv2+0x429>
and    $0xfffffffc,%r15d
xorpd  %xmm2,%xmm2
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm2,-0x50(%rbp)
movsd  (%r12,%rbx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  -0x38(%rbp),%xmm0
call   1050 <pow@plt>
mulsd  -0x30(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0x8(%r12,%rbx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0x1(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  -0x38(%rbp),%xmm0
call   1050 <pow@plt>
mulsd  -0x30(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0x10(%r12,%rbx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0x2(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  -0x38(%rbp),%xmm0
call   1050 <pow@plt>
mulsd  -0x30(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0x18(%r12,%rbx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0x3(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  -0x38(%rbp),%xmm0
call   1050 <pow@plt>
movapd %xmm0,%xmm2
mulsd  -0x30(%rbp),%xmm2
addsd  -0x50(%rbp),%xmm2
add    $0x4,%rbx
cmp    %r15,%rbx
jne    1490 <deriv2+0x360>
test   %r13,%r13
je     1599 <deriv2+0x469>
xchg   %ax,%ax
movsd  %xmm2,-0x50(%rbp)
movsd  (%r12,%rbx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  -0x38(%rbp),%xmm0
call   1050 <pow@plt>
movsd  -0x50(%rbp),%xmm2
mulsd  -0x30(%rbp),%xmm0
addsd  %xmm0,%xmm2
add    $0x1,%rbx
add    $0xffffffffffffffff,%r13
jne    1560 <deriv2+0x430>
mov    %r14,%rsp
movapd %xmm2,%xmm0
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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