#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_byte(char, int);
int strlen(char *);
void lcd_string(char *message) {
  int i = 0;
  for (i = 0; i < 20; i++) {
    if (i < strlen(message)) {
      lcd_byte(message[i], 1);
    } else {
      lcd_byte(' ', 1);
    }
  }
}


x86 assembly (clang, -O0):
<lcd_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    119d <lcd_string+0x7d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    117b <lcd_string+0x5b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    $0x1,%esi
movsbl (%rax,%rcx,1),%edi
call   1030 <lcd_byte@plt>
jmp    118a <lcd_string+0x6a>
mov    $0x20,%edi
mov    $0x1,%esi
call   1030 <lcd_byte@plt>
jmp    118f <lcd_string+0x6f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113a <lcd_string+0x1a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_string>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
jmp    1147 <lcd_string+0x27>
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
mov    $0x1,%esi
call   1030 <lcd_byte@plt>
add    $0x1,%rbx
cmp    $0x14,%rbx
je     1160 <lcd_string+0x40>
mov    %r14,%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
mov    $0x20,%al
cmp    %rcx,%rbx
jge    1130 <lcd_string+0x10>
movzbl (%r14,%rbx,1),%eax
jmp    1130 <lcd_string+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @lcd_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %3
br label %4
4: ; preds = %22, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 20
br i1 %6, label %7, label %25
7: ; preds = %4
%8 = load i32, i32* %3
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %19
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = call i32 @lcd_byte(i8 signext %17, i32 1)
br label %21
19: ; preds = %7
%20 = call i32 @lcd_byte(i8 signext 32, i32 1)
br label %21
21: ; preds = %19, %12
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %4
25: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @lcd_string(i8* %0) {
br label %2
2: ; preds = %1, %10
%3 = phi i64 [ 0, %1 ], [ %13, %10 ]
%4 = tail call i32 @strlen(i8* %0)
%5 = sext i32 %4 to i64
%6 = icmp slt i64 %3, %5
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 %3
%9 = load i8, i8* %8
br label %10
10: ; preds = %2, %7
%11 = phi i8 [ %9, %7 ], [ 32, %2 ]
%12 = tail call i32 @lcd_byte(i8 signext %11, i32 1)
%13 = add nuw nsw i64 %3, 1
%14 = icmp eq i64 %13, 20
br i1 %14, label %15, label %2
15: ; preds = %10
ret void
}