#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 */
int /*<<< orphan*/ printf(char *, char, char);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ system(char *);
void main() {
  char ch;
  do {
    scanf("%c", &ch);
    if (ch != 10)
      printf("%c的ASCII码是%d\n", ch, ch);
  } while (ch != '?');
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x1(%rbp),%eax
cmp    $0xa,%eax
je     116b <main+0x3b>
mov    -0x1(%rbp),%al
lea    0xea4(%rip),%rdi
movsbl %al,%esi
movsbl -0x1(%rbp),%edx
call   1040 <printf@plt>
jmp    1170 <main+0x40>
movsbl -0x1(%rbp),%eax
cmp    $0x3f,%eax
jne    1138 <main+0x8>
lea    0xe93(%rip),%rdi
call   1030 <system@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%r14
lea    0xf(%rsp),%rbx
lea    0xeb7(%rip),%r15
jmp    1154 <main+0x24>
xchg   %ax,%ax
cmp    $0x3f,%al
je     117f <main+0x4f>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movzbl 0xf(%rsp),%ecx
mov    $0xa,%al
cmp    $0xa,%cl
je     1150 <main+0x20>
movsbl %cl,%edx
mov    %r15,%rdi
mov    %edx,%esi
call   1040 <printf@plt>
movzbl 0xf(%rsp),%eax
jmp    1150 <main+0x20>
lea    0xe91(%rip),%rdi
call   1030 <system@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [20 x i8] c"%c\E7\9A\84ASCII\E7\A0\81\E6\98\AF%d\0A\00"
@.str.2 = [6 x i8] c"pause\00"
define void @main() {
%1 = alloca i8
br label %2
2: ; preds = %12, %0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = sext i8 %4 to i32
%6 = icmp ne i32 %5, 10
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8, i8* %1
%9 = load i8, i8* %1
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8 signext %8, i8 signext %9)
br label %11
11: ; preds = %7, %2
br label %12
12: ; preds = %11
%13 = load i8, i8* %1
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 63
br i1 %15, label %2, label %16
16: ; preds = %12
%17 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [20 x i8] c"%c\E7\9A\84ASCII\E7\A0\81\E6\98\AF%d\0A\00"
@.str.2 = [6 x i8] c"pause\00"
define void @main() {
%1 = alloca i8
br label %2
2: ; preds = %9, %0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 10
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8 signext %4, i8 signext %4)
%8 = load i8, i8* %1
br label %9
9: ; preds = %2, %6
%10 = phi i8 [ 10, %2 ], [ %8, %6 ]
%11 = icmp eq i8 %10, 63
br i1 %11, label %12, label %2
12: ; preds = %9
%13 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret void
}