#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*/ printchar(unsigned int, unsigned int, char const,
                             unsigned int, unsigned int);
void printtext(unsigned x, unsigned y, const char *text, unsigned fg,
               unsigned bg) {
  while (*text) {
    printchar(x, y, *text, fg, bg);
    text++;
    x += 8;
  }
}


x86 assembly (clang, -O0):
<printtext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     116b <printtext+0x5b>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
movsbl %al,%edx
call   1030 <printchar@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x4(%rbp)
jmp    1129 <printtext+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printtext>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rdx),%al
test   %al,%al
je     1151 <printtext+0x41>
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %esi,%r12d
mov    %edi,%ebp
add    $0x1,%rbx
movsbl %al,%edx
mov    %ebp,%edi
mov    %r12d,%esi
mov    %r15d,%ecx
mov    %r14d,%r8d
call   1030 <printchar@plt>
add    $0x8,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <printtext+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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