#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*/ lcd44780_command(int);
int /*<<< orphan*/ lcd44780_data(char const);
void lcd44780_puts(const char *s) {
  int i, j;
  int pos = 0;
  lcd44780_command(0x01);
  while (*s) {
    lcd44780_data(*s);
    s++;
    pos++;
    if (pos == 8) {
      for (j = 0; j < 32; j++) {
        lcd44780_data(' ');
      }
    }
    if (pos == 16) {
      break;
    }
  }
}


x86 assembly (clang, -O0):
<lcd44780_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x1,%edi
call   1040 <lcd44780_command@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b7 <lcd44780_puts+0x97>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <lcd44780_data@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jne    11a3 <lcd44780_puts+0x83>
movl   $0x0,-0x10(%rbp)
cmpl   $0x20,-0x10(%rbp)
jge    119e <lcd44780_puts+0x7e>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117c <lcd44780_puts+0x5c>
jmp    11a3 <lcd44780_puts+0x83>
cmpl   $0x10,-0x14(%rbp)
jne    11b2 <lcd44780_puts+0x92>
jmp    11b7 <lcd44780_puts+0x97>
jmp    113d <lcd44780_puts+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd44780_puts>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1,%edi
call   1040 <lcd44780_command@plt>
mov    (%r14),%al
test   %al,%al
je     12b4 <lcd44780_puts+0x194>
xor    %ebx,%ebx
jmp    129e <lcd44780_puts+0x17e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
je     12b4 <lcd44780_puts+0x194>
movsbl %al,%edi
call   1030 <lcd44780_data@plt>
cmp    $0x7,%ebx
je     1150 <lcd44780_puts+0x30>
cmp    $0xf,%ebx
jne    1290 <lcd44780_puts+0x170>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @lcd44780_puts(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %5
%6 = call i32 @lcd44780_command(i32 1)
br label %7
7: ; preds = %35, %1
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %36
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = call i32 @lcd44780_data(i8 signext %13)
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %2
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 8
br i1 %20, label %21, label %31
21: ; preds = %11
store i32 0, i32* %4
br label %22
22: ; preds = %27, %21
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 32
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = call i32 @lcd44780_data(i8 signext 32)
br label %27
27: ; preds = %25
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %22
30: ; preds = %22
br label %31
31: ; preds = %30, %11
%32 = load i32, i32* %5
%33 = icmp eq i32 %32, 16
br i1 %33, label %34, label %35
34: ; preds = %31
br label %36
35: ; preds = %31
br label %7
36: ; preds = %34, %7
ret void
}

LLVM IR (-O2):
define void @lcd44780_puts(i8* nocapture %0) {
%2 = tail call i32 @lcd44780_command(i32 1)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %48, label %5
5: ; preds = %1, %45
%6 = phi i8 [ %46, %45 ], [ %3, %1 ]
%7 = phi i32 [ %11, %45 ], [ 0, %1 ]
%8 = phi i8* [ %10, %45 ], [ %0, %1 ]
%9 = tail call i32 @lcd44780_data(i8 signext %6)
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = add nuw nsw i32 %7, 1
switch i32 %7, label %45 [
i32 7, label %12
i32 15, label %48
]
12: ; preds = %5
%13 = tail call i32 @lcd44780_data(i8 signext 32)
%14 = tail call i32 @lcd44780_data(i8 signext 32)
%15 = tail call i32 @lcd44780_data(i8 signext 32)
%16 = tail call i32 @lcd44780_data(i8 signext 32)
%17 = tail call i32 @lcd44780_data(i8 signext 32)
%18 = tail call i32 @lcd44780_data(i8 signext 32)
%19 = tail call i32 @lcd44780_data(i8 signext 32)
%20 = tail call i32 @lcd44780_data(i8 signext 32)
%21 = tail call i32 @lcd44780_data(i8 signext 32)
%22 = tail call i32 @lcd44780_data(i8 signext 32)
%23 = tail call i32 @lcd44780_data(i8 signext 32)
%24 = tail call i32 @lcd44780_data(i8 signext 32)
%25 = tail call i32 @lcd44780_data(i8 signext 32)
%26 = tail call i32 @lcd44780_data(i8 signext 32)
%27 = tail call i32 @lcd44780_data(i8 signext 32)
%28 = tail call i32 @lcd44780_data(i8 signext 32)
%29 = tail call i32 @lcd44780_data(i8 signext 32)
%30 = tail call i32 @lcd44780_data(i8 signext 32)
%31 = tail call i32 @lcd44780_data(i8 signext 32)
%32 = tail call i32 @lcd44780_data(i8 signext 32)
%33 = tail call i32 @lcd44780_data(i8 signext 32)
%34 = tail call i32 @lcd44780_data(i8 signext 32)
%35 = tail call i32 @lcd44780_data(i8 signext 32)
%36 = tail call i32 @lcd44780_data(i8 signext 32)
%37 = tail call i32 @lcd44780_data(i8 signext 32)
%38 = tail call i32 @lcd44780_data(i8 signext 32)
%39 = tail call i32 @lcd44780_data(i8 signext 32)
%40 = tail call i32 @lcd44780_data(i8 signext 32)
%41 = tail call i32 @lcd44780_data(i8 signext 32)
%42 = tail call i32 @lcd44780_data(i8 signext 32)
%43 = tail call i32 @lcd44780_data(i8 signext 32)
%44 = tail call i32 @lcd44780_data(i8 signext 32)
br label %45
45: ; preds = %12, %5
%46 = load i8, i8* %10
%47 = icmp eq i8 %46, 0
br i1 %47, label %48, label %5
48: ; preds = %45, %5, %1
ret void
}