void dlevmar_fdif_cent_jac_approx(void (*func)(double *p, double *hx, int m,
                                               int n, void *adata),
                                  double *p, double *hxm, double *hxp,
                                  double delta, double *jac, int m, int n,
                                  void *adata) {
  register int i, j;
  double tmp;
  register double d;
  for (j = 0; j < m; ++j) {
    d = (1E-04) * p[j];
    d = (((d) >= 0.0) ? (d) : -(d));
    if (d < delta)
      d = delta;
    tmp = p[j];
    p[j] -= d;
    (*func)(p, hxm, m, n, adata);
    p[j] = tmp + d;
    (*func)(p, hxp, m, n, adata);
    p[j] = tmp;
    d = (0.5) / d;
    for (i = 0; i < n; ++i) {
      jac[i * m + j] = (hxp[i] - hxm[i]) * d;
    }
  }
}


x86 assembly (clang, -O0):
<dlevmar_fdif_cent_jac_approx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    12c4 <dlevmar_fdif_cent_jac_approx+0x1c4>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  0xeb1(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     117a <dlevmar_fdif_cent_jac_approx+0x7a>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    119b <dlevmar_fdif_cent_jac_approx+0x9b>
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c3 <dlevmar_fdif_cent_jac_approx+0xc3>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x50(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x34(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    0x18(%rbp),%r8
call   *%rax
movsd  -0x48(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x34(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    0x18(%rbp),%r8
call   *%rax
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xdb7(%rip),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    12b1 <dlevmar_fdif_cent_jac_approx+0x1b1>
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mulsd  -0x50(%rbp),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1262 <dlevmar_fdif_cent_jac_approx+0x162>
jmp    12b6 <dlevmar_fdif_cent_jac_approx+0x1b6>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1133 <dlevmar_fdif_cent_jac_approx+0x33>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dlevmar_fdif_cent_jac_approx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8,0x8(%rsp)
movsd  %xmm0,0x48(%rsp)
mov    %rsi,0x40(%rsp)
mov    %rdi,0x38(%rsp)
mov    %r9d,0x4(%rsp)
test   %r9d,%r9d
jle    1309 <dlevmar_fdif_cent_jac_approx+0x209>
mov    %rcx,%rbx
mov    %rdx,%rbp
mov    0x4(%rsp),%edx
mov    0x90(%rsp),%eax
mov    %eax,%esi
and    $0xfffffffe,%esi
mov    %rdx,%rdi
shl    $0x4,%rdi
xor    %r12d,%r12d
mov    0x8(%rsp),%r8
mov    %rdx,0x30(%rsp)
mov    %rsi,0x28(%rsp)
mov    %rdi,0x20(%rsp)
mov    0x40(%rsp),%r15
mov    0x38(%rsp),%r14
jmp    1191 <dlevmar_fdif_cent_jac_approx+0x91>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
add    $0x8,%r8
cmp    %rdx,%r12
je     1309 <dlevmar_fdif_cent_jac_approx+0x209>
mov    %r8,0x50(%rsp)
movsd  (%r15,%r12,8),%xmm1
movapd %xmm1,%xmm0
movapd %xmm1,%xmm3
movsd  %xmm1,0x18(%rsp)
mulsd  0xe4e(%rip),%xmm0
movapd %xmm0,%xmm1
xorpd  0xe52(%rip),%xmm1
xorpd  %xmm2,%xmm2
cmplesd %xmm0,%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
movsd  0x48(%rsp),%xmm1
maxsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp)
movapd %xmm3,%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%r15,%r12,8)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    0x4(%rsp),%r13d
mov    %r13d,%edx
mov    0x90(%rsp),%ecx
mov    0x98(%rsp),%r8
call   *%r14
movsd  0x18(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r15,%r12,8)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13d,%edx
mov    0x90(%rsp),%r13d
mov    %r13d,%ecx
mov    0x98(%rsp),%r8
call   *%r14
mov    0x50(%rsp),%r8
mov    0x20(%rsp),%rdi
mov    0x28(%rsp),%rsi
mov    0x30(%rsp),%rdx
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%r15,%r12,8)
test   %r13d,%r13d
jle    1180 <dlevmar_fdif_cent_jac_approx+0x80>
movsd  0xd95(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
cmpl   $0x1,0x90(%rsp)
01
jne    1290 <dlevmar_fdif_cent_jac_approx+0x190>
xor    %eax,%eax
jmp    12d4 <dlevmar_fdif_cent_jac_approx+0x1d4>
nopw   0x0(%rax,%rax,1)
mov    %r8,%rcx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rbx,%rax,8),%xmm1
subsd  0x0(%rbp,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rcx)
movsd  0x8(%rbx,%rax,8),%xmm1
subsd  0x8(%rbp,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rcx,%rdx,8)
add    $0x2,%rax
add    %rdi,%rcx
cmp    %rax,%rsi
jne    12a0 <dlevmar_fdif_cent_jac_approx+0x1a0>
mov    0x90(%rsp),%ecx
test   $0x1,%cl
je     1180 <dlevmar_fdif_cent_jac_approx+0x80>
movsd  (%rbx,%rax,8),%xmm1
subsd  0x0(%rbp,%rax,8),%xmm1
mulsd  %xmm1,%xmm0
imul   %rdx,%rax
add    %r12,%rax
mov    0x8(%rsp),%rcx
movsd  %xmm0,(%rcx,%rax,8)
jmp    1180 <dlevmar_fdif_cent_jac_approx+0x80>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @dlevmar_fdif_cent_jac_approx(void (double*, double*, i32, i32, i8*)* nocapture %0, double* %1, double* %2, double* %3, double %4, double* nocapture writeonly %5, i32 %6, i32 %7, i8* %8) {
%10 = icmp sgt i32 %6, 0
br i1 %10, label %11, label %74
11: ; preds = %9
%12 = icmp sgt i32 %7, 0
%13 = zext i32 %6 to i64
%14 = zext i32 %6 to i64
%15 = zext i32 %7 to i64
%16 = and i64 %15, 1
%17 = icmp eq i32 %7, 1
%18 = and i64 %15, 4294967294
%19 = icmp eq i64 %16, 0
br label %20
20: ; preds = %11, %71
%21 = phi i64 [ 0, %11 ], [ %72, %71 ]
%22 = getelementptr inbounds double, double* %1, i64 %21
%23 = load double, double* %22
%24 = fmul double %23, 1.000000e-04
%25 = fcmp oge double %24, 0.000000e+00
%26 = fneg double %24
%27 = select i1 %25, double %24, double %26
%28 = fcmp olt double %27, %4
%29 = select i1 %28, double %4, double %27
%30 = fsub double %23, %29
store double %30, double* %22
tail call void %0(double* %1, double* %2, i32 %6, i32 %7, i8* %8)
%31 = fadd double %23, %29
store double %31, double* %22
tail call void %0(double* %1, double* %3, i32 %6, i32 %7, i8* %8)
store double %23, double* %22
%32 = fdiv double 5.000000e-01, %29
br i1 %12, label %33, label %71
33: ; preds = %20
br i1 %17, label %59, label %34
34: ; preds = %33, %34
%35 = phi i64 [ %56, %34 ], [ 0, %33 ]
%36 = phi i64 [ %57, %34 ], [ 0, %33 ]
%37 = getelementptr inbounds double, double* %3, i64 %35
%38 = load double, double* %37
%39 = getelementptr inbounds double, double* %2, i64 %35
%40 = load double, double* %39
%41 = fsub double %38, %40
%42 = fmul double %32, %41
%43 = mul nsw i64 %35, %13
%44 = add nuw nsw i64 %43, %21
%45 = getelementptr inbounds double, double* %5, i64 %44
store double %42, double* %45
%46 = or i64 %35, 1
%47 = getelementptr inbounds double, double* %3, i64 %46
%48 = load double, double* %47
%49 = getelementptr inbounds double, double* %2, i64 %46
%50 = load double, double* %49
%51 = fsub double %48, %50
%52 = fmul double %32, %51
%53 = mul nsw i64 %46, %13
%54 = add nuw nsw i64 %53, %21
%55 = getelementptr inbounds double, double* %5, i64 %54
store double %52, double* %55
%56 = add nuw nsw i64 %35, 2
%57 = add i64 %36, 2
%58 = icmp eq i64 %57, %18
br i1 %58, label %59, label %34
59: ; preds = %34, %33
%60 = phi i64 [ 0, %33 ], [ %56, %34 ]
br i1 %19, label %71, label %61
61: ; preds = %59
%62 = getelementptr inbounds double, double* %3, i64 %60
%63 = load double, double* %62
%64 = getelementptr inbounds double, double* %2, i64 %60
%65 = load double, double* %64
%66 = fsub double %63, %65
%67 = fmul double %32, %66
%68 = mul nsw i64 %60, %13
%69 = add nuw nsw i64 %68, %21
%70 = getelementptr inbounds double, double* %5, i64 %69
store double %67, double* %70
br label %71
71: ; preds = %61, %59, %20
%72 = add nuw nsw i64 %21, 1
%73 = icmp eq i64 %72, %14
br i1 %73, label %74, label %20
74: ; preds = %71, %9
ret void
}