#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 */
scalar_t__ chr_get_pixel(unsigned char *, unsigned char, unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void chr_show(unsigned char *buf) {
  unsigned char x, y;
  if (((buf)[0]) == 0)
    return;
  for (y = 0; y < ((buf)[2]); y++) {
    printf("%4d ", y);
    for (x = 0; x < ((buf)[1] & 0x1f); x++) {
      if (chr_get_pixel(buf, x, ((buf)[2]) - y - 1) == 0)
        printf(". ");
      else
        printf("* ");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<chr_show>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1141 <chr_show+0x21>
jmp    1201 <chr_show+0xe1>
movb   $0x0,-0xa(%rbp)
movzbl -0xa(%rbp),%eax
mov    -0x8(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
cmp    %ecx,%eax
jge    1201 <chr_show+0xe1>
movzbl -0xa(%rbp),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x0,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
mov    -0x8(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
and    $0x1f,%ecx
cmp    %ecx,%eax
jge    11e6 <chr_show+0xc6>
mov    -0x8(%rbp),%rdi
mov    -0x9(%rbp),%cl
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%eax
movzbl -0xa(%rbp),%edx
sub    %edx,%eax
sub    $0x1,%eax
movzbl %cl,%esi
movzbl %al,%edx
call   1040 <chr_get_pixel@plt>
cmp    $0x0,%rax
jne    11c6 <chr_show+0xa6>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d4 <chr_show+0xb4>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <chr_show+0xb9>
mov    -0x9(%rbp),%al
add    $0x1,%al
mov    %al,-0x9(%rbp)
jmp    116f <chr_show+0x4f>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa(%rbp),%al
add    $0x1,%al
mov    %al,-0xa(%rbp)
jmp    1145 <chr_show+0x25>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chr_show>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmpb   $0x0,(%rdi)
je     11ea <chr_show+0xba>
mov    %rdi,%rbx
cmpb   $0x0,0x2(%rdi)
je     11ea <chr_show+0xba>
lea    0xead(%rip),%r12
lea    0xea9(%rip),%r13
xor    %r15d,%r15d
jmp    1187 <chr_show+0x57>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15d
movzbl 0x2(%rbx),%eax
cmp    %eax,%r15d
jae    11ea <chr_show+0xba>
lea    0xe72(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
testb  $0x1f,0x1(%rbx)
je     1170 <chr_show+0x40>
mov    %r15d,%r14d
not    %r14b
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movzbl 0x2(%rbx),%eax
add    %r14b,%al
movzbl %al,%edx
movzbl %bpl,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <chr_get_pixel@plt>
test   %rax,%rax
mov    %r13,%rdi
cmove  %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%bpl
movzbl 0x1(%rbx),%eax
and    $0x1f,%al
cmp    %al,%bpl
jb     11b0 <chr_show+0x80>
jmp    1170 <chr_show+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%4d \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 @chr_show(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
br label %60
11: ; preds = %1
store i8 0, i8* %4
br label %12
12: ; preds = %57, %11
%13 = load i8, i8* %4
%14 = zext i8 %13 to i32
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 2
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = icmp slt i32 %14, %18
br i1 %19, label %20, label %60
20: ; preds = %12
%21 = load i8, i8* %4
%22 = zext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22)
store i8 0, i8* %3
br label %24
24: ; preds = %52, %20
%25 = load i8, i8* %3
%26 = zext i8 %25 to i32
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = and i32 %30, 31
%32 = icmp slt i32 %26, %31
br i1 %32, label %33, label %55
33: ; preds = %24
%34 = load i8*, i8** %2
%35 = load i8, i8* %3
%36 = load i8*, i8** %2
%37 = getelementptr inbounds i8, i8* %36, i64 2
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = load i8, i8* %4
%41 = zext i8 %40 to i32
%42 = sub nsw i32 %39, %41
%43 = sub nsw i32 %42, 1
%44 = trunc i32 %43 to i8
%45 = call i64 @chr_get_pixel(i8* %34, i8 zeroext %35, i8 zeroext %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %33
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %51
49: ; preds = %33
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
br label %52
52: ; preds = %51
%53 = load i8, i8* %3
%54 = add i8 %53, 1
store i8 %54, i8* %3
br label %24
55: ; preds = %24
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %57
57: ; preds = %55
%58 = load i8, i8* %4
%59 = add i8 %58, 1
store i8 %59, i8* %4
br label %12
60: ; preds = %10, %12
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%4d \00"
@.str.1 = [3 x i8] c". \00"
@.str.2 = [3 x i8] c"* \00"
define void @chr_show(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %37, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 2
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %37, label %8
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %0, i64 1
br label %10
10: ; preds = %8, %31
%11 = phi i32 [ 0, %8 ], [ %33, %31 ]
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i8, i8* %9
%14 = and i8 %13, 31
%15 = icmp eq i8 %14, 0
br i1 %15, label %31, label %16
16: ; preds = %10
%17 = trunc i32 %11 to i8
%18 = xor i8 %17, -1
br label %19
19: ; preds = %16, %19
%20 = phi i8 [ 0, %16 ], [ %27, %19 ]
%21 = load i8, i8* %5
%22 = add i8 %21, %18
%23 = tail call i64 @chr_get_pixel(i8* %0, i8 zeroext %20, i8 zeroext %22)
%24 = icmp eq i64 %23, 0
%25 = select i1 %24, 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)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %25)
%27 = add nuw nsw i8 %20, 1
%28 = load i8, i8* %9
%29 = and i8 %28, 31
%30 = icmp ult i8 %27, %29
br i1 %30, label %19, label %31
31: ; preds = %19, %10
%32 = tail call i32 @putchar(i32 10)
%33 = add nuw nsw i32 %11, 1
%34 = load i8, i8* %5
%35 = zext i8 %34 to i32
%36 = icmp ult i32 %33, %35
br i1 %36, label %10, label %37
37: ; preds = %31, %4, %1
ret void
}