#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*/ clear_screen();
int /*<<< orphan*/ kprint(char *);
int /*<<< orphan*/ kprint_at(char *, int, int);
void main() {
  clear_screen();
  kprint_at("X", 1, 6);
  kprint_at("This text spans multiple lines", 75, 10);
  kprint_at("There is a line\nbreak", 0, 20);
  kprint("There is a line\nbreak");
  kprint_at("What happens when we run out of space?", 45, 24);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1050 <clear_screen@plt>
lea    0xebe(%rip),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1030 <kprint_at@plt>
lea    0xeaa(%rip),%rdi
mov    $0x4b,%esi
mov    $0xa,%edx
call   1030 <kprint_at@plt>
lea    0xeb3(%rip),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1030 <kprint_at@plt>
lea    0xea0(%rip),%rdi
call   1040 <kprint@plt>
lea    0xeaa(%rip),%rdi
mov    $0x2d,%esi
mov    $0x18,%edx
call   1030 <kprint_at@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <clear_screen@plt>
lea    0xec1(%rip),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1030 <kprint_at@plt>
lea    0xead(%rip),%rdi
mov    $0x4b,%esi
mov    $0xa,%edx
call   1030 <kprint_at@plt>
lea    0xeb6(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1030 <kprint_at@plt>
mov    %rbx,%rdi
call   1040 <kprint@plt>
lea    0xeae(%rip),%rdi
mov    $0x2d,%esi
mov    $0x18,%edx
pop    %rbx
jmp    1030 <kprint_at@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"X\00"
@.str.1 = [31 x i8] c"This text spans multiple lines\00"
@.str.2 = [22 x i8] c"There is a line\0Abreak\00"
@.str.3 = [39 x i8] c"What happens when we run out of space?\00"
define void @main() {
%1 = call i32 (...) @clear_screen()
%2 = call i32 @kprint_at(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1, i32 6)
%3 = call i32 @kprint_at(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 75, i32 10)
%4 = call i32 @kprint_at(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 20)
%5 = call i32 @kprint(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @kprint_at(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 45, i32 24)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"X\00"
@.str.1 = [31 x i8] c"This text spans multiple lines\00"
@.str.2 = [22 x i8] c"There is a line\0Abreak\00"
@.str.3 = [39 x i8] c"What happens when we run out of space?\00"
define void @main() {
%1 = tail call i32 (...) @clear_screen()
%2 = tail call i32 @kprint_at(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1, i32 6)
%3 = tail call i32 @kprint_at(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 75, i32 10)
%4 = tail call i32 @kprint_at(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 20)
%5 = tail call i32 @kprint(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @kprint_at(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 45, i32 24)
ret void
}