#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*/ drv_generic_serial_write(char const *, int);
void drv_SL_vt100_write(const int row, const int col, const char *data,
                        int len) {
  char cmd[8];
  cmd[0] = 0x1b;
  cmd[1] = '[';
  cmd[2] = row + '1';
  cmd[3] = ';';
  cmd[4] = (col / 10) + '0';
  cmd[5] = (col % 10) + '1';
  cmd[6] = 'H';
  drv_generic_serial_write(cmd, 7);
  drv_generic_serial_write(data, len);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movb   $0x1b,-0x1c(%rbp)
movb   $0x5b,-0x1b(%rbp)
mov    -0x4(%rbp),%eax
add    $0x31,%eax
mov    %al,-0x1a(%rbp)
movb   $0x3b,-0x19(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x31,%edx
mov    %dl,%al
mov    %al,-0x17(%rbp)
movb   $0x48,-0x16(%rbp)
lea    -0x1c(%rbp),%rdi
mov    $0x7,%esi
call   1030 <drv_generic_serial_write@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <drv_generic_serial_write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%rbx
movw   $0x5b1b,(%rsp)
add    $0x31,%dil
mov    %dil,0x2(%rsp)
movb   $0x3b,0x3(%rsp)
movslq %esi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    0x30(%rcx),%edx
mov    %dl,0x4(%rsp)
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x31,%al
mov    %al,0x5(%rsp)
movb   $0x48,0x6(%rsp)
mov    %rsp,%rdi
mov    $0x7,%esi
call   1030 <drv_generic_serial_write@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <drv_generic_serial_write@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @drv_SL_vt100_write(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [8 x i8]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
store i8 27, i8* %10
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 1
store i8 91, i8* %11
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 49
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 2
store i8 %14, i8* %15
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 3
store i8 59, i8* %16
%17 = load i32, i32* %6
%18 = sdiv i32 %17, 10
%19 = add nsw i32 %18, 48
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 4
store i8 %20, i8* %21
%22 = load i32, i32* %6
%23 = srem i32 %22, 10
%24 = add nsw i32 %23, 49
%25 = trunc i32 %24 to i8
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 5
store i8 %25, i8* %26
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 6
store i8 72, i8* %27
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%29 = call i32 @drv_generic_serial_write(i8* %28, i32 7)
%30 = load i8*, i8** %7
%31 = load i32, i32* %8
%32 = call i32 @drv_generic_serial_write(i8* %30, i32 %31)
ret void
}

LLVM IR (-O2):
define void @drv_SL_vt100_write(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca [8 x i8]
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
store i8 27, i8* %6
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 1
store i8 91, i8* %7
%8 = trunc i32 %0 to i8
%9 = add i8 %8, 49
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 2
store i8 %9, i8* %10
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 3
store i8 59, i8* %11
%12 = sdiv i32 %1, 10
%13 = trunc i32 %12 to i8
%14 = add i8 %13, 48
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 4
store i8 %14, i8* %15
%16 = srem i32 %1, 10
%17 = trunc i32 %16 to i8
%18 = add nsw i8 %17, 49
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 5
store i8 %18, i8* %19
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 6
store i8 72, i8* %20
%21 = call i32 @drv_generic_serial_write(i8* %6, i32 7)
%22 = call i32 @drv_generic_serial_write(i8* %2, i32 %3)
ret void
}