#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__ malloc(scalar_t__);
int /*<<< orphan*/ printf(char *, char *);
char *strcat(char *, char const *);
scalar_t__ strlen(char const *);
main() {
  char *a = "kammo DJ";
  const char *b = "roomies!!";
  char *c;
  a = (char *)malloc(strlen(a) + strlen(b));
  c = (char *)malloc(strlen(a) + strlen(b));
  c = strcat(a, b);
  printf("\n%s", a);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xeaf(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
add    %rax,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x11,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <strlen@plt>
lea    0x9(%rax),%rdi
call   1050 <malloc@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movabs $0x217365696d6f6f72,%rcx
65 73 21
mov    %rcx,(%rbx,%rax,1)
movw   $0x21,0x8(%rbx,%rax,1)
lea    0xe97(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"kammo DJ\00"
@.str.1 = [10 x i8] c"roomies!!\00"
@.str.2 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %2
%4 = load i8*, i8** %1
%5 = call i64 @strlen(i8* %4)
%6 = load i8*, i8** %2
%7 = call i64 @strlen(i8* %6)
%8 = add nsw i64 %5, %7
%9 = call i64 @malloc(i64 %8)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %1
%11 = load i8*, i8** %1
%12 = call i64 @strlen(i8* %11)
%13 = load i8*, i8** %2
%14 = call i64 @strlen(i8* %13)
%15 = add nsw i64 %12, %14
%16 = call i64 @malloc(i64 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %3
%18 = load i8*, i8** %1
%19 = load i8*, i8** %2
%20 = call i8* @strcat(i8* %18, i8* %19)
store i8* %20, i8** %3
%21 = load i8*, i8** %1
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"roomies!!\00"
@.str.2 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = tail call i64 @malloc(i64 17)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%4 = add nsw i64 %3, 9
%5 = tail call i64 @malloc(i64 %4)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%7 = getelementptr i8, i8* %2, i64 %6
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(10) %7, i8* align 1 dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 10, i1 false)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %2)
ret i32 0
}