#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 */
char *m330_cleanse(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ xfree(char *);
char *xstrdup(char const *);
void append(char *buf, const char *str) {
  char *cleansed1, *cleansed2;
  strcat(buf, ",");
  if (!str) {
    return;
  }
  cleansed1 = xstrdup(str);
  cleansed2 = m330_cleanse(cleansed1);
  strcat(buf, cleansed2);
  xfree(cleansed1);
  xfree(cleansed2);
}


x86 assembly (clang, -O0):
<append>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <strcat@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1170 <append+0x30>
jmp    11a9 <append+0x69>
mov    -0x10(%rbp),%rdi
call   1050 <xstrdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <m330_cleanse@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   1040 <xfree@plt>
mov    -0x20(%rbp),%rdi
call   1040 <xfree@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xeae(%rip),%rsi
call   1060 <strcat@plt>
test   %rbx,%rbx
je     1192 <append+0x52>
mov    %rbx,%rdi
call   1050 <xstrdup@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1030 <m330_cleanse@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <strcat@plt>
mov    %r15,%rdi
call   1040 <xfree@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <xfree@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
define void @append(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %2
br label %24
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i8* @xstrdup(i8* %13)
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = call i8* @m330_cleanse(i8* %15)
store i8* %16, i8** %6
%17 = load i8*, i8** %3
%18 = load i8*, i8** %6
%19 = call i32 @strcat(i8* %17, i8* %18)
%20 = load i8*, i8** %5
%21 = call i32 @xfree(i8* %20)
%22 = load i8*, i8** %6
%23 = call i32 @xfree(i8* %22)
br label %24
24: ; preds = %12, %11
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define void @append(i8* %0, i8* %1) {
%3 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %1, null
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = tail call i8* @xstrdup(i8* %1)
%7 = tail call i8* @m330_cleanse(i8* %6)
%8 = tail call i32 @strcat(i8* %0, i8* %7)
%9 = tail call i32 @xfree(i8* %6)
%10 = tail call i32 @xfree(i8* %7)
br label %11
11: ; preds = %2, %5
ret void
}