void dlevmar_fdif_forw_jac_approx(void (*func)(double *p, double *hx, int m,
                                               int n, void *adata),
                                  double *p, double *hx, double *hxx,
                                  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, hxx, m, n, adata);
    p[j] = tmp;
    d = (1.0) / d;
    for (i = 0; i < n; ++i) {
      jac[i * m + j] = (hxx[i] - hx[i]) * d;
    }
  }
}


x86 assembly (clang, -O0):
<dlevmar_fdif_forw_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    1291 <dlevmar_fdif_forw_jac_approx+0x191>
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_forw_jac_approx+0x7a>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    119b <dlevmar_fdif_forw_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_forw_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),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
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  0xdea(%rip),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    127e <dlevmar_fdif_forw_jac_approx+0x17e>
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    122f <dlevmar_fdif_forw_jac_approx+0x12f>
jmp    1283 <dlevmar_fdif_forw_jac_approx+0x183>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1133 <dlevmar_fdif_forw_jac_approx+0x33>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dlevmar_fdif_forw_jac_approx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8,0x8(%rsp)
movsd  %xmm0,0x28(%rsp)
mov    %rsi,0x20(%rsp)
mov    %rdi,0x18(%rsp)
mov    %r9d,0x4(%rsp)
test   %r9d,%r9d
jle    12ba <dlevmar_fdif_forw_jac_approx+0x1ba>
mov    %rcx,%rbx
mov    %rdx,%rbp
mov    0x4(%rsp),%r13d
mov    0x80(%rsp),%eax
mov    %eax,%edx
and    $0xfffffffe,%edx
mov    %r13,%r14
shl    $0x4,%r14
xor    %r12d,%r12d
mov    0x8(%rsp),%rsi
mov    %rdx,0x10(%rsp)
mov    0x20(%rsp),%r15
jmp    1181 <dlevmar_fdif_forw_jac_approx+0x81>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r12
add    $0x8,%rsi
cmp    %r13,%r12
je     12ba <dlevmar_fdif_forw_jac_approx+0x1ba>
mov    %rsi,0x40(%rsp)
movsd  (%r15,%r12,8),%xmm1
movapd %xmm1,%xmm0
movapd %xmm1,%xmm3
movsd  %xmm1,0x38(%rsp)
mulsd  0xe5e(%rip),%xmm0
movapd %xmm0,%xmm1
xorpd  0xe62(%rip),%xmm1
xorpd  %xmm2,%xmm2
cmplesd %xmm0,%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
movsd  0x28(%rsp),%xmm1
maxsd  %xmm2,%xmm1
movapd %xmm3,%xmm0
movsd  %xmm1,0x30(%rsp)
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r15,%r12,8)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    0x4(%rsp),%edx
mov    0x80(%rsp),%ecx
mov    0x88(%rsp),%r8
call   *0x18(%rsp)
mov    0x40(%rsp),%rsi
mov    0x10(%rsp),%rdx
movsd  0x38(%rsp),%xmm0
movsd  %xmm0,(%r15,%r12,8)
cmpl   $0x0,0x80(%rsp)
jle    1170 <dlevmar_fdif_forw_jac_approx+0x70>
movsd  0xdde(%rip),%xmm0
divsd  0x30(%rsp),%xmm0
cmpl   $0x1,0x80(%rsp)
01
jne    1240 <dlevmar_fdif_forw_jac_approx+0x140>
xor    %eax,%eax
jmp    1285 <dlevmar_fdif_forw_jac_approx+0x185>
xchg   %ax,%ax
mov    %rsi,%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,%r13,8)
add    $0x2,%rax
add    %r14,%rcx
cmp    %rax,%rdx
jne    1250 <dlevmar_fdif_forw_jac_approx+0x150>
mov    0x80(%rsp),%ecx
test   $0x1,%cl
je     1170 <dlevmar_fdif_forw_jac_approx+0x70>
movsd  (%rbx,%rax,8),%xmm1
subsd  0x0(%rbp,%rax,8),%xmm1
mulsd  %xmm1,%xmm0
imul   %r13,%rax
add    %r12,%rax
mov    0x8(%rsp),%rcx
movsd  %xmm0,(%rcx,%rax,8)
jmp    1170 <dlevmar_fdif_forw_jac_approx+0x70>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @dlevmar_fdif_forw_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 = %104, %9
%24 = load i32, i32* %20
%25 = load i32, i32* %16
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %107
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 = fadd 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** %13
%64 = load i32, i32* %16
%65 = load i32, i32* %17
%66 = load i8*, i8** %18
%67 = load double, double* %21
%68 = load double*, double** %11
%69 = load i32, i32* %20
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
store double %67, double* %71
%72 = load double, double* %22
%73 = fdiv double 1.000000e+00, %72
store double %73, double* %22
store i32 0, i32* %19
br label %74
74: ; preds = %100, %48
%75 = load i32, i32* %19
%76 = load i32, i32* %17
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %103
78: ; preds = %74
%79 = load double*, double** %13
%80 = load i32, i32* %19
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %79, i64 %81
%83 = load double, double* %82
%84 = load double*, double** %12
%85 = load i32, i32* %19
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double, double* %87
%89 = fsub double %83, %88
%90 = load double, double* %22
%91 = fmul double %89, %90
%92 = load double*, double** %15
%93 = load i32, i32* %19
%94 = load i32, i32* %16
%95 = mul nsw i32 %93, %94
%96 = load i32, i32* %20
%97 = add nsw i32 %95, %96
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds double, double* %92, i64 %98
store double %91, double* %99
br label %100
100: ; preds = %78
%101 = load i32, i32* %19
%102 = add nsw i32 %101, 1
store i32 %102, i32* %19
br label %74
103: ; preds = %74
br label %104
104: ; preds = %103
%105 = load i32, i32* %20
%106 = add nsw i32 %105, 1
store i32 %106, i32* %20
br label %23
107: ; preds = %23
ret void
}

