#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*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, scalar_t__);
int /*<<< orphan*/ system(char *);
void merge_entries(char *tarname, char **entries, int length) {
  int i;
  char command[1000];
  char fcommand[1000];
  strcpy(command, "cat ");
  for (i = 0; i < 2; i++) {
    strcat(command, entries[i]);
    strcat(command, " ");
  }
  strncpy(fcommand, command, strlen(command) - 1);
  strcat(fcommand, " > ");
  strcat(fcommand, tarname);
  printf("%s\n", fcommand);
  system(fcommand);
}


x86 assembly (clang, -O0):
<merge_entries>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x400(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jge    11d3 <merge_entries+0x73>
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1080 <strcat@plt>
lea    -0x400(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1190 <merge_entries+0x30>
lea    -0x7f0(%rbp),%rax
mov    %rax,-0x800(%rbp)
lea    -0x400(%rbp),%rax
mov    %rax,-0x7f8(%rbp)
lea    -0x400(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x800(%rbp),%rdi
mov    -0x7f8(%rbp),%rsi
mov    %rax,%rdx
sub    $0x1,%rdx
call   1030 <strncpy@plt>
lea    -0x7f0(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x7f0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x7f0(%rbp),%rsi
lea    0xdc3(%rip),%rdi
call   1070 <printf@plt>
lea    -0x7f0(%rbp),%rdi
call   1060 <system@plt>
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge_entries>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x7d8,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe85(%rip),%rsi
lea    0x3f0(%rsp),%r15
mov    %r15,%rdi
call   1040 <strcpy@plt>
mov    (%rbx),%rsi
mov    %r15,%rdi
call   1080 <strcat@plt>
lea    0xe6a(%rip),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
mov    0x8(%rbx),%rsi
mov    %r15,%rdi
call   1080 <strcat@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strncpy@plt>
lea    0xe25(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
lea    0xe0f(%rip),%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
add    $0x7d8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"cat \00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [4 x i8] c" > \00"
@.str.3 = [4 x i8] c"%s\0A\00"
define void @merge_entries(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1000 x i8]
%9 = alloca [1000 x i8]
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %12
12: ; preds = %25, %3
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%17 = load i8**, i8*** %5
%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 @strcat(i8* %16, i8* %21)
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %15
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %12
28: ; preds = %12
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%30 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%32 = call i64 @strlen(i8* %31)
%33 = sub nsw i64 %32, 1
%34 = call i32 @strncpy(i8* %29, i8* %30, i64 %33)
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%36 = call i32 @strcat(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%38 = load i8*, i8** %4
%39 = call i32 @strcat(i8* %37, i8* %38)
%40 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%43 = call i32 @system(i8* %42)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"cat \00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [4 x i8] c" > \00"
@.str.3 = [4 x i8] c"%s\0A\00"
define void @merge_entries(i8* %0, i8** nocapture %1, i32 %2) {
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%8 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %1
%10 = call i32 @strcat(i8* %6, i8* %9)
%11 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strcat(i8* %6, i8* %13)
%15 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = call i64 @strlen(i8* %6)
%17 = add nsw i64 %16, -1
%18 = call i32 @strncpy(i8* %7, i8* %6, i64 %17)
%19 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @strcat(i8* %7, i8* %0)
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%22 = call i32 @system(i8* %7)
ret void
}