#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*/ s;

/* Variables and functions */
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
char *argstr(int arg, int argc, char **argv) {
  static char s[102400];
  int i;
  s[0] = '\0';
  for (i = arg; i < argc; i++) {
    strncat(s, argv[i], sizeof(s) - strlen(s) - 1);
    strncat(s, " ", sizeof(s) - strlen(s) - 1);
  }
  if ((i = strlen(s)) > 0)
    s[i - 1] = '\0';
  return s;
}


x86 assembly (clang, -O0):
<argstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movb   $0x0,0x2f07(%rip)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c6 <argstr+0xa6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
lea    0x2ede(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rsi
movslq %eax,%rcx
mov    $0x19000,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
lea    0x2ebd(%rip),%rdi
call   1040 <strncat@plt>
lea    0x2eb1(%rip),%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    $0x19000,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
lea    0x2e94(%rip),%rdi
lea    0xe4d(%rip),%rsi
call   1040 <strncat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113f <argstr+0x1f>
lea    0x2e73(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    11f2 <argstr+0xd2>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2e52(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e47(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<argstr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movb   $0x0,0x2f0e(%rip)
cmp    %esi,%edi
jge    11a2 <argstr+0x82>
mov    %esi,%r14d
movslq %edi,%rax
lea    (%rdx,%rax,8),%r13
sub    %edi,%r14d
xor    %ebp,%ebp
lea    0x2ef4(%rip),%r12
lea    0xead(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbp,8),%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    $0x18fff,%edx
sub    %eax,%edx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <strncat@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    $0x18fff,%edx
sub    %eax,%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <strncat@plt>
add    $0x1,%rbp
cmp    %ebp,%r14d
jne    1160 <argstr+0x40>
lea    0x2e97(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11bc <argstr+0x9c>
add    $0xffffffff,%eax
movb   $0x0,(%rax,%rbx,1)
lea    0x2e7d(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@argstr.s = internal global [102400 x i8] zeroinitializer
@.str = [2 x i8] c" \00"
define i8* @argstr(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
store i8 0, i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0)
%8 = load i32, i32* %4
store i32 %8, i32* %7
br label %9
9: ; preds = %31, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %34
13: ; preds = %9
%14 = load i8**, i8*** %6
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0))
%20 = sext i32 %19 to i64
%21 = sub i64 102400, %20
%22 = sub i64 %21, 1
%23 = trunc i64 %22 to i32
%24 = call i32 @strncat(i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0), i8* %18, i32 %23)
%25 = call i32 @strlen(i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0))
%26 = sext i32 %25 to i64
%27 = sub i64 102400, %26
%28 = sub i64 %27, 1
%29 = trunc i64 %28 to i32
%30 = call i32 @strncat(i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %13
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %9
34: ; preds = %9
%35 = call i32 @strlen(i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0))
store i32 %35, i32* %7
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i32, i32* %7
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 %40
store i8 0, i8* %41
br label %42
42: ; preds = %37, %34
ret i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0)
}

LLVM IR (-O2):
@argstr.s = internal global [102400 x i8] zeroinitializer
@.str = [2 x i8] c" \00"
define i8* @argstr(i32 %0, i32 %1, i8** nocapture %2) {
store i8 0, i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0)
%4 = icmp slt i32 %0, %1
br i1 %4, label %5, label %20
5: ; preds = %3
%6 = sext i32 %0 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ %6, %5 ], [ %17, %7 ]
%9 = getelementptr inbounds i8*, i8** %2, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0))
%12 = sub i32 102399, %11
%13 = tail call i32 @strncat(i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0), i8* %10, i32 %12)
%14 = tail call i32 @strlen(i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0))
%15 = sub i32 102399, %14
%16 = tail call i32 @strncat(i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = add nsw i64 %8, 1
%18 = trunc i64 %17 to i32
%19 = icmp eq i32 %18, %1
br i1 %19, label %20, label %7
20: ; preds = %7, %3
%21 = tail call i32 @strlen(i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0))
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = add nsw i32 %21, -1
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds [102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 %25
store i8 0, i8* %26
br label %27
27: ; preds = %23, %20
ret i8* getelementptr inbounds ([102400 x i8], [102400 x i8]* @argstr.s, i64 0, i64 0)
}