#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 */
typedef int /*<<< orphan*/ command;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int);
int /*<<< orphan*/ stdout;
void moveto(int x, int y) {
  char command[64];
  if (x < 0) {
    x = 0;
  }
  if (y < 0) {
    y = 0;
  }
  snprintf(command, sizeof(command), "%c[%d;%dH", 0x1B, y, x);
  fprintf(stdout, "%s", command);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<moveto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    114f <moveto+0x1f>
movl   $0x0,-0x4(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1160 <moveto+0x30>
movl   $0x0,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%r8d
mov    -0x4(%rbp),%r9d
mov    $0x40,%esi
lea    0xe88(%rip),%rdx
mov    $0x1b,%ecx
call   1030 <snprintf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rdx
lea    0xe74(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<moveto>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %edi,%r9d
xor    %r8d,%r8d
test   %edi,%edi
cmovs  %r8d,%r9d
test   %esi,%esi
cmovns %esi,%r8d
lea    0xeb0(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x40,%esi
mov    $0x1b,%ecx
call   1030 <snprintf@plt>
mov    0x2e74(%rip),%rbx
mov    (%rbx),%edi
lea    0xe95(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    (%rbx),%edi
call   1050 <fflush@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%c[%d;%dH\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define void @moveto(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [64 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 0, i32* %3
br label %9
9: ; preds = %8, %2
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 0, i32* %4
br label %13
13: ; preds = %12, %9
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = call i32 @snprintf(i8* %14, i32 64, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 27, i32 %15, i32 %16)
%18 = load i32, i32* @stdout
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @stdout
%22 = call i32 @fflush(i32 %21)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%c[%d;%dH\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define void @moveto(i32 %0, i32 %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 0
%6 = select i1 %5, i32 %0, i32 0
%7 = icmp sgt i32 %1, 0
%8 = select i1 %7, i32 %1, i32 0
%9 = call i32 @snprintf(i8* %4, i32 64, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 27, i32 %8, i32 %6)
%10 = load i32, i32* @stdout
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%12 = load i32, i32* @stdout
%13 = call i32 @fflush(i32 %12)
ret void
}