#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*/ append_char(char **, size_t *, size_t *, int /*<<< orphan*/);
void append_str(char **buf, size_t *l, size_t *i, const char *str) {
  while (str && *str) {
    append_char(buf, l, i, *str++);
  }
}


x86 assembly (clang, -O0):
<append_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x21(%rbp)
je     1148 <append_str+0x38>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1158 <append_str+0x48>
jmp    1180 <append_str+0x70>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl (%rax),%ecx
call   1030 <append_char@plt>
jmp    1128 <append_str+0x18>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_str>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rcx,%rcx
je     115c <append_str+0x4c>
mov    %rcx,%rbx
mov    (%rcx),%al
test   %al,%al
je     115c <append_str+0x4c>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%ecx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <append_char@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <append_str+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @append_str(i8** %0, i64* %1, i64* %2, i8* %3) {
%5 = alloca i8**
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca i8*
store i8** %0, i8*** %5
store i64* %1, i64** %6
store i64* %2, i64** %7
store i8* %3, i8** %8
br label %9
9: ; preds = %19, %4
%10 = load i8*, i8** %8
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i8*, i8** %8
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br label %17
17: ; preds = %12, %9
%18 = phi i1 [ false, %9 ], [ %16, %12 ]
br i1 %18, label %19, label %28
19: ; preds = %17
%20 = load i8**, i8*** %5
%21 = load i64*, i64** %6
%22 = load i64*, i64** %7
%23 = load i8*, i8** %8
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %8
%25 = load i8, i8* %23
%26 = sext i8 %25 to i32
%27 = call i32 @append_char(i8** %20, i64* %21, i64* %22, i32 %26)
br label %9
28: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @append_str(i8** %0, i64* %1, i64* %2, i8* %3) {
%5 = icmp eq i8* %3, null
br i1 %5, label %17, label %6
6: ; preds = %4
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %6, %9
%10 = phi i8 [ %15, %9 ], [ %7, %6 ]
%11 = phi i8* [ %13, %9 ], [ %3, %6 ]
%12 = sext i8 %10 to i32
%13 = getelementptr inbounds i8, i8* %11, i64 1
%14 = tail call i32 @append_char(i8** %0, i64* %1, i64* %2, i32 %12)
%15 = load i8, i8* %13
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %9
17: ; preds = %9, %6, %4
ret void
}