#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 */
typedef size_t uint8_t;
struct mcp23017 {
  int dummy;
};
struct hd44780 {
  int dummy;
};
typedef int /*<<< orphan*/ int8_t;

/* Variables and functions */
int /*<<< orphan*/ hd44780WriteByte(struct mcp23017 *, struct hd44780 *, char,
                                    int);
int8_t hd44780WriteString(struct mcp23017 *mcp23017, struct hd44780 *hd44780,
                          char *string, uint8_t len) {
  uint8_t i;
  for (i = 0; i < len; i++)
    hd44780WriteByte(mcp23017, hd44780, string[i], 1);
  return 0;
}


x86 assembly (clang, -O0):
<hd44780WriteString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    116d <hd44780WriteString+0x5d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rdx
mov    $0x1,%ecx
movsbl (%rax,%rdx,1),%edx
call   1030 <hd44780WriteByte@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1130 <hd44780WriteString+0x20>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hd44780WriteString>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rcx,%rcx
je     114e <hd44780WriteString+0x3e>
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%r14,%rbx,1),%edx
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x1,%ecx
call   1030 <hd44780WriteByte@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <hd44780WriteString+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.mcp23017 = type { i32 }
%struct.hd44780 = type { i32 }
define i32 @hd44780WriteString(%struct.mcp23017* %0, %struct.hd44780* %1, i8* nocapture %2, i64 %3) {
%5 = icmp eq i64 %3, 0
br i1 %5, label %13, label %6
6: ; preds = %4, %6
%7 = phi i64 [ %11, %6 ], [ 0, %4 ]
%8 = getelementptr inbounds i8, i8* %2, i64 %7
%9 = load i8, i8* %8
%10 = tail call i32 @hd44780WriteByte(%struct.mcp23017* %0, %struct.hd44780* %1, i8 signext %9, i32 1)
%11 = add nuw i64 %7, 1
%12 = icmp eq i64 %11, %3
br i1 %12, label %13, label %6
13: ; preds = %6, %4
ret i32 0
}