#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*/ check_if_win(int ***, int ***);
int /*<<< orphan*/ find_pivot(int ***, int *, int *);
int /*<<< orphan*/ make_movement_on_puzzle(int ***, int, int, int);
char posix_reader();
int /*<<< orphan*/ show_multi_array_ptr(int ***);
int main(int argc, char const *argv[]) {
  int valid_puzzle[4][4] = {
      {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 0}};
  int puzzle[4][4] = {
      {5, 6, 7, 0}, {9, 10, 11, 12}, {1, 2, 3, 4}, {13, 14, 15, 8}};
  show_multi_array_ptr(&puzzle);
  char ch;
  int pivot_x = 0;
  int pivot_y = 0;
  do {
    find_pivot(&puzzle, &pivot_x, &pivot_y);
    ch = posix_reader();
    switch (ch) {
    case 65:
      make_movement_on_puzzle(&puzzle, 1, pivot_x, pivot_y);
      break;
    case 66:
      make_movement_on_puzzle(&puzzle, 2, pivot_x, pivot_y);
      break;
    case 67:
      make_movement_on_puzzle(&puzzle, 3, pivot_x, pivot_y);
      break;
    case 68:
      make_movement_on_puzzle(&puzzle, 4, pivot_x, pivot_y);
      break;
    case 'e':
      return 0;
      break;
    }
    show_multi_array_ptr(&puzzle);
  } while (!check_if_win(&valid_puzzle, &puzzle));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xf1c(%rip),%rsi
mov    $0x40,%edx
call   1070 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0xf44(%rip),%rsi
mov    $0x40,%edx
call   1070 <memcpy@plt>
lea    -0x90(%rbp),%rdi
call   1030 <show_multi_array_ptr@plt>
movl   $0x0,-0x98(%rbp)
movl   $0x0,-0x9c(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0x98(%rbp),%rsi
lea    -0x9c(%rbp),%rdx
call   1060 <find_pivot@plt>
xor    %eax,%eax
call   1050 <posix_reader@plt>
mov    %al,-0x91(%rbp)
movsbl -0x91(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0xa8(%rbp)
sub    $0x24,%eax
ja     12b4 <main+0x154>
mov    -0xa8(%rbp),%rax
lea    0xde9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%edx
mov    -0x9c(%rbp),%ecx
mov    $0x1,%esi
call   1080 <make_movement_on_puzzle@plt>
jmp    12b4 <main+0x154>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%edx
mov    -0x9c(%rbp),%ecx
mov    $0x2,%esi
call   1080 <make_movement_on_puzzle@plt>
jmp    12b4 <main+0x154>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%edx
mov    -0x9c(%rbp),%ecx
mov    $0x3,%esi
call   1080 <make_movement_on_puzzle@plt>
jmp    12b4 <main+0x154>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%edx
mov    -0x9c(%rbp),%ecx
mov    $0x4,%esi
call   1080 <make_movement_on_puzzle@plt>
jmp    12b4 <main+0x154>
movl   $0x0,-0x4(%rbp)
jmp    12e7 <main+0x187>
lea    -0x90(%rbp),%rdi
call   1030 <show_multi_array_ptr@plt>
lea    -0x50(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1040 <check_if_win@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c6 <main+0x66>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x90,%rsp
movaps 0xf69(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xf4a(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xf2e(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xf12(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xf76(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xf5a(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xf3e(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xf22(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <show_multi_array_ptr@plt>
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
lea    0x50(%rsp),%r12
lea    0xe0a(%rip),%r13
jmp    122c <main+0xdc>
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <make_movement_on_puzzle@plt>
mov    %rbx,%rdi
call   1030 <show_multi_array_ptr@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <check_if_win@plt>
test   %eax,%eax
jne    12a5 <main+0x155>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <find_pivot@plt>
xor    %eax,%eax
call   1050 <posix_reader@plt>
movsbl %al,%eax
add    $0xffffffbf,%eax
cmp    $0x24,%eax
ja     1215 <main+0xc5>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
jmp    1210 <main+0xc0>
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
jmp    1210 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x3,%esi
jmp    1210 <main+0xc0>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.valid_puzzle = [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 0]]
@__const.main.puzzle = [4 x [4 x i32]] [[4 x i32] [i32 5, i32 6, i32 7, i32 0], [4 x i32] [i32 9, i32 10, i32 11, i32 12], [4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32] [i32 13, i32 14, i32 15, i32 8]]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x [4 x i32]]
%7 = alloca [4 x [4 x i32]]
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [4 x [4 x i32]]* %6 to i8*
%12 = bitcast [4 x [4 x i32]]* %7 to i8*
%13 = bitcast [4 x [4 x i32]]* %7 to i32***
%14 = call i32 @show_multi_array_ptr(i32*** %13)
store i32 0, i32* %9
store i32 0, i32* %10
br label %15
15: ; preds = %45, %2
%16 = bitcast [4 x [4 x i32]]* %7 to i32***
%17 = call i32 @find_pivot(i32*** %16, i32* %9, i32* %10)
%18 = call signext i8 (...) @posix_reader()
store i8 %18, i8* %8
%19 = load i8, i8* %8
%20 = sext i8 %19 to i32
switch i32 %20, label %42 [
i32 65, label %21
i32 66, label %26
i32 67, label %31
i32 68, label %36
i32 101, label %41
]
21: ; preds = %15
%22 = bitcast [4 x [4 x i32]]* %7 to i32***
%23 = load i32, i32* %9
%24 = load i32, i32* %10
%25 = call i32 @make_movement_on_puzzle(i32*** %22, i32 1, i32 %23, i32 %24)
br label %42
26: ; preds = %15
%27 = bitcast [4 x [4 x i32]]* %7 to i32***
%28 = load i32, i32* %9
%29 = load i32, i32* %10
%30 = call i32 @make_movement_on_puzzle(i32*** %27, i32 2, i32 %28, i32 %29)
br label %42
31: ; preds = %15
%32 = bitcast [4 x [4 x i32]]* %7 to i32***
%33 = load i32, i32* %9
%34 = load i32, i32* %10
%35 = call i32 @make_movement_on_puzzle(i32*** %32, i32 3, i32 %33, i32 %34)
br label %42
36: ; preds = %15
%37 = bitcast [4 x [4 x i32]]* %7 to i32***
%38 = load i32, i32* %9
%39 = load i32, i32* %10
%40 = call i32 @make_movement_on_puzzle(i32*** %37, i32 4, i32 %38, i32 %39)
br label %42
41: ; preds = %15
store i32 0, i32* %3
br label %52
42: ; preds = %15, %36, %31, %26, %21
%43 = bitcast [4 x [4 x i32]]* %7 to i32***
%44 = call i32 @show_multi_array_ptr(i32*** %43)
br label %45
45: ; preds = %42
%46 = bitcast [4 x [4 x i32]]* %6 to i32***
%47 = bitcast [4 x [4 x i32]]* %7 to i32***
%48 = call i32 @check_if_win(i32*** %46, i32*** %47)
%49 = icmp ne i32 %48, 0
%50 = xor i1 %49, true
br i1 %50, label %15, label %51
51: ; preds = %45
store i32 0, i32* %3
br label %52
52: ; preds = %51, %41
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@__const.main.valid_puzzle = [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 0]]
@__const.main.puzzle = [4 x [4 x i32]] [[4 x i32] [i32 5, i32 6, i32 7, i32 0], [4 x i32] [i32 9, i32 10, i32 11, i32 12], [4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32] [i32 13, i32 14, i32 15, i32 8]]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x [4 x i32]]
%4 = alloca [4 x [4 x i32]]
%5 = alloca i32
%6 = alloca i32
%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]]* %4 to i32***
%10 = call i32 @show_multi_array_ptr(i32*** %9)
%11 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%12 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%13 = bitcast [4 x [4 x i32]]* %3 to i32***
br label %14
14: ; preds = %34, %2
%15 = call i32 @find_pivot(i32*** %9, i32* %5, i32* %6)
%16 = call signext i8 (...) @posix_reader()
%17 = sext i8 %16 to i32
switch i32 %17, label %34 [
i32 65, label %18
i32 66, label %22
i32 67, label %26
i32 68, label %30
i32 101, label %38
]
18: ; preds = %14
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = call i32 @make_movement_on_puzzle(i32*** %9, i32 1, i32 %19, i32 %20)
br label %34
22: ; preds = %14
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = call i32 @make_movement_on_puzzle(i32*** %9, i32 2, i32 %23, i32 %24)
br label %34
26: ; preds = %14
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = call i32 @make_movement_on_puzzle(i32*** %9, i32 3, i32 %27, i32 %28)
br label %34
30: ; preds = %14
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = call i32 @make_movement_on_puzzle(i32*** %9, i32 4, i32 %31, i32 %32)
br label %34
34: ; preds = %14, %30, %26, %22, %18
%35 = call i32 @show_multi_array_ptr(i32*** %9)
%36 = call i32 @check_if_win(i32*** %13, i32*** %9)
%37 = icmp eq i32 %36, 0
br i1 %37, label %14, label %38
38: ; preds = %34, %14
ret i32 0
}