int texture_feature_inverse_diff_moment(double ***glcm, int n_object,
                                        double *inverse_diff_moment) {
  unsigned int i = 0, j = 0, k = 0;
  for (i = 0; i < n_object; i++) {
    for (j = 0; j < 256; j++) {
      for (k = 0; k < 256; k++) {
        double tmp = (j - k);
        inverse_diff_moment[i] += glcm[i][j][k] / (1.0 + (tmp * tmp));
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<texture_feature_inverse_diff_moment>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11ee <texture_feature_inverse_diff_moment+0xee>
movl   $0x0,-0x20(%rbp)
cmpl   $0x100,-0x20(%rbp)
jae    11db <texture_feature_inverse_diff_moment+0xdb>
movl   $0x0,-0x24(%rbp)
cmpl   $0x100,-0x24(%rbp)
jae    11c8 <texture_feature_inverse_diff_moment+0xc8>
mov    -0x20(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    %ecx,%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x24(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe5f(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1152 <texture_feature_inverse_diff_moment+0x52>
jmp    11cd <texture_feature_inverse_diff_moment+0xcd>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113e <texture_feature_inverse_diff_moment+0x3e>
jmp    11e0 <texture_feature_inverse_diff_moment+0xe0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <texture_feature_inverse_diff_moment+0x2b>
mov    $0x1,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<texture_feature_inverse_diff_moment>:
push   %r14
push   %rbx
test   %esi,%esi
je     11ca <texture_feature_inverse_diff_moment+0xca>
mov    %esi,%r8d
xor    %r14d,%r14d
movsd  0xee7(%rip),%xmm0
nopl   0x0(%rax)
mov    (%rdi,%r14,8),%r9
movsd  (%rdx,%r14,8),%xmm1
mov    $0xffffffff,%r10d
xor    %r11d,%r11d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r9,%r11,8),%rax
mov    %r10d,%esi
xor    %ebx,%ebx
nopl   0x0(%rax)
lea    0x1(%rsi),%ecx
xorps  %xmm2,%xmm2
cvtsi2sd %rcx,%xmm2
movsd  (%rax,%rbx,8),%xmm3
mulsd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
divsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,(%rdx,%r14,8)
mov    %esi,%ecx
xorps  %xmm2,%xmm2
cvtsi2sd %rcx,%xmm2
movsd  0x8(%rax,%rbx,8),%xmm1
mulsd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm3,%xmm1
movsd  %xmm1,(%rdx,%r14,8)
add    $0x2,%rbx
add    $0xfffffffe,%esi
cmp    $0x100,%rbx
jne    1150 <texture_feature_inverse_diff_moment+0x50>
add    $0x1,%r11
add    $0x1,%r10d
cmp    $0x100,%r11
jne    1140 <texture_feature_inverse_diff_moment+0x40>
add    $0x1,%r14
cmp    %r8,%r14
jne    1120 <texture_feature_inverse_diff_moment+0x20>
mov    $0x1,%eax
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @texture_feature_inverse_diff_moment(double*** %0, i32 %1, double* %2) {
%4 = alloca double***
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store double*** %0, double**** %4
store i32 %1, i32* %5
store double* %2, double** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %7
br label %11
11: ; preds = %59, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %5
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %62
15: ; preds = %11
store i32 0, i32* %8
br label %16
16: ; preds = %55, %15
%17 = load i32, i32* %8
%18 = icmp ult i32 %17, 256
br i1 %18, label %19, label %58
19: ; preds = %16
store i32 0, i32* %9
br label %20
20: ; preds = %51, %19
%21 = load i32, i32* %9
%22 = icmp ult i32 %21, 256
br i1 %22, label %23, label %54
23: ; preds = %20
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = sub i32 %24, %25
%27 = uitofp i32 %26 to double
store double %27, double* %10
%28 = load double***, double**** %4
%29 = load i32, i32* %7
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds double**, double*** %28, i64 %30
%32 = load double**, double*** %31
%33 = load i32, i32* %8
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds double*, double** %32, i64 %34
%36 = load double*, double** %35
%37 = load i32, i32* %9
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
%41 = load double, double* %10
%42 = load double, double* %10
%43 = call double @llvm.fmuladd.f64(double %41, double %42, double 1.000000e+00)
%44 = fdiv double %40, %43
%45 = load double*, double** %6
%46 = load i32, i32* %7
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = load double, double* %48
%50 = fadd double %49, %44
store double %50, double* %48
br label %51
51: ; preds = %23
%52 = load i32, i32* %9
%53 = add i32 %52, 1
store i32 %53, i32* %9
br label %20
54: ; preds = %20
br label %55
55: ; preds = %54
%56 = load i32, i32* %8
%57 = add i32 %56, 1
store i32 %57, i32* %8
br label %16
58: ; preds = %16
br label %59
59: ; preds = %58
%60 = load i32, i32* %7
%61 = add i32 %60, 1
store i32 %61, i32* %7
br label %11
62: ; preds = %11
ret i32 1
}

LLVM IR (-O2):
define i32 @texture_feature_inverse_diff_moment(double*** nocapture %0, i32 %1, double* nocapture %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %46, label %5
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %43
%8 = phi i64 [ 0, %5 ], [ %44, %43 ]
%9 = getelementptr inbounds double**, double*** %0, i64 %8
%10 = load double**, double*** %9
%11 = getelementptr inbounds double, double* %2, i64 %8
%12 = load double, double* %11
br label %13
13: ; preds = %7, %40
%14 = phi double [ %12, %7 ], [ %37, %40 ]
%15 = phi i64 [ 0, %7 ], [ %41, %40 ]
%16 = getelementptr inbounds double*, double** %10, i64 %15
%17 = load double*, double** %16
br label %18
18: ; preds = %18, %13
%19 = phi double [ %14, %13 ], [ %37, %18 ]
%20 = phi i64 [ 0, %13 ], [ %38, %18 ]
%21 = sub nsw i64 %15, %20
%22 = trunc i64 %21 to i32
%23 = uitofp i32 %22 to double
%24 = getelementptr inbounds double, double* %17, i64 %20
%25 = load double, double* %24
%26 = tail call double @llvm.fmuladd.f64(double %23, double %23, double 1.000000e+00)
%27 = fdiv double %25, %26
%28 = fadd double %19, %27
store double %28, double* %11
%29 = or i64 %20, 1
%30 = sub nsw i64 %15, %29
%31 = trunc i64 %30 to i32
%32 = uitofp i32 %31 to double
%33 = getelementptr inbounds double, double* %17, i64 %29
%34 = load double, double* %33
%35 = tail call double @llvm.fmuladd.f64(double %32, double %32, double 1.000000e+00)
%36 = fdiv double %34, %35
%37 = fadd double %28, %36
store double %37, double* %11
%38 = add nuw nsw i64 %20, 2
%39 = icmp eq i64 %38, 256
br i1 %39, label %40, label %18
40: ; preds = %18
%41 = add nuw nsw i64 %15, 1
%42 = icmp eq i64 %41, 256
br i1 %42, label %43, label %13
43: ; preds = %40
%44 = add nuw nsw i64 %8, 1
%45 = icmp eq i64 %44, %6
br i1 %45, label %46, label %7
46: ; preds = %43, %3
ret i32 1
}