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


x86 assembly (clang, -O0):
<print_at>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1168 <print_at+0x38>
cmpl   $0x0,-0x10(%rbp)
jl     1168 <print_at+0x38>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <get_screen_offset@plt>
mov    %eax,%edi
call   1040 <set_cursor@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11ae <print_at+0x7e>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    $0xf,%ecx
movsbl %al,%edi
call   1050 <print_char@plt>
jmp    116f <print_at+0x3f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_at>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %edx,%eax
or     %esi,%eax
js     1153 <print_at+0x23>
mov    %ebp,%edi
mov    %r14d,%esi
call   1030 <get_screen_offset@plt>
mov    %eax,%edi
call   1040 <set_cursor@plt>
mov    (%rbx),%al
test   %al,%al
je     117d <print_at+0x4d>
add    $0x1,%rbx
nopl   (%rax)
movsbl %al,%edi
mov    %ebp,%esi
mov    %r14d,%edx
mov    $0xf,%ecx
call   1050 <print_char@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <print_at+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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