#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_writecom(int);
int /*<<< orphan*/ lcd_writedata(int /*<<< orphan*/);
void lcd_display_string(unsigned char line_num, char *ptr) {
  if (line_num == 0) {
    lcd_writecom(0x80);
  } else if (line_num == 1) {
    lcd_writecom(0xc0);
  }
  while (*ptr) {
    lcd_writedata(*ptr++);
  }
}


x86 assembly (clang, -O0):
<lcd_display_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    114e <lcd_display_string+0x2e>
mov    $0x80,%edi
call   1030 <lcd_writecom@plt>
jmp    116a <lcd_display_string+0x4a>
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    1165 <lcd_display_string+0x45>
mov    $0xc0,%edi
call   1030 <lcd_writecom@plt>
jmp    116a <lcd_display_string+0x4a>
jmp    116f <lcd_display_string+0x4f>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1198 <lcd_display_string+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1040 <lcd_writedata@plt>
jmp    116f <lcd_display_string+0x4f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_display_string>:
push   %rbx
mov    %rsi,%rbx
test   %edi,%edi
je     1135 <lcd_display_string+0x15>
cmp    $0x1,%dil
jne    113f <lcd_display_string+0x1f>
mov    $0xc0,%edi
jmp    113a <lcd_display_string+0x1a>
mov    $0x80,%edi
call   1030 <lcd_writecom@plt>
mov    (%rbx),%al
test   %al,%al
je     1163 <lcd_display_string+0x43>
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1040 <lcd_writedata@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <lcd_display_string+0x30>
pop    %rbx
ret

LLVM IR (-O0):
define void @lcd_display_string(i8 zeroext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
store i8 %0, i8* %3
store i8* %1, i8** %4
%5 = load i8, i8* %3
%6 = zext i8 %5 to i32
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @lcd_writecom(i32 128)
br label %17
10: ; preds = %2
%11 = load i8, i8* %3
%12 = zext i8 %11 to i32
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @lcd_writecom(i32 192)
br label %16
16: ; preds = %14, %10
br label %17
17: ; preds = %16, %8
br label %18
18: ; preds = %22, %17
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %4
%25 = load i8, i8* %23
%26 = sext i8 %25 to i32
%27 = call i32 @lcd_writedata(i32 %26)
br label %18
28: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @lcd_display_string(i8 zeroext %0, i8* nocapture %1) {
switch i8 %0, label %7 [
i8 0, label %4
i8 1, label %3
]
3: ; preds = %2
br label %4
4: ; preds = %2, %3
%5 = phi i32 [ 192, %3 ], [ 128, %2 ]
%6 = tail call i32 @lcd_writecom(i32 %5)
br label %7
7: ; preds = %4, %2
%8 = load i8, i8* %1
%9 = icmp eq i8 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %7, %10
%11 = phi i8 [ %16, %10 ], [ %8, %7 ]
%12 = phi i8* [ %13, %10 ], [ %1, %7 ]
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = sext i8 %11 to i32
%15 = tail call i32 @lcd_writedata(i32 %14)
%16 = load i8, i8* %13
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %10
18: ; preds = %10, %7
ret void
}