#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 */
struct PIN_LCD {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ LCD_PutChar(char, struct PIN_LCD *);
char strlen(char *);
void LCD_Printf(char s[], struct PIN_LCD *PIN_LCD) {
  char i = strlen(s);
  char c;
  for (c = 0; c < i; c++) {
    LCD_PutChar(s[c], PIN_LCD);
  }
}


x86 assembly (clang, -O0):
<LCD_Printf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %al,-0x11(%rbp)
movb   $0x0,-0x12(%rbp)
movsbl -0x12(%rbp),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jge    1175 <LCD_Printf+0x55>
mov    -0x8(%rbp),%rax
movsbq -0x12(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1030 <LCD_PutChar@plt>
mov    -0x12(%rbp),%al
add    $0x1,%al
mov    %al,-0x12(%rbp)
jmp    1140 <LCD_Printf+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LCD_Printf>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
test   %al,%al
jle    1156 <LCD_Printf+0x36>
movzbl %al,%r12d
xor    %ebx,%ebx
nopl   (%rax)
movsbl (%r15,%rbx,1),%edi
mov    %r14,%rsi
call   1030 <LCD_PutChar@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <LCD_Printf+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.PIN_LCD = type { i32 }
define void @LCD_Printf(i8* %0, %struct.PIN_LCD* %1) {
%3 = tail call signext i8 @strlen(i8* %0)
%4 = icmp sgt i8 %3, 0
br i1 %4, label %5, label %14
5: ; preds = %2
%6 = zext i8 %3 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %12, %7 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = tail call i32 @LCD_PutChar(i8 signext %10, %struct.PIN_LCD* %1)
%12 = add nuw nsw i64 %8, 1
%13 = icmp eq i64 %12, %6
br i1 %13, label %14, label %7
14: ; preds = %7, %2
ret void
}