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


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   1040 <get_screen_offset@plt>
mov    %eax,%edi
call   1050 <set_cursor@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11af <print_at+0x7f>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rsi
mov    $0xffffffff,%edx
mov    $0xf,%ecx
movsbl (%rax,%rsi,1),%edi
mov    %edx,%esi
call   1030 <writechar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <print_at+0x3f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_at>:
push   %rbx
mov    %rdi,%rbx
mov    %edx,%eax
or     %esi,%eax
js     114a <print_at+0x1a>
mov    %esi,%edi
mov    %edx,%esi
call   1040 <get_screen_offset@plt>
mov    %eax,%edi
call   1050 <set_cursor@plt>
mov    (%rbx),%al
test   %al,%al
je     1182 <print_at+0x52>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
mov    $0xf,%ecx
call   1030 <writechar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <print_at+0x30>
pop    %rbx
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 = %27, %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 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %19
%28 = load i8*, i8** %4
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = call i32 @writechar(i8 signext %32, i32 -1, i32 -1, i32 15)
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
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 [ %16, %12 ], [ 0, %9 ]
%14 = phi i8 [ %18, %12 ], [ %10, %9 ]
%15 = tail call i32 @writechar(i8 signext %14, i32 -1, i32 -1, i32 15)
%16 = add nuw i64 %13, 1
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %12
20: ; preds = %12, %9
ret void
}