#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 */
scalar_t__ realloc(char *, int);
int /*<<< orphan*/ strcat(char *, char const *);
int strlen(char const *);
void AddChars(char *currentWord, const char *value) {
  if (currentWord == NULL || strlen(value) == 0) {
    return;
  }
  int len = strlen(value);
  currentWord = (char *)realloc(currentWord, strlen(currentWord) + len);
  strcat(currentWord, value);
}


x86 assembly (clang, -O0):
<AddChars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     115d <AddChars+0x2d>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    1162 <AddChars+0x32>
jmp    119e <AddChars+0x6e>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
add    -0x14(%rbp),%esi
call   1040 <realloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AddChars>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     1178 <AddChars+0x48>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1178 <AddChars+0x48>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    %eax,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <realloc@plt>
mov    %rax,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <strcat@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @AddChars(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = tail call i32 @strlen(i8* %1)
%9 = tail call i32 @strlen(i8* %0)
%10 = add nsw i32 %9, %8
%11 = tail call i64 @realloc(i8* %0, i32 %10)
%12 = inttoptr i64 %11 to i8*
%13 = tail call i32 @strcat(i8* %12, i8* %1)
br label %14
14: ; preds = %2, %4, %7
ret void
}