#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 *pl_cat(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int main() {
  char foo[] = "foo";
  char bar[] = "bar";
  char *concatenated = NULL;
  concatenated = pl_cat(foo, bar);
  if (concatenated != NULL) {
    printf("foo:%s\nbar:%s\nconcatenated:%s\n", foo, bar, concatenated);
  }
  free(concatenated);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xebb(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xeb6(%rip),%eax
mov    %eax,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <pl_cat@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118d <main+0x5d>
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe80(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x6f6f66,0xc(%rsp)
movl   $0x726162,0x8(%rsp)
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <pl_cat@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1175 <main+0x45>
lea    0xe9d(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rcx
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.foo = [4 x i8] c"foo\00"
@__const.main.bar = [4 x i8] c"bar\00"
@.str = [31 x i8] c"foo:%s\0Abar:%s\0Aconcatenated:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca [4 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [4 x i8]* %2 to i8*
%6 = bitcast [4 x i8]* %3 to i8*
store i8* null, i8** %4
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%9 = call i8* @pl_cat(i8* %7, i8* %8)
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %0
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%15 = load i8*, i8** %4
%16 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14, i8* %15)
br label %17
17: ; preds = %12, %0
%18 = load i8*, i8** %4
%19 = call i32 @free(i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"foo:%s\0Abar:%s\0Aconcatenated:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 7303014, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 7496034, i32* %2
%5 = call i8* @pl_cat(i8* %3, i8* %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4, i8* %5)
br label %9
9: ; preds = %7, %0
%10 = call i32 @free(i8* %5)
ret i32 0
}