#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 argvcat(char *buf, int argc, char **argv, int start, int space) {
  *buf = '\0';
  for (; start < argc; ++start) {
    strcat(buf, argv[start]);
    if (space && start != argc - 1)
      strcat(buf, " ");
  }
}


x86 assembly (clang, -O0):
<argvcat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1190 <argvcat+0x80>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcat@plt>
cmpl   $0x0,-0x20(%rbp)
je     117d <argvcat+0x6d>
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     117d <argvcat+0x6d>
mov    -0x8(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1030 <strcat@plt>
jmp    1182 <argvcat+0x72>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <argvcat+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<argvcat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movb   $0x0,(%rdi)
cmp    %esi,%ecx
jge    1180 <argvcat+0x70>
mov    %r8d,%r14d
mov    %esi,%r13d
mov    %rdi,%rbp
lea    -0x1(%r13),%eax
movslq %ecx,%rsi
movslq %eax,%r12
sub    %rsi,%r12
lea    (%rdx,%rsi,8),%rbx
sub    %ecx,%r13d
xor    %r15d,%r15d
jmp    1159 <argvcat+0x49>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r15
cmp    %r15d,%r13d
je     1180 <argvcat+0x70>
mov    (%rbx,%r15,8),%rsi
mov    %rbp,%rdi
call   1030 <strcat@plt>
test   %r14d,%r14d
je     1150 <argvcat+0x40>
cmp    %r15,%r12
je     1150 <argvcat+0x40>
mov    %rbp,%rdi
lea    0xe87(%rip),%rsi
call   1030 <strcat@plt>
jmp    1150 <argvcat+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 @argvcat(i8* %0, i32 %1, i8** %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8** %2, i8*** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i8*, i8** %6
store i8 0, i8* %11
br label %12
12: ; preds = %35, %5
%13 = load i32, i32* %9
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %38
16: ; preds = %12
%17 = load i8*, i8** %6
%18 = load i8**, i8*** %8
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @strcat(i8* %17, i8* %22)
%24 = load i32, i32* %10
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %16
%27 = load i32, i32* %9
%28 = load i32, i32* %7
%29 = sub nsw i32 %28, 1
%30 = icmp ne i32 %27, %29
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i8*, i8** %6
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %31, %26, %16
br label %35
35: ; preds = %34
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %12
38: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define void @argvcat(i8* %0, i32 %1, i8** nocapture %2, i32 %3, i32 %4) {
store i8 0, i8* %0
%6 = icmp slt i32 %3, %1
br i1 %6, label %7, label %25
7: ; preds = %5
%8 = icmp eq i32 %4, 0
%9 = add nsw i32 %1, -1
%10 = sext i32 %3 to i64
%11 = sext i32 %9 to i64
br label %12
12: ; preds = %7, %21
%13 = phi i64 [ %10, %7 ], [ %22, %21 ]
%14 = getelementptr inbounds i8*, i8** %2, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 @strcat(i8* %0, i8* %15)
%17 = icmp eq i64 %13, %11
%18 = select i1 %8, i1 true, i1 %17
br i1 %18, label %21, label %19
19: ; preds = %12
%20 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %12, %19
%22 = add nsw i64 %13, 1
%23 = trunc i64 %22 to i32
%24 = icmp eq i32 %23, %1
br i1 %24, label %25, label %12
25: ; preds = %21, %5
ret void
}