#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 */
unsigned int **CreateMap(unsigned int *, unsigned int *);
unsigned int **FreeMap(unsigned int **);
int /*<<< orphan*/ InitMap(unsigned int **, unsigned int *, unsigned int *,
                           unsigned int *, unsigned int *);
scalar_t__ InputRowCol(unsigned int *, unsigned int *, unsigned int *,
                       unsigned int *);
int /*<<< orphan*/ OutPutResult(unsigned int **, unsigned int *, unsigned int *,
                                unsigned int *, unsigned int *, unsigned int *);
int /*<<< orphan*/ RandomWalk(unsigned int **, unsigned int *, unsigned int *,
                              unsigned int *, unsigned int *, unsigned int *);
int main(int argc, char *argv[]) {
  unsigned int **map = NULL;
  unsigned int Row = 0, Col = 0;
  unsigned int x = 0, y = 0;
  unsigned int moveStep = 0;
  while (InputRowCol(&Row, &Col, &y, &x)) {
    map = CreateMap(&Row, &Col);
    InitMap(map, &Row, &Col, &y, &x);
    RandomWalk(map, &moveStep, &Row, &Col, &y, &x);
    OutPutResult(map, &moveStep, &Row, &Col, &y, &x);
    map = FreeMap(map);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1060 <InputRowCol@plt>
cmp    $0x0,%rax
je     1236 <main+0xd6>
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <CreateMap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x24(%rbp),%r8
call   1080 <InitMap@plt>
mov    -0x18(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
lea    -0x24(%rbp),%r9
call   1040 <RandomWalk@plt>
mov    -0x18(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
lea    -0x24(%rbp),%r9
call   1030 <OutPutResult@plt>
mov    -0x18(%rbp),%rdi
call   1050 <FreeMap@plt>
mov    %rax,-0x18(%rbp)
jmp    11a1 <main+0x41>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0x14(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1060 <InputRowCol@plt>
test   %rax,%rax
je     124e <main+0xee>
lea    0x10(%rsp),%r14
lea    0xc(%rsp),%rbx
lea    0x4(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0x14(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <CreateMap@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r12,%r8
call   1080 <InitMap@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
mov    %r12,%r9
call   1040 <RandomWalk@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
mov    %r12,%r9
call   1030 <OutPutResult@plt>
mov    %rbp,%rdi
call   1050 <FreeMap@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1060 <InputRowCol@plt>
test   %rax,%rax
jne    11e0 <main+0x80>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
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
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32** null, i32*** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %12
12: ; preds = %15, %2
%13 = call i64 @InputRowCol(i32* %7, i32* %8, i32* %10, i32* %9)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = call i32** @CreateMap(i32* %7, i32* %8)
store i32** %16, i32*** %6
%17 = load i32**, i32*** %6
%18 = call i32 @InitMap(i32** %17, i32* %7, i32* %8, i32* %10, i32* %9)
%19 = load i32**, i32*** %6
%20 = call i32 @RandomWalk(i32** %19, i32* %11, i32* %7, i32* %8, i32* %10, i32* %9)
%21 = load i32**, i32*** %6
%22 = call i32 @OutPutResult(i32** %21, i32* %11, i32* %7, i32* %8, i32* %10, i32* %9)
%23 = load i32**, i32*** %6
%24 = call i32** @FreeMap(i32** %23)
store i32** %24, i32*** %6
br label %12
25: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%10 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%11 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%12 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%13 = call i64 @InputRowCol(i32* %3, i32* %4, i32* %6, i32* %5)
%14 = icmp eq i64 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %2, %15
%16 = call i32** @CreateMap(i32* %3, i32* %4)
%17 = call i32 @InitMap(i32** %16, i32* %3, i32* %4, i32* %6, i32* %5)
%18 = call i32 @RandomWalk(i32** %16, i32* %7, i32* %3, i32* %4, i32* %6, i32* %5)
%19 = call i32 @OutPutResult(i32** %16, i32* %7, i32* %3, i32* %4, i32* %6, i32* %5)
%20 = call i32** @FreeMap(i32** %16)
%21 = call i64 @InputRowCol(i32* %3, i32* %4, i32* %6, i32* %5)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %15
23: ; preds = %15, %2
ret i32 0
}