#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 exp(double);
int exponential_residual(void *user_data, double **parameters,
                         double *residuals, double **jacobians) {
  double *measurement = (double *)user_data;
  double x = measurement[0];
  double y = measurement[1];
  double m = parameters[0][0];
  double c = parameters[1][0];
  residuals[0] = y - exp(m * x + c);
  if (jacobians == NULL) {
    return 1;
  }
  if (jacobians[0] != NULL) {
    jacobians[0][0] = -x * exp(m * x + c);
  }
  if (jacobians[1] != NULL) {
    jacobians[1][0] = -exp(m * x + c);
  }
  return 1;
}


x86 assembly (clang, -O0):
<exponential_residual>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x30(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
subsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,-0x28(%rbp)
jne    11bd <exponential_residual+0xad>
movl   $0x1,-0x4(%rbp)
jmp    1274 <exponential_residual+0x164>
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     121f <exponential_residual+0x10f>
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     126d <exponential_residual+0x15d>
movsd  -0x48(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <exp@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exponential_residual>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    (%rsi),%rax
mov    0x8(%rsi),%rcx
movsd  (%rax),%xmm0
movapd %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm0
addsd  (%rcx),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <exp@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
test   %rbx,%rbx
je     11b5 <exponential_residual+0xa5>
cmpq   $0x0,(%rbx)
je     1193 <exponential_residual+0x83>
movaps 0x10(%rsp),%xmm0
xorps  0xe8a(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <exp@plt>
mulsd  0x10(%rsp),%xmm0
mov    (%rbx),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,0x8(%rbx)
je     11b5 <exponential_residual+0xa5>
movsd  0x8(%rsp),%xmm0
call   1030 <exp@plt>
xorpd  0xe53(%rip),%xmm0
mov    0x8(%rbx),%rax
movlpd %xmm0,(%rax)
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @exponential_residual(i8* %0, double** %1, double* %2, double** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca double**
%8 = alloca double*
%9 = alloca double**
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store i8* %0, i8** %6
store double** %1, double*** %7
store double* %2, double** %8
store double** %3, double*** %9
%15 = load i8*, i8** %6
%16 = bitcast i8* %15 to double*
store double* %16, double** %10
%17 = load double*, double** %10
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
store double %19, double* %11
%20 = load double*, double** %10
%21 = getelementptr inbounds double, double* %20, i64 1
%22 = load double, double* %21
store double %22, double* %12
%23 = load double**, double*** %7
%24 = getelementptr inbounds double*, double** %23, i64 0
%25 = load double*, double** %24
%26 = getelementptr inbounds double, double* %25, i64 0
%27 = load double, double* %26
store double %27, double* %13
%28 = load double**, double*** %7
%29 = getelementptr inbounds double*, double** %28, i64 1
%30 = load double*, double** %29
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = load double, double* %31
store double %32, double* %14
%33 = load double, double* %12
%34 = load double, double* %13
%35 = load double, double* %11
%36 = load double, double* %14
%37 = call double @llvm.fmuladd.f64(double %34, double %35, double %36)
%38 = call double @exp(double %37)
%39 = fsub double %33, %38
%40 = load double*, double** %8
%41 = getelementptr inbounds double, double* %40, i64 0
store double %39, double* %41
%42 = load double**, double*** %9
%43 = icmp eq double** %42, null
br i1 %43, label %44, label %45
44: ; preds = %4
store i32 1, i32* %5
br label %80
45: ; preds = %4
%46 = load double**, double*** %9
%47 = getelementptr inbounds double*, double** %46, i64 0
%48 = load double*, double** %47
%49 = icmp ne double* %48, null
br i1 %49, label %50, label %63
50: ; preds = %45
%51 = load double, double* %11
%52 = fneg double %51
%53 = load double, double* %13
%54 = load double, double* %11
%55 = load double, double* %14
%56 = call double @llvm.fmuladd.f64(double %53, double %54, double %55)
%57 = call double @exp(double %56)
%58 = fmul double %52, %57
%59 = load double**, double*** %9
%60 = getelementptr inbounds double*, double** %59, i64 0
%61 = load double*, double** %60
%62 = getelementptr inbounds double, double* %61, i64 0
store double %58, double* %62
br label %63
63: ; preds = %50, %45
%64 = load double**, double*** %9
%65 = getelementptr inbounds double*, double** %64, i64 1
%66 = load double*, double** %65
%67 = icmp ne double* %66, null
br i1 %67, label %68, label %79
68: ; preds = %63
%69 = load double, double* %13
%70 = load double, double* %11
%71 = load double, double* %14
%72 = call double @llvm.fmuladd.f64(double %69, double %70, double %71)
%73 = call double @exp(double %72)
%74 = fneg double %73
%75 = load double**, double*** %9
%76 = getelementptr inbounds double*, double** %75, i64 1
%77 = load double*, double** %76
%78 = getelementptr inbounds double, double* %77, i64 0
store double %74, double* %78
br label %79
79: ; preds = %68, %63
store i32 1, i32* %5
br label %80
80: ; preds = %79, %44
%81 = load i32, i32* %5
ret i32 %81
}

LLVM IR (-O2):
define i32 @exponential_residual(i8* nocapture %0, double** nocapture %1, double* nocapture writeonly %2, double** %3) {
%5 = bitcast i8* %0 to double*
%6 = load double, double* %5
%7 = getelementptr inbounds i8, i8* %0, i64 8
%8 = bitcast i8* %7 to double*
%9 = load double, double* %8
%10 = load double*, double** %1
%11 = load double, double* %10
%12 = getelementptr inbounds double*, double** %1, i64 1
%13 = load double*, double** %12
%14 = load double, double* %13
%15 = tail call double @llvm.fmuladd.f64(double %11, double %6, double %14)
%16 = tail call double @exp(double %15)
%17 = fsub double %9, %16
store double %17, double* %2
%18 = icmp eq double** %3, null
br i1 %18, label %35, label %19
19: ; preds = %4
%20 = load double*, double** %3
%21 = icmp eq double* %20, null
br i1 %21, label %27, label %22
22: ; preds = %19
%23 = fneg double %6
%24 = tail call double @exp(double %15)
%25 = fmul double %24, %23
%26 = load double*, double** %3
store double %25, double* %26
br label %27
27: ; preds = %22, %19
%28 = getelementptr inbounds double*, double** %3, i64 1
%29 = load double*, double** %28
%30 = icmp eq double* %29, null
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = tail call double @exp(double %15)
%33 = fneg double %32
%34 = load double*, double** %28
store double %33, double* %34
br label %35
35: ; preds = %27, %31, %4
ret i32 1
}