#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 short ***kv6_points();
long kv6_xsiz();
long kv6_ysiz();
int /*<<< orphan*/ printf(char *, ...);
void debug_print_layer(long z) {
  unsigned short ***points = kv6_points();
  long xsiz = kv6_xsiz(), ysiz = kv6_ysiz();
  long x, y;
  printf("z=%ld \n", z);
  for (y = 0; y < ysiz; y++) {
    for (x = 0; x < xsiz; x++) {
      if (points[x][y][z] == 1) {
        printf(" ");
      } else if (points[x][y][z] == 2) {
        printf("*");
      } else {
        printf("#");
      }
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<debug_print_layer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <kv6_points@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <kv6_xsiz@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <kv6_ysiz@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    1263 <debug_print_layer+0x123>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1244 <debug_print_layer+0x104>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x8(%rbp),%rcx
movzwl (%rax,%rcx,2),%eax
cmp    $0x1,%eax
jne    11e3 <debug_print_layer+0xa3>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122e <debug_print_layer+0xee>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x8(%rbp),%rcx
movzwl (%rax,%rcx,2),%eax
cmp    $0x2,%eax
jne    121b <debug_print_layer+0xdb>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1229 <debug_print_layer+0xe9>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122e <debug_print_layer+0xee>
jmp    1233 <debug_print_layer+0xf3>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    119d <debug_print_layer+0x5d>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1187 <debug_print_layer+0x47>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_print_layer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1070 <kv6_points@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1060 <kv6_xsiz@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1050 <kv6_ysiz@plt>
mov    %rax,%rbx
lea    0xe7d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,(%rsp)
test   %rbx,%rbx
jle    11f4 <debug_print_layer+0xa4>
xor    %ebx,%ebx
mov    $0x20,%ebp
jmp    11b4 <debug_print_layer+0x64>
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    (%rsp),%rbx
je     11f4 <debug_print_layer+0xa4>
test   %r13,%r13
jle    11a0 <debug_print_layer+0x50>
xor    %r12d,%r12d
jmp    11d5 <debug_print_layer+0x85>
xchg   %ax,%ax
cmp    $0x1,%ax
cmove  %ebp,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
cmp    %r12,%r13
je     11a0 <debug_print_layer+0x50>
mov    (%r15,%r12,8),%rax
mov    (%rax,%rbx,8),%rax
movzwl (%rax,%r14,2),%eax
mov    $0x2a,%edi
cmp    $0x2,%ax
je     11c0 <debug_print_layer+0x70>
mov    $0x23,%edi
jmp    11c0 <debug_print_layer+0x70>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"z=%ld \0A\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"*\00"
@.str.3 = [2 x i8] c"#\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @debug_print_layer(i64 %0) {
%2 = alloca i64
%3 = alloca i16***
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i64 %0, i64* %2
%8 = call i16*** (...) @kv6_points()
store i16*** %8, i16**** %3
%9 = call i64 (...) @kv6_xsiz()
store i64 %9, i64* %4
%10 = call i64 (...) @kv6_ysiz()
store i64 %10, i64* %5
%11 = load i64, i64* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %11)
store i64 0, i64* %7
br label %13
13: ; preds = %61, %1
%14 = load i64, i64* %7
%15 = load i64, i64* %5
%16 = icmp slt i64 %14, %15
br i1 %16, label %17, label %64
17: ; preds = %13
store i64 0, i64* %6
br label %18
18: ; preds = %56, %17
%19 = load i64, i64* %6
%20 = load i64, i64* %4
%21 = icmp slt i64 %19, %20
br i1 %21, label %22, label %59
22: ; preds = %18
%23 = load i16***, i16**** %3
%24 = load i64, i64* %6
%25 = getelementptr inbounds i16**, i16*** %23, i64 %24
%26 = load i16**, i16*** %25
%27 = load i64, i64* %7
%28 = getelementptr inbounds i16*, i16** %26, i64 %27
%29 = load i16*, i16** %28
%30 = load i64, i64* %2
%31 = getelementptr inbounds i16, i16* %29, i64 %30
%32 = load i16, i16* %31
%33 = zext i16 %32 to i32
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %37
35: ; preds = %22
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %55
37: ; preds = %22
%38 = load i16***, i16**** %3
%39 = load i64, i64* %6
%40 = getelementptr inbounds i16**, i16*** %38, i64 %39
%41 = load i16**, i16*** %40
%42 = load i64, i64* %7
%43 = getelementptr inbounds i16*, i16** %41, i64 %42
%44 = load i16*, i16** %43
%45 = load i64, i64* %2
%46 = getelementptr inbounds i16, i16* %44, i64 %45
%47 = load i16, i16* %46
%48 = zext i16 %47 to i32
%49 = icmp eq i32 %48, 2
br i1 %49, label %50, label %52
50: ; preds = %37
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %54
52: ; preds = %37
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
br label %55
55: ; preds = %54, %35
br label %56
56: ; preds = %55
%57 = load i64, i64* %6
%58 = add nsw i64 %57, 1
store i64 %58, i64* %6
br label %18
59: ; preds = %18
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %61
61: ; preds = %59
%62 = load i64, i64* %7
%63 = add nsw i64 %62, 1
store i64 %63, i64* %7
br label %13
64: ; preds = %13
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

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