#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*/ lcd_out(short, short, char *);
void lcd_const(short row, short col, const char *data) {
  char buf[20];
  short idx = 0;
  do {
    buf[idx] = data[idx];
  } while (buf[idx++]);
  lcd_out(row, col, buf);
}


x86 assembly (clang, -O0):
<lcd_const>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %si,%ax
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %ax,-0x4(%rbp)
mov    %rdx,-0x10(%rbp)
movw   $0x0,-0x32(%rbp)
mov    -0x10(%rbp),%rax
movswq -0x32(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movswq -0x32(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x32(%rbp),%ax
mov    %ax,%cx
add    $0x1,%cx
mov    %cx,-0x32(%rbp)
movswq %ax,%rax
cmpb   $0x0,-0x30(%rbp,%rax,1)
jne    1130 <lcd_const+0x20>
mov    -0x2(%rbp),%cx
mov    -0x4(%rbp),%ax
lea    -0x30(%rbp),%rdx
movswl %cx,%edi
movswl %ax,%esi
call   1030 <lcd_out@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_const>:
sub    $0x18,%rsp
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movswq %ax,%rcx
movzbl (%rdx,%rcx,1),%r8d
mov    %r8b,(%rsp,%rcx,1)
add    $0x1,%eax
test   %r8b,%r8b
jne    1120 <lcd_const+0x10>
movswl %di,%edi
movswl %si,%esi
mov    %rsp,%rdx
call   1030 <lcd_out@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @lcd_const(i16 signext %0, i16 signext %1, i8* %2) {
%4 = alloca i16
%5 = alloca i16
%6 = alloca i8*
%7 = alloca [20 x i8]
%8 = alloca i16
store i16 %0, i16* %4
store i16 %1, i16* %5
store i8* %2, i8** %6
store i16 0, i16* %8
br label %9
9: ; preds = %18, %3
%10 = load i8*, i8** %6
%11 = load i16, i16* %8
%12 = sext i16 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = load i16, i16* %8
%16 = sext i16 %15 to i64
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %16
store i8 %14, i8* %17
br label %18
18: ; preds = %9
%19 = load i16, i16* %8
%20 = add i16 %19, 1
store i16 %20, i16* %8
%21 = sext i16 %19 to i64
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp ne i8 %23, 0
br i1 %24, label %9, label %25
25: ; preds = %18
%26 = load i16, i16* %4
%27 = load i16, i16* %5
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%29 = call i32 @lcd_out(i16 signext %26, i16 signext %27, i8* %28)
ret void
}

LLVM IR (-O2):
define void @lcd_const(i16 signext %0, i16 signext %1, i8* nocapture %2) {
%4 = alloca [20 x i8]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
br label %6
6: ; preds = %6, %3
%7 = phi i16 [ 0, %3 ], [ %12, %6 ]
%8 = sext i16 %7 to i64
%9 = getelementptr inbounds i8, i8* %2, i64 %8
%10 = load i8, i8* %9
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 %8
store i8 %10, i8* %11
%12 = add i16 %7, 1
%13 = icmp eq i8 %10, 0
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = call i32 @lcd_out(i16 signext %0, i16 signext %1, i8* %5)
ret void
}