#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 */
scalar_t__ abs(int);
int find_sad_16x16(int *mode) {
  int current, best;
  int M1[16][16], M0[4][4][4][4], M3[4], M4[4][4];
  int i, j, k;
  int ii, jj;
  for (jj = 0; jj < 4; jj++)
    for (ii = 0; ii < 4; ii++)
      for (j = 0; j < 4; j++)
        for (j = 0; j < 4; j++)
          current += abs(M0[i][ii][j][jj]);
  if (current < best) {
    best = current;
    *mode = k;
  }
}


x86 assembly (clang, -O0):
<find_sad_16x16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x890,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x884(%rbp)
cmpl   $0x4,-0x884(%rbp)
jge    1227 <find_sad_16x16+0x117>
movl   $0x0,-0x880(%rbp)
cmpl   $0x4,-0x880(%rbp)
jge    120e <find_sad_16x16+0xfe>
movl   $0x0,-0x878(%rbp)
cmpl   $0x4,-0x878(%rbp)
jge    11f5 <find_sad_16x16+0xe5>
movl   $0x0,-0x878(%rbp)
cmpl   $0x4,-0x878(%rbp)
jge    11dc <find_sad_16x16+0xcc>
movslq -0x874(%rbp),%rcx
lea    -0x820(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x880(%rbp),%rcx
shl    $0x6,%rcx
add    %rcx,%rax
movslq -0x878(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x884(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <abs@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x878(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x878(%rbp)
jmp    116e <find_sad_16x16+0x5e>
jmp    11e1 <find_sad_16x16+0xd1>
mov    -0x878(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x878(%rbp)
jmp    1157 <find_sad_16x16+0x47>
jmp    11fa <find_sad_16x16+0xea>
mov    -0x880(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x880(%rbp)
jmp    1140 <find_sad_16x16+0x30>
jmp    1213 <find_sad_16x16+0x103>
mov    -0x884(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x884(%rbp)
jmp    1129 <find_sad_16x16+0x19>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1245 <find_sad_16x16+0x135>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x87c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
add    $0x890,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_sad_16x16>:
push   %rax
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
call   1030 <abs@plt>
pop    %rax
jmp    1030 <abs@plt>

LLVM IR (-O0):
define i32 @find_sad_16x16(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [16 x [16 x i32]]
%7 = alloca [4 x [4 x [4 x [4 x i32]]]]
%8 = alloca [4 x i32]
%9 = alloca [4 x [4 x i32]]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %3
store i32 0, i32* %14
br label %15
15: ; preds = %61, %1
%16 = load i32, i32* %14
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %64
18: ; preds = %15
store i32 0, i32* %13
br label %19
19: ; preds = %57, %18
%20 = load i32, i32* %13
%21 = icmp slt i32 %20, 4
br i1 %21, label %22, label %60
22: ; preds = %19
store i32 0, i32* %11
br label %23
23: ; preds = %53, %22
%24 = load i32, i32* %11
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %56
26: ; preds = %23
store i32 0, i32* %11
br label %27
27: ; preds = %49, %26
%28 = load i32, i32* %11
%29 = icmp slt i32 %28, 4
br i1 %29, label %30, label %52
30: ; preds = %27
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [4 x [4 x [4 x [4 x i32]]]], [4 x [4 x [4 x [4 x i32]]]]* %7, i64 0, i64 %32
%34 = load i32, i32* %13
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4 x [4 x [4 x i32]]], [4 x [4 x [4 x i32]]]* %33, i64 0, i64 %35
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %36, i64 0, i64 %38
%40 = load i32, i32* %14
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [4 x i32], [4 x i32]* %39, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = call i64 @abs(i32 %43)
%45 = load i32, i32* %4
%46 = sext i32 %45 to i64
%47 = add nsw i64 %46, %44
%48 = trunc i64 %47 to i32
store i32 %48, i32* %4
br label %49
49: ; preds = %30
%50 = load i32, i32* %11
%51 = add nsw i32 %50, 1
store i32 %51, i32* %11
br label %27
52: ; preds = %27
br label %53
53: ; preds = %52
%54 = load i32, i32* %11
%55 = add nsw i32 %54, 1
store i32 %55, i32* %11
br label %23
56: ; preds = %23
br label %57
57: ; preds = %56
%58 = load i32, i32* %13
%59 = add nsw i32 %58, 1
store i32 %59, i32* %13
br label %19
60: ; preds = %19
br label %61
61: ; preds = %60
%62 = load i32, i32* %14
%63 = add nsw i32 %62, 1
store i32 %63, i32* %14
br label %15
64: ; preds = %15
%65 = load i32, i32* %4
%66 = load i32, i32* %5
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %72
68: ; preds = %64
%69 = load i32, i32* %4
store i32 %69, i32* %5
%70 = load i32, i32* %12
%71 = load i32*, i32** %3
store i32 %70, i32* %71
br label %72
72: ; preds = %68, %64
%73 = load i32, i32* %2
ret i32 %73
}

LLVM IR (-O2):
define i32 @find_sad_16x16(i32* nocapture readnone %0) {
%2 = tail call i64 @abs(i32 undef)
%3 = tail call i64 @abs(i32 undef)
%4 = tail call i64 @abs(i32 undef)
%5 = tail call i64 @abs(i32 undef)
%6 = tail call i64 @abs(i32 undef)
%7 = tail call i64 @abs(i32 undef)
%8 = tail call i64 @abs(i32 undef)
%9 = tail call i64 @abs(i32 undef)
%10 = tail call i64 @abs(i32 undef)
%11 = tail call i64 @abs(i32 undef)
%12 = tail call i64 @abs(i32 undef)
%13 = tail call i64 @abs(i32 undef)
%14 = tail call i64 @abs(i32 undef)
%15 = tail call i64 @abs(i32 undef)
%16 = tail call i64 @abs(i32 undef)
%17 = tail call i64 @abs(i32 undef)
%18 = tail call i64 @abs(i32 undef)
%19 = tail call i64 @abs(i32 undef)
%20 = tail call i64 @abs(i32 undef)
%21 = tail call i64 @abs(i32 undef)
%22 = tail call i64 @abs(i32 undef)
%23 = tail call i64 @abs(i32 undef)
%24 = tail call i64 @abs(i32 undef)
%25 = tail call i64 @abs(i32 undef)
%26 = tail call i64 @abs(i32 undef)
%27 = tail call i64 @abs(i32 undef)
%28 = tail call i64 @abs(i32 undef)
%29 = tail call i64 @abs(i32 undef)
%30 = tail call i64 @abs(i32 undef)
%31 = tail call i64 @abs(i32 undef)
%32 = tail call i64 @abs(i32 undef)
%33 = tail call i64 @abs(i32 undef)
%34 = tail call i64 @abs(i32 undef)
%35 = tail call i64 @abs(i32 undef)
%36 = tail call i64 @abs(i32 undef)
%37 = tail call i64 @abs(i32 undef)
%38 = tail call i64 @abs(i32 undef)
%39 = tail call i64 @abs(i32 undef)
%40 = tail call i64 @abs(i32 undef)
%41 = tail call i64 @abs(i32 undef)
%42 = tail call i64 @abs(i32 undef)
%43 = tail call i64 @abs(i32 undef)
%44 = tail call i64 @abs(i32 undef)
%45 = tail call i64 @abs(i32 undef)
%46 = tail call i64 @abs(i32 undef)
%47 = tail call i64 @abs(i32 undef)
%48 = tail call i64 @abs(i32 undef)
%49 = tail call i64 @abs(i32 undef)
%50 = tail call i64 @abs(i32 undef)
%51 = tail call i64 @abs(i32 undef)
%52 = tail call i64 @abs(i32 undef)
%53 = tail call i64 @abs(i32 undef)
%54 = tail call i64 @abs(i32 undef)
%55 = tail call i64 @abs(i32 undef)
%56 = tail call i64 @abs(i32 undef)
%57 = tail call i64 @abs(i32 undef)
%58 = tail call i64 @abs(i32 undef)
%59 = tail call i64 @abs(i32 undef)
%60 = tail call i64 @abs(i32 undef)
%61 = tail call i64 @abs(i32 undef)
%62 = tail call i64 @abs(i32 undef)
%63 = tail call i64 @abs(i32 undef)
%64 = tail call i64 @abs(i32 undef)
%65 = tail call i64 @abs(i32 undef)
ret i32 undef
}