#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ merge_sort(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                              int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int main() {
  FILE *data;
  FILE *fp;
  FILE *fp1;
  FILE *fp2;
  char c;
  int j;
  data = fopen("data.txt", "r");
  if (data == NULL) {
    printf("数据文件打开错误！\n");
    exit(0);
  }
  fp = fopen("result.txt", "r+");
  if (fp == NULL) {
    printf("主文件打开错误！\n");
  } else {
    for (j = 0; j < 8; j++) {
      c = getc(data);
      putc(c, fp);
    }
    fclose(data);
    rewind(fp);
    fp1 = fopen("split1.txt", "r+");
    if (fp1 == NULL) {
      printf("第一分割文件打开错误！\n");
    } else {
      fp2 = fopen("split2.txt", "r+");
      if (fp2 == NULL) {
        printf("第二分割文件打开错误！\n");
      } else {
        printf("数据处理中，请稍待。。。\n");
        merge_sort(fp, fp1, fp2, 8);
        printf("数据处理完成！\n");
        fclose(fp);
        fclose(fp1);
        fclose(fp2);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c4 <main+0x44>
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xe5d(%rip),%rdi
lea    0xe61(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f7 <main+0x77>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
jmp    12fc <main+0x17c>
movl   $0x0,-0x30(%rbp)
cmpl   $0x8,-0x30(%rbp)
jge    1231 <main+0xb1>
mov    -0x10(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <putc@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11fe <main+0x7e>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1050 <rewind@plt>
lea    0xe06(%rip),%rdi
lea    0xde2(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1276 <main+0xf6>
lea    0xdef(%rip),%rdi
call   1040 <printf@plt>
jmp    12f7 <main+0x177>
lea    0xe01(%rip),%rdi
lea    0xdaf(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12a9 <main+0x129>
lea    0xdea(%rip),%rdi
call   1040 <printf@plt>
jmp    12f2 <main+0x172>
lea    0xdfc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    $0x8,%ecx
call   1070 <merge_sort@plt>
lea    0xe00(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
jmp    12f7 <main+0x177>
jmp    12fc <main+0x17c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xe74(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     130c <main+0x18c>
mov    %rax,%rbx
lea    0xe60(%rip),%rdi
lea    0xe64(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12e6 <main+0x166>
mov    %rax,%r14
mov    %rbx,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
mov    %rbx,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
mov    %rbx,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
mov    %rbx,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
mov    %rbx,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
mov    %rbx,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
mov    %rbx,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
mov    %rbx,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1050 <rewind@plt>
lea    0xda7(%rip),%rdi
lea    0xd9d(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12ef <main+0x16f>
mov    %rax,%rbx
lea    0xd97(%rip),%rdi
lea    0xd82(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12f8 <main+0x178>
mov    %rax,%r15
lea    0xd87(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    $0x8,%ecx
call   1070 <merge_sort@plt>
lea    0xd8d(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    1304 <main+0x184>
lea    0xdc1(%rip),%rdi
jmp    12ff <main+0x17f>
lea    0xd96(%rip),%rdi
jmp    12ff <main+0x17f>
lea    0xd6b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xdb4(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"data.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [29 x i8] c"\E6\95\B0\E6\8D\AE\E6\96\87\E4\BB\B6\E6\89\93\E5\BC\80\E9\94\99\E8\AF\AF\EF\BC\81\0A\00"
@.str.3 = [11 x i8] c"result.txt\00"
@.str.4 = [3 x i8] c"r+\00"
@.str.5 = [26 x i8] c"\E4\B8\BB\E6\96\87\E4\BB\B6\E6\89\93\E5\BC\80\E9\94\99\E8\AF\AF\EF\BC\81\0A\00"
@.str.6 = [11 x i8] c"split1.txt\00"
@.str.7 = [35 x i8] c"\E7\AC\AC\E4\B8\80\E5\88\86\E5\89\B2\E6\96\87\E4\BB\B6\E6\89\93\E5\BC\80\E9\94\99\E8\AF\AF\EF\BC\81\0A\00"
@.str.8 = [11 x i8] c"split2.txt\00"
@.str.9 = [35 x i8] c"\E7\AC\AC\E4\BA\8C\E5\88\86\E5\89\B2\E6\96\87\E4\BB\B6\E6\89\93\E5\BC\80\E9\94\99\E8\AF\AF\EF\BC\81\0A\00"
@.str.10 = [38 x i8] c"\E6\95\B0\E6\8D\AE\E5\A4\84\E7\90\86\E4\B8\AD\EF\BC\8C\E8\AF\B7\E7\A8\8D\E5\BE\85\E3\80\82\E3\80\82\E3\80\82\0A\00"
@.str.11 = [23 x i8] c"\E6\95\B0\E6\8D\AE\E5\A4\84\E7\90\86\E5\AE\8C\E6\88\90\EF\BC\81\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %0
%15 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %15, i32** %3
%16 = load i32*, i32** %3
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %64
20: ; preds = %14
store i32 0, i32* %7
br label %21
21: ; preds = %30, %20
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 8
br i1 %23, label %24, label %33
24: ; preds = %21
%25 = load i32*, i32** %2
%26 = call signext i8 @getc(i32* %25)
store i8 %26, i8* %6
%27 = load i8, i8* %6
%28 = load i32*, i32** %3
%29 = call i32 @putc(i8 signext %27, i32* %28)
br label %30
30: ; preds = %24
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %21
33: ; preds = %21
%34 = load i32*, i32** %2
%35 = call i32 @fclose(i32* %34)
%36 = load i32*, i32** %3
%37 = call i32 @rewind(i32* %36)
%38 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %38, i32** %4
%39 = load i32*, i32** %4
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %43
41: ; preds = %33
%42 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
br label %63
43: ; preds = %33
%44 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %44, i32** %5
%45 = load i32*, i32** %5
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
br label %62
49: ; preds = %43
%50 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0))
%51 = load i32*, i32** %3
%52 = load i32*, i32** %4
%53 = load i32*, i32** %5
%54 = call i32 @merge_sort(i32* %51, i32* %52, i32* %53, i32 8)
%55 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
%56 = load i32*, i32** %3
%57 = call i32 @fclose(i32* %56)
%58 = load i32*, i32** %4
%59 = call i32 @fclose(i32* %58)
%60 = load i32*, i32** %5
%61 = call i32 @fclose(i32* %60)
br label %62
62: ; preds = %49, %47
br label %63
63: ; preds = %62, %41
br label %64
64: ; preds = %63, %18
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"data.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [11 x i8] c"result.txt\00"
@.str.4 = [3 x i8] c"r+\00"
@.str.6 = [11 x i8] c"split1.txt\00"
@.str.8 = [11 x i8] c"split2.txt\00"
@str = [37 x i8] c"\E6\95\B0\E6\8D\AE\E5\A4\84\E7\90\86\E4\B8\AD\EF\BC\8C\E8\AF\B7\E7\A8\8D\E5\BE\85\E3\80\82\E3\80\82\E3\80\82\00"
@str.12 = [22 x i8] c"\E6\95\B0\E6\8D\AE\E5\A4\84\E7\90\86\E5\AE\8C\E6\88\90\EF\BC\81\00"
@str.13 = [34 x i8] c"\E7\AC\AC\E4\BA\8C\E5\88\86\E5\89\B2\E6\96\87\E4\BB\B6\E6\89\93\E5\BC\80\E9\94\99\E8\AF\AF\EF\BC\81\00"
@str.14 = [34 x i8] c"\E7\AC\AC\E4\B8\80\E5\88\86\E5\89\B2\E6\96\87\E4\BB\B6\E6\89\93\E5\BC\80\E9\94\99\E8\AF\AF\EF\BC\81\00"
@str.15 = [25 x i8] c"\E4\B8\BB\E6\96\87\E4\BB\B6\E6\89\93\E5\BC\80\E9\94\99\E8\AF\AF\EF\BC\81\00"
@str.16 = [28 x i8] c"\E6\95\B0\E6\8D\AE\E6\96\87\E4\BB\B6\E6\89\93\E5\BC\80\E9\94\99\E8\AF\AF\EF\BC\81\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.16, i64 0, i64 0))
%5 = tail call i32 @exit(i32 0)
unreachable
6: ; preds = %0
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %30, label %9
9: ; preds = %6
%10 = tail call signext i8 @getc(i32* %1)
%11 = tail call i32 @putc(i8 signext %10, i32* %7)
%12 = tail call signext i8 @getc(i32* %1)
%13 = tail call i32 @putc(i8 signext %12, i32* %7)
%14 = tail call signext i8 @getc(i32* %1)
%15 = tail call i32 @putc(i8 signext %14, i32* %7)
%16 = tail call signext i8 @getc(i32* %1)
%17 = tail call i32 @putc(i8 signext %16, i32* %7)
%18 = tail call signext i8 @getc(i32* %1)
%19 = tail call i32 @putc(i8 signext %18, i32* %7)
%20 = tail call signext i8 @getc(i32* %1)
%21 = tail call i32 @putc(i8 signext %20, i32* %7)
%22 = tail call signext i8 @getc(i32* %1)
%23 = tail call i32 @putc(i8 signext %22, i32* %7)
%24 = tail call signext i8 @getc(i32* %1)
%25 = tail call i32 @putc(i8 signext %24, i32* %7)
%26 = tail call i32 @fclose(i32* %1)
%27 = tail call i32 @rewind(i32* %7)
%28 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %32, label %34
30: ; preds = %6
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.15, i64 0, i64 0))
br label %46
32: ; preds = %9
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.14, i64 0, i64 0))
br label %46
34: ; preds = %9
%35 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.13, i64 0, i64 0))
br label %46
39: ; preds = %34
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%41 = tail call i32 @merge_sort(i32* %7, i32* %28, i32* %35, i32 8)
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0))
%43 = tail call i32 @fclose(i32* %7)
%44 = tail call i32 @fclose(i32* %28)
%45 = tail call i32 @fclose(i32* %35)
br label %46
46: ; preds = %32, %39, %37, %30
ret i32 0
}