#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 print_chunk(float *chunk, unsigned xs, unsigned ys, unsigned zs) {
  for (unsigned z = 0; z < zs; z++) {
    for (unsigned x = 0; x < xs; x++) {
      printf("\n");
      for (unsigned y = 0; y < ys; y++) {
        float val = chunk[x + (y * ys) + (z * zs * zs)];
        if (val > 0)
          printf(" . ");
        else
          printf(" # ");
      }
    }
  }
  printf("\n\n");
}


x86 assembly (clang, -O0):
<print_chunk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11fa <print_chunk+0xea>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11e7 <print_chunk+0xd7>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    11d4 <print_chunk+0xc4>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%edx
imul   -0x10(%rbp),%edx
add    %edx,%ecx
mov    -0x18(%rbp),%edx
imul   -0x14(%rbp),%edx
imul   -0x14(%rbp),%edx
add    %edx,%ecx
mov    %ecx,%ecx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11b5 <print_chunk+0xa5>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
jmp    11c1 <print_chunk+0xb1>
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
jmp    11c6 <print_chunk+0xb6>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115e <print_chunk+0x4e>
jmp    11d9 <print_chunk+0xc9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <print_chunk+0x2f>
jmp    11ec <print_chunk+0xdc>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <print_chunk+0x1c>
lea    0xe07(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_chunk>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,0x10(%rsp)
mov    %ecx,0xc(%rsp)
test   %ecx,%ecx
je     120b <print_chunk+0xdb>
mov    %edx,%ebp
mov    %rdi,%rbx
mov    0xc(%rsp),%eax
imul   %eax,%eax
mov    %eax,0x14(%rsp)
mov    %edx,%eax
mov    %rax,0x20(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe90(%rip),%r12
xor    %ecx,%ecx
jmp    1199 <print_chunk+0x69>
nopl   0x0(%rax,%rax,1)
mov    0x18(%rsp),%ecx
add    $0x1,%ecx
mov    0x8(%rsp),%eax
add    0x14(%rsp),%eax
mov    %eax,0x8(%rsp)
cmp    0xc(%rsp),%ecx
je     120b <print_chunk+0xdb>
mov    %ecx,0x18(%rsp)
cmpl   $0x0,0x10(%rsp)
je     1180 <print_chunk+0x50>
xor    %eax,%eax
mov    0x8(%rsp),%r15d
jmp    11c1 <print_chunk+0x91>
nopl   (%rax)
mov    0x1c(%rsp),%eax
add    $0x1,%eax
add    $0x1,%r15d
cmp    0x10(%rsp),%eax
je     1180 <print_chunk+0x50>
mov    %eax,0x1c(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x20(%rsp),%r14
mov    %r15d,%r13d
test   %ebp,%ebp
jne    11ee <print_chunk+0xbe>
jmp    11b0 <print_chunk+0x80>
nopl   (%rax)
call   1050 <printf@plt>
add    %ebp,%r13d
add    $0xffffffffffffffff,%r14
je     11b0 <print_chunk+0x80>
mov    %r13d,%eax
movss  (%rbx,%rax,4),%xmm0
ucomiss 0xe03(%rip),%xmm0
mov    %r12,%rdi
ja     11e0 <print_chunk+0xb0>
lea    0xdff(%rip),%rdi
jmp    11e0 <print_chunk+0xb0>
lea    0xdfa(%rip),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

LLVM IR (-O2):
@.str.1 = [4 x i8] c" . \00"
@.str.2 = [4 x i8] c" # \00"
@str = [2 x i8] c"\0A\00"
define void @print_chunk(float* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %15, label %6
6: ; preds = %4
%7 = icmp eq i32 %1, 0
%8 = icmp eq i32 %2, 0
%9 = mul i32 %3, %3
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %6, %17
%12 = phi i32 [ 0, %6 ], [ %18, %17 ]
br i1 %7, label %17, label %13
13: ; preds = %11
%14 = mul i32 %9, %12
br label %20
15: ; preds = %17, %4
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
17: ; preds = %25, %11
%18 = add nuw i32 %12, 1
%19 = icmp eq i32 %18, %3
br i1 %19, label %15, label %11
20: ; preds = %13, %25
%21 = phi i32 [ 0, %13 ], [ %26, %25 ]
%22 = tail call i32 @putchar(i32 10)
br i1 %8, label %25, label %23
23: ; preds = %20
%24 = add i32 %21, %14
br label %28
25: ; preds = %28, %20
%26 = add nuw i32 %21, 1
%27 = icmp eq i32 %26, %1
br i1 %27, label %17, label %20
28: ; preds = %23, %28
%29 = phi i64 [ 0, %23 ], [ %39, %28 ]
%30 = trunc i64 %29 to i32
%31 = mul i32 %30, %2
%32 = add i32 %24, %31
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds float, float* %0, i64 %33
%35 = load float, float* %34
%36 = fcmp ogt float %35, 0.000000e+00
%37 = select i1 %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%38 = tail call i32 @printf(i8* dereferenceable(1) %37)
%39 = add nuw nsw i64 %29, 1
%40 = icmp eq i64 %39, %10
br i1 %40, label %25, label %28
}