#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*/ HwMdSetNTable(int);
int /*<<< orphan*/ HwMdSetOffset(int);
void HwMdPuts(char *str, int color, int x, int y) {
  HwMdSetOffset(((y << 6) | x) << 1);
  while (*str)
    HwMdSetNTable(((*str++ - 0x20) & 0xFF) | color);
}


x86 assembly (clang, -O0):
<HwMdPuts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
shl    $0x6,%edi
or     -0x10(%rbp),%edi
shl    $0x1,%edi
call   1040 <HwMdSetOffset@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     117b <HwMdPuts+0x5b>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
sub    $0x20,%edi
and    $0xff,%edi
or     -0xc(%rbp),%edi
call   1030 <HwMdSetNTable@plt>
jmp    1146 <HwMdPuts+0x26>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HwMdPuts>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
shl    $0x7,%ecx
lea    (%rdx,%rdx,1),%edi
or     %ecx,%edi
call   1040 <HwMdSetOffset@plt>
mov    (%rbx),%al
test   %al,%al
je     1157 <HwMdPuts+0x37>
add    $0x1,%rbx
nop
add    $0xe0,%al
movzbl %al,%edi
or     %ebp,%edi
call   1030 <HwMdSetNTable@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <HwMdPuts+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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