#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(int, int, int, int **);
int /*<<< orphan*/ fail(int, char *, char *);
int **initialize_matrix(int, int **);
void *execute_increment(void *args) {
  int mat[3][3] = {{0, 1, 2}, {1, 0, 5}, {2, 5, 0}};
  int **arr = initialize_matrix(3, mat);
  int i = 1;
  int j = 2;
  int k = 0;
  execute(i, j, k, arr);
  if (arr[i][j] != 3) {
    fail(-1, "execute_increment", "Array did not increment correctly.");
  }
  return (NULL);
}


x86 assembly (clang, -O0):
<execute_increment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x24,%edx
call   1040 <memset@plt>
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x5,-0x1c(%rbp)
movl   $0x2,-0x18(%rbp)
movl   $0x5,-0x14(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x3,%edi
call   1060 <initialize_matrix@plt>
mov    %rax,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
movl   $0x2,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x40(%rbp),%esi
mov    -0x44(%rbp),%edx
mov    -0x38(%rbp),%rcx
call   1050 <execute@plt>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
cmpl   $0x3,(%rax,%rcx,4)
je     11f1 <execute_increment+0xb1>
mov    $0xffffffff,%edi
lea    0xe1b(%rip),%rsi
lea    0xe26(%rip),%rdx
call   1030 <fail@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_increment>:
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
movabs $0x200000001,%rax
mov    %rax,0x4(%rsp)
movl   $0x1,0xc(%rsp)
movabs $0x200000005,%rax
mov    %rax,0x14(%rsp)
movl   $0x5,0x1c(%rsp)
mov    %rsp,%rsi
mov    $0x3,%edi
call   1050 <initialize_matrix@plt>
mov    %rax,%rbx
mov    $0x1,%edi
mov    $0x2,%esi
xor    %edx,%edx
mov    %rax,%rcx
call   1040 <execute@plt>
mov    0x8(%rbx),%rax
cmpl   $0x3,0x8(%rax)
je     11bd <execute_increment+0x8d>
lea    0xe54(%rip),%rsi
lea    0xe5f(%rip),%rdx
mov    $0xffffffff,%edi
call   1030 <fail@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"execute_increment\00"
@.str.1 = [35 x i8] c"Array did not increment correctly.\00"
define i8* @execute_increment(i8* %0) {
%2 = alloca i8*
%3 = alloca [3 x [3 x i32]]
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = bitcast [3 x [3 x i32]]* %3 to i8*
%9 = bitcast i8* %8 to [3 x [3 x i32]]*
%10 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %9, i32 0, i32 0
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i32 0, i32 1
store i32 1, i32* %11
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i32 0, i32 2
store i32 2, i32* %12
%13 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %9, i32 0, i32 1
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %13, i32 0, i32 0
store i32 1, i32* %14
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %13, i32 0, i32 2
store i32 5, i32* %15
%16 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %9, i32 0, i32 2
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %16, i32 0, i32 0
store i32 2, i32* %17
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %16, i32 0, i32 1
store i32 5, i32* %18
%19 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %3, i64 0, i64 0
%20 = bitcast [3 x i32]* %19 to i32**
%21 = call i32** @initialize_matrix(i32 3, i32** %20)
store i32** %21, i32*** %4
store i32 1, i32* %5
store i32 2, i32* %6
store i32 0, i32* %7
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = load i32**, i32*** %4
%26 = call i32 @execute(i32 %22, i32 %23, i32 %24, i32** %25)
%27 = load i32**, i32*** %4
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32*, i32** %27, i64 %29
%31 = load i32*, i32** %30
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = icmp ne i32 %35, 3
br i1 %36, label %37, label %39
37: ; preds = %1
%38 = call i32 @fail(i32 -1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %1
ret i8* null
}

LLVM IR (-O2):
@.str = [18 x i8] c"execute_increment\00"
@.str.1 = [35 x i8] c"Array did not increment correctly.\00"
define noalias i8* @execute_increment(i8* nocapture readnone %0) {
%2 = alloca [3 x [3 x i32]]
%3 = bitcast [3 x [3 x i32]]* %2 to i8*
%4 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 0, i64 1
store i32 1, i32* %4
%5 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 0, i64 2
store i32 2, i32* %5
%6 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 1, i64 0
store i32 1, i32* %6
%7 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 1, i64 2
store i32 5, i32* %7
%8 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 2, i64 0
store i32 2, i32* %8
%9 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 2, i64 1
store i32 5, i32* %9
%10 = bitcast [3 x [3 x i32]]* %2 to i32**
%11 = call i32** @initialize_matrix(i32 3, i32** %10)
%12 = call i32 @execute(i32 1, i32 2, i32 0, i32** %11)
%13 = getelementptr inbounds i32*, i32** %11, i64 1
%14 = load i32*, i32** %13
%15 = getelementptr inbounds i32, i32* %14, i64 2
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 3
br i1 %17, label %20, label %18
18: ; preds = %1
%19 = call i32 @fail(i32 -1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %1
ret i8* null
}