#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 atoi(char *);
scalar_t__ check_input(int, int, int, int);
int /*<<< orphan*/ knight_tour(int, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int size_x;
  int size_y;
  int start_x;
  int start_y;
  if (argc != 5) {
    printf("Usage: %s : [size_x] [size_y] [pos_x] [pos_y]\n\n", argv[0]);
    printf("size_x & size_y : Size of the map.\n");
    printf("pos_x  & pos_y  : Knight starting position\n");
    return (1);
  }
  size_x = atoi(argv[1]);
  size_y = atoi(argv[2]);
  start_x = atoi(argv[3]);
  start_y = atoi(argv[4]);
  if (check_input(size_x, size_y, start_x, start_y))
    return (1);
  knight_tour(size_x, size_y, start_x, start_y);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     119d <main+0x5d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    121c <main+0xdc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1030 <check_input@plt>
cmp    $0x0,%rax
je     1204 <main+0xc4>
movl   $0x1,-0x4(%rbp)
jmp    121c <main+0xdc>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1060 <knight_tour@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbp
cmp    $0x5,%edi
jne    11bc <main+0x6c>
mov    0x8(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%r15d
mov    0x18(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    0x20(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    %r14d,%edi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1040 <check_input@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11eb <main+0x9b>
mov    %r14d,%edi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1070 <knight_tour@plt>
xor    %eax,%eax
jmp    11eb <main+0x9b>
mov    0x0(%rbp),%rsi
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Usage: %s : [size_x] [size_y] [pos_x] [pos_y]\0A\0A\00"
@.str.1 = [36 x i8] c"size_x & size_y : Size of the map.\0A\00"
@.str.2 = [44 x i8] c"pos_x & pos_y : Knight starting position\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 5
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %49
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %7
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %8
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 4
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %9
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = load i32, i32* %9
%40 = call i64 @check_input(i32 %36, i32 %37, i32 %38, i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %19
store i32 1, i32* %3
br label %49
43: ; preds = %19
%44 = load i32, i32* %6
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = load i32, i32* %9
%48 = call i32 @knight_tour(i32 %44, i32 %45, i32 %46, i32 %47)
store i32 0, i32* %3
br label %49
49: ; preds = %43, %42, %12
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str = [48 x i8] c"Usage: %s : [size_x] [size_y] [pos_x] [pos_y]\0A\0A\00"
@str = [35 x i8] c"size_x & size_y : Size of the map.\00"
@str.3 = [43 x i8] c"pos_x & pos_y : Knight starting position\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 5
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.3, i64 0, i64 0))
br label %26
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 4
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = tail call i64 @check_input(i32 %12, i32 %15, i32 %18, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %9
%25 = tail call i32 @knight_tour(i32 %12, i32 %15, i32 %18, i32 %21)
br label %26
26: ; preds = %9, %24, %4
%27 = phi i32 [ 1, %4 ], [ 0, %24 ], [ 1, %9 ]
ret i32 %27
}