#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*/ strcat(char *, char *);
void concatenate(int n, char **ss, char *a) {
  int i;
  char *s;
  a[0] = '\0';
  for (i = 0; i < n; ++i) {
    s = ss[i];
    if (i > 0)
      strcat(a, " ");
    strcat(a, s);
  }
}


x86 assembly (clang, -O0):
<concatenate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1182 <concatenate+0x72>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1167 <concatenate+0x57>
mov    -0x18(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcat@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <concatenate+0x21>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<concatenate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movb   $0x0,(%rdx)
test   %edi,%edi
jle    1173 <concatenate+0x63>
mov    %rdx,%r13
mov    %rsi,%r14
mov    %edi,%ebp
mov    (%rsi),%rsi
mov    %rdx,%rdi
call   1030 <strcat@plt>
cmp    $0x1,%ebp
je     1173 <concatenate+0x63>
mov    %ebp,%r12d
mov    $0x1,%ebx
lea    0xeb7(%rip),%r15
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rbp
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <strcat@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1030 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <concatenate+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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