#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*/ printf(char *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ quick(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int main() {
  FILE *data;
  FILE *fp;
  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);
    printf("数据处理中，请等待。。。\n");
    quick(fp, 8);
    printf("数据处理完成！\n");
    fclose(fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1070 <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   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f7 <main+0x77>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
jmp    1272 <main+0xf2>
movl   $0x0,-0x20(%rbp)
cmpl   $0x8,-0x20(%rbp)
jge    1231 <main+0xb1>
mov    -0x10(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <putc@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%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
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x8,%esi
call   1080 <quick@plt>
lea    0xe12(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe75(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12af <main+0x12f>
mov    %rax,%r14
lea    0xe61(%rip),%rdi
lea    0xe65(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1299 <main+0x119>
mov    %rax,%rbx
mov    %r14,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
mov    %r14,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
mov    %r14,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
mov    %r14,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
mov    %r14,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
mov    %r14,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
mov    %r14,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
mov    %r14,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1050 <rewind@plt>
lea    0xda8(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1080 <quick@plt>
lea    0xdb4(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    12a5 <main+0x125>
lea    0xdb4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdb7(%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 = [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\AD\89\E5\BE\85\E3\80\82\E3\80\82\E3\80\82\0A\00"
@.str.7 = [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 i8
%5 = alloca i32
store i32 0, i32* %1
%6 = 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* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %0
%13 = 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* %13, i32** %3
%14 = load i32*, i32** %3
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %42
18: ; preds = %12
store i32 0, i32* %5
br label %19
19: ; preds = %28, %18
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 8
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i32*, i32** %2
%24 = call signext i8 @getc(i32* %23)
store i8 %24, i8* %4
%25 = load i8, i8* %4
%26 = load i32*, i32** %3
%27 = call i32 @putc(i8 signext %25, i32* %26)
br label %28
28: ; preds = %22
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %19
31: ; preds = %19
%32 = load i32*, i32** %2
%33 = call i32 @fclose(i32* %32)
%34 = load i32*, i32** %3
%35 = call i32 @rewind(i32* %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%37 = load i32*, i32** %3
%38 = call i32 @quick(i32* %37, i32 8)
%39 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%40 = load i32*, i32** %3
%41 = call i32 @fclose(i32* %40)
br label %42
42: ; preds = %31, %16
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 = [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\AD\89\E5\BE\85\E3\80\82\E3\80\82\E3\80\82\00"
@str.8 = [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.9 = [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.10 = [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.10, 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 %32, 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 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%29 = tail call i32 @quick(i32* %7, i32 8)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%31 = tail call i32 @fclose(i32* %7)
br label %34
32: ; preds = %6
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
br label %34
34: ; preds = %9, %32
ret i32 0
}