#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 *);
int /*<<< orphan*/ strcpy(char *, char *);
void formatCommand(char *command, int count, char **arguments) {
  for (int i = 1; i < count; i++) {
    if (i == 1) {
      strcpy(command, arguments[i]);
    } else {
      strcat(command, arguments[i]);
    }
    if (i != count - 1) {
      strcat(command, " ");
    }
  }
}


x86 assembly (clang, -O0):
<formatCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b3 <formatCommand+0x93>
cmpl   $0x1,-0x1c(%rbp)
jne    116a <formatCommand+0x4a>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
jmp    117f <formatCommand+0x5f>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcat@plt>
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11a0 <formatCommand+0x80>
mov    -0x8(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1040 <strcat@plt>
jmp    11a5 <formatCommand+0x85>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <formatCommand+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<formatCommand>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%esi
jl     114c <formatCommand+0x2c>
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbx
lea    -0x1(%r15),%r12d
mov    0x8(%rdx),%rsi
call   1030 <strcpy@plt>
cmp    $0x1,%r12d
jne    115b <formatCommand+0x3b>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15d,%r13d
lea    0xe9b(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
mov    $0x2,%ebp
jmp    1189 <formatCommand+0x69>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r13
je     114c <formatCommand+0x2c>
mov    (%r14,%rbp,8),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
cmp    %rbp,%r12
je     1180 <formatCommand+0x60>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
jmp    1180 <formatCommand+0x60>

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

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