void c_calcon(int n, double *x, int ind, double *c, int *flag) {
  *flag = 0;
  if (ind == 0) {
    *c = -72.0 + x[0] + 2.0 * x[1] + 2.0 * x[2];
  } else if (ind == 1) {
    *c = -x[0] - 2.0 * x[1] - 2.0 * x[2];
  } else {
    *flag = -1;
  }
  return;
}


x86 assembly (clang, -O0):
<c_calcon>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x0,-0x14(%rbp)
jne    1169 <c_calcon+0x69>
mov    -0x10(%rbp),%rax
movsd  0xeca(%rip),%xmm0
addsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
addsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11d0 <c_calcon+0xd0>
cmpl   $0x1,-0x14(%rbp)
jne    11c1 <c_calcon+0xc1>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11cb <c_calcon+0xcb>
mov    -0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    11d0 <c_calcon+0xd0>
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_calcon>:
movl   $0x0,(%r8)
cmp    $0x1,%edx
je     113b <c_calcon+0x3b>
test   %edx,%edx
jne    115e <c_calcon+0x5e>
movsd  (%rsi),%xmm0
movsd  0x8(%rsi),%xmm1
addsd  0xee7(%rip),%xmm0
addsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rsi),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rcx)
ret
movsd  0x8(%rsi),%xmm0
mulsd  0xeb8(%rip),%xmm0
subsd  (%rsi),%xmm0
movsd  0x10(%rsi),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rcx)
ret
movl   $0xffffffff,(%r8)
ret

LLVM IR (-O0):
define void @c_calcon(i32 %0, double* %1, i32 %2, double* %3, i32* %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32*
store i32 %0, i32* %6
store double* %1, double** %7
store i32 %2, i32* %8
store double* %3, double** %9
store i32* %4, i32** %10
%11 = load i32*, i32** %10
store i32 0, i32* %11
%12 = load i32, i32* %8
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %5
%15 = load double*, double** %7
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = fadd double -7.200000e+01, %17
%19 = load double*, double** %7
%20 = getelementptr inbounds double, double* %19, i64 1
%21 = load double, double* %20
%22 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %21, double %18)
%23 = load double*, double** %7
%24 = getelementptr inbounds double, double* %23, i64 2
%25 = load double, double* %24
%26 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %25, double %22)
%27 = load double*, double** %9
store double %26, double* %27
br label %48
28: ; preds = %5
%29 = load i32, i32* %8
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %45
31: ; preds = %28
%32 = load double*, double** %7
%33 = getelementptr inbounds double, double* %32, i64 0
%34 = load double, double* %33
%35 = fneg double %34
%36 = load double*, double** %7
%37 = getelementptr inbounds double, double* %36, i64 1
%38 = load double, double* %37
%39 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %38, double %35)
%40 = load double*, double** %7
%41 = getelementptr inbounds double, double* %40, i64 2
%42 = load double, double* %41
%43 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %42, double %39)
%44 = load double*, double** %9
store double %43, double* %44
br label %47
45: ; preds = %28
%46 = load i32*, i32** %10
store i32 -1, i32* %46
br label %47
47: ; preds = %45, %31
br label %48
48: ; preds = %47, %14
ret void
}

LLVM IR (-O2):
define void @c_calcon(i32 %0, double* nocapture %1, i32 %2, double* nocapture writeonly %3, i32* nocapture writeonly %4) {
store i32 0, i32* %4
switch i32 %2, label %24 [
i32 0, label %6
i32 1, label %15
]
6: ; preds = %5
%7 = load double, double* %1
%8 = fadd double %7, -7.200000e+01
%9 = getelementptr inbounds double, double* %1, i64 1
%10 = load double, double* %9
%11 = tail call double @llvm.fmuladd.f64(double %10, double 2.000000e+00, double %8)
%12 = getelementptr inbounds double, double* %1, i64 2
%13 = load double, double* %12
%14 = tail call double @llvm.fmuladd.f64(double %13, double 2.000000e+00, double %11)
store double %14, double* %3
br label %25
15: ; preds = %5
%16 = load double, double* %1
%17 = fneg double %16
%18 = getelementptr inbounds double, double* %1, i64 1
%19 = load double, double* %18
%20 = tail call double @llvm.fmuladd.f64(double %19, double -2.000000e+00, double %17)
%21 = getelementptr inbounds double, double* %1, i64 2
%22 = load double, double* %21
%23 = tail call double @llvm.fmuladd.f64(double %22, double -2.000000e+00, double %20)
store double %23, double* %3
br label %25
24: ; preds = %5
store i32 -1, i32* %4
br label %25
25: ; preds = %15, %24, %6
ret void
}