#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(int /*<<< orphan*/);
scalar_t__ realloc(char *, scalar_t__);
scalar_t__ strLength(char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
void __strAppend(char **destPtr, char *src) {
  assert(destPtr != NULL);
  assert(*destPtr != NULL);
  assert(src != NULL);
  if (strLength(src) == 0)
    return;
  *destPtr = (char *)realloc(*destPtr, strlen(*destPtr) + strlen(src) + 1);
  strcat(*destPtr, src);
}


x86 assembly (clang, -O0):
<__strAppend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1070 <strLength@plt>
cmp    $0x0,%rax
jne    11b1 <__strAppend+0x61>
jmp    1203 <__strAppend+0xb3>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdi
add    %rax,%rsi
add    $0x1,%rsi
call   1050 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__strAppend>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%rbx)
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
mov    %r14,%rdi
call   1070 <strLength@plt>
test   %rax,%rax
je     11d5 <__strAppend+0x85>
mov    (%rbx),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%r12,%rax,1),%rsi
add    $0x1,%rsi
mov    %r15,%rdi
call   1050 <realloc@plt>
mov    %rax,(%rbx)
mov    %rax,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <strcat@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @__strAppend(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
store i8** %0, i8*** %3
store i8* %1, i8** %4
%5 = load i8**, i8*** %3
%6 = icmp ne i8** %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i8**, i8*** %3
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %4
%19 = call i64 @strLength(i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %2
br label %39
22: ; preds = %2
%23 = load i8**, i8*** %3
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %3
%26 = load i8*, i8** %25
%27 = call i64 @strlen(i8* %26)
%28 = load i8*, i8** %4
%29 = call i64 @strlen(i8* %28)
%30 = add nsw i64 %27, %29
%31 = add nsw i64 %30, 1
%32 = call i64 @realloc(i8* %24, i64 %31)
%33 = inttoptr i64 %32 to i8*
%34 = load i8**, i8*** %3
store i8* %33, i8** %34
%35 = load i8**, i8*** %3
%36 = load i8*, i8** %35
%37 = load i8*, i8** %4
%38 = call i32 @strcat(i8* %36, i8* %37)
br label %39
39: ; preds = %22, %21
ret void
}

LLVM IR (-O2):
define void @__strAppend(i8** %0, i8* %1) {
%3 = icmp ne i8** %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = load i8*, i8** %0
%7 = icmp ne i8* %6, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp ne i8* %1, null
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i64 @strLength(i8* %1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %24, label %15
15: ; preds = %2
%16 = load i8*, i8** %0
%17 = tail call i64 @strlen(i8* dereferenceable(1) %16)
%18 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%19 = add i64 %17, 1
%20 = add i64 %19, %18
%21 = tail call i64 @realloc(i8* %16, i64 %20)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %0
%23 = tail call i32 @strcat(i8* %22, i8* %1)
br label %24
24: ; preds = %2, %15
ret void
}