#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ GenerateMaze(char *, int, int);
int /*<<< orphan*/ ShowMaze(char *, int, int);
int /*<<< orphan*/ SolveMaze(char *, int, int);
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  int width, height;
  char *maze;
  printf("Maze by Joe Wingbermuehle 19990805\n");
  if (argc != 3 && argc != 4) {
    printf("usage: maze <width> <height> [s]\n");
    exit(EXIT_FAILURE);
  }
  width = atoi(argv[1]) * 2 + 3;
  height = atoi(argv[2]) * 2 + 3;
  if (width < 7 || height < 7) {
    printf("error: illegal maze size\n");
    exit(EXIT_FAILURE);
  }
  if (argc == 4 && argv[3][0] != 's') {
    printf("error: invalid argument\n");
    exit(EXIT_FAILURE);
  }
  maze = (char *)malloc(width * height * sizeof(char));
  if (maze == NULL) {
    printf("error: not enough memory\n");
    exit(EXIT_FAILURE);
  }
  GenerateMaze(maze, width, height);
  ShowMaze(maze, width, height);
  if (argc == 4) {
    SolveMaze(maze, width, height);
    ShowMaze(maze, width, height);
  }
  free(maze);
  exit(EXIT_SUCCESS);
}


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)
lea    0xe63(%rip),%rdi
call   1050 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
je     11d0 <main+0x50>
cmpl   $0x4,-0x8(%rbp)
je     11d0 <main+0x50>
lea    0xe67(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
shl    $0x1,%eax
add    $0x3,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
shl    $0x1,%eax
add    $0x3,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x7,-0x14(%rbp)
jl     1210 <main+0x90>
cmpl   $0x7,-0x18(%rbp)
jge    122a <main+0xaa>
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jne    1262 <main+0xe2>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
je     1262 <main+0xe2>
lea    0xe11(%rip),%rdi
call   1050 <printf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    129f <main+0x11f>
lea    0xded(%rip),%rdi
call   1050 <printf@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1090 <GenerateMaze@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10a0 <ShowMaze@plt>
cmpl   $0x4,-0x8(%rbp)
jne    12e5 <main+0x165>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <SolveMaze@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10a0 <ShowMaze@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %edi,%ebx
lea    0xe6d(%rip),%rdi
call   1050 <puts@plt>
lea    -0x5(%rbx),%eax
cmp    $0xfffffffd,%eax
ja     11a9 <main+0x29>
lea    0xec6(%rip),%rdi
jmp    120b <main+0x8b>
mov    0x8(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbp),%rdi
call   1070 <atoi@plt>
cmp    $0x2,%r14d
jl     1204 <main+0x84>
cmp    $0x1,%eax
jle    1204 <main+0x84>
cmp    $0x4,%ebx
jne    11db <main+0x5b>
mov    0x18(%rbp),%rcx
cmpb   $0x73,(%rcx)
jne    1274 <main+0xf4>
add    %r14d,%r14d
add    $0x3,%r14d
lea    (%rax,%rax,1),%r15d
add    $0x3,%r15d
mov    %r15d,%edi
imul   %r14d,%edi
call   1060 <malloc@plt>
test   %rax,%rax
jne    121e <main+0x9e>
lea    0xe21(%rip),%rdi
jmp    120b <main+0x8b>
lea    0xe49(%rip),%rdi
call   1050 <puts@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14d,%esi
mov    %r15d,%edx
call   1090 <GenerateMaze@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %r15d,%edx
call   10a0 <ShowMaze@plt>
cmp    $0x4,%ebx
jne    125e <main+0xde>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %r15d,%edx
call   1040 <SolveMaze@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %r15d,%edx
call   10a0 <ShowMaze@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    0xdc1(%rip),%rdi
jmp    120b <main+0x8b>

LLVM IR (-O0):
@.str = [36 x i8] c"Maze by Joe Wingbermuehle 19990805\0A\00"
@.str.1 = [34 x i8] c"usage: maze <width> <height> [s]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [26 x i8] c"error: illegal maze size\0A\00"
@.str.3 = [25 x i8] c"error: invalid argument\0A\00"
@.str.4 = [26 x i8] c"error: not enough memory\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 4
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %12, %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)
%24 = mul nsw i32 %23, 2
%25 = add nsw i32 %24, 3
store i32 %25, i32* %6
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
%30 = mul nsw i32 %29, 2
%31 = add nsw i32 %30, 3
store i32 %31, i32* %7
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 7
br i1 %33, label %37, label %34
34: ; preds = %19
%35 = load i32, i32* %7
%36 = icmp slt i32 %35, 7
br i1 %36, label %37, label %41
37: ; preds = %34, %19
%38 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %34
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, 4
br i1 %43, label %44, label %56
44: ; preds = %41
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 3
%47 = load i8*, i8** %46
%48 = getelementptr inbounds i8, i8* %47, i64 0
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 115
br i1 %51, label %52, label %56
52: ; preds = %44
%53 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %44, %41
%57 = load i32, i32* %6
%58 = load i32, i32* %7
%59 = mul nsw i32 %57, %58
%60 = sext i32 %59 to i64
%61 = mul i64 %60, 1
%62 = trunc i64 %61 to i32
%63 = call i64 @malloc(i32 %62)
%64 = inttoptr i64 %63 to i8*
store i8* %64, i8** %8
%65 = load i8*, i8** %8
%66 = icmp eq i8* %65, null
br i1 %66, label %67, label %71
67: ; preds = %56
%68 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %56
%72 = load i8*, i8** %8
%73 = load i32, i32* %6
%74 = load i32, i32* %7
%75 = call i32 @GenerateMaze(i8* %72, i32 %73, i32 %74)
%76 = load i8*, i8** %8
%77 = load i32, i32* %6
%78 = load i32, i32* %7
%79 = call i32 @ShowMaze(i8* %76, i32 %77, i32 %78)
%80 = load i32, i32* %4
%81 = icmp eq i32 %80, 4
br i1 %81, label %82, label %91
82: ; preds = %71
%83 = load i8*, i8** %8
%84 = load i32, i32* %6
%85 = load i32, i32* %7
%86 = call i32 @SolveMaze(i8* %83, i32 %84, i32 %85)
%87 = load i8*, i8** %8
%88 = load i32, i32* %6
%89 = load i32, i32* %7
%90 = call i32 @ShowMaze(i8* %87, i32 %88, i32 %89)
br label %91
91: ; preds = %82, %71
%92 = load i8*, i8** %8
%93 = call i32 @free(i8* %92)
%94 = load i32, i32* @EXIT_SUCCESS
%95 = call i32 @exit(i32 %94)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [35 x i8] c"Maze by Joe Wingbermuehle 19990805\00"
@str.5 = [25 x i8] c"error: not enough memory\00"
@str.6 = [24 x i8] c"error: invalid argument\00"
@str.7 = [25 x i8] c"error: illegal maze size\00"
@str.8 = [33 x i8] c"usage: maze <width> <height> [s]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%4 = add i32 %0, -5
%5 = icmp ult i32 %4, -2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.8, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = shl nsw i32 %13, 1
%15 = add nsw i32 %14, 3
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = shl nsw i32 %18, 1
%20 = add nsw i32 %19, 3
%21 = icmp slt i32 %13, 2
%22 = icmp slt i32 %18, 2
%23 = select i1 %21, i1 true, i1 %22
br i1 %23, label %24, label %28
24: ; preds = %10
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.7, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = tail call i32 @exit(i32 %26)
unreachable
28: ; preds = %10
%29 = icmp eq i32 %0, 4
br i1 %29, label %30, label %39
30: ; preds = %28
%31 = getelementptr inbounds i8*, i8** %1, i64 3
%32 = load i8*, i8** %31
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 115
br i1 %34, label %39, label %35
35: ; preds = %30
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = tail call i32 @exit(i32 %37)
unreachable
39: ; preds = %30, %28
%40 = mul nsw i32 %20, %15
%41 = tail call i64 @malloc(i32 %40)
%42 = inttoptr i64 %41 to i8*
%43 = icmp eq i64 %41, 0
br i1 %43, label %44, label %48
44: ; preds = %39
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = tail call i32 @exit(i32 %46)
unreachable
48: ; preds = %39
%49 = tail call i32 @GenerateMaze(i8* %42, i32 %15, i32 %20)
%50 = tail call i32 @ShowMaze(i8* %42, i32 %15, i32 %20)
br i1 %29, label %51, label %54
51: ; preds = %48
%52 = tail call i32 @SolveMaze(i8* %42, i32 %15, i32 %20)
%53 = tail call i32 @ShowMaze(i8* %42, i32 %15, i32 %20)
br label %54
54: ; preds = %51, %48
%55 = tail call i32 @free(i8* %42)
%56 = load i32, i32* @EXIT_SUCCESS
%57 = tail call i32 @exit(i32 %56)
unreachable
}