#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ merge(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                         int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printf(char *);
int main() {
  FILE *fp;
  FILE *fp1;
  FILE *fp2;
  fp = fopen("result.txt", "r+");
  if (fp == NULL) {
    printf("主文件打开错误！\n");
  } else {
    fp1 = fopen("sort1.txt", "r+");
    if (fp1 == NULL) {
      printf("第一数据文件打开错误！\n");
    } else {
      fp2 = fopen("sort2.txt", "r+");
      if (fp2 == NULL)
        printf("第二数据文件打开错误！\n");
      else {
        printf("数据处理中，请稍等。。。\n");
        merge(fp, fp1, fp2, 4);
        printf("数据处理完成！\n");
        fclose(fp);
        fclose(fp1);
        fclose(fp2);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1182 <main+0x42>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
jmp    123b <main+0xfb>
lea    0xe9f(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b5 <main+0x75>
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
jmp    1236 <main+0xf6>
lea    0xe99(%rip),%rdi
lea    0xe48(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e8 <main+0xa8>
lea    0xe81(%rip),%rdi
call   1040 <printf@plt>
jmp    1231 <main+0xf1>
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    $0x4,%ecx
call   1050 <merge@plt>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1236 <main+0xf6>
jmp    123b <main+0xfb>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11db <main+0x9b>
mov    %rax,%rbx
lea    0xea7(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11e4 <main+0xa4>
mov    %rax,%r14
lea    0xe96(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11ed <main+0xad>
mov    %rax,%r15
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x4,%ecx
call   1050 <merge@plt>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    11f9 <main+0xb9>
lea    0xebf(%rip),%rdi
jmp    11f4 <main+0xb4>
lea    0xe94(%rip),%rdi
jmp    11f4 <main+0xb4>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"result.txt\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [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.3 = [10 x i8] c"sort1.txt\00"
@.str.4 = [35 x i8] c"\E7\AC\AC\E4\B8\80\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.5 = [10 x i8] c"sort2.txt\00"
@.str.6 = [35 x i8] c"\E7\AC\AC\E4\BA\8C\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.7 = [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\E7\AD\89\E3\80\82\E3\80\82\E3\80\82\0A\00"
@.str.8 = [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*
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %37
10: ; preds = %0
%11 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %3
%12 = load i32*, i32** %3
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
br label %36
16: ; preds = %10
%17 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %4
%18 = load i32*, i32** %4
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %35
22: ; preds = %16
%23 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0))
%24 = load i32*, i32** %2
%25 = load i32*, i32** %3
%26 = load i32*, i32** %4
%27 = call i32 @merge(i32* %24, i32* %25, i32* %26, i32 4)
%28 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%29 = load i32*, i32** %2
%30 = call i32 @fclose(i32* %29)
%31 = load i32*, i32** %3
%32 = call i32 @fclose(i32* %31)
%33 = load i32*, i32** %4
%34 = call i32 @fclose(i32* %33)
br label %35
35: ; preds = %22, %20
br label %36
36: ; preds = %35, %14
br label %37
37: ; preds = %36, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"result.txt\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.3 = [10 x i8] c"sort1.txt\00"
@.str.5 = [10 x i8] c"sort2.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\E7\AD\89\E3\80\82\E3\80\82\E3\80\82\00"
@str.9 = [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.10 = [34 x i8] c"\E7\AC\AC\E4\BA\8C\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"
@str.11 = [34 x i8] c"\E7\AC\AC\E4\B8\80\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"
@str.12 = [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"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.12, i64 0, i64 0))
br label %22
5: ; preds = %0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.11, i64 0, i64 0))
br label %22
10: ; preds = %5
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.10, i64 0, i64 0))
br label %22
15: ; preds = %10
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%17 = tail call i32 @merge(i32* %1, i32* %6, i32* %11, i32 4)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%19 = tail call i32 @fclose(i32* %1)
%20 = tail call i32 @fclose(i32* %6)
%21 = tail call i32 @fclose(i32* %11)
br label %22
22: ; preds = %8, %15, %13, %3
ret i32 0
}