#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 lcd_inc_pos();
int lcd_putc(char const);
size_t strlen(char const *);
int /*<<< orphan*/ usleep(int);
int lcd_put_str(const char *str) {
  int ret;
  unsigned int i;
  size_t len = strlen(str);
  for (i = 0; i < len; ++i) {
    ret = lcd_putc(str[i]);
    if (ret)
      return ret;
    usleep(500);
    ret = lcd_inc_pos();
    if (ret)
      return ret;
  }
  return 0;
}


x86 assembly (clang, -O0):
<lcd_put_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%rax
jae    11d1 <lcd_put_str+0x91>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1050 <lcd_putc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1195 <lcd_put_str+0x55>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d8 <lcd_put_str+0x98>
mov    $0x1f4,%edi
call   1060 <usleep@plt>
mov    $0x0,%al
call   1030 <lcd_inc_pos@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11be <lcd_put_str+0x7e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d8 <lcd_put_str+0x98>
jmp    11c3 <lcd_put_str+0x83>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1160 <lcd_put_str+0x20>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_put_str>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %rax,%rax
je     118b <lcd_put_str+0x4b>
mov    %rax,%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%edi
call   1050 <lcd_putc@plt>
test   %eax,%eax
jne    118d <lcd_put_str+0x4d>
mov    $0x1f4,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <lcd_inc_pos@plt>
test   %eax,%eax
jne    118d <lcd_put_str+0x4d>
add    $0x1,%ebx
cmp    %rbx,%r15
ja     1160 <lcd_put_str+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @lcd_put_str(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %6
store i32 0, i32* %5
br label %9
9: ; preds = %33, %1
%10 = load i32, i32* %5
%11 = zext i32 %10 to i64
%12 = load i64, i64* %6
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %36
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i32, i32* %5
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @lcd_putc(i8 signext %19)
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %14
%24 = load i32, i32* %4
store i32 %24, i32* %2
br label %37
25: ; preds = %14
%26 = call i32 @usleep(i32 500)
%27 = call i32 (...) @lcd_inc_pos()
store i32 %27, i32* %4
%28 = load i32, i32* %4
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = load i32, i32* %4
store i32 %31, i32* %2
br label %37
32: ; preds = %25
br label %33
33: ; preds = %32
%34 = load i32, i32* %5
%35 = add i32 %34, 1
store i32 %35, i32* %5
br label %9
36: ; preds = %9
store i32 0, i32* %2
br label %37
37: ; preds = %36, %30, %23
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
define i32 @lcd_put_str(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %18, label %8
4: ; preds = %14
%5 = add nuw nsw i64 %9, 1
%6 = and i64 %5, 4294967295
%7 = icmp ugt i64 %2, %6
br i1 %7, label %8, label %18
8: ; preds = %1, %4
%9 = phi i64 [ %6, %4 ], [ 0, %1 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = tail call i32 @lcd_putc(i8 signext %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = tail call i32 @usleep(i32 500)
%16 = tail call i32 (...) @lcd_inc_pos()
%17 = icmp eq i32 %16, 0
br i1 %17, label %4, label %18
18: ; preds = %8, %14, %4, %1
%19 = phi i32 [ 0, %1 ], [ 0, %4 ], [ %16, %14 ], [ %12, %8 ]
ret i32 %19
}