#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 *malloc(scalar_t__);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  char *arg_1 = argv[(argc > 2) ? argc - 2 : argc - 1];
  char *arg_2 = argv[argc - 1];
  char *string;
  string = malloc(strlen(arg_1) + strlen(arg_2));
  strcpy(string, arg_1);
  printf("string"
         " = [%s]\n",
         string);
  strcat(string, arg_2);
  printf("string"
         " = [%s]\n",
         string);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1186 <main+0x36>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x34(%rbp)
jmp    118f <main+0x3f>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
add    %rax,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rsi
lea    0xe0c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x28(%rbp),%rsi
lea    0xdef(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
cmp    $0x3,%edi
setge  %al
not    %eax
add    %edi,%eax
cltq
mov    (%rsi,%rax,8),%r15
movslq %edi,%rax
mov    -0x8(%rsi,%rax,8),%r14
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe5e(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"string = [%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 i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 2
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 2
br label %18
15: ; preds = %2
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
br label %18
18: ; preds = %15, %12
%19 = phi i32 [ %14, %12 ], [ %17, %15 ]
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %9, i64 %20
%22 = load i8*, i8** %21
store i8* %22, i8** %6
%23 = load i8**, i8*** %5
%24 = load i32, i32* %4
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %23, i64 %26
%28 = load i8*, i8** %27
store i8* %28, i8** %7
%29 = load i8*, i8** %6
%30 = call i64 @strlen(i8* %29)
%31 = load i8*, i8** %7
%32 = call i64 @strlen(i8* %31)
%33 = add nsw i64 %30, %32
%34 = call i8* @malloc(i64 %33)
store i8* %34, i8** %8
%35 = load i8*, i8** %8
%36 = load i8*, i8** %6
%37 = call i32 @strcpy(i8* %35, i8* %36)
%38 = load i8*, i8** %8
%39 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %8
%41 = load i8*, i8** %7
%42 = call i32 @strcat(i8* %40, i8* %41)
%43 = load i8*, i8** %8
%44 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %43)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"string = [%s]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
%4 = add nsw i32 %0, -2
%5 = add nsw i32 %0, -1
%6 = select i1 %3, i32 %4, i32 %5
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = sext i32 %5 to i64
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i64 @strlen(i8* dereferenceable(1) %9)
%14 = tail call i64 @strlen(i8* dereferenceable(1) %12)
%15 = add nsw i64 %14, %13
%16 = tail call i8* @malloc(i64 %15)
%17 = tail call i32 @strcpy(i8* %16, i8* %9)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %16)
%19 = tail call i32 @strcat(i8* %16, i8* %12)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %16)
ret i32 0
}