LLVM IR (-O2):
define void @dlevmar_fdif_forw_jac_approx(void (double*, double*, i32, i32, i8*)* nocapture %0, double* %1, double* nocapture %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 %73
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, %70
%21 = phi i64 [ 0, %11 ], [ %71, %70 ]
%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 = fadd double %23, %29
store double %30, double* %22
tail call void %0(double* %1, double* %3, i32 %6, i32 %7, i8* %8)
store double %23, double* %22
%31 = fdiv double 1.000000e+00, %29
br i1 %12, label %32, label %70
32: ; preds = %20
br i1 %17, label %58, label %33
33: ; preds = %32, %33
%34 = phi i64 [ %55, %33 ], [ 0, %32 ]
%35 = phi i64 [ %56, %33 ], [ 0, %32 ]
%36 = getelementptr inbounds double, double* %3, i64 %34
%37 = load double, double* %36
%38 = getelementptr inbounds double, double* %2, i64 %34
%39 = load double, double* %38
%40 = fsub double %37, %39
%41 = fmul double %31, %40
%42 = mul nsw i64 %34, %13
%43 = add nuw nsw i64 %42, %21
%44 = getelementptr inbounds double, double* %5, i64 %43
store double %41, double* %44
%45 = or i64 %34, 1
%46 = getelementptr inbounds double, double* %3, i64 %45
%47 = load double, double* %46
%48 = getelementptr inbounds double, double* %2, i64 %45
%49 = load double, double* %48
%50 = fsub double %47, %49
%51 = fmul double %31, %50
%52 = mul nsw i64 %45, %13
%53 = add nuw nsw i64 %52, %21
%54 = getelementptr inbounds double, double* %5, i64 %53
store double %51, double* %54
%55 = add nuw nsw i64 %34, 2
%56 = add i64 %35, 2
%57 = icmp eq i64 %56, %18
br i1 %57, label %58, label %33
58: ; preds = %33, %32
%59 = phi i64 [ 0, %32 ], [ %55, %33 ]
br i1 %19, label %70, label %60
60: ; preds = %58
%61 = getelementptr inbounds double, double* %3, i64 %59
%62 = load double, double* %61
%63 = getelementptr inbounds double, double* %2, i64 %59
%64 = load double, double* %63
%65 = fsub double %62, %64
%66 = fmul double %31, %65
%67 = mul nsw i64 %59, %13
%68 = add nuw nsw i64 %67, %21
%69 = getelementptr inbounds double, double* %5, i64 %68
store double %66, double* %69
br label %70
70: ; preds = %60, %58, %20
%71 = add nuw nsw i64 %21, 1
%72 = icmp eq i64 %71, %14
br i1 %72, label %73, label %20
73: ; preds = %70, %9
ret void
}