#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_home();
int /*<<< orphan*/ lcd_setcursor(int /*<<< orphan*/, int);
int /*<<< orphan*/ lcd_write(char);
void display(char *str) {
  int row = 0;
  lcd_home();
  while (*str) {
    if ((*str == '\\') && (*(str + 1) == 'n')) {
      row++;
      lcd_setcursor(0, row);
      str += 2;
      continue;
    }
    lcd_write(*str);
    str++;
  }
}


x86 assembly (clang, -O0):
<display>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1030 <lcd_home@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b9 <display+0x89>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    119c <display+0x6c>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6e,%eax
jne    119c <display+0x6c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
xor    %edi,%edi
call   1040 <lcd_setcursor@plt>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    114a <display+0x1a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <lcd_write@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    114a <display+0x1a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <lcd_home@plt>
add    $0x2,%rbx
jmp    1162 <display+0x32>
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x6e,-0x1(%rbx)
je     1170 <display+0x40>
movsbl %al,%edi
call   1050 <lcd_write@plt>
add    $0x1,%rbx
movzbl -0x2(%rbx),%eax
cmp    $0x5c,%al
je     1150 <display+0x20>
test   %al,%al
jne    1156 <display+0x26>
jmp    117e <display+0x4e>
add    $0x1,%ebp
xor    %edi,%edi
mov    %ebp,%esi
call   1040 <lcd_setcursor@plt>
jmp    113f <display+0xf>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define void @display(i8* nocapture %0) {
%2 = tail call i32 (...) @lcd_home()
br label %3
3: ; preds = %13, %1
%4 = phi i8* [ %16, %13 ], [ %0, %1 ]
%5 = phi i32 [ %14, %13 ], [ 0, %1 ]
br label %6
6: ; preds = %3, %17
%7 = phi i8* [ %19, %17 ], [ %4, %3 ]
%8 = load i8, i8* %7
switch i8 %8, label %17 [
i8 0, label %20
i8 92, label %9
]
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 110
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = add nuw nsw i32 %5, 1
%15 = tail call i32 @lcd_setcursor(i32 0, i32 %14)
%16 = getelementptr inbounds i8, i8* %7, i64 2
br label %3
17: ; preds = %6, %9
%18 = tail call i32 @lcd_write(i8 signext %8)
%19 = getelementptr inbounds i8, i8* %7, i64 1
br label %6
20: ; preds = %6
ret void
}