#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ gpu_draw_texmask(int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ gpu_push_vertex(int, int);
int /*<<< orphan*/ gpu_send_control_gp0(int);
int /*<<< orphan*/ gpu_send_data(int);
void screen_print(int x, int y, uint32_t c, const char *str) {
  int i;
  for (i = 0; str[i] != '\x00'; i++) {
    uint32_t ch = str[i];
    gpu_send_control_gp0(0xE1080208 | ((ch >> 5)));
    gpu_draw_texmask(8, 8, (ch & 31) << 3, 0);
    gpu_send_control_gp0(0x74000000 | (c & 0x00FFFFFF));
    gpu_push_vertex(i * 8 + x - 160, y - 120);
    gpu_send_data(0x001C0000);
  }
}


x86 assembly (clang, -O0):
<screen_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11ee <screen_print+0xae>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
sar    $0x5,%edi
or     $0xe1080208,%edi
call   1040 <gpu_send_control_gp0@plt>
mov    -0x20(%rbp),%edx
and    $0x1f,%edx
shl    $0x3,%edx
mov    $0x8,%esi
xor    %ecx,%ecx
mov    %esi,%edi
call   1060 <gpu_draw_texmask@plt>
mov    -0xc(%rbp),%edi
and    $0xffffff,%edi
or     $0x74000000,%edi
call   1040 <gpu_send_control_gp0@plt>
mov    -0x1c(%rbp),%edi
shl    $0x3,%edi
add    -0x4(%rbp),%edi
sub    $0xa0,%edi
mov    -0x8(%rbp),%esi
sub    $0x78,%esi
call   1030 <gpu_push_vertex@plt>
mov    $0x1c0000,%edi
call   1050 <gpu_send_data@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <screen_print+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<screen_print>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rcx),%al
test   %al,%al
je     11d6 <screen_print+0x96>
mov    %rcx,%r12
mov    %edx,%r15d
mov    %esi,%r14d
mov    %edi,%ebp
and    $0xffffff,%r15d
or     $0x74000000,%r15d
add    $0xffffff60,%ebp
add    $0xffffff88,%r14d
add    $0x1,%r12
nopl   0x0(%rax)
movsbl %al,%ebx
mov    %ebx,%edi
sar    $0x5,%edi
or     $0xe1080208,%edi
call   1040 <gpu_send_control_gp0@plt>
shl    $0x3,%ebx
movzbl %bl,%edx
mov    $0x8,%edi
mov    $0x8,%esi
xor    %ecx,%ecx
call   1060 <gpu_draw_texmask@plt>
mov    %r15d,%edi
call   1040 <gpu_send_control_gp0@plt>
mov    %ebp,%edi
mov    %r14d,%esi
call   1030 <gpu_push_vertex@plt>
mov    $0x1c0000,%edi
call   1050 <gpu_send_data@plt>
movzbl (%r12),%eax
add    $0x8,%ebp
add    $0x1,%r12
test   %al,%al
jne    1180 <screen_print+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @screen_print(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32 0, i32* %9
br label %11
11: ; preds = %47, %4
%12 = load i8*, i8** %8
%13 = load i32, i32* %9
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %50
19: ; preds = %11
%20 = load i8*, i8** %8
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
store i32 %25, i32* %10
%26 = load i32, i32* %10
%27 = ashr i32 %26, 5
%28 = or i32 -519568888, %27
%29 = call i32 @gpu_send_control_gp0(i32 %28)
%30 = load i32, i32* %10
%31 = and i32 %30, 31
%32 = shl i32 %31, 3
%33 = call i32 @gpu_draw_texmask(i32 8, i32 8, i32 %32, i32 0)
%34 = load i32, i32* %7
%35 = and i32 %34, 16777215
%36 = or i32 1946157056, %35
%37 = call i32 @gpu_send_control_gp0(i32 %36)
%38 = load i32, i32* %9
%39 = mul nsw i32 %38, 8
%40 = load i32, i32* %5
%41 = add nsw i32 %39, %40
%42 = sub nsw i32 %41, 160
%43 = load i32, i32* %6
%44 = sub nsw i32 %43, 120
%45 = call i32 @gpu_push_vertex(i32 %42, i32 %44)
%46 = call i32 @gpu_send_data(i32 1835008)
br label %47
47: ; preds = %19
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %11
50: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @screen_print(i32 %0, i32 %1, i32 %2, i8* nocapture %3) {
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %32, label %7
7: ; preds = %4
%8 = and i32 %2, 16777215
%9 = or i32 %8, 1946157056
%10 = add i32 %0, -160
%11 = add nsw i32 %1, -120
br label %12
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %28, %12 ]
%14 = phi i8 [ %5, %7 ], [ %30, %12 ]
%15 = sext i8 %14 to i32
%16 = ashr i32 %15, 5
%17 = or i32 %16, -519568888
%18 = tail call i32 @gpu_send_control_gp0(i32 %17)
%19 = shl nsw i32 %15, 3
%20 = and i32 %19, 248
%21 = tail call i32 @gpu_draw_texmask(i32 8, i32 8, i32 %20, i32 0)
%22 = tail call i32 @gpu_send_control_gp0(i32 %9)
%23 = trunc i64 %13 to i32
%24 = shl nsw i32 %23, 3
%25 = add i32 %10, %24
%26 = tail call i32 @gpu_push_vertex(i32 %25, i32 %11)
%27 = tail call i32 @gpu_send_data(i32 1835008)
%28 = add nuw i64 %13, 1
%29 = getelementptr inbounds i8, i8* %3, i64 %28
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %12
32: ; preds = %12, %4
ret void
}