#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 */
void coef_deriv_p(size_t axis, const double *coef, double *der) {
  switch (axis) {
  case 0:
    der[0] = 0.0;
    der[1] = coef[2];
    der[2] = -coef[1];
    break;
  case 1:
    der[0] = -coef[2];
    der[1] = 0.0;
    der[2] = coef[0];
    break;
  case 2:
    der[0] = coef[1];
    der[1] = -coef[0];
    der[2] = 0.0;
    break;
  };
}


x86 assembly (clang, -O0):
<coef_deriv_p>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
test   %rax,%rax
je     114c <coef_deriv_p+0x4c>
jmp    1126 <coef_deriv_p+0x26>
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
je     1197 <coef_deriv_p+0x97>
jmp    1139 <coef_deriv_p+0x39>
mov    -0x20(%rbp),%rax
sub    $0x2,%rax
je     11e1 <coef_deriv_p+0xe1>
jmp    1226 <coef_deriv_p+0x126>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1226 <coef_deriv_p+0x126>
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1226 <coef_deriv_p+0x126>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<coef_deriv_p>:
cmp    $0x2,%rdi
je     1130 <coef_deriv_p+0x30>
cmp    $0x1,%rdi
je     114d <coef_deriv_p+0x4d>
test   %rdi,%rdi
jne    116d <coef_deriv_p+0x6d>
movq   $0x0,(%rdx)
movsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x8(%rdx)
movsd  0x8(%rsi),%xmm0
xorps  0xed2(%rip),%xmm0
jmp    1168 <coef_deriv_p+0x68>
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,(%rdx)
movsd  (%rsi),%xmm0
xorps  0xebc(%rip),%xmm0
movlps %xmm0,0x8(%rdx)
xorps  %xmm0,%xmm0
jmp    1168 <coef_deriv_p+0x68>
movsd  0x10(%rsi),%xmm0
xorps  0xea7(%rip),%xmm0
movlps %xmm0,(%rdx)
movq   $0x0,0x8(%rdx)
movsd  (%rsi),%xmm0
movsd  %xmm0,0x10(%rdx)
ret

LLVM IR (-O0):
define void @coef_deriv_p(i64 %0, double* %1, double* %2) {
%4 = alloca i64
%5 = alloca double*
%6 = alloca double*
store i64 %0, i64* %4
store double* %1, double** %5
store double* %2, double** %6
%7 = load i64, i64* %4
switch i64 %7, label %50 [
i64 0, label %8
i64 1, label %22
i64 2, label %36
]
8: ; preds = %3
%9 = load double*, double** %6
%10 = getelementptr inbounds double, double* %9, i64 0
store double 0.000000e+00, double* %10
%11 = load double*, double** %5
%12 = getelementptr inbounds double, double* %11, i64 2
%13 = load double, double* %12
%14 = load double*, double** %6
%15 = getelementptr inbounds double, double* %14, i64 1
store double %13, double* %15
%16 = load double*, double** %5
%17 = getelementptr inbounds double, double* %16, i64 1
%18 = load double, double* %17
%19 = fneg double %18
%20 = load double*, double** %6
%21 = getelementptr inbounds double, double* %20, i64 2
store double %19, double* %21
br label %50
22: ; preds = %3
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 2
%25 = load double, double* %24
%26 = fneg double %25
%27 = load double*, double** %6
%28 = getelementptr inbounds double, double* %27, i64 0
store double %26, double* %28
%29 = load double*, double** %6
%30 = getelementptr inbounds double, double* %29, i64 1
store double 0.000000e+00, double* %30
%31 = load double*, double** %5
%32 = getelementptr inbounds double, double* %31, i64 0
%33 = load double, double* %32
%34 = load double*, double** %6
%35 = getelementptr inbounds double, double* %34, i64 2
store double %33, double* %35
br label %50
36: ; preds = %3
%37 = load double*, double** %5
%38 = getelementptr inbounds double, double* %37, i64 1
%39 = load double, double* %38
%40 = load double*, double** %6
%41 = getelementptr inbounds double, double* %40, i64 0
store double %39, double* %41
%42 = load double*, double** %5
%43 = getelementptr inbounds double, double* %42, i64 0
%44 = load double, double* %43
%45 = fneg double %44
%46 = load double*, double** %6
%47 = getelementptr inbounds double, double* %46, i64 1
store double %45, double* %47
%48 = load double*, double** %6
%49 = getelementptr inbounds double, double* %48, i64 2
store double 0.000000e+00, double* %49
br label %50
50: ; preds = %3, %36, %22, %8
ret void
}

LLVM IR (-O2):
define void @coef_deriv_p(i64 %0, double* nocapture %1, double* nocapture writeonly %2) {
switch i64 %0, label %26 [
i64 0, label %4
i64 1, label %11
i64 2, label %17
]
4: ; preds = %3
store double 0.000000e+00, double* %2
%5 = getelementptr inbounds double, double* %1, i64 2
%6 = load double, double* %5
%7 = getelementptr inbounds double, double* %2, i64 1
store double %6, double* %7
%8 = getelementptr inbounds double, double* %1, i64 1
%9 = load double, double* %8
%10 = fneg double %9
br label %23
11: ; preds = %3
%12 = getelementptr inbounds double, double* %1, i64 2
%13 = load double, double* %12
%14 = fneg double %13
store double %14, double* %2
%15 = getelementptr inbounds double, double* %2, i64 1
store double 0.000000e+00, double* %15
%16 = load double, double* %1
br label %23
17: ; preds = %3
%18 = getelementptr inbounds double, double* %1, i64 1
%19 = load double, double* %18
store double %19, double* %2
%20 = load double, double* %1
%21 = fneg double %20
%22 = getelementptr inbounds double, double* %2, i64 1
store double %21, double* %22
br label %23
23: ; preds = %4, %11, %17
%24 = phi double [ 0.000000e+00, %17 ], [ %16, %11 ], [ %10, %4 ]
%25 = getelementptr inbounds double, double* %2, i64 2
store double %24, double* %25
br label %26
26: ; preds = %23, %3
ret void
}