#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*/ free(char *);
char *join_str_double(char const *const, char const *const);
char *join_str_triple(const char *const left, const char *const middle,
                      const char *const right) {
  char *tmp_str = NULL;
  char *out_str = NULL;
  tmp_str = join_str_double(left, middle);
  if (right == NULL) {
    out_str = tmp_str;
  } else {
    out_str = join_str_double(tmp_str, right);
    if (tmp_str != NULL) {
      free(tmp_str);
    }
  }
  return out_str;
}


x86 assembly (clang, -O0):
<join_str_triple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <join_str_double@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116d <join_str_triple+0x4d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1197 <join_str_triple+0x77>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <join_str_double@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1192 <join_str_triple+0x72>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    1197 <join_str_triple+0x77>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<join_str_triple>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
call   1040 <join_str_double@plt>
mov    %rax,%rbx
test   %r14,%r14
je     1151 <join_str_triple+0x31>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <join_str_double@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     1154 <join_str_triple+0x34>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1154 <join_str_triple+0x34>
mov    %rbx,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @join_str_triple(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i8* null, i8** %7
store i8* null, i8** %8
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i8* @join_str_double(i8* %9, i8* %10)
store i8* %11, i8** %7
%12 = load i8*, i8** %6
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = load i8*, i8** %7
store i8* %15, i8** %8
br label %26
16: ; preds = %3
%17 = load i8*, i8** %7
%18 = load i8*, i8** %6
%19 = call i8* @join_str_double(i8* %17, i8* %18)
store i8* %19, i8** %8
%20 = load i8*, i8** %7
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i8*, i8** %7
%24 = call i32 @free(i8* %23)
br label %25
25: ; preds = %22, %16
br label %26
26: ; preds = %25, %14
%27 = load i8*, i8** %8
ret i8* %27
}

LLVM IR (-O2):
define i8* @join_str_triple(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @join_str_double(i8* %0, i8* %1)
%5 = icmp eq i8* %2, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i8* @join_str_double(i8* %4, i8* %2)
%8 = icmp eq i8* %4, null
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @free(i8* %4)
br label %11
11: ; preds = %3, %6, %9
%12 = phi i8* [ %7, %9 ], [ %7, %6 ], [ %4, %3 ]
ret i8* %12
}