#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 */
int /*<<< orphan*/ dump_4x4(int **, char *);
int /*<<< orphan*/ forward4x4(int **, int **);
int /*<<< orphan*/ inverse4x4(int **, int **);
int rshift_rnd_sf(int, int);
int main() {
  int residual[4][4] = {
      {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};
  int in1[4][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
  int coeff[4][4];
  int rresidual[4][4];
  inverse4x4(in1, rresidual);
  dump_4x4(rresidual, "Recon residual");
  dump_4x4(residual, "Residual");
  forward4x4(residual, coeff);
  dump_4x4(coeff, "Coeffisients");
  inverse4x4(coeff, rresidual);
  dump_4x4(rresidual, "Recon residual");
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      int tmp = rresidual[i][j];
      rresidual[i][j] = rshift_rnd_sf(tmp, 6);
    }
  }
  dump_4x4(rresidual, "Scaled recon residual");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x40,%edx
call   1060 <memcpy@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
lea    -0x90(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1080 <inverse4x4@plt>
lea    -0x110(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1070 <dump_4x4@plt>
lea    -0x50(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1070 <dump_4x4@plt>
lea    -0x50(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
call   1030 <forward4x4@plt>
lea    -0xd0(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1070 <dump_4x4@plt>
lea    -0xd0(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1080 <inverse4x4@plt>
lea    -0x110(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1070 <dump_4x4@plt>
movl   $0x0,-0x114(%rbp)
cmpl   $0x4,-0x114(%rbp)
jge    12ca <main+0x16a>
movl   $0x0,-0x118(%rbp)
cmpl   $0x4,-0x118(%rbp)
jge    12b1 <main+0x151>
movslq -0x114(%rbp),%rcx
lea    -0x110(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x118(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x11c(%rbp)
mov    -0x11c(%rbp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,%edx
movslq -0x114(%rbp),%rcx
lea    -0x110(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x118(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    123a <main+0xda>
jmp    12b6 <main+0x156>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1223 <main+0xc3>
lea    -0x110(%rbp),%rdi
lea    0xd8d(%rip),%rsi
call   1070 <dump_4x4@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
movaps 0xedb(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe9d(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe7e(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
lea    0x40(%rsp),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1060 <inverse4x4@plt>
lea    0xe88(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <dump_4x4@plt>
lea    0xe85(%rip),%rsi
lea    0x80(%rsp),%r12
mov    %r12,%rdi
call   1050 <dump_4x4@plt>
lea    0xc0(%rsp),%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <forward4x4@plt>
lea    0xe64(%rip),%rsi
mov    %rbx,%rdi
call   1050 <dump_4x4@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <inverse4x4@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <dump_4x4@plt>
mov    (%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,(%rsp)
mov    0x4(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x4(%rsp)
mov    0x8(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x8(%rsp)
mov    0xc(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x10(%rsp)
mov    0x14(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x14(%rsp)
mov    0x18(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x18(%rsp)
mov    0x1c(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x1c(%rsp)
mov    0x20(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x20(%rsp)
mov    0x24(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x24(%rsp)
mov    0x28(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x28(%rsp)
mov    0x2c(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x2c(%rsp)
mov    0x30(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x30(%rsp)
mov    0x34(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x34(%rsp)
mov    0x38(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x38(%rsp)
mov    0x3c(%rsp),%edi
mov    $0x6,%esi
call   1040 <rshift_rnd_sf@plt>
mov    %eax,0x3c(%rsp)
lea    0xd2e(%rip),%rsi
mov    %r14,%rdi
call   1050 <dump_4x4@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.residual = [4 x [4 x i32]] [[4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32] [i32 5, i32 6, i32 7, i32 8], [4 x i32] [i32 9, i32 10, i32 11, i32 12], [4 x i32] [i32 13, i32 14, i32 15, i32 16]]
@.str = [15 x i8] c"Recon residual\00"
@.str.1 = [9 x i8] c"Residual\00"
@.str.2 = [13 x i8] c"Coeffisients\00"
@.str.3 = [22 x i8] c"Scaled recon residual\00"
define i32 @main() {
%1 = alloca [4 x [4 x i32]]
%2 = alloca [4 x [4 x i32]]
%3 = alloca [4 x [4 x i32]]
%4 = alloca [4 x [4 x i32]]
%5 = bitcast [4 x [4 x i32]]* %1 to i8*
%6 = bitcast [4 x [4 x i32]]* %2 to i8*
%7 = bitcast [4 x [4 x i32]]* %3 to i8*
%8 = bitcast [4 x [4 x i32]]* %4 to i8*
%9 = bitcast [4 x [4 x i32]]* %2 to i32**
%10 = bitcast [4 x [4 x i32]]* %4 to i32**
%11 = call i32 @inverse4x4(i32** %9, i32** %10)
%12 = call i32 @dump_4x4(i32** %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%13 = bitcast [4 x [4 x i32]]* %1 to i32**
%14 = call i32 @dump_4x4(i32** %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%15 = bitcast [4 x [4 x i32]]* %3 to i32**
%16 = call i32 @forward4x4(i32** %13, i32** %15)
%17 = call i32 @dump_4x4(i32** %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @inverse4x4(i32** %15, i32** %10)
%19 = call i32 @dump_4x4(i32** %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%20 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 0, i64 0
%21 = load i32, i32* %20
%22 = call i32 @rshift_rnd_sf(i32 %21, i32 6)
store i32 %22, i32* %20
%23 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 0, i64 1
%24 = load i32, i32* %23
%25 = call i32 @rshift_rnd_sf(i32 %24, i32 6)
store i32 %25, i32* %23
%26 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 0, i64 2
%27 = load i32, i32* %26
%28 = call i32 @rshift_rnd_sf(i32 %27, i32 6)
store i32 %28, i32* %26
%29 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 0, i64 3
%30 = load i32, i32* %29
%31 = call i32 @rshift_rnd_sf(i32 %30, i32 6)
store i32 %31, i32* %29
%32 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 1, i64 0
%33 = load i32, i32* %32
%34 = call i32 @rshift_rnd_sf(i32 %33, i32 6)
store i32 %34, i32* %32
%35 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 1, i64 1
%36 = load i32, i32* %35
%37 = call i32 @rshift_rnd_sf(i32 %36, i32 6)
store i32 %37, i32* %35
%38 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 1, i64 2
%39 = load i32, i32* %38
%40 = call i32 @rshift_rnd_sf(i32 %39, i32 6)
store i32 %40, i32* %38
%41 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 1, i64 3
%42 = load i32, i32* %41
%43 = call i32 @rshift_rnd_sf(i32 %42, i32 6)
store i32 %43, i32* %41
%44 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 2, i64 0
%45 = load i32, i32* %44
%46 = call i32 @rshift_rnd_sf(i32 %45, i32 6)
store i32 %46, i32* %44
%47 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 2, i64 1
%48 = load i32, i32* %47
%49 = call i32 @rshift_rnd_sf(i32 %48, i32 6)
store i32 %49, i32* %47
%50 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 2, i64 2
%51 = load i32, i32* %50
%52 = call i32 @rshift_rnd_sf(i32 %51, i32 6)
store i32 %52, i32* %50
%53 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 2, i64 3
%54 = load i32, i32* %53
%55 = call i32 @rshift_rnd_sf(i32 %54, i32 6)
store i32 %55, i32* %53
%56 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 3, i64 0
%57 = load i32, i32* %56
%58 = call i32 @rshift_rnd_sf(i32 %57, i32 6)
store i32 %58, i32* %56
%59 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 3, i64 1
%60 = load i32, i32* %59
%61 = call i32 @rshift_rnd_sf(i32 %60, i32 6)
store i32 %61, i32* %59
%62 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 3, i64 2
%63 = load i32, i32* %62
%64 = call i32 @rshift_rnd_sf(i32 %63, i32 6)
store i32 %64, i32* %62
%65 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %4, i64 0, i64 3, i64 3
%66 = load i32, i32* %65
%67 = call i32 @rshift_rnd_sf(i32 %66, i32 6)
store i32 %67, i32* %65
%68 = call i32 @dump_4x4(i32** %10, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}