#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*/ draw_char(int, int, char const);
void print32(const char *s) {
  int x = 8;
  int y = 8;
  int old_x = x;
  for (; *s; s++) {
    if (*s == '\n') {
      x = old_x;
      y += (16);
    } else {
      draw_char(x, y, *s);
      x += (8);
    }
  }
}


x86 assembly (clang, -O0):
<print32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x8,-0xc(%rbp)
movl   $0x8,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1192 <print32+0x82>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1161 <print32+0x51>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    117c <print32+0x6c>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
call   1030 <draw_char@plt>
mov    -0xc(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0xc(%rbp)
jmp    1181 <print32+0x71>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1130 <print32+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print32>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x8,%ebp
mov    $0x8,%r14d
jmp    113d <print32+0x2d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x10,%r14d
add    $0x1,%rbx
mov    $0x8,%ebp
movzbl (%rbx),%eax
cmp    $0xa,%al
je     1130 <print32+0x20>
test   %al,%al
je     115e <print32+0x4e>
movsbl %al,%edx
mov    %ebp,%edi
mov    %r14d,%esi
call   1030 <draw_char@plt>
add    $0x8,%ebp
add    $0x1,%rbx
jmp    113d <print32+0x2d>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @print32(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 8, i32* %3
store i32 8, i32* %4
%6 = load i32, i32* %3
store i32 %6, i32* %5
br label %7
7: ; preds = %29, %1
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %32
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* %5
store i32 %17, i32* %3
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 16
store i32 %19, i32* %4
br label %28
20: ; preds = %11
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = load i8*, i8** %2
%24 = load i8, i8* %23
%25 = call i32 @draw_char(i32 %21, i32 %22, i8 signext %24)
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 8
store i32 %27, i32* %3
br label %28
28: ; preds = %20, %16
br label %29
29: ; preds = %28
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %2
br label %7
32: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @print32(i8* nocapture %0) {
br label %2
2: ; preds = %12, %1
%3 = phi i32 [ 8, %1 ], [ %13, %12 ]
%4 = phi i32 [ 8, %1 ], [ %14, %12 ]
%5 = phi i8* [ %0, %1 ], [ %15, %12 ]
%6 = load i8, i8* %5
switch i8 %6, label %9 [
i8 0, label %16
i8 10, label %7
]
7: ; preds = %2
%8 = add nsw i32 %4, 16
br label %12
9: ; preds = %2
%10 = tail call i32 @draw_char(i32 %3, i32 %4, i8 signext %6)
%11 = add nsw i32 %3, 8
br label %12
12: ; preds = %7, %9
%13 = phi i32 [ 8, %7 ], [ %11, %9 ]
%14 = phi i32 [ %8, %7 ], [ %4, %9 ]
%15 = getelementptr inbounds i8, i8* %5, i64 1
br label %2
16: ; preds = %2
ret void
}