#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*/ assert(char const *);
char *realloc(char *, scalar_t__);
int /*<<< orphan*/ strcat(char *, char const *);
char *strdup(char const *);
scalar_t__ strlen(char const *);
char *addr_list_append(char *list, const char *tail) {
  assert(tail);
  if (!list) {
    list = strdup(tail);
    assert(list);
    return list;
  }
  list = realloc(list, strlen(list) + strlen(tail) + 2);
  assert(list);
  strcat(list, " ");
  strcat(list, tail);
  return list;
}


x86 assembly (clang, -O0):
<addr_list_append>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1197 <addr_list_append+0x47>
mov    -0x18(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fb <addr_list_append+0xab>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdi
add    %rax,%rsi
add    $0x2,%rsi
call   1050 <realloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addr_list_append>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <assert@plt>
test   %rbx,%rbx
je     11b2 <addr_list_append+0x62>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%r15,%rax,1),%rsi
add    $0x2,%rsi
mov    %rbx,%rdi
call   1050 <realloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <assert@plt>
lea    0xe63(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
jmp    11c5 <addr_list_append+0x75>
mov    %r14,%rdi
call   1070 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <assert@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i8* @addr_list_append(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = call i32 @assert(i8* %6)
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i8* @strdup(i8* %11)
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = call i32 @assert(i8* %13)
%15 = load i8*, i8** %4
store i8* %15, i8** %3
br label %33
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = load i8*, i8** %4
%19 = call i64 @strlen(i8* %18)
%20 = load i8*, i8** %5
%21 = call i64 @strlen(i8* %20)
%22 = add nsw i64 %19, %21
%23 = add nsw i64 %22, 2
%24 = call i8* @realloc(i8* %17, i64 %23)
store i8* %24, i8** %4
%25 = load i8*, i8** %4
%26 = call i32 @assert(i8* %25)
%27 = load i8*, i8** %4
%28 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%29 = load i8*, i8** %4
%30 = load i8*, i8** %5
%31 = call i32 @strcat(i8* %29, i8* %30)
%32 = load i8*, i8** %4
store i8* %32, i8** %3
br label %33
33: ; preds = %16, %10
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i8* @addr_list_append(i8* %0, i8* %1) {
%3 = tail call i32 @assert(i8* %1)
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i8* @strdup(i8* %1)
%7 = tail call i32 @assert(i8* %6)
br label %17
8: ; preds = %2
%9 = tail call i64 @strlen(i8* %0)
%10 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%11 = add i64 %9, 2
%12 = add i64 %11, %10
%13 = tail call i8* @realloc(i8* %0, i64 %12)
%14 = tail call i32 @assert(i8* %13)
%15 = tail call i32 @strcat(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @strcat(i8* %13, i8* %1)
br label %17
17: ; preds = %8, %5
%18 = phi i8* [ %13, %8 ], [ %6, %5 ]
ret i8* %18
}