#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 lcd_read(int /*<<< orphan*/);
int /*<<< orphan*/ lcd_write(int, char);
void lcd_puts(char *s) {
  int c;
  for (; *s; s++) {
    switch (*s) {
    case '\n':
      lcd_write(0, (0x40) | 0x80);
      break;
    case '\r':
      lcd_write(0, (0) | 0x80);
      break;
    case '\t':
      c = (lcd_read(0) & 0x7F);
      while (c & 7) {
        lcd_write(1, (' '));
        c++;
      }
      if (c > 15)
        lcd_write(0, (0x40) | 0x80);
      break;
    default:
      lcd_write(1, (*s));
      break;
    }
  }
}


x86 assembly (clang, -O0):
<lcd_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1210 <lcd_puts+0xf0>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x10(%rbp)
sub    $0x9,%eax
je     1195 <lcd_puts+0x75>
jmp    1151 <lcd_puts+0x31>
mov    -0x10(%rbp),%eax
sub    $0xa,%eax
je     1173 <lcd_puts+0x53>
jmp    1162 <lcd_puts+0x42>
mov    -0x10(%rbp),%eax
sub    $0xd,%eax
je     1184 <lcd_puts+0x64>
jmp    11e9 <lcd_puts+0xc9>
xor    %edi,%edi
mov    $0xffffffc0,%esi
call   1040 <lcd_write@plt>
jmp    11fa <lcd_puts+0xda>
xor    %edi,%edi
mov    $0xffffff80,%esi
call   1040 <lcd_write@plt>
jmp    11fa <lcd_puts+0xda>
xor    %edi,%edi
call   1030 <lcd_read@plt>
and    $0x7f,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
je     11ce <lcd_puts+0xae>
mov    $0x1,%edi
mov    $0x20,%esi
call   1040 <lcd_write@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a2 <lcd_puts+0x82>
cmpl   $0xf,-0xc(%rbp)
jle    11e4 <lcd_puts+0xc4>
xor    %edi,%edi
mov    $0xffffffc0,%esi
call   1040 <lcd_write@plt>
jmp    11fa <lcd_puts+0xda>
mov    -0x8(%rbp),%rax
mov    $0x1,%edi
movsbl (%rax),%esi
call   1040 <lcd_write@plt>
jmp    11ff <lcd_puts+0xdf>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112c <lcd_puts+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_puts>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     119f <lcd_puts+0x7f>
mov    %rdi,%rbx
jmp    1147 <lcd_puts+0x27>
xchg   %ax,%ax
xor    %edi,%edi
mov    $0xffffffc0,%esi
call   1040 <lcd_write@plt>
mov    0x1(%rbx),%al
add    $0x1,%rbx
test   %al,%al
je     119f <lcd_puts+0x7f>
movsbl %al,%esi
cmp    $0x9,%esi
je     1170 <lcd_puts+0x50>
cmp    $0xd,%esi
je     1160 <lcd_puts+0x40>
cmp    $0xa,%esi
je     1130 <lcd_puts+0x10>
mov    $0x1,%edi
jmp    1137 <lcd_puts+0x17>
xor    %edi,%edi
mov    $0xffffff80,%esi
jmp    1137 <lcd_puts+0x17>
nopl   0x0(%rax)
xor    %edi,%edi
call   1030 <lcd_read@plt>
mov    %eax,%ebp
and    $0x7f,%ebp
test   $0x7,%al
je     1198 <lcd_puts+0x78>
mov    $0x1,%edi
mov    $0x20,%esi
call   1040 <lcd_write@plt>
add    $0x1,%ebp
test   $0x7,%bpl
jne    1180 <lcd_puts+0x60>
cmp    $0x10,%ebp
jae    1130 <lcd_puts+0x10>
jmp    113c <lcd_puts+0x1c>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @lcd_puts(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
br label %4
4: ; preds = %38, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %41
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %33 [
i32 10, label %12
i32 13, label %14
i32 9, label %16
]
12: ; preds = %8
%13 = call i32 @lcd_write(i32 0, i8 signext -64)
br label %37
14: ; preds = %8
%15 = call i32 @lcd_write(i32 0, i8 signext -128)
br label %37
16: ; preds = %8
%17 = call i32 @lcd_read(i32 0)
%18 = and i32 %17, 127
store i32 %18, i32* %3
br label %19
19: ; preds = %23, %16
%20 = load i32, i32* %3
%21 = and i32 %20, 7
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = call i32 @lcd_write(i32 1, i8 signext 32)
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %19
27: ; preds = %19
%28 = load i32, i32* %3
%29 = icmp sgt i32 %28, 15
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @lcd_write(i32 0, i8 signext -64)
br label %32
32: ; preds = %30, %27
br label %37
33: ; preds = %8
%34 = load i8*, i8** %2
%35 = load i8, i8* %34
%36 = call i32 @lcd_write(i32 1, i8 signext %35)
br label %37
37: ; preds = %33, %32, %14, %12
br label %38
38: ; preds = %37
%39 = load i8*, i8** %2
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %2
br label %4
41: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @lcd_puts(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %34, label %4
4: ; preds = %1, %30
%5 = phi i8 [ %32, %30 ], [ %2, %1 ]
%6 = phi i8* [ %31, %30 ], [ %0, %1 ]
%7 = sext i8 %5 to i32
switch i32 %7, label %28 [
i32 10, label %8
i32 13, label %10
i32 9, label %12
]
8: ; preds = %4
%9 = tail call i32 @lcd_write(i32 0, i8 signext -64)
br label %30
10: ; preds = %4
%11 = tail call i32 @lcd_write(i32 0, i8 signext -128)
br label %30
12: ; preds = %4
%13 = tail call i32 @lcd_read(i32 0)
%14 = and i32 %13, 127
%15 = and i32 %13, 7
%16 = icmp eq i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %12, %17
%18 = phi i32 [ %20, %17 ], [ %14, %12 ]
%19 = tail call i32 @lcd_write(i32 1, i8 signext 32)
%20 = add nuw nsw i32 %18, 1
%21 = and i32 %20, 7
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %17
23: ; preds = %17, %12
%24 = phi i32 [ %14, %12 ], [ %20, %17 ]
%25 = icmp ugt i32 %24, 15
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = tail call i32 @lcd_write(i32 0, i8 signext -64)
br label %30
28: ; preds = %4
%29 = tail call i32 @lcd_write(i32 1, i8 signext %5)
br label %30
30: ; preds = %8, %10, %28, %26, %23
%31 = getelementptr inbounds i8, i8* %6, i64 1
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
br i1 %33, label %34, label %4
34: ; preds = %30, %1
ret void
}