#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 sqrt(double);
void coef_deriv_d(size_t axis, const double *coef, double *der) {
  const double sqrt3 = sqrt(3.0);
  switch (axis) {
  case 0:
    der[0] = 0.0;
    der[1] = sqrt3 * coef[5];
    der[2] = -sqrt3 * coef[5];
    der[3] = coef[4];
    der[4] = -coef[3];
    der[5] = 2.0 / sqrt3 * (coef[2] - coef[1]);
    break;
  case 1:
    der[0] = -sqrt3 * coef[4];
    der[1] = 0.0;
    der[2] = sqrt3 * coef[4];
    der[3] = -coef[5];
    der[4] = 2.0 / sqrt3 * (coef[0] - coef[2]);
    der[5] = coef[3];
    break;
  case 2:
    der[0] = sqrt3 * coef[3];
    der[1] = -sqrt3 * coef[3];
    der[2] = 0.0;
    der[3] = 2.0 / sqrt3 * (coef[1] - coef[0]);
    der[4] = coef[5];
    der[5] = -coef[4];
    break;
  };
}


x86 assembly (clang, -O0):
<coef_deriv_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  0xed4(%rip),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
test   %rax,%rax
je     1172 <coef_deriv_d+0x62>
jmp    114c <coef_deriv_d+0x3c>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
je     122e <coef_deriv_d+0x11e>
jmp    115f <coef_deriv_d+0x4f>
mov    -0x28(%rbp),%rax
sub    $0x2,%rax
je     12e9 <coef_deriv_d+0x1d9>
jmp    139f <coef_deriv_d+0x28f>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x28(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x28(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  0xe03(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x28(%rax)
jmp    139f <coef_deriv_d+0x28f>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x20(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x20(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  0xd59(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  0x10(%rax),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x28(%rax)
jmp    139f <coef_deriv_d+0x28f>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x18(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x18(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
movsd  0xcc7(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x28(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<coef_deriv_d>:
cmp    $0x2,%rdi
je     1175 <coef_deriv_d+0x75>
cmp    $0x1,%rdi
je     11cf <coef_deriv_d+0xcf>
test   %rdi,%rdi
jne    122a <coef_deriv_d+0x12a>
movq   $0x0,(%rdx)
movsd  0x28(%rsi),%xmm0
mulsd  0xed3(%rip),%xmm0
movsd  %xmm0,0x8(%rdx)
movsd  0x28(%rsi),%xmm0
mulsd  0xec9(%rip),%xmm0
movsd  %xmm0,0x10(%rdx)
movsd  0x20(%rsi),%xmm0
movsd  %xmm0,0x18(%rdx)
movsd  0x18(%rsi),%xmm0
xorps  0xec6(%rip),%xmm0
movlps %xmm0,0x20(%rdx)
movsd  0x10(%rsi),%xmm0
subsd  0x8(%rsi),%xmm0
mulsd  0xea0(%rip),%xmm0
jmp    1225 <coef_deriv_d+0x125>
movsd  0x18(%rsi),%xmm0
mulsd  0xe7e(%rip),%xmm0
movsd  %xmm0,(%rdx)
movsd  0x18(%rsi),%xmm0
mulsd  0xe75(%rip),%xmm0
movsd  %xmm0,0x8(%rdx)
movq   $0x0,0x10(%rdx)
movsd  0x8(%rsi),%xmm0
subsd  (%rsi),%xmm0
mulsd  0xe5f(%rip),%xmm0
movsd  %xmm0,0x18(%rdx)
movsd  0x28(%rsi),%xmm0
movsd  %xmm0,0x20(%rdx)
movsd  0x20(%rsi),%xmm0
xorpd  0xe53(%rip),%xmm0
jmp    1225 <coef_deriv_d+0x125>
movsd  0x20(%rsi),%xmm0
mulsd  0xe2c(%rip),%xmm0
movsd  %xmm0,(%rdx)
movq   $0x0,0x8(%rdx)
movsd  0x20(%rsi),%xmm0
mulsd  0xe0b(%rip),%xmm0
movsd  %xmm0,0x10(%rdx)
movsd  0x28(%rsi),%xmm0
xorps  0xe1a(%rip),%xmm0
movlps %xmm0,0x18(%rdx)
movsd  (%rsi),%xmm0
subsd  0x10(%rsi),%xmm0
mulsd  0xdf5(%rip),%xmm0
movsd  %xmm0,0x20(%rdx)
movsd  0x18(%rsi),%xmm0
movsd  %xmm0,0x28(%rdx)
ret

LLVM IR (-O0):
define void @coef_deriv_d(i64 %0, double* %1, double* %2) {
%4 = alloca i64
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
store i64 %0, i64* %4
store double* %1, double** %5
store double* %2, double** %6
%8 = call double @sqrt(double 3.000000e+00)
store double %8, double* %7
%9 = load i64, i64* %4
switch i64 %9, label %133 [
i64 0, label %10
i64 1, label %51
i64 2, label %92
]
10: ; preds = %3
%11 = load double*, double** %6
%12 = getelementptr inbounds double, double* %11, i64 0
store double 0.000000e+00, double* %12
%13 = load double, double* %7
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i64 5
%16 = load double, double* %15
%17 = fmul double %13, %16
%18 = load double*, double** %6
%19 = getelementptr inbounds double, double* %18, i64 1
store double %17, double* %19
%20 = load double, double* %7
%21 = fneg double %20
%22 = load double*, double** %5
%23 = getelementptr inbounds double, double* %22, i64 5
%24 = load double, double* %23
%25 = fmul double %21, %24
%26 = load double*, double** %6
%27 = getelementptr inbounds double, double* %26, i64 2
store double %25, double* %27
%28 = load double*, double** %5
%29 = getelementptr inbounds double, double* %28, i64 4
%30 = load double, double* %29
%31 = load double*, double** %6
%32 = getelementptr inbounds double, double* %31, i64 3
store double %30, double* %32
%33 = load double*, double** %5
%34 = getelementptr inbounds double, double* %33, i64 3
%35 = load double, double* %34
%36 = fneg double %35
%37 = load double*, double** %6
%38 = getelementptr inbounds double, double* %37, i64 4
store double %36, double* %38
%39 = load double, double* %7
%40 = fdiv double 2.000000e+00, %39
%41 = load double*, double** %5
%42 = getelementptr inbounds double, double* %41, i64 2
%43 = load double, double* %42
%44 = load double*, double** %5
%45 = getelementptr inbounds double, double* %44, i64 1
%46 = load double, double* %45
%47 = fsub double %43, %46
%48 = fmul double %40, %47
%49 = load double*, double** %6
%50 = getelementptr inbounds double, double* %49, i64 5
store double %48, double* %50
br label %133
51: ; preds = %3
%52 = load double, double* %7
%53 = fneg double %52
%54 = load double*, double** %5
%55 = getelementptr inbounds double, double* %54, i64 4
%56 = load double, double* %55
%57 = fmul double %53, %56
%58 = load double*, double** %6
%59 = getelementptr inbounds double, double* %58, i64 0
store double %57, double* %59
%60 = load double*, double** %6
%61 = getelementptr inbounds double, double* %60, i64 1
store double 0.000000e+00, double* %61
%62 = load double, double* %7
%63 = load double*, double** %5
%64 = getelementptr inbounds double, double* %63, i64 4
%65 = load double, double* %64
%66 = fmul double %62, %65
%67 = load double*, double** %6
%68 = getelementptr inbounds double, double* %67, i64 2
store double %66, double* %68
%69 = load double*, double** %5
%70 = getelementptr inbounds double, double* %69, i64 5
%71 = load double, double* %70
%72 = fneg double %71
%73 = load double*, double** %6
%74 = getelementptr inbounds double, double* %73, i64 3
store double %72, double* %74
%75 = load double, double* %7
%76 = fdiv double 2.000000e+00, %75
%77 = load double*, double** %5
%78 = getelementptr inbounds double, double* %77, i64 0
%79 = load double, double* %78
%80 = load double*, double** %5
%81 = getelementptr inbounds double, double* %80, i64 2
%82 = load double, double* %81
%83 = fsub double %79, %82
%84 = fmul double %76, %83
%85 = load double*, double** %6
%86 = getelementptr inbounds double, double* %85, i64 4
store double %84, double* %86
%87 = load double*, double** %5
%88 = getelementptr inbounds double, double* %87, i64 3
%89 = load double, double* %88
%90 = load double*, double** %6
%91 = getelementptr inbounds double, double* %90, i64 5
store double %89, double* %91
br label %133
92: ; preds = %3
%93 = load double, double* %7
%94 = load double*, double** %5
%95 = getelementptr inbounds double, double* %94, i64 3
%96 = load double, double* %95
%97 = fmul double %93, %96
%98 = load double*, double** %6
%99 = getelementptr inbounds double, double* %98, i64 0
store double %97, double* %99
%100 = load double, double* %7
%101 = fneg double %100
%102 = load double*, double** %5
%103 = getelementptr inbounds double, double* %102, i64 3
%104 = load double, double* %103
%105 = fmul double %101, %104
%106 = load double*, double** %6
%107 = getelementptr inbounds double, double* %106, i64 1
store double %105, double* %107
%108 = load double*, double** %6
%109 = getelementptr inbounds double, double* %108, i64 2
store double 0.000000e+00, double* %109
%110 = load double, double* %7
%111 = fdiv double 2.000000e+00, %110
%112 = load double*, double** %5
%113 = getelementptr inbounds double, double* %112, i64 1
%114 = load double, double* %113
%115 = load double*, double** %5
%116 = getelementptr inbounds double, double* %115, i64 0
%117 = load double, double* %116
%118 = fsub double %114, %117
%119 = fmul double %111, %118
%120 = load double*, double** %6
%121 = getelementptr inbounds double, double* %120, i64 3
store double %119, double* %121
%122 = load double*, double** %5
%123 = getelementptr inbounds double, double* %122, i64 5
%124 = load double, double* %123
%125 = load double*, double** %6
%126 = getelementptr inbounds double, double* %125, i64 4
store double %124, double* %126
%127 = load double*, double** %5
%128 = getelementptr inbounds double, double* %127, i64 4
%129 = load double, double* %128
%130 = fneg double %129
%131 = load double*, double** %6
%132 = getelementptr inbounds double, double* %131, i64 5
store double %130, double* %132
br label %133
133: ; preds = %3, %92, %51, %10
ret void
}

LLVM IR (-O2):
define void @coef_deriv_d(i64 %0, double* nocapture %1, double* nocapture writeonly %2) {
switch i64 %0, label %68 [
i64 0, label %4
i64 1, label %25
i64 2, label %45
]
4: ; preds = %3
store double 0.000000e+00, double* %2
%5 = getelementptr inbounds double, double* %1, i64 5
%6 = load double, double* %5
%7 = fmul double %6, 0x3FFBB67AE8584CAA
%8 = getelementptr inbounds double, double* %2, i64 1
store double %7, double* %8
%9 = load double, double* %5
%10 = fmul double %9, 0xBFFBB67AE8584CAA
%11 = getelementptr inbounds double, double* %2, i64 2
store double %10, double* %11
%12 = getelementptr inbounds double, double* %1, i64 4
%13 = load double, double* %12
%14 = getelementptr inbounds double, double* %2, i64 3
store double %13, double* %14
%15 = getelementptr inbounds double, double* %1, i64 3
%16 = load double, double* %15
%17 = fneg double %16
%18 = getelementptr inbounds double, double* %2, i64 4
store double %17, double* %18
%19 = getelementptr inbounds double, double* %1, i64 2
%20 = load double, double* %19
%21 = getelementptr inbounds double, double* %1, i64 1
%22 = load double, double* %21
%23 = fsub double %20, %22
%24 = fmul double %23, 0x3FF279A74590331D
br label %65
25: ; preds = %3
%26 = getelementptr inbounds double, double* %1, i64 4
%27 = load double, double* %26
%28 = fmul double %27, 0xBFFBB67AE8584CAA
store double %28, double* %2
%29 = getelementptr inbounds double, double* %2, i64 1
store double 0.000000e+00, double* %29
%30 = load double, double* %26
%31 = fmul double %30, 0x3FFBB67AE8584CAA
%32 = getelementptr inbounds double, double* %2, i64 2
store double %31, double* %32
%33 = getelementptr inbounds double, double* %1, i64 5
%34 = load double, double* %33
%35 = fneg double %34
%36 = getelementptr inbounds double, double* %2, i64 3
store double %35, double* %36
%37 = load double, double* %1
%38 = getelementptr inbounds double, double* %1, i64 2
%39 = load double, double* %38
%40 = fsub double %37, %39
%41 = fmul double %40, 0x3FF279A74590331D
%42 = getelementptr inbounds double, double* %2, i64 4
store double %41, double* %42
%43 = getelementptr inbounds double, double* %1, i64 3
%44 = load double, double* %43
br label %65
45: ; preds = %3
%46 = getelementptr inbounds double, double* %1, i64 3
%47 = load double, double* %46
%48 = fmul double %47, 0x3FFBB67AE8584CAA
store double %48, double* %2
%49 = load double, double* %46
%50 = fmul double %49, 0xBFFBB67AE8584CAA
%51 = getelementptr inbounds double, double* %2, i64 1
store double %50, double* %51
%52 = getelementptr inbounds double, double* %2, i64 2
store double 0.000000e+00, double* %52
%53 = getelementptr inbounds double, double* %1, i64 1
%54 = load double, double* %53
%55 = load double, double* %1
%56 = fsub double %54, %55
%57 = fmul double %56, 0x3FF279A74590331D
%58 = getelementptr inbounds double, double* %2, i64 3
store double %57, double* %58
%59 = getelementptr inbounds double, double* %1, i64 5
%60 = load double, double* %59
%61 = getelementptr inbounds double, double* %2, i64 4
store double %60, double* %61
%62 = getelementptr inbounds double, double* %1, i64 4
%63 = load double, double* %62
%64 = fneg double %63
br label %65
65: ; preds = %4, %25, %45
%66 = phi double [ %64, %45 ], [ %44, %25 ], [ %24, %4 ]
%67 = getelementptr inbounds double, double* %2, i64 5
store double %66, double* %67
br label %68
68: ; preds = %65, %3
ret void
}