#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 *calloc(int, int);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
char *concatStringVector(char **inputVector, int size) {
  int i;
  int resultSize;
  char *result;
  resultSize = 3 * size + 1;
  result = calloc(resultSize, sizeof(char));
  strcpy(result, inputVector[0]);
  for (i = 1; i < size; i++) {
    strcat(result, " ");
    strcat(result, (const char *)inputVector[i]);
  }
  return result;
}


x86 assembly (clang, -O0):
<concatStringVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
imul   $0x3,-0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b0 <concatStringVector+0x80>
mov    -0x20(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1171 <concatStringVector+0x41>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<concatStringVector>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
lea    (%r15,%r15,2),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%r13
mov    (%r14),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
cmp    $0x2,%r15d
jl     11a0 <concatStringVector+0x70>
mov    %r15d,%r12d
mov    $0x1,%ebx
lea    0xe8d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
mov    (%r14,%rbx,8),%rsi
mov    %r13,%rdi
call   1050 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1180 <concatStringVector+0x50>
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i8* @concatStringVector(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8** %0, i8*** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = mul nsw i32 3, %8
%10 = add nsw i32 %9, 1
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = call i8* @calloc(i32 %11, i32 1)
store i8* %12, i8** %7
%13 = load i8*, i8** %7
%14 = load i8**, i8*** %3
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @strcpy(i8* %13, i8* %16)
store i32 1, i32* %5
br label %18
18: ; preds = %32, %2
%19 = load i32, i32* %5
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %35
22: ; preds = %18
%23 = load i8*, i8** %7
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = load i8*, i8** %7
%26 = load i8**, i8*** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @strcat(i8* %25, i8* %30)
br label %32
32: ; preds = %22
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %18
35: ; preds = %18
%36 = load i8*, i8** %7
ret i8* %36
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i8* @concatStringVector(i8** nocapture %0, i32 %1) {
%3 = mul nsw i32 %1, 3
%4 = add nsw i32 %3, 1
%5 = tail call i8* @calloc(i32 %4, i32 1)
%6 = load i8*, i8** %0
%7 = tail call i32 @strcpy(i8* %5, i8* %6)
%8 = icmp sgt i32 %1, 1
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 1, %9 ], [ %17, %11 ]
%13 = tail call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds i8*, i8** %0, i64 %12
%15 = load i8*, i8** %14
%16 = tail call i32 @strcat(i8* %5, i8* %15)
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %10
br i1 %18, label %19, label %11
19: ; preds = %11, %2
ret i8* %5
}