#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 */
char *strappend(char *, char *);
char *strclone(char *);
char *collapse_tokenlist(int argnum, char **args) {
  char *temp = strclone(args[0]);
  int i = 1;
  while (i < argnum) {
    temp = strappend(temp, " ");
    temp = strappend(temp, args[i]);
    i++;
  }
  return temp;
}


x86 assembly (clang, -O0):
<collapse_tokenlist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strclone@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118d <collapse_tokenlist+0x6d>
mov    -0x18(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strappend@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strappend@plt>
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1146 <collapse_tokenlist+0x26>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<collapse_tokenlist>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1040 <strclone@plt>
cmp    $0x2,%ebp
jl     1170 <collapse_tokenlist+0x50>
mov    %ebp,%ebp
mov    $0x1,%ebx
lea    0xeb9(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strappend@plt>
mov    (%r15,%rbx,8),%rsi
mov    %rax,%rdi
call   1030 <strappend@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <collapse_tokenlist+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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