#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 */
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char ch, filename[10];
  printf("请输入所用的文件名：");
  scanf("%s", filename);
  ch = getchar();
  printf("请输入一个准备存储到键盘的字符串（以#结束）：");
  ch = getchar();
  while (ch != '#') {
    putchar(ch);
    ch = getchar();
  }
  putchar(10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    -0xf(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x23,%eax
je     11b0 <main+0x70>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
jmp    118b <main+0x4b>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
lea    0xe(%rsp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x23,%al
je     1195 <main+0x55>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E6\89\80\E7\94\A8\E7\9A\84\E6\96\87\E4\BB\B6\E5\90\8D\EF\BC\9A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [68 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E5\87\86\E5\A4\87\E5\AD\98\E5\82\A8\E5\88\B0\E9\94\AE\E7\9B\98\E7\9A\84\E5\AD\97\E7\AC\A6\E4\B8\B2\EF\BC\88\E4\BB\A5#\E7\BB\93\E6\9D\9F\EF\BC\89\EF\BC\9A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [10 x i8]
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %2
%8 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0))
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %2
br label %10
10: ; preds = %14, %0
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 35
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = call i32 @putchar(i32 %16)
%18 = call signext i8 (...) @getchar()
store i8 %18, i8* %2
br label %10
19: ; preds = %10
%20 = call i32 @putchar(i32 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E6\89\80\E7\94\A8\E7\9A\84\E6\96\87\E4\BB\B6\E5\90\8D\EF\BC\9A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [68 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E5\87\86\E5\A4\87\E5\AD\98\E5\82\A8\E5\88\B0\E9\94\AE\E7\9B\98\E7\9A\84\E5\AD\97\E7\AC\A6\E4\B8\B2\EF\BC\88\E4\BB\A5#\E7\BB\93\E6\9D\9F\EF\BC\89\EF\BC\9A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call signext i8 (...) @getchar()
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0))
%7 = call signext i8 (...) @getchar()
%8 = icmp eq i8 %7, 35
br i1 %8, label %15, label %9
9: ; preds = %0, %9
%10 = phi i8 [ %13, %9 ], [ %7, %0 ]
%11 = sext i8 %10 to i32
%12 = call i32 @putchar(i32 %11)
%13 = call signext i8 (...) @getchar()
%14 = icmp eq i8 %13, 35
br i1 %14, label %15, label %9
15: ; preds = %9, %0
%16 = call i32 @putchar(i32 10)
ret i32 0
}