#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 background_process_buffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ buffer_append_mem(struct background_process_buffer *,
                                     unsigned char const *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(unsigned char const *);
void buffer_append_str(struct background_process_buffer *p,
                       const unsigned char *str) {
  if (!str || !*str)
    return;
  buffer_append_mem(p, str, strlen(str));
}


x86 assembly (clang, -O0):
<buffer_append_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1148 <buffer_append_str+0x28>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    114d <buffer_append_str+0x2d>
jmp    1175 <buffer_append_str+0x55>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1040 <buffer_append_mem@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buffer_append_str>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     1150 <buffer_append_str+0x30>
mov    %rsi,%rbx
cmpb   $0x0,(%rsi)
je     1150 <buffer_append_str+0x30>
mov    %rdi,%r14
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <buffer_append_mem@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.background_process_buffer = type { i32 }
define void @buffer_append_str(%struct.background_process_buffer* %0, i8* %1) {
%3 = alloca %struct.background_process_buffer*
%4 = alloca i8*
store %struct.background_process_buffer* %0, %struct.background_process_buffer** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7, %2
br label %18
12: ; preds = %7
%13 = load %struct.background_process_buffer*, %struct.background_process_buffer** %3
%14 = load i8*, i8** %4
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @buffer_append_mem(%struct.background_process_buffer* %13, i8* %14, i32 %16)
br label %18
18: ; preds = %12, %11
ret void
}

LLVM IR (-O2):
%struct.background_process_buffer = type { i32 }
define void @buffer_append_str(%struct.background_process_buffer* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @strlen(i8* %1)
%9 = tail call i32 @buffer_append_mem(%struct.background_process_buffer* %0, i8* %1, i32 %8)
br label %10
10: ; preds = %2, %4, %7
ret void
}