#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*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  FILE *tempFile;
  if (argc > 1) {
    if ((tempFile = fopen(argv[1], "wb")) == NULL) {
      printf("打开缓存文件失败！\n");
      return 1;
    } else {
      char chInstream[1];
      while (1) {
        fread(chInstream, sizeof(char), 1, stdin);
        if (!feof(stdin)) {
          fwrite(chInstream, sizeof(char), 1, tempFile);
        } else {
          break;
        }
      }
    }
    fclose(tempFile);
  } else {
    printf("请给出缓存文件路径！\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1225 <main+0xc5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe71(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ba <main+0x5a>
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1244 <main+0xe4>
jmp    11bf <main+0x5f>
lea    -0x19(%rbp),%rdi
mov    0x2e1e(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1060 <feof@plt>
cmp    $0x0,%eax
jne    1208 <main+0xa8>
lea    -0x19(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
jmp    120d <main+0xad>
jmp    1212 <main+0xb2>
jmp    11bf <main+0x5f>
jmp    1217 <main+0xb7>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    123d <main+0xdd>
lea    0xdf4(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1244 <main+0xe4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jl     11fa <main+0x9a>
mov    0x8(%rsi),%rdi
lea    0xe83(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1203 <main+0xa3>
mov    %rax,%rbx
mov    0x2e53(%rip),%r15
mov    (%r15),%ecx
lea    0xf(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
mov    (%r15),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    11ee <main+0x8e>
lea    0xf(%rsp),%r14
nopl   (%rax)
movsbl 0xf(%rsp),%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    (%r15),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
mov    (%r15),%edi
call   1070 <feof@plt>
test   %eax,%eax
je     11c0 <main+0x60>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    1214 <main+0xb4>
lea    0xe02(%rip),%rdi
jmp    120a <main+0xaa>
lea    0xe18(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
@.str.1 = [29 x i8] c"\E6\89\93\E5\BC\80\E7\BC\93\E5\AD\98\E6\96\87\E4\BB\B6\E5\A4\B1\E8\B4\A5\EF\BC\81\0A\00"
@stdin = global i32 0
@.str.2 = [32 x i8] c"\E8\AF\B7\E7\BB\99\E5\87\BA\E7\BC\93\E5\AD\98\E6\96\87\E4\BB\B6\E8\B7\AF\E5\BE\84\EF\BC\81\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [1 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %36
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %39
18: ; preds = %10
br label %19
19: ; preds = %18, %31
%20 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%21 = load i32, i32* @stdin
%22 = call i32 @fread(i8* %20, i32 1, i32 1, i32 %21)
%23 = load i32, i32* @stdin
%24 = call i32 @feof(i32 %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %19
%27 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%28 = load i32*, i32** %6
%29 = call i32 @fwrite(i8* %27, i32 1, i32 1, i32* %28)
br label %31
30: ; preds = %19
br label %32
31: ; preds = %26
br label %19
32: ; preds = %30
br label %33
33: ; preds = %32
%34 = load i32*, i32** %6
%35 = call i32 @fclose(i32* %34)
br label %38
36: ; preds = %2
%37 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %39
38: ; preds = %33
store i32 0, i32* %3
br label %39
39: ; preds = %38, %36, %16
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
@stdin = global i32 0
@str = [31 x i8] c"\E8\AF\B7\E7\BB\99\E5\87\BA\E7\BC\93\E5\AD\98\E6\96\87\E4\BB\B6\E8\B7\AF\E5\BE\84\EF\BC\81\00"
@str.3 = [28 x i8] c"\E6\89\93\E5\BC\80\E7\BC\93\E5\AD\98\E6\96\87\E4\BB\B6\E5\A4\B1\E8\B4\A5\EF\BC\81\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1 x i8]
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %30
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.3, i64 0, i64 0))
br label %32
12: ; preds = %5
%13 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fread(i8* %13, i32 1, i32 1, i32 %14)
%16 = load i32, i32* @stdin
%17 = call i32 @feof(i32 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %12, %19
%20 = load i8, i8* %13
%21 = sext i8 %20 to i32
%22 = call i32 @fputc(i32 %21, i32* %8)
%23 = load i32, i32* @stdin
%24 = call i32 @fread(i8* %13, i32 1, i32 1, i32 %23)
%25 = load i32, i32* @stdin
%26 = call i32 @feof(i32 %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %19, label %28
28: ; preds = %19, %12
%29 = call i32 @fclose(i32* %8)
br label %32
30: ; preds = %2
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %28, %30, %10
%33 = phi i32 [ 1, %10 ], [ 0, %28 ], [ 1, %30 ]
ret i32 %33
}