#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 *ConcatArgs(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 (len == 1024 - 1)
      break;
    if (i != c - 1) {
      line[len] = ' ';
      len++;
    }
  }
  line[len] = 0;
  return line;
}


x86 assembly (clang, -O0):
<ConcatArgs>:
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    121e <ConcatArgs+0xde>
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 <ConcatArgs+0x6a>
jmp    121e <ConcatArgs+0xde>
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)
cmpl   $0x3ff,-0x14(%rbp)
jne    11e2 <ConcatArgs+0xa2>
jmp    121e <ConcatArgs+0xde>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     120b <ConcatArgs+0xcb>
movslq -0x14(%rbp),%rcx
lea    0x2e52(%rip),%rax
movb   $0x20,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1210 <ConcatArgs+0xd0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1165 <ConcatArgs+0x25>
movslq -0x14(%rbp),%rcx
lea    0x2e27(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e1c(%rip),%rax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConcatArgs>:
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 <ConcatArgs+0x91>
mov    %eax,%r14d
neg    %r14d
xor    %r13d,%r13d
mov    %rsp,%r15
jmp    117d <ConcatArgs+0x3d>
xchg   %ax,%ax
add    $0x1,%ebx
mov    %r14d,%eax
mov    %ebp,%r13d
add    %ebx,%eax
je     11d1 <ConcatArgs+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 <ConcatArgs+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 <ConcatArgs+0x30>
movslq %ebp,%rax
movb   $0x20,(%rax,%r13,1)
add    $0x1,%ebp
jmp    1170 <ConcatArgs+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):
@ConcatArgs.line = internal global [1024 x i8] zeroinitializer
define i8* @ConcatArgs(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 = %50, %1
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %53
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 %53
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]* @ConcatArgs.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* %6
%36 = icmp eq i32 %35, 1023
br i1 %36, label %37, label %38
37: ; preds = %25
br label %53
38: ; preds = %25
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = sub nsw i32 %40, 1
%42 = icmp ne i32 %39, %41
br i1 %42, label %43, label %49
43: ; preds = %38
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* @ConcatArgs.line, i64 0, i64 %45
store i8 32, i8* %46
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %49
49: ; preds = %43, %38
br label %50
50: ; preds = %49
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %10
53: ; preds = %37, %24, %10
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* @ConcatArgs.line, i64 0, i64 %55
store i8 0, i8* %56
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @ConcatArgs.line, i64 0, i64 0)
}

LLVM IR (-O2):
@ConcatArgs.line = internal global [1024 x i8] zeroinitializer
define i8* @ConcatArgs(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]* @ConcatArgs.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]* @ConcatArgs.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]* @ConcatArgs.line, i64 0, i64 %30
store i8 0, i8* %31
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @ConcatArgs.line, i64 0, i64 0)
}