#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 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    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%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    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jne    11a3 <lcd44780_puts+0x83>
movl   $0x0,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jge    119e <lcd44780_puts+0x7e>
mov    $0x20,%edi
call   1030 <lcd44780_data@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117c <lcd44780_puts+0x5c>
jmp    11a3 <lcd44780_puts+0x83>
cmpl   $0x10,-0x10(%rbp)
jne    11b2 <lcd44780_puts+0x92>
jmp    11b7 <lcd44780_puts+0x97>
jmp    113d <lcd44780_puts+0x1d>
add    $0x10,%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
store i8* %0, i8** %2
store i32 0, i32* %4
%5 = call i32 @lcd44780_command(i32 1)
br label %6
6: ; preds = %34, %1
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %35
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = call i32 @lcd44780_data(i8 signext %12)
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %2
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 8
br i1 %19, label %20, label %30
20: ; preds = %10
store i32 0, i32* %3
br label %21
21: ; preds = %26, %20
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 32
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = call i32 @lcd44780_data(i8 signext 32)
br label %26
26: ; preds = %24
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %21
29: ; preds = %21
br label %30
30: ; preds = %29, %10
%31 = load i32, i32* %4
%32 = icmp eq i32 %31, 16
br i1 %32, label %33, label %34
33: ; preds = %30
br label %35
34: ; preds = %30
br label %6
35: ; preds = %33, %6
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
}