#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_LW_ABP_send(char const *, int);
int /*<<< orphan*/ sprintf(char *, char *, int const);
int strlen(char *);
void drv_LW_ABP_write(const int row, const int col, const char *data, int len) {
  char cmd[] = "lcd set line ";
  char row_[5];
  char col_[5];
  drv_LW_ABP_send(cmd, strlen(cmd));
  sprintf(row_, "%d", row + 1);
  drv_LW_ABP_send(row_, strlen(row_));
  if (col > 0) {
    drv_LW_ABP_send(",", 1);
    sprintf(col_, "%d", col + 1);
    drv_LW_ABP_send(col_, strlen(col_));
  }
  drv_LW_ABP_send(" ", 1);
  drv_LW_ABP_send(data, len);
  drv_LW_ABP_send("\r\n", 2);
}


x86 assembly (clang, -O0):
<drv_LW_ABP_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x22(%rbp)
mov    0xeb2(%rip),%eax
mov    %eax,-0x1a(%rbp)
mov    0xeac(%rip),%ax
mov    %ax,-0x16(%rbp)
lea    -0x22(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x22(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1030 <drv_LW_ABP_send@plt>
lea    -0x27(%rbp),%rdi
mov    -0x4(%rbp),%edx
add    $0x1,%edx
lea    0xe7d(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x27(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x27(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1030 <drv_LW_ABP_send@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11ff <drv_LW_ABP_write+0xcf>
lea    0xe4e(%rip),%rdi
mov    $0x1,%esi
call   1030 <drv_LW_ABP_send@plt>
lea    -0x2c(%rbp),%rdi
mov    -0x8(%rbp),%edx
add    $0x1,%edx
lea    0xe30(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x2c(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x2c(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   1030 <drv_LW_ABP_send@plt>
lea    0xe06(%rip),%rdi
mov    $0x1,%esi
call   1030 <drv_LW_ABP_send@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <drv_LW_ABP_send@plt>
lea    0xdf0(%rip),%rdi
mov    $0x2,%esi
call   1030 <drv_LW_ABP_send@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drv_LW_ABP_write>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %esi,%r13d
mov    %edi,%ebx
movabs $0x20656e696c2074,%rax
mov    %rax,0x6(%rsp)
movabs $0x207465732064636c,%rax
65 74 20
mov    %rax,(%rsp)
mov    %rsp,%r12
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <drv_LW_ABP_send@plt>
add    $0x1,%ebx
lea    0xe89(%rip),%rsi
lea    0x13(%rsp),%rbp
mov    %rbp,%rdi
mov    %ebx,%edx
call   1050 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1030 <drv_LW_ABP_send@plt>
test   %r13d,%r13d
jle    11e9 <drv_LW_ABP_write+0xb9>
lea    0xe5f(%rip),%rdi
mov    $0x1,%esi
call   1030 <drv_LW_ABP_send@plt>
add    $0x1,%r13d
lea    0xe47(%rip),%rsi
lea    0xe(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13d,%edx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <drv_LW_ABP_send@plt>
lea    0xe1c(%rip),%rdi
mov    $0x1,%esi
call   1030 <drv_LW_ABP_send@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <drv_LW_ABP_send@plt>
lea    0xe07(%rip),%rdi
mov    $0x2,%esi
call   1030 <drv_LW_ABP_send@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.drv_LW_ABP_write.cmd = [14 x i8] c"lcd set line \00"
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [3 x i8] c"\0D\0A\00"
define void @drv_LW_ABP_write(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [14 x i8]
%10 = alloca [5 x i8]
%11 = alloca [5 x i8]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%12 = bitcast [14 x i8]* %9 to i8*
%13 = getelementptr inbounds [14 x i8], [14 x i8]* %9, i64 0, i64 0
%14 = getelementptr inbounds [14 x i8], [14 x i8]* %9, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = call i32 @drv_LW_ABP_send(i8* %13, i32 %15)
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
%20 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = call i32 @drv_LW_ABP_send(i8* %21, i32 %23)
%25 = load i32, i32* %6
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %4
%28 = call i32 @drv_LW_ABP_send(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 0
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
%32 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 0
%34 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 0
%35 = call i32 @strlen(i8* %34)
%36 = call i32 @drv_LW_ABP_send(i8* %33, i32 %35)
br label %37
37: ; preds = %27, %4
%38 = call i32 @drv_LW_ABP_send(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%39 = load i8*, i8** %7
%40 = load i32, i32* %8
%41 = call i32 @drv_LW_ABP_send(i8* %39, i32 %40)
%42 = call i32 @drv_LW_ABP_send(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
ret void
}

LLVM IR (-O2):
@__const.drv_LW_ABP_write.cmd = [14 x i8] c"lcd set line \00"
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [3 x i8] c"\0D\0A\00"
define void @drv_LW_ABP_write(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca [14 x i8]
%6 = alloca [5 x i8]
%7 = alloca [5 x i8]
%8 = getelementptr inbounds [14 x i8], [14 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%11 = call i32 @strlen(i8* %8)
%12 = call i32 @drv_LW_ABP_send(i8* %8, i32 %11)
%13 = add nsw i32 %0, 1
%14 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @strlen(i8* %9)
%16 = call i32 @drv_LW_ABP_send(i8* %9, i32 %15)
%17 = icmp sgt i32 %1, 0
br i1 %17, label %18, label %24
18: ; preds = %4
%19 = call i32 @drv_LW_ABP_send(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%20 = add nuw nsw i32 %1, 1
%21 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = call i32 @strlen(i8* %10)
%23 = call i32 @drv_LW_ABP_send(i8* %10, i32 %22)
br label %24
24: ; preds = %18, %4
%25 = call i32 @drv_LW_ABP_send(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%26 = call i32 @drv_LW_ABP_send(i8* %2, i32 %3)
%27 = call i32 @drv_LW_ABP_send(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
ret void
}