#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 strlen(char *);
int /*<<< orphan*/ write_char(char);
void lcd_line(char *s) {
  int i;
  for (i = 0; i < 20; i++) {
    if ((i + 1) > strlen(s)) {
      write_char(' ');
    } else {
      write_char(s[i]);
    }
  }
}


x86 assembly (clang, -O0):
<lcd_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    118f <lcd_line+0x6f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jle    116b <lcd_line+0x4b>
mov    $0x20,%edi
call   1040 <write_char@plt>
jmp    117c <lcd_line+0x5c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <write_char@plt>
jmp    1181 <lcd_line+0x61>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <lcd_line+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_line>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
jmp    1141 <lcd_line+0x21>
nopl   0x0(%rax)
movsbl %al,%edi
call   1040 <write_char@plt>
mov    %r15,%rbx
cmp    $0x14,%r15
je     115e <lcd_line+0x3e>
lea    0x1(%rbx),%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    $0x20,%al
cmp    %rcx,%rbx
jge    1130 <lcd_line+0x10>
movzbl (%r14,%rbx,1),%eax
jmp    1130 <lcd_line+0x10>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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