#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 array2dindex(int, int, int);
int /*<<< orphan*/ drawer_clear_screen();
char *get_char(int, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
void drawer_process(const int *const p_buffer, int width, int hight, int near,
                    int far, int depth_value) {
  int x = 0;
  int y = 0;
  int key = 0;
  int value = 0;
  const char *color = " ";
  drawer_clear_screen();
  for (x = 0; x < hight; x++) {
    for (y = 0; y < width; y++) {
      key = array2dindex(x, y, width);
      if (key >= width * hight) {
        break;
      }
      value = p_buffer[key];
      color = get_char(value, near, far, depth_value);
      printf("%s", color);
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<drawer_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xe80(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1050 <drawer_clear_screen@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1238 <drawer_process+0xf8>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    121c <drawer_process+0xdc>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <array2dindex@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jl     11d9 <drawer_process+0x99>
jmp    121c <drawer_process+0xdc>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1060 <get_char@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a5 <drawer_process+0x65>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1192 <drawer_process+0x52>
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawer_process>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0x14(%rsp)
mov    %r8d,0x10(%rsp)
mov    %ecx,%r13d
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <drawer_clear_screen@plt>
mov    %r14d,0xc(%rsp)
test   %r14d,%r14d
jle    1203 <drawer_process+0xb3>
mov    0xc(%rsp),%r12d
imul   %ebp,%r12d
xor    %r15d,%r15d
jmp    11b5 <drawer_process+0x65>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15d
cmp    0xc(%rsp),%r15d
je     1203 <drawer_process+0xb3>
test   %ebp,%ebp
jle    11a0 <drawer_process+0x50>
xor    %r14d,%r14d
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1050 <array2dindex@plt>
cmp    %r12d,%eax
jge    11a0 <drawer_process+0x50>
cltq
mov    (%rbx,%rax,4),%edi
mov    %r13d,%esi
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%ecx
call   1070 <get_char@plt>
lea    0xe12(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14d
cmp    %r14d,%ebp
jne    11c0 <drawer_process+0x70>
jmp    11a0 <drawer_process+0x50>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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