#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*/ write(int, char *, int);
void terra_visualize(char *area, size_t max_y, size_t max_x) {
  if (area == NULL) {
    return;
  }
  for (size_t i = 0; i < max_y; i++) {
    write(1, area + i * max_x, max_x);
    write(1, "\n", 1);
  }
}


x86 assembly (clang, -O0):
<terra_visualize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1134 <terra_visualize+0x24>
jmp    118e <terra_visualize+0x7e>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118e <terra_visualize+0x7e>
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rax
imul   -0x18(%rbp),%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe8a(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113c <terra_visualize+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<terra_visualize>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     116b <terra_visualize+0x5b>
mov    %rsi,%r15
test   %rsi,%rsi
je     116b <terra_visualize+0x5b>
mov    %rdx,%r14
mov    %rdi,%rbx
lea    0xece(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r12,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    %r14,%rbx
add    $0xffffffffffffffff,%r15
jne    1140 <terra_visualize+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define void @terra_visualize(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %3
br label %29
11: ; preds = %3
store i64 0, i64* %7
br label %12
12: ; preds = %26, %11
%13 = load i64, i64* %7
%14 = load i64, i64* %5
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = load i64, i64* %7
%19 = load i64, i64* %6
%20 = mul i64 %18, %19
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = load i64, i64* %6
%23 = trunc i64 %22 to i32
%24 = call i32 @write(i32 1, i8* %21, i32 %23)
%25 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %26
26: ; preds = %16
%27 = load i64, i64* %7
%28 = add i64 %27, 1
store i64 %28, i64* %7
br label %12
29: ; preds = %10, %12
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define void @terra_visualize(i8* %0, i64 %1, i64 %2) {
%4 = icmp ne i8* %0, null
%5 = icmp ne i64 %1, 0
%6 = and i1 %4, %5
br i1 %6, label %7, label %17
7: ; preds = %3
%8 = trunc i64 %2 to i32
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %15, %9 ]
%11 = mul i64 %10, %2
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32 @write(i32 1, i8* %12, i32 %8)
%14 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%15 = add nuw i64 %10, 1
%16 = icmp eq i64 %15, %1
br i1 %16, label %17, label %9
17: ; preds = %9, %3
ret void
}