#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(int);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
size_t strlen(char *);
int main(int argc, char **argv) {
  char *str1 = argv[1];
  char *str2 = argv[2];
  size_t str1Len = strlen(str1);
  size_t str2Len = strlen(str2);
  char *container = (char *)malloc(sizeof(char) * (str1Len + str2Len + 1));
  memcpy(container, str1, str1Len + 1);
  strcat(container, str2);
  printf("string 1: %s\n", container);
  char *container2 = (char *)malloc(sizeof(char) * (str1Len + str2Len + 1));
  strcpy(container2, str1);
  strcat(container2, str2);
  printf("string 2: %s\n", container2);
  char *container3 = (char *)malloc(sizeof(char) * (str1Len + str2Len + 1));
  strcpy(container3, str1);
  strcpy(container3 + str1Len, str2);
  printf("string 3: %s\n", container3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    -0x30(%rbp),%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
add    $0x1,%rdx
call   1060 <memcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x38(%rbp),%rsi
lea    0xe10(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rax
add    -0x30(%rbp),%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x40(%rbp),%rsi
lea    0xdd9(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rax
add    -0x30(%rbp),%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%rdi
add    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%rsi
lea    0xd9e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x8(%rsi),%r15
mov    0x10(%rsi),%r14
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%rax,%rbx,1),%r12d
add    $0x1,%r12d
mov    %r12d,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
lea    0x1(%rbx),%rdx
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <memcpy@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
lea    0xe49(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    %r12d,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
lea    0xe27(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    %r12d,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
add    %rbp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe02(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"string 1: %s\0A\00"
@.str.1 = [14 x i8] c"string 2: %s\0A\00"
@.str.2 = [14 x i8] c"string 3: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %6
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
store i8* %18, i8** %7
%19 = load i8*, i8** %6
%20 = call i64 @strlen(i8* %19)
store i64 %20, i64* %8
%21 = load i8*, i8** %7
%22 = call i64 @strlen(i8* %21)
store i64 %22, i64* %9
%23 = load i64, i64* %8
%24 = load i64, i64* %9
%25 = add i64 %23, %24
%26 = add i64 %25, 1
%27 = mul i64 1, %26
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %10
%31 = load i8*, i8** %10
%32 = load i8*, i8** %6
%33 = load i64, i64* %8
%34 = add i64 %33, 1
%35 = call i32 @memcpy(i8* %31, i8* %32, i64 %34)
%36 = load i8*, i8** %10
%37 = load i8*, i8** %7
%38 = call i32 @strcat(i8* %36, i8* %37)
%39 = load i8*, i8** %10
%40 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %39)
%41 = load i64, i64* %8
%42 = load i64, i64* %9
%43 = add i64 %41, %42
%44 = add i64 %43, 1
%45 = mul i64 1, %44
%46 = trunc i64 %45 to i32
%47 = call i64 @malloc(i32 %46)
%48 = inttoptr i64 %47 to i8*
store i8* %48, i8** %11
%49 = load i8*, i8** %11
%50 = load i8*, i8** %6
%51 = call i32 @strcpy(i8* %49, i8* %50)
%52 = load i8*, i8** %11
%53 = load i8*, i8** %7
%54 = call i32 @strcat(i8* %52, i8* %53)
%55 = load i8*, i8** %11
%56 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %55)
%57 = load i64, i64* %8
%58 = load i64, i64* %9
%59 = add i64 %57, %58
%60 = add i64 %59, 1
%61 = mul i64 1, %60
%62 = trunc i64 %61 to i32
%63 = call i64 @malloc(i32 %62)
%64 = inttoptr i64 %63 to i8*
store i8* %64, i8** %12
%65 = load i8*, i8** %12
%66 = load i8*, i8** %6
%67 = call i32 @strcpy(i8* %65, i8* %66)
%68 = load i8*, i8** %12
%69 = load i64, i64* %8
%70 = getelementptr inbounds i8, i8* %68, i64 %69
%71 = load i8*, i8** %7
%72 = call i32 @strcpy(i8* %70, i8* %71)
%73 = load i8*, i8** %12
%74 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %73)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"string 1: %s\0A\00"
@.str.1 = [14 x i8] c"string 2: %s\0A\00"
@.str.2 = [14 x i8] c"string 3: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %6)
%9 = add i64 %8, %7
%10 = trunc i64 %9 to i32
%11 = add i32 %10, 1
%12 = tail call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
%14 = add i64 %7, 1
%15 = tail call i32 @memcpy(i8* %13, i8* %4, i64 %14)
%16 = tail call i32 @strcat(i8* %13, i8* %6)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %13)
%18 = tail call i64 @malloc(i32 %11)
%19 = inttoptr i64 %18 to i8*
%20 = tail call i32 @strcpy(i8* %19, i8* %4)
%21 = tail call i32 @strcat(i8* %19, i8* %6)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%23 = tail call i64 @malloc(i32 %11)
%24 = inttoptr i64 %23 to i8*
%25 = tail call i32 @strcpy(i8* %24, i8* %4)
%26 = getelementptr inbounds i8, i8* %24, i64 %7
%27 = tail call i32 @strcpy(i8* %26, i8* %6)
%28 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %24)
ret i32 0
}