#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*/ delay_ms(int);
int /*<<< orphan*/ lcd_envia_byte(int, char);
int /*<<< orphan*/ lcd_pos_xy(int, int);
void lcd_escreve(char c) {
  switch (c) {
  case '\f':
    lcd_envia_byte(0, 1);
    delay_ms(2);
    break;
  case '\n':
  case '\r':
    lcd_pos_xy(1, 2);
    break;
  case '\b':
    lcd_envia_byte(0, 0x10);
    break;
  default:
    lcd_envia_byte(1, c);
    break;
  }
}


x86 assembly (clang, -O0):
<lcd_escreve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xfffffff8,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     11a8 <lcd_escreve+0x78>
mov    -0x10(%rbp),%rax
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <lcd_envia_byte@plt>
mov    $0x2,%edi
call   1050 <delay_ms@plt>
jmp    11b6 <lcd_escreve+0x86>
mov    $0x1,%edi
mov    $0x2,%esi
call   1030 <lcd_pos_xy@plt>
jmp    11b6 <lcd_escreve+0x86>
xor    %edi,%edi
mov    $0x10,%esi
call   1040 <lcd_envia_byte@plt>
jmp    11b6 <lcd_escreve+0x86>
mov    $0x1,%edi
movsbl -0x1(%rbp),%esi
call   1040 <lcd_envia_byte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_escreve>:
push   %rax
lea    -0x8(%rdi),%eax
cmp    $0x5,%eax
ja     117d <lcd_escreve+0x4d>
lea    0xec0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%edi
mov    $0x2,%esi
pop    %rax
jmp    1030 <lcd_pos_xy@plt>
xor    %edi,%edi
mov    $0x10,%esi
pop    %rax
jmp    1040 <lcd_envia_byte@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <lcd_envia_byte@plt>
mov    $0x2,%edi
pop    %rax
jmp    1050 <delay_ms@plt>
movsbl %dil,%esi
mov    $0x1,%edi
pop    %rax
jmp    1040 <lcd_envia_byte@plt>

LLVM IR (-O0):
define void @lcd_escreve(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
switch i32 %4, label %12 [
i32 12, label %5
i32 10, label %8
i32 13, label %8
i32 8, label %10
]
5: ; preds = %1
%6 = call i32 @lcd_envia_byte(i32 0, i8 signext 1)
%7 = call i32 @delay_ms(i32 2)
br label %15
8: ; preds = %1, %1
%9 = call i32 @lcd_pos_xy(i32 1, i32 2)
br label %15
10: ; preds = %1
%11 = call i32 @lcd_envia_byte(i32 0, i8 signext 16)
br label %15
12: ; preds = %1
%13 = load i8, i8* %2
%14 = call i32 @lcd_envia_byte(i32 1, i8 signext %13)
br label %15
15: ; preds = %12, %10, %8, %5
ret void
}

LLVM IR (-O2):
define void @lcd_escreve(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %10 [
i32 12, label %3
i32 10, label %6
i32 13, label %6
i32 8, label %8
]
3: ; preds = %1
%4 = tail call i32 @lcd_envia_byte(i32 0, i8 signext 1)
%5 = tail call i32 @delay_ms(i32 2)
br label %12
6: ; preds = %1, %1
%7 = tail call i32 @lcd_pos_xy(i32 1, i32 2)
br label %12
8: ; preds = %1
%9 = tail call i32 @lcd_envia_byte(i32 0, i8 signext 16)
br label %12
10: ; preds = %1
%11 = tail call i32 @lcd_envia_byte(i32 1, i8 signext %0)
br label %12
12: ; preds = %10, %8, %6, %3
ret void
}