#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*/ printf(char *);
int /*<<< orphan*/ test_append(char *, char *);
int main(void) {
  printf("\nWorking\n");
  test_append("asdf", "asdf");
  printf("\nEmpty Start\n");
  test_append("", "asdf");
  printf("\nEmpty End\n");
  test_append("asdf", "");
  printf("\nWorking 2\n");
  test_append("Hello!", " Hi!");
  printf("\nEmbedded Zero\n");
  test_append("asdf\0ghjk", "qwerty");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
lea    0xed3(%rip),%rsi
mov    %rsi,%rdi
call   1040 <test_append@plt>
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <test_append@plt>
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
lea    0xe99(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1040 <test_append@plt>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1040 <test_append@plt>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    0xea9(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <test_append@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%rbx
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1040 <test_append@plt>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xebb(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <test_append@plt>
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <test_append@plt>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7b(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <test_append@plt>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaa(%rip),%rdi
lea    0xe61(%rip),%rsi
call   1040 <test_append@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"\0AWorking\0A\00"
@.str.1 = [5 x i8] c"asdf\00"
@.str.2 = [14 x i8] c"\0AEmpty Start\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [12 x i8] c"\0AEmpty End\0A\00"
@.str.5 = [12 x i8] c"\0AWorking 2\0A\00"
@.str.6 = [7 x i8] c"Hello!\00"
@.str.7 = [5 x i8] c" Hi!\00"
@.str.8 = [16 x i8] c"\0AEmbedded Zero\0A\00"
@.str.9 = [10 x i8] c"asdf\00ghjk\00"
@.str.10 = [7 x i8] c"qwerty\00"
define i32 @main() {
%1 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @test_append(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32 @test_append(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%6 = call i32 @test_append(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 @test_append(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%10 = call i32 @test_append(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"asdf\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.6 = [7 x i8] c"Hello!\00"
@.str.7 = [5 x i8] c" Hi!\00"
@.str.9 = [10 x i8] c"asdf\00ghjk\00"
@.str.10 = [7 x i8] c"qwerty\00"
@str = [9 x i8] c"\0AWorking\00"
@str.11 = [13 x i8] c"\0AEmpty Start\00"
@str.12 = [11 x i8] c"\0AEmpty End\00"
@str.13 = [11 x i8] c"\0AWorking 2\00"
@str.14 = [15 x i8] c"\0AEmbedded Zero\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @test_append(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
%4 = tail call i32 @test_append(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.12, i64 0, i64 0))
%6 = tail call i32 @test_append(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.13, i64 0, i64 0))
%8 = tail call i32 @test_append(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0))
%10 = tail call i32 @test_append(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}