#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 */
typedef int /*<<< orphan*/ arg;

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char *, int);
int strlen(char *);
int trap_Argc();
int /*<<< orphan*/ trap_Argv(int, char *, int);
char *ConcatArgs2(int start) {
  int i, c, tlen;
  static char line[1024];
  int len;
  char arg[1024];
  len = 0;
  c = trap_Argc();
  for (i = start; i < c; i++) {
    trap_Argv(i, arg, sizeof(arg));
    tlen = strlen(arg);
    if (len + tlen >= 1024 - 1) {
      break;
    }
    memcpy(line + len, arg, tlen);
    len += tlen;
    if (i != c - 1) {
      line[len] = ' ';
      len++;
    }
  }
  line[len] = 0;
  return line;
}


x86 assembly (clang, -O0):
<ConcatArgs2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1040 <trap_Argc@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120c <ConcatArgs2+0xcc>
mov    -0x8(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <trap_Argv@plt>
lea    -0x420(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
cmp    $0x3ff,%eax
jl     11aa <ConcatArgs2+0x6a>
jmp    120c <ConcatArgs2+0xcc>
movslq -0x14(%rbp),%rax
lea    0x2e9b(%rip),%rdi
add    %rax,%rdi
lea    -0x420(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11f9 <ConcatArgs2+0xb9>
movslq -0x14(%rbp),%rcx
lea    0x2e64(%rip),%rax
movb   $0x20,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11fe <ConcatArgs2+0xbe>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1165 <ConcatArgs2+0x25>
movslq -0x14(%rbp),%rcx
lea    0x2e39(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e2e(%rip),%rax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConcatArgs2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %edi,%ebx
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <trap_Argc@plt>
cmp    %ebx,%eax
jle    11d1 <ConcatArgs2+0x91>
mov    %eax,%r14d
neg    %r14d
xor    %r13d,%r13d
mov    %rsp,%r15
jmp    117d <ConcatArgs2+0x3d>
xchg   %ax,%ax
add    $0x1,%ebx
mov    %r14d,%eax
mov    %ebp,%r13d
add    %ebx,%eax
je     11d1 <ConcatArgs2+0x91>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x400,%edx
call   1060 <trap_Argv@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
lea    (%rax,%r13,1),%ebp
cmp    $0x3fe,%ebp
jg     11ce <ConcatArgs2+0x8e>
lea    (%r14,%rbx,1),%r12d
movslq %r13d,%rdi
lea    0x2ea2(%rip),%r13
add    %r13,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1050 <memcpy@plt>
cmp    $0xffffffff,%r12d
je     1170 <ConcatArgs2+0x30>
movslq %ebp,%rax
movb   $0x20,(%rax,%r13,1)
add    $0x1,%ebp
jmp    1170 <ConcatArgs2+0x30>
mov    %r13d,%ebp
movslq %ebp,%rcx
lea    0x2e75(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ConcatArgs2.line = internal global [1024 x i8] zeroinitializer
define i8* @ConcatArgs2(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1024 x i8]
store i32 %0, i32* %2
store i32 0, i32* %6
%8 = call i32 (...) @trap_Argc()
store i32 %8, i32* %4
%9 = load i32, i32* %2
store i32 %9, i32* %3
br label %10
10: ; preds = %46, %1
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %49
14: ; preds = %10
%15 = load i32, i32* %3
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%17 = call i32 @trap_Argv(i32 %15, i8* %16, i32 1024)
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %5
%20 = load i32, i32* %6
%21 = load i32, i32* %5
%22 = add nsw i32 %20, %21
%23 = icmp sge i32 %22, 1023
br i1 %23, label %24, label %25
24: ; preds = %14
br label %49
25: ; preds = %14
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @ConcatArgs2.line, i64 0, i64 0), i64 %27
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%30 = load i32, i32* %5
%31 = call i32 @memcpy(i8* %28, i8* %29, i32 %30)
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = add nsw i32 %33, %32
store i32 %34, i32* %6
%35 = load i32, i32* %3
%36 = load i32, i32* %4
%37 = sub nsw i32 %36, 1
%38 = icmp ne i32 %35, %37
br i1 %38, label %39, label %45
39: ; preds = %25
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* @ConcatArgs2.line, i64 0, i64 %41
store i8 32, i8* %42
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %45
45: ; preds = %39, %25
br label %46
46: ; preds = %45
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %10
49: ; preds = %24, %10
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* @ConcatArgs2.line, i64 0, i64 %51
store i8 0, i8* %52
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @ConcatArgs2.line, i64 0, i64 0)
}

LLVM IR (-O2):
@ConcatArgs2.line = internal global [1024 x i8] zeroinitializer
define i8* @ConcatArgs2(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (...) @trap_Argc()
%5 = icmp sgt i32 %4, %0
br i1 %5, label %6, label %28
6: ; preds = %1
%7 = add nsw i32 %4, -1
br label %8
8: ; preds = %6, %24
%9 = phi i32 [ 0, %6 ], [ %25, %24 ]
%10 = phi i32 [ %0, %6 ], [ %26, %24 ]
%11 = call i32 @trap_Argv(i32 %10, i8* %3, i32 1024)
%12 = call i32 @strlen(i8* %3)
%13 = add nsw i32 %12, %9
%14 = icmp sgt i32 %13, 1022
br i1 %14, label %28, label %15
15: ; preds = %8
%16 = sext i32 %9 to i64
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* @ConcatArgs2.line, i64 0, i64 %16
%18 = call i32 @memcpy(i8* %17, i8* %3, i32 %12)
%19 = icmp eq i32 %10, %7
br i1 %19, label %24, label %20
20: ; preds = %15
%21 = sext i32 %13 to i64
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* @ConcatArgs2.line, i64 0, i64 %21
store i8 32, i8* %22
%23 = add nsw i32 %13, 1
br label %24
24: ; preds = %15, %20
%25 = phi i32 [ %23, %20 ], [ %13, %15 ]
%26 = add i32 %10, 1
%27 = icmp eq i32 %26, %4
br i1 %27, label %28, label %8
28: ; preds = %24, %8, %1
%29 = phi i32 [ 0, %1 ], [ %9, %8 ], [ %25, %24 ]
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* @ConcatArgs2.line, i64 0, i64 %30
store i8 0, i8* %31
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @ConcatArgs2.line, i64 0, i64 0)
}