#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*/ itoa(char *, int);
int /*<<< orphan*/ serial_echo_print(char const *);
void ttyprint(int y, int x, const char *p) {
  static char sx[3];
  static char sy[3];
  sx[0] = '\0';
  sy[0] = '\0';
  x++;
  y++;
  itoa(sx, x);
  itoa(sy, y);
  serial_echo_print("[");
  serial_echo_print(sy);
  serial_echo_print(";");
  serial_echo_print(sx);
  serial_echo_print("H");
  serial_echo_print(p);
}


x86 assembly (clang, -O0):
<ttyprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movb   $0x0,0x2ef8(%rip)
movb   $0x0,0x2ef4(%rip)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%esi
lea    0x2ed5(%rip),%rdi
call   1040 <itoa@plt>
mov    -0x4(%rbp),%esi
lea    0x2ec9(%rip),%rdi
call   1040 <itoa@plt>
lea    0xe89(%rip),%rdi
call   1030 <serial_echo_print@plt>
lea    0x2eb1(%rip),%rdi
call   1030 <serial_echo_print@plt>
lea    0xe74(%rip),%rdi
call   1030 <serial_echo_print@plt>
lea    0x2e96(%rip),%rdi
call   1030 <serial_echo_print@plt>
lea    0xe5e(%rip),%rdi
call   1030 <serial_echo_print@plt>
mov    -0x10(%rbp),%rdi
call   1030 <serial_echo_print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ttyprint>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
movb   $0x0,0x2f00(%rip)
lea    0x2ef9(%rip),%r14
movb   $0x0,0x2ef5(%rip)
lea    0x2eee(%rip),%rbx
add    $0x1,%esi
lea    0x1(%rdi),%ebp
mov    %r14,%rdi
call   1040 <itoa@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <itoa@plt>
lea    0xe9b(%rip),%rdi
call   1030 <serial_echo_print@plt>
mov    %rbx,%rdi
call   1030 <serial_echo_print@plt>
lea    0xe8a(%rip),%rdi
call   1030 <serial_echo_print@plt>
mov    %r14,%rdi
call   1030 <serial_echo_print@plt>
lea    0xe78(%rip),%rdi
call   1030 <serial_echo_print@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <serial_echo_print@plt>

LLVM IR (-O0):
@ttyprint.sx = internal global [3 x i8] zeroinitializer
@ttyprint.sy = internal global [3 x i8] zeroinitializer
@.str = [3 x i8] c"\1B[\00"
@.str.1 = [2 x i8] c";\00"
@.str.2 = [2 x i8] c"H\00"
define void @ttyprint(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i8 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sx, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sy, i64 0, i64 0)
%7 = load i32, i32* %5
%8 = add nsw i32 %7, 1
store i32 %8, i32* %5
%9 = load i32, i32* %4
%10 = add nsw i32 %9, 1
store i32 %10, i32* %4
%11 = load i32, i32* %5
%12 = call i32 @itoa(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sx, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %4
%14 = call i32 @itoa(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sy, i64 0, i64 0), i32 %13)
%15 = call i32 @serial_echo_print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @serial_echo_print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sy, i64 0, i64 0))
%17 = call i32 @serial_echo_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @serial_echo_print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sx, i64 0, i64 0))
%19 = call i32 @serial_echo_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = load i8*, i8** %6
%21 = call i32 @serial_echo_print(i8* %20)
ret void
}

LLVM IR (-O2):
@ttyprint.sx = internal global [3 x i8] zeroinitializer
@ttyprint.sy = internal global [3 x i8] zeroinitializer
@.str = [3 x i8] c"\1B[\00"
@.str.1 = [2 x i8] c";\00"
@.str.2 = [2 x i8] c"H\00"
define void @ttyprint(i32 %0, i32 %1, i8* %2) {
store i8 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sx, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sy, i64 0, i64 0)
%4 = add nsw i32 %1, 1
%5 = add nsw i32 %0, 1
%6 = tail call i32 @itoa(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sx, i64 0, i64 0), i32 %4)
%7 = tail call i32 @itoa(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sy, i64 0, i64 0), i32 %5)
%8 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sy, i64 0, i64 0))
%10 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ttyprint.sx, i64 0, i64 0))
%12 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @serial_echo_print(i8* %2)
ret void
}