#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*/ assert(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, char const);
int /*<<< orphan*/ stdout;
void move(int which, int n) {
  char command[13];
  static const char movement[] = {'A', 'B', 'C', 'D'};
  assert(which >= 0 && which < 4);
  snprintf(command, sizeof(command), "%c[%d%c", 0x1B, n, movement[which]);
  fprintf(stdout, "%s", command);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x16(%rbp)
jl     1167 <move+0x27>
cmpl   $0x4,-0x4(%rbp)
setl   %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x15(%rbp),%rdi
mov    -0x8(%rbp),%r8d
movslq -0x4(%rbp),%r9
mov    $0xd,%esi
lea    0xe78(%rip),%rdx
mov    $0x1b,%ecx
lea    0xe68(%rip),%rax
movsbl (%rax,%r9,1),%r9d
call   1030 <snprintf@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    -0x15(%rbp),%rdx
lea    0xe56(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x4,%ebp
setb   %dil
call   1040 <assert@plt>
movslq %ebp,%rax
lea    0xe9e(%rip),%rcx
movsbl (%rax,%rcx,1),%r9d
lea    0xe96(%rip),%rdx
lea    0xb(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xd,%esi
mov    $0x1b,%ecx
mov    %ebx,%r8d
call   1030 <snprintf@plt>
mov    0x2e51(%rip),%rbx
mov    (%rbx),%edi
lea    0xe74(%rip),%rsi
mov    %rbp,%rdx
call   1050 <fprintf@plt>
mov    (%rbx),%edi
call   1060 <fflush@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@move.movement = internal constant [4 x i8] c"ABCD"
@.str = [8 x i8] c"%c[%d%c\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define void @move(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [13 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 4
br label %11
11: ; preds = %8, %2
%12 = phi i1 [ false, %2 ], [ %10, %8 ]
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [4 x i8], [4 x i8]* @move.movement, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call i32 @snprintf(i8* %15, i32 13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 27, i32 %16, i8 signext %20)
%22 = load i32, i32* @stdout
%23 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @stdout
%26 = call i32 @fflush(i32 %25)
ret void
}

LLVM IR (-O2):
@move.movement = internal unnamed_addr constant [4 x i8] c"ABCD"
@.str = [8 x i8] c"%c[%d%c\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define void @move(i32 %0, i32 %1) {
%3 = alloca [13 x i8]
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%5 = icmp ult i32 %0, 4
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = sext i32 %0 to i64
%9 = getelementptr inbounds [4 x i8], [4 x i8]* @move.movement, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = call i32 @snprintf(i8* %4, i32 13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 27, i32 %1, i8 signext %10)
%12 = load i32, i32* @stdout
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
ret void
}