#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*/ printf(char *);
void show_maze(char *maze, int width, int height) {
  int x, y;
  for (y = 0; y < height; y++) {
    for (x = 0; x < width; x++) {
      switch (maze[y * width + x]) {
      case 1:
        printf("[]");
        break;
      case 2:
        printf("<>");
        break;
      default:
        printf("  ");
        break;
      }
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<show_maze>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11de <show_maze+0xce>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c4 <show_maze+0xb4>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    -0xc(%rbp),%edx
imul   %edx,%ecx
mov    -0x14(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     1183 <show_maze+0x73>
jmp    1172 <show_maze+0x62>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     1194 <show_maze+0x84>
jmp    11a5 <show_maze+0x95>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
jmp    11b1 <show_maze+0xa1>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
jmp    11b1 <show_maze+0xa1>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    11b6 <show_maze+0xa6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <show_maze+0x2c>
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1129 <show_maze+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_maze>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,0x4(%rsp)
test   %edx,%edx
jle    11c9 <show_maze+0xa9>
mov    %rdi,%rbx
movslq 0x4(%rsp),%rax
mov    %edx,%ecx
mov    %rcx,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    %eax,%ebp
xor    %r13d,%r13d
lea    0xea9(%rip),%r14
lea    0xe9f(%rip),%r12
jmp    118a <show_maze+0x6a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
add    0x10(%rsp),%rbx
cmp    0x8(%rsp),%r13
je     11c9 <show_maze+0xa9>
cmpl   $0x0,0x4(%rsp)
jle    1170 <show_maze+0x50>
xor    %r15d,%r15d
jmp    11b4 <show_maze+0x94>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x1,%al
cmove  %r12,%rdi
call   1040 <printf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
je     1170 <show_maze+0x50>
movzbl (%rbx,%r15,1),%eax
mov    %r14,%rdi
cmp    $0x2,%al
je     11a0 <show_maze+0x80>
lea    0xe3f(%rip),%rdi
jmp    11a0 <show_maze+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"[]\00"
@.str.1 = [3 x i8] c"<>\00"
@.str.2 = [3 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @show_maze(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %8
br label %9
9: ; preds = %41, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %44
13: ; preds = %9
store i32 0, i32* %7
br label %14
14: ; preds = %36, %13
%15 = load i32, i32* %7
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %39
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = load i32, i32* %8
%21 = load i32, i32* %5
%22 = mul nsw i32 %20, %21
%23 = load i32, i32* %7
%24 = add nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %19, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
switch i32 %28, label %33 [
i32 1, label %29
i32 2, label %31
]
29: ; preds = %18
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %35
31: ; preds = %18
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %35
33: ; preds = %18
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33, %31, %29
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %14
39: ; preds = %14
%40 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %9
44: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"[]\00"
@.str.1 = [3 x i8] c"<>\00"
@.str.2 = [3 x i8] c" \00"
define void @show_maze(i8* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %30
5: ; preds = %3
%6 = icmp sgt i32 %1, 0
%7 = sext i32 %1 to i64
%8 = zext i32 %2 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %5, %26
%11 = phi i64 [ 0, %5 ], [ %28, %26 ]
br i1 %6, label %12, label %26
12: ; preds = %10
%13 = mul nsw i64 %11, %7
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %24, %14 ]
%16 = add nsw i64 %15, %13
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 2
%20 = select i1 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%21 = icmp eq i8 %18, 1
%22 = select i1 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %20
%23 = tail call i32 @printf(i8* dereferenceable(1) %22)
%24 = add nuw nsw i64 %15, 1
%25 = icmp eq i64 %24, %9
br i1 %25, label %26, label %14
26: ; preds = %14, %10
%27 = tail call i32 @putchar(i32 10)
%28 = add nuw nsw i64 %11, 1
%29 = icmp eq i64 %28, %8
br i1 %29, label %30, label %10
30: ; preds = %26, %3
ret void
}