#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*/ exit(int);
int /*<<< orphan*/ k_merge_sort(char *, char **);
int /*<<< orphan*/ printf(char *, ...);
void main(int argc, char *argv[]) {
  if (argc != 2 + 4) {
    printf("usage: \t%s [output filename] [input filenames]\n", argv[0]);
    printf("\tshould contain %d input-files. \n", 4);
    printf("\tchange config in utils.h\n");
    exit(-1);
  }
  printf("K-merge sort following files: \n");
  int i = 0;
  for (; i < 4; ++i) {
    printf("\t%s\n", argv[i + 2]);
  }
  printf("to output file: %s\n", argv[1]);
  char *ofname = argv[1];
  char **ifnames = argv + 2;
  k_merge_sort(ofname, ifnames);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x6,-0x4(%rbp)
je     1189 <main+0x59>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11d5 <main+0xa5>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119e <main+0x6e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <k_merge_sort@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x6,%edi
jne    11bf <main+0x7f>
lea    0xf17(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rbx),%r14
mov    0x10(%rbx),%rsi
lea    0xeea(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rbx),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rbx),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rsi
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <k_merge_sort@plt>
mov    (%rbx),%rsi
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"usage: \09%s [output filename] [input filenames]\0A\00"
@.str.1 = [34 x i8] c"\09should contain %d input-files. \0A\00"
@.str.2 = [27 x i8] c"\09change config in utils.h\0A\00"
@.str.3 = [32 x i8] c"K-merge sort following files: \0A\00"
@.str.4 = [5 x i8] c"\09%s\0A\00"
@.str.5 = [20 x i8] c"to output file: %s\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 6
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 4)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %20
20: ; preds = %31, %18
%21 = load i32, i32* %5
%22 = icmp slt i32 %21, 4
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = load i8**, i8*** %4
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %24, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %23
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %20
34: ; preds = %20
%35 = load i8**, i8*** %4
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %37)
%39 = load i8**, i8*** %4
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
store i8* %41, i8** %6
%42 = load i8**, i8*** %4
%43 = getelementptr inbounds i8*, i8** %42, i64 2
store i8** %43, i8*** %7
%44 = load i8*, i8** %6
%45 = load i8**, i8*** %7
%46 = call i32 @k_merge_sort(i8* %44, i8** %45)
ret void
}

LLVM IR (-O2):
@.str = [48 x i8] c"usage: \09%s [output filename] [input filenames]\0A\00"
@.str.1 = [34 x i8] c"\09should contain %d input-files. \0A\00"
@.str.4 = [5 x i8] c"\09%s\0A\00"
@.str.5 = [20 x i8] c"to output file: %s\0A\00"
@str = [31 x i8] c"K-merge sort following files: \00"
@str.6 = [26 x i8] c"\09change config in utils.h\00"
define void @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 6
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 4)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.6, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 4
%19 = load i8*, i8** %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds i8*, i8** %1, i64 5
%22 = load i8*, i8** %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %24
%28 = tail call i32 @k_merge_sort(i8* %27, i8** %12)
ret void
}