int texture_feature_angular_second_moment(double ***glcm, int n_object,
                                          double *angular_second_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++) {
        angular_second_moment[i] += glcm[i][j][k] * glcm[i][j][k];
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<texture_feature_angular_second_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    11e0 <texture_feature_angular_second_moment+0xe0>
movl   $0x0,-0x20(%rbp)
cmpl   $0x100,-0x20(%rbp)
jae    11cd <texture_feature_angular_second_moment+0xcd>
movl   $0x0,-0x24(%rbp)
cmpl   $0x100,-0x24(%rbp)
jae    11ba <texture_feature_angular_second_moment+0xba>
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
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),%xmm2
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1152 <texture_feature_angular_second_moment+0x52>
jmp    11bf <texture_feature_angular_second_moment+0xbf>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113e <texture_feature_angular_second_moment+0x3e>
jmp    11d2 <texture_feature_angular_second_moment+0xd2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <texture_feature_angular_second_moment+0x2b>
mov    $0x1,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<texture_feature_angular_second_moment>:
test   %esi,%esi
je     11a1 <texture_feature_angular_second_moment+0xa1>
mov    %esi,%r8d
xor    %ecx,%ecx
nopl   (%rax)
mov    (%rdi,%rcx,8),%r9
movsd  (%rdx,%rcx,8),%xmm0
xor    %r10d,%r10d
nopl   0x0(%rax)
mov    (%r9,%r10,8),%rsi
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movsd  (%rsi,%rax,8),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%rcx,8)
movsd  0x8(%rsi,%rax,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx,%rcx,8)
movsd  0x10(%rsi,%rax,8),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%rcx,8)
movsd  0x18(%rsi,%rax,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx,%rcx,8)
add    $0x4,%rax
cmp    $0x100,%rax
jne    1130 <texture_feature_angular_second_moment+0x30>
add    $0x1,%r10
cmp    $0x100,%r10
jne    1120 <texture_feature_angular_second_moment+0x20>
add    $0x1,%rcx
cmp    %r8,%rcx
jne    1110 <texture_feature_angular_second_moment+0x10>
mov    $0x1,%eax
ret

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

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