#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 */
typedef char *node;

/* Variables and functions */
char **cell;
char **create_node(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char **);
int /*<<< orphan*/ generate_maze(long, char **, long, char **, long, char **,
                                 long);
int /*<<< orphan*/ generate_soln(long, char **, char **, long, char **, long);
int /*<<< orphan*/ init_display(long, char **, long);
int /*<<< orphan*/ initialize_cells(long, char **, long);
void *malloc(int);
int /*<<< orphan*/ stack_destroy(char **);
int /*<<< orphan*/ stderr;
long strtol(char *, char **, int);
void **uint16_t(char *);
int main(int argc, char *argv[]) {
  long row;
  long col;
  char *endptr = NULL;
  if (argc < 3) {
    fprintf(stderr, "usage: maze <row count> <column count>\n");
    return 1;
  }
  row = strtol(argv[1], &endptr, 10);
  if (endptr == NULL || *endptr != (char)0) {
    fprintf(stderr, "error: unknown row count\n");
    return 1;
  }
  col = strtol(argv[2], &endptr, 10);
  if (endptr == NULL || *endptr != (char)0) {
    fprintf(stderr, "error: unknown column count\n");
    return 1;
  }
  uint16_t(*cell)[col] = malloc(sizeof(*cell) * row);
  initialize_cells(col, cell, row);
  long cl = col * 2 + 1 + 1;
  long rl = row * 2 + 1;
  char(*maze)[cl] = malloc(sizeof(*maze) * rl);
  init_display(cl, maze, rl);
  struct node *head = create_node(0, 0);
  generate_maze(col, cell, row, head, cl, maze, rl);
  generate_soln(col, cell, head, cl, maze, rl);
  stack_destroy(head);
  free(head);
  free(maze);
  free(cell);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11f9 <main+0x49>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe18(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13c2 <main+0x212>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     122e <main+0x7e>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     124f <main+0x9f>
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13c2 <main+0x212>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1284 <main+0xd4>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12a5 <main+0xf5>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
lea    0xdae(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13c2 <main+0x212>
mov    -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    0x2d19(%rip),%rax
mov    (%rax),%rax
mov    (%rax),%rdi
call   10d0 <uint16_t@plt>
mov    -0x50(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdi
mov    0x2cf7(%rip),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <initialize_cells@plt>
mov    -0x20(%rbp),%rax
shl    $0x1,%rax
add    $0x1,%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
imul   -0x38(%rbp),%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   10a0 <init_display@plt>
xor    %esi,%esi
mov    %esi,%edi
call   10c0 <create_node@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2c8a(%rip),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x40(%rbp),%r9
mov    -0x38(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <generate_maze@plt>
mov    -0x20(%rbp),%rdi
mov    0x2c5f(%rip),%rax
mov    (%rax),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    -0x38(%rbp),%r9
call   1060 <generate_soln@plt>
mov    -0x48(%rbp),%rdi
call   1080 <stack_destroy@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x10(%rsp)
cmp    $0x2,%edi
jg     11de <main+0x2e>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
jmp    1216 <main+0x66>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rax
test   %rax,%rax
je     1206 <main+0x56>
cmpb   $0x0,(%rax)
je     1231 <main+0x81>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xe12(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rbp),%rdi
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,%r14
mov    0x10(%rsp),%rax
test   %rax,%rax
je     1256 <main+0xa6>
cmpb   $0x0,(%rax)
je     1268 <main+0xb8>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
jmp    1216 <main+0x66>
lea    0x0(,%rbx,8),%edi
call   10b0 <malloc@plt>
mov    %rax,%rbp
mov    0x2d5a(%rip),%r15
mov    (%r15),%rax
mov    (%rax),%rdi
call   10d0 <uint16_t@plt>
mov    %rbp,(%rax,%r14,8)
mov    (%r15),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1050 <initialize_cells@plt>
lea    (%r14,%r14,1),%r13
add    $0x2,%r13
lea    (%rbx,%rbx,1),%r12
add    $0x1,%r12
mov    %r13d,%edi
imul   %r12d,%edi
call   10b0 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    %r13,%rdi
mov    %rax,%rsi
mov    %r12,%rdx
mov    %r12,0x18(%rsp)
call   10a0 <init_display@plt>
xor    %ebp,%ebp
xor    %edi,%edi
xor    %esi,%esi
call   10c0 <create_node@plt>
mov    %rax,%r15
mov    0x2cf4(%rip),%rax
mov    (%rax),%rsi
mov    %r12,(%rsp)
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r13,%r8
mov    0x20(%rsp),%r12
mov    %r12,%r9
call   1040 <generate_maze@plt>
mov    0x2ccd(%rip),%rbx
mov    (%rbx),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
mov    %r13,%rcx
mov    %r12,%r8
mov    0x18(%rsp),%r9
call   1060 <generate_soln@plt>
mov    %r15,%rdi
call   1080 <stack_destroy@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x2c95(%rip),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
jmp    1220 <main+0x70>

LLVM IR (-O0):
%struct.node = type opaque
@stderr = global i32 0
@.str = [40 x i8] c"usage: maze <row count> <column count>\0A\00"
@.str.1 = [26 x i8] c"error: unknown row count\0A\00"
@.str.2 = [29 x i8] c"error: unknown column count\0A\00"
@cell = global i8** null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca %struct.node*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %8
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %112
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strtol(i8* %21, i8** %8, i32 10)
store i64 %22, i64* %6
%23 = load i8*, i8** %8
%24 = icmp eq i8* %23, null
br i1 %24, label %30, label %25
25: ; preds = %18
%26 = load i8*, i8** %8
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %25, %18
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %112
33: ; preds = %25
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i64 @strtol(i8* %36, i8** %8, i32 10)
store i64 %37, i64* %7
%38 = load i8*, i8** %8
%39 = icmp eq i8* %38, null
br i1 %39, label %45, label %40
40: ; preds = %33
%41 = load i8*, i8** %8
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %40, %33
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %112
48: ; preds = %40
%49 = load i64, i64* %6
%50 = mul i64 8, %49
%51 = trunc i64 %50 to i32
%52 = call i8* @malloc(i32 %51)
%53 = load i8**, i8*** @cell
%54 = load i8*, i8** %53
%55 = call i8** @uint16_t(i8* %54)
%56 = load i64, i64* %7
%57 = getelementptr inbounds i8*, i8** %55, i64 %56
store i8* %52, i8** %57
%58 = load i64, i64* %7
%59 = load i8**, i8*** @cell
%60 = load i64, i64* %6
%61 = call i32 @initialize_cells(i64 %58, i8** %59, i64 %60)
%62 = load i64, i64* %7
%63 = mul nsw i64 %62, 2
%64 = add nsw i64 %63, 1
%65 = add nsw i64 %64, 1
store i64 %65, i64* %9
%66 = load i64, i64* %6
%67 = mul nsw i64 %66, 2
%68 = add nsw i64 %67, 1
store i64 %68, i64* %10
%69 = load i64, i64* %9
%70 = load i8*, i8** %11
%71 = load i64, i64* %10
%72 = mul i64 %69, %71
%73 = trunc i64 %72 to i32
%74 = call i8* @malloc(i32 %73)
store i8* %74, i8** %11
%75 = load i64, i64* %9
%76 = load i8*, i8** %11
%77 = bitcast i8* %76 to i8**
%78 = load i64, i64* %10
%79 = call i32 @init_display(i64 %75, i8** %77, i64 %78)
%80 = call i8** @create_node(i32 0, i32 0)
%81 = bitcast i8** %80 to %struct.node*
store %struct.node* %81, %struct.node** %12
%82 = load i64, i64* %7
%83 = load i8**, i8*** @cell
%84 = load i64, i64* %6
%85 = load %struct.node*, %struct.node** %12
%86 = bitcast %struct.node* %85 to i8**
%87 = load i64, i64* %9
%88 = load i8*, i8** %11
%89 = bitcast i8* %88 to i8**
%90 = load i64, i64* %10
%91 = call i32 @generate_maze(i64 %82, i8** %83, i64 %84, i8** %86, i64 %87, i8** %89, i64 %90)
%92 = load i64, i64* %7
%93 = load i8**, i8*** @cell
%94 = load %struct.node*, %struct.node** %12
%95 = bitcast %struct.node* %94 to i8**
%96 = load i64, i64* %9
%97 = load i8*, i8** %11
%98 = bitcast i8* %97 to i8**
%99 = load i64, i64* %10
%100 = call i32 @generate_soln(i64 %92, i8** %93, i8** %95, i64 %96, i8** %98, i64 %99)
%101 = load %struct.node*, %struct.node** %12
%102 = bitcast %struct.node* %101 to i8**
%103 = call i32 @stack_destroy(i8** %102)
%104 = load %struct.node*, %struct.node** %12
%105 = bitcast %struct.node* %104 to i8**
%106 = call i32 @free(i8** %105)
%107 = load i8*, i8** %11
%108 = bitcast i8* %107 to i8**
%109 = call i32 @free(i8** %108)
%110 = load i8**, i8*** @cell
%111 = call i32 @free(i8** %110)
store i32 0, i32* %3
br label %112
112: ; preds = %48, %45, %30, %15
%113 = load i32, i32* %3
ret i32 %113
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [40 x i8] c"usage: maze <row count> <column count>\0A\00"
@.str.1 = [26 x i8] c"error: unknown row count\0A\00"
@.str.2 = [29 x i8] c"error: unknown column count\0A\00"
@cell = global i8** null
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %62
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strtol(i8* %11, i8** %3, i32 10)
%13 = load i8*, i8** %3
%14 = icmp eq i8* %13, null
br i1 %14, label %18, label %15
15: ; preds = %9
%16 = load i8, i8* %13
%17 = icmp eq i8 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15, %9
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %62
21: ; preds = %15
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i64 @strtol(i8* %23, i8** %3, i32 10)
%25 = load i8*, i8** %3
%26 = icmp eq i8* %25, null
br i1 %26, label %30, label %27
27: ; preds = %21
%28 = load i8, i8* %25
%29 = icmp eq i8 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27, %21
%31 = load i32, i32* @stderr
%32 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %62
33: ; preds = %27
%34 = trunc i64 %12 to i32
%35 = shl i32 %34, 3
%36 = tail call i8* @malloc(i32 %35)
%37 = load i8**, i8*** @cell
%38 = load i8*, i8** %37
%39 = tail call i8** @uint16_t(i8* %38)
%40 = getelementptr inbounds i8*, i8** %39, i64 %24
store i8* %36, i8** %40
%41 = load i8**, i8*** @cell
%42 = tail call i32 @initialize_cells(i64 %24, i8** %41, i64 %12)
%43 = shl nsw i64 %24, 1
%44 = add i64 %43, 2
%45 = shl nsw i64 %12, 1
%46 = or i64 %45, 1
%47 = mul i64 %44, %46
%48 = trunc i64 %47 to i32
%49 = tail call i8* @malloc(i32 %48)
%50 = bitcast i8* %49 to i8**
%51 = tail call i32 @init_display(i64 %44, i8** %50, i64 %46)
%52 = tail call i8** @create_node(i32 0, i32 0)
%53 = load i8**, i8*** @cell
%54 = tail call i32 @generate_maze(i64 %24, i8** %53, i64 %12, i8** %52, i64 %44, i8** %50, i64 %46)
%55 = load i8**, i8*** @cell
%56 = tail call i32 @generate_soln(i64 %24, i8** %55, i8** %52, i64 %44, i8** %50, i64 %46)
%57 = tail call i32 @stack_destroy(i8** %52)
%58 = tail call i32 @free(i8** %52)
%59 = tail call i32 @free(i8** %50)
%60 = load i8**, i8*** @cell
%61 = tail call i32 @free(i8** %60)
br label %62
62: ; preds = %33, %30, %18, %6
%63 = phi i32 [ 1, %6 ], [ 1, %18 ], [ 1, %30 ], [ 0, %33 ]
ret i32 %63
}