#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_font8(unsigned char *, int, int, int, char, char *);
void draw_font8_asc(unsigned char *vram, int xsize, int x, int y, char color,
                    unsigned char *string) {
  extern char charlib[4096];
  for (; *string != 0x00; ++string) {
    draw_font8(vram, xsize, x, y, color, charlib + *string * 16);
    x += 8;
  }
}


x86 assembly (clang, -O0):
<draw_font8_asc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8b,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %al,-0x15(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
je     118b <draw_font8_asc+0x7b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x15(%rbp),%al
mov    -0x20(%rbp),%r8
movzbl (%r8),%r8d
shl    $0x4,%r8d
movslq %r8d,%r8
mov    0x2e7b(%rip),%r9
add    %r8,%r9
movsbl %al,%r8d
call   1030 <draw_font8@plt>
mov    -0x10(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112f <draw_font8_asc+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_font8_asc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%r9),%al
test   %al,%al
je     1170 <draw_font8_asc+0x60>
mov    %r9,%rbx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%r12
add    $0x1,%rbx
movsbl %r8b,%r13d
nopl   0x0(%rax,%rax,1)
movzbl %al,%r9d
shl    $0x4,%r9
add    0x2e91(%rip),%r9
mov    %r12,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
mov    %r13d,%r8d
call   1030 <draw_font8@plt>
add    $0x8,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <draw_font8_asc+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@charlib = external global [4096 x i8]
define void @draw_font8_asc(i8* %0, i32 %1, i32 %2, i32 %3, i8 signext %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
%12 = alloca i8*
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8 %4, i8* %11
store i8* %5, i8** %12
br label %13
13: ; preds = %33, %6
%14 = load i8*, i8** %12
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %36
18: ; preds = %13
%19 = load i8*, i8** %7
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = load i8, i8* %11
%24 = load i8*, i8** %12
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = mul nsw i32 %26, 16
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @charlib, i64 0, i64 0), i64 %28
%30 = call i32 @draw_font8(i8* %19, i32 %20, i32 %21, i32 %22, i8 signext %23, i8* %29)
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 8
store i32 %32, i32* %9
br label %33
33: ; preds = %18
%34 = load i8*, i8** %12
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %12
br label %13
36: ; preds = %13
ret void
}

LLVM IR (-O2):
@charlib = external global [4096 x i8]
define void @draw_font8_asc(i8* %0, i32 %1, i32 %2, i32 %3, i8 signext %4, i8* nocapture %5) {
%7 = load i8, i8* %5
%8 = icmp eq i8 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %6, %9
%10 = phi i8 [ %19, %9 ], [ %7, %6 ]
%11 = phi i8* [ %18, %9 ], [ %5, %6 ]
%12 = phi i32 [ %17, %9 ], [ %2, %6 ]
%13 = zext i8 %10 to i64
%14 = shl nuw nsw i64 %13, 4
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* @charlib, i64 0, i64 %14
%16 = tail call i32 @draw_font8(i8* %0, i32 %1, i32 %12, i32 %3, i8 signext %4, i8* %15)
%17 = add nsw i32 %12, 8
%18 = getelementptr inbounds i8, i8* %11, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %9
21: ; preds = %9, %6
ret void
}