#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*/ execute_serial(int, int **);
int /*<<< orphan*/ fail(int, char *, char *);
int **initialize_matrix(int, int **);
void *trivial_exec_serial(void *args) {
  int mat[4][4] = {{0, 1, 1, 1}, {1, 0, 1, 1}, {1, 1, 0, 1}, {1, 1, 1, 0}};
  int **arr = initialize_matrix(4, mat);
  execute_serial(4, arr);
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      if (mat[i][j] != arr[i][j]) {
        fail(-1, "trivial_exec_serial",
             "Serial execution did not match expected outcome.");
      }
    }
  }
  return (NULL);
}


x86 assembly (clang, -O0):
<trivial_exec_serial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xea9(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
lea    -0x50(%rbp),%rsi
mov    $0x4,%edi
call   1060 <initialize_matrix@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rsi
mov    $0x4,%edi
call   1040 <execute_serial@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    1210 <trivial_exec_serial+0xd0>
movl   $0x0,-0x60(%rbp)
cmpl   $0x4,-0x60(%rbp)
jge    11fd <trivial_exec_serial+0xbd>
movslq -0x5c(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x60(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x58(%rbp),%rcx
movslq -0x5c(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
movslq -0x60(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
je     11ea <trivial_exec_serial+0xaa>
mov    $0xffffffff,%edi
lea    0xe62(%rip),%rsi
lea    0xe6f(%rip),%rdx
call   1030 <fail@plt>
jmp    11ef <trivial_exec_serial+0xaf>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1199 <trivial_exec_serial+0x59>
jmp    1202 <trivial_exec_serial+0xc2>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1188 <trivial_exec_serial+0x48>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trivial_exec_serial>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
movaps 0xeee(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe9a(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    $0x4,%edi
call   1050 <initialize_matrix@plt>
mov    %rax,%r12
mov    $0x4,%edi
mov    %rax,%rsi
call   1040 <execute_serial@plt>
xor    %ebx,%ebx
lea    0xeb0(%rip),%r14
lea    0xebd(%rip),%r15
jmp    11aa <trivial_exec_serial+0x7a>
nopl   0x0(%rax)
add    $0x8,%rbx
cmp    $0x20,%rbx
je     121e <trivial_exec_serial+0xee>
mov    (%rsp,%rbx,2),%ecx
mov    (%r12,%rbx,1),%rax
cmp    (%rax),%ecx
je     11c9 <trivial_exec_serial+0x99>
mov    $0xffffffff,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fail@plt>
mov    (%r12,%rbx,1),%rax
mov    0x4(%rsp,%rbx,2),%ecx
cmp    0x4(%rax),%ecx
je     11e6 <trivial_exec_serial+0xb6>
mov    $0xffffffff,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fail@plt>
mov    (%r12,%rbx,1),%rax
mov    0x8(%rsp,%rbx,2),%ecx
cmp    0x8(%rax),%ecx
je     1203 <trivial_exec_serial+0xd3>
mov    $0xffffffff,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fail@plt>
mov    (%r12,%rbx,1),%rax
mov    0xc(%rsp,%rbx,2),%ecx
cmp    0xc(%rax),%ecx
je     11a0 <trivial_exec_serial+0x70>
mov    $0xffffffff,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fail@plt>
jmp    11a0 <trivial_exec_serial+0x70>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.trivial_exec_serial.mat = [4 x [4 x i32]] [[4 x i32] [i32 0, i32 1, i32 1, i32 1], [4 x i32] [i32 1, i32 0, i32 1, i32 1], [4 x i32] [i32 1, i32 1, i32 0, i32 1], [4 x i32] [i32 1, i32 1, i32 1, i32 0]]
@.str = [20 x i8] c"trivial_exec_serial\00"
@.str.1 = [49 x i8] c"Serial execution did not match expected outcome.\00"
define i8* @trivial_exec_serial(i8* %0) {
%2 = alloca i8*
%3 = alloca [4 x [4 x i32]]
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = bitcast [4 x [4 x i32]]* %3 to i8*
%8 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 0
%9 = bitcast [4 x i32]* %8 to i32**
%10 = call i32** @initialize_matrix(i32 4, i32** %9)
store i32** %10, i32*** %4
%11 = load i32**, i32*** %4
%12 = call i32 @execute_serial(i32 4, i32** %11)
store i32 0, i32* %5
br label %13
13: ; preds = %45, %1
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %48
16: ; preds = %13
store i32 0, i32* %6
br label %17
17: ; preds = %41, %16
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %44
20: ; preds = %17
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %3, i64 0, i64 %22
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %23, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = load i32**, i32*** %4
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32*, i32** %28, i64 %30
%32 = load i32*, i32** %31
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = icmp ne i32 %27, %36
br i1 %37, label %38, label %40
38: ; preds = %20
%39 = call i32 @fail(i32 -1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38, %20
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %17
44: ; preds = %17
br label %45
45: ; preds = %44
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %13
48: ; preds = %13
ret i8* null
}

LLVM IR (-O2):
@__const.trivial_exec_serial.mat = [4 x [4 x i32]] [[4 x i32] [i32 0, i32 1, i32 1, i32 1], [4 x i32] [i32 1, i32 0, i32 1, i32 1], [4 x i32] [i32 1, i32 1, i32 0, i32 1], [4 x i32] [i32 1, i32 1, i32 1, i32 0]]
@.str = [20 x i8] c"trivial_exec_serial\00"
@.str.1 = [49 x i8] c"Serial execution did not match expected outcome.\00"
define noalias i8* @trivial_exec_serial(i8* nocapture readnone %0) {
%2 = alloca [4 x [4 x i32]]
%3 = bitcast [4 x [4 x i32]]* %2 to i8*
%4 = bitcast [4 x [4 x i32]]* %2 to i32**
%5 = call i32** @initialize_matrix(i32 4, i32** %4)
%6 = call i32 @execute_serial(i32 4, i32** %5)
br label %7
7: ; preds = %1, %48
%8 = phi i64 [ 0, %1 ], [ %49, %48 ]
%9 = getelementptr inbounds i32*, i32** %5, i64 %8
%10 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 %8, i64 0
%11 = load i32, i32* %10
%12 = load i32*, i32** %9
%13 = load i32, i32* %12
%14 = icmp eq i32 %11, %13
br i1 %14, label %19, label %16
15: ; preds = %48
ret i8* null
16: ; preds = %7
%17 = call i32 @fail(i32 -1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32*, i32** %9
br label %19
19: ; preds = %7, %16
%20 = phi i32* [ %12, %7 ], [ %18, %16 ]
%21 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 %8, i64 1
%22 = load i32, i32* %21
%23 = getelementptr inbounds i32, i32* %20, i64 1
%24 = load i32, i32* %23
%25 = icmp eq i32 %22, %24
br i1 %25, label %29, label %26
26: ; preds = %19
%27 = call i32 @fail(i32 -1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32*, i32** %9
br label %29
29: ; preds = %26, %19
%30 = phi i32* [ %28, %26 ], [ %20, %19 ]
%31 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 %8, i64 2
%32 = load i32, i32* %31
%33 = getelementptr inbounds i32, i32* %30, i64 2
%34 = load i32, i32* %33
%35 = icmp eq i32 %32, %34
br i1 %35, label %39, label %36
36: ; preds = %29
%37 = call i32 @fail(i32 -1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%38 = load i32*, i32** %9
br label %39
39: ; preds = %36, %29
%40 = phi i32* [ %38, %36 ], [ %30, %29 ]
%41 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %2, i64 0, i64 %8, i64 3
%42 = load i32, i32* %41
%43 = getelementptr inbounds i32, i32* %40, i64 3
%44 = load i32, i32* %43
%45 = icmp eq i32 %42, %44
br i1 %45, label %48, label %46
46: ; preds = %39
%47 = call i32 @fail(i32 -1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %46, %39
%49 = add nuw nsw i64 %8, 1
%50 = icmp eq i64 %49, 4
br i1 %50, label %15, label %7
}