#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_display_char(unsigned int, unsigned int, unsigned int,
                                    unsigned int, char);
void lcd_display_string(int line, int column, unsigned int font_color,
                        unsigned int bg_color, char *str) {
  unsigned int x = column * 8;
  unsigned int y = line * 16;
  for (int i = 0; str[i] != '\0'; ++i) {
    lcd_display_char(x, y, font_color, bg_color, str[i]);
    x += 8;
  }
  return;
}


x86 assembly (clang, -O0):
<lcd_display_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     118b <lcd_display_string+0x7b>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%r8
movsbl (%rax,%r8,1),%r8d
call   1030 <lcd_display_char@plt>
mov    -0x1c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1141 <lcd_display_string+0x31>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_display_string>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%r8),%al
test   %al,%al
je     1162 <lcd_display_string+0x52>
mov    %r8,%rbx
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%r12d
shl    $0x4,%r12d
shl    $0x3,%ebp
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movsbl %al,%r8d
mov    %ebp,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1030 <lcd_display_char@plt>
add    $0x8,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <lcd_display_string+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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