#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*/ get_screen_offset(int, int);
int /*<<< orphan*/ print_char(char const, int, int, unsigned char);
int /*<<< orphan*/ set_cursor(int /*<<< orphan*/);
void print_at_clr(const char *message, int col, int row, unsigned char color) {
  if (col >= 0 && row >= 0) {
    set_cursor(get_screen_offset(col, row));
  }
  int i = 0;
  while (message[i] != 0) {
    print_char(message[i++], -1, -1, color);
  }
}


x86 assembly (clang, -O0):
<print_at_clr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %al,-0x11(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     116d <print_at_clr+0x3d>
cmpl   $0x0,-0x10(%rbp)
jl     116d <print_at_clr+0x3d>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <get_screen_offset@plt>
mov    %eax,%edi
call   1040 <set_cursor@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11b6 <print_at_clr+0x86>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    $0xffffffff,%edx
movsbl %al,%edi
mov    %edx,%esi
movzbl -0x11(%rbp),%ecx
call   1050 <print_char@plt>
jmp    1174 <print_at_clr+0x44>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_at_clr>:
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdi,%rbx
mov    %edx,%eax
or     %esi,%eax
js     114e <print_at_clr+0x1e>
mov    %esi,%edi
mov    %edx,%esi
call   1030 <get_screen_offset@plt>
mov    %eax,%edi
call   1040 <set_cursor@plt>
mov    (%rbx),%al
test   %al,%al
je     117f <print_at_clr+0x4f>
add    $0x1,%rbx
movzbl %bpl,%ebp
nopl   0x0(%rax)
movsbl %al,%edi
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
mov    %ebp,%ecx
call   1050 <print_char@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <print_at_clr+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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