#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*/ MergeFiles(char *, char **);
int /*<<< orphan*/ UnmergeFiles(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (!argv[1]) {
    printf("%s [mu] <merged file> <file to merge1> <file to merge2> ..\n",
           argv[0]);
    exit(1);
  }
  if (strcmp(argv[1], "m") == 0) {
    MergeFiles(argv[2], argv + 3);
  } else if (strcmp(argv[1], "u") == 0) {
    UnmergeFiles(argv[2]);
  } else {
    printf("ERROR\n");
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1194 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe99(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11cc <main+0x7c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x18,%rsi
call   1030 <MergeFiles@plt>
jmp    120f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe63(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11fc <main+0xac>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <UnmergeFiles@plt>
jmp    120a <main+0xba>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120f <main+0xbf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     11c0 <main+0x60>
lea    0xec8(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11a1 <main+0x41>
mov    0x8(%rbx),%rdi
lea    0xeb5(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11b3 <main+0x53>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
jmp    11bc <main+0x5c>
mov    0x10(%rbx),%rdi
add    $0x18,%rbx
mov    %rbx,%rsi
call   1040 <MergeFiles@plt>
jmp    11bc <main+0x5c>
mov    0x10(%rbx),%rdi
call   1080 <UnmergeFiles@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    (%rbx),%rsi
lea    0xe36(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [60 x i8] c"%s [mu] <merged file> <file to merge1> <file to merge2> ..\0A\00"
@.str.1 = [2 x i8] c"m\00"
@.str.2 = [2 x i8] c"u\00"
@.str.3 = [7 x i8] c"ERROR\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 1
%8 = load i8*, i8** %7
%9 = icmp ne i8* %8, null
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %16
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = call i32 @MergeFiles(i8* %25, i8** %27)
br label %43
29: ; preds = %16
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %29
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @UnmergeFiles(i8* %38)
br label %42
40: ; preds = %29
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %35
br label %43
43: ; preds = %42, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [60 x i8] c"%s [mu] <merged file> <file to merge1> <file to merge2> ..\0A\00"
@.str.1 = [2 x i8] c"m\00"
@.str.2 = [2 x i8] c"u\00"
@str = [6 x i8] c"ERROR\00"
define i32 @main(i32 %0, i8** %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = tail call i32 @MergeFiles(i8* %15, i8** %16)
br label %28
18: ; preds = %10
%19 = load i8*, i8** %3
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i32 @UnmergeFiles(i8* %24)
br label %28
26: ; preds = %18
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %28
28: ; preds = %22, %26, %13
ret i32 0
}