void c_caljac(int n, double *x, int ind, int *jcvar, double *jcval, int *jcnnz,
              int lim, _Bool *lmem, int *flag) {
  *flag = 0;
  *lmem = 0;
  if (ind == 0) {
    *jcnnz = 3;
    jcvar[0] = 0;
    jcval[0] = 1.0;
    jcvar[1] = 1;
    jcval[1] = 2.0;
    jcvar[2] = 2;
    jcval[2] = 2.0;
  } else if (ind == 1) {
    *jcnnz = 3;
    jcvar[0] = 0;
    jcval[0] = -1.0;
    jcvar[1] = 1;
    jcval[1] = -2.0;
    jcvar[2] = 2;
    jcval[2] = -2.0;
  } else {
    *flag = -1;
  }
  return;
}


x86 assembly (clang, -O0):
<c_caljac>:
push   %rbp
mov    %rsp,%rbp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    0x18(%rbp),%rax
movb   $0x0,(%rax)
cmpl   $0x0,-0x14(%rbp)
jne    11a1 <c_caljac+0xa1>
mov    -0x30(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    -0x28(%rbp),%rax
movsd  0xe95(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
movl   $0x2,0x8(%rax)
mov    -0x28(%rbp),%rax
movsd  0xe79(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
jmp    121b <c_caljac+0x11b>
cmpl   $0x1,-0x14(%rbp)
jne    120c <c_caljac+0x10c>
mov    -0x30(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xe3d(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    -0x28(%rbp),%rax
movsd  0xe1a(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
movl   $0x2,0x8(%rax)
mov    -0x28(%rbp),%rax
movsd  0xdfe(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
jmp    1216 <c_caljac+0x116>
mov    0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    121b <c_caljac+0x11b>
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_caljac>:
mov    0x18(%rsp),%rax
mov    0x10(%rsp),%rsi
movl   $0x0,(%rax)
movb   $0x0,(%rsi)
cmp    $0x1,%edx
je     1151 <c_caljac+0x51>
test   %edx,%edx
jne    1186 <c_caljac+0x86>
movl   $0x3,(%r9)
movabs $0x100000000,%rax
mov    %rax,(%rcx)
movaps 0xed9(%rip),%xmm0
movups %xmm0,(%r8)
movl   $0x2,0x8(%rcx)
movabs $0x4000000000000000,%rax
mov    %rax,0x10(%r8)
ret
movl   $0x3,(%r9)
movabs $0x100000000,%rax
mov    %rax,(%rcx)
movaps 0xe94(%rip),%xmm0
movups %xmm0,(%r8)
movl   $0x2,0x8(%rcx)
movabs $0xc000000000000000,%rax
mov    %rax,0x10(%r8)
ret
movl   $0xffffffff,(%rax)
ret

LLVM IR (-O0):
define void @c_caljac(i32 %0, double* %1, i32 %2, i32* %3, double* %4, i32* %5, i32 %6, i8* %7, i32* %8) {
%10 = alloca i32
%11 = alloca double*
%12 = alloca i32
%13 = alloca i32*
%14 = alloca double*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i32*
store i32 %0, i32* %10
store double* %1, double** %11
store i32 %2, i32* %12
store i32* %3, i32** %13
store double* %4, double** %14
store i32* %5, i32** %15
store i32 %6, i32* %16
store i8* %7, i8** %17
store i32* %8, i32** %18
%19 = load i32*, i32** %18
store i32 0, i32* %19
%20 = load i8*, i8** %17
store i8 0, i8* %20
%21 = load i32, i32* %12
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %37
23: ; preds = %9
%24 = load i32*, i32** %15
store i32 3, i32* %24
%25 = load i32*, i32** %13
%26 = getelementptr inbounds i32, i32* %25, i64 0
store i32 0, i32* %26
%27 = load double*, double** %14
%28 = getelementptr inbounds double, double* %27, i64 0
store double 1.000000e+00, double* %28
%29 = load i32*, i32** %13
%30 = getelementptr inbounds i32, i32* %29, i64 1
store i32 1, i32* %30
%31 = load double*, double** %14
%32 = getelementptr inbounds double, double* %31, i64 1
store double 2.000000e+00, double* %32
%33 = load i32*, i32** %13
%34 = getelementptr inbounds i32, i32* %33, i64 2
store i32 2, i32* %34
%35 = load double*, double** %14
%36 = getelementptr inbounds double, double* %35, i64 2
store double 2.000000e+00, double* %36
br label %57
37: ; preds = %9
%38 = load i32, i32* %12
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %54
40: ; preds = %37
%41 = load i32*, i32** %15
store i32 3, i32* %41
%42 = load i32*, i32** %13
%43 = getelementptr inbounds i32, i32* %42, i64 0
store i32 0, i32* %43
%44 = load double*, double** %14
%45 = getelementptr inbounds double, double* %44, i64 0
store double -1.000000e+00, double* %45
%46 = load i32*, i32** %13
%47 = getelementptr inbounds i32, i32* %46, i64 1
store i32 1, i32* %47
%48 = load double*, double** %14
%49 = getelementptr inbounds double, double* %48, i64 1
store double -2.000000e+00, double* %49
%50 = load i32*, i32** %13
%51 = getelementptr inbounds i32, i32* %50, i64 2
store i32 2, i32* %51
%52 = load double*, double** %14
%53 = getelementptr inbounds double, double* %52, i64 2
store double -2.000000e+00, double* %53
br label %56
54: ; preds = %37
%55 = load i32*, i32** %18
store i32 -1, i32* %55
br label %56
56: ; preds = %54, %40
br label %57
57: ; preds = %56, %23
ret void
}

LLVM IR (-O2):
define void @c_caljac(i32 %0, double* nocapture readnone %1, i32 %2, i32* nocapture writeonly %3, double* nocapture writeonly %4, i32* nocapture writeonly %5, i32 %6, i8* nocapture writeonly %7, i32* nocapture writeonly %8) {
store i32 0, i32* %8
store i8 0, i8* %7
switch i32 %2, label %20 [
i32 0, label %10
i32 1, label %15
]
10: ; preds = %9
store i32 3, i32* %5
store i32 0, i32* %3
%11 = getelementptr inbounds i32, i32* %3, i64 1
store i32 1, i32* %11
%12 = bitcast double* %4 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 2.000000e+00>, <2 x double>* %12
%13 = getelementptr inbounds i32, i32* %3, i64 2
store i32 2, i32* %13
%14 = getelementptr inbounds double, double* %4, i64 2
store double 2.000000e+00, double* %14
br label %21
15: ; preds = %9
store i32 3, i32* %5
store i32 0, i32* %3
%16 = getelementptr inbounds i32, i32* %3, i64 1
store i32 1, i32* %16
%17 = bitcast double* %4 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -2.000000e+00>, <2 x double>* %17
%18 = getelementptr inbounds i32, i32* %3, i64 2
store i32 2, i32* %18
%19 = getelementptr inbounds double, double* %4, i64 2
store double -2.000000e+00, double* %19
br label %21
20: ; preds = %9
store i32 -1, i32* %8
br label %21
21: ; preds = %15, %20, %10
ret void
}