#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 EOF;
int EXIT_SUCCESS;
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char const);
int strlen(char const *);
int main(int argc, char **argv) {
  const char *strList = "`134567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./";
  int i = 0;
  int len = strlen(strList);
  printf("字符参考表:%s，长度:%d \n", strList, len);
  printf("请输入一行字符串，按回车结束输入:");
  char c = getchar();
  while (c != EOF && c != '\n') {
    if (c == ' ') {
      putchar(c);
      continue;
    }
    for (i = 0; i < len; i++) {
      if (strList[i] == c) {
        if (strList[i - 1]) {
          putchar(strList[i - 1]);
        } else {
          putchar(c);
        }
      }
    }
    c = getchar();
  }
  putchar('\n');
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%ecx
mov    0x2e3c(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x22(%rbp)
je     11c9 <main+0x89>
movsbl -0x21(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    11d9 <main+0x99>
jmp    1281 <main+0x141>
movsbl -0x21(%rbp),%eax
cmp    $0x20,%eax
jne    11f4 <main+0xb4>
movsbl -0x21(%rbp),%edi
call   1030 <putchar@plt>
jmp    11a1 <main+0x61>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1272 <main+0x132>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x21(%rbp),%ecx
cmp    %ecx,%eax
jne    125f <main+0x11f>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1251 <main+0x111>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
jmp    125a <main+0x11a>
movsbl -0x21(%rbp),%edi
call   1030 <putchar@plt>
jmp    125f <main+0x11f>
jmp    1264 <main+0x124>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11fb <main+0xbb>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x21(%rbp)
jmp    11a1 <main+0x61>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%r12
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
lea    0xecb(%rip),%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xed9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
je     1213 <main+0xd3>
mov    %eax,%ebx
mov    0x2e52(%rip),%r15
cmp    (%r15),%al
je     1213 <main+0xd3>
mov    %r14d,%r13d
xchg   %ax,%ax
cmp    $0x20,%bl
jne    11c0 <main+0x80>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%bl
cmp    $0xa,%bl
jne    120e <main+0xce>
jmp    1213 <main+0xd3>
nopl   0x0(%rax,%rax,1)
test   %r14d,%r14d
jle    1200 <main+0xc0>
xor    %ebp,%ebp
jmp    11e1 <main+0xa1>
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     1200 <main+0xc0>
cmp    %bl,0x0(%rbp,%r12,1)
jne    11d8 <main+0x98>
mov    %ebx,%eax
cmp    $0x2f,%rbp
je     11d0 <main+0x90>
movzbl -0x1(%rbp,%r12,1),%eax
jmp    11d0 <main+0x90>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebx
cmp    $0xa,%bl
je     1213 <main+0xd3>
cmp    (%r15),%bl
jne    11a0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"`134567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./\00"
@.str.1 = [33 x i8] c"\E5\AD\97\E7\AC\A6\E5\8F\82\E8\80\83\E8\A1\A8:%s\EF\BC\8C\E9\95\BF\E5\BA\A6:%d \0A\00"
@.str.2 = [50 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E8\A1\8C\E5\AD\97\E7\AC\A6\E4\B8\B2\EF\BC\8C\E6\8C\89\E5\9B\9E\E8\BD\A6\E7\BB\93\E6\9D\9F\E8\BE\93\E5\85\A5:\00"
@EOF = global i8 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 0, i32* %7
%10 = load i8*, i8** %6
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %8
%12 = load i8*, i8** %6
%13 = load i32, i32* %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%16 = call signext i8 (...) @getchar()
store i8 %16, i8* %9
br label %17
17: ; preds = %75, %33, %2
%18 = load i8, i8* %9
%19 = sext i8 %18 to i32
%20 = load i8, i8* @EOF
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %19, %21
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = load i8, i8* %9
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 10
br label %27
27: ; preds = %23, %17
%28 = phi i1 [ false, %17 ], [ %26, %23 ]
br i1 %28, label %29, label %77
29: ; preds = %27
%30 = load i8, i8* %9
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 32
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i8, i8* %9
%35 = call i32 @putchar(i8 signext %34)
br label %17
36: ; preds = %29
store i32 0, i32* %7
br label %37
37: ; preds = %72, %36
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %75
41: ; preds = %37
%42 = load i8*, i8** %6
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = load i8, i8* %9
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %47, %49
br i1 %50, label %51, label %71
51: ; preds = %41
%52 = load i8*, i8** %6
%53 = load i32, i32* %7
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %52, i64 %55
%57 = load i8, i8* %56
%58 = icmp ne i8 %57, 0
br i1 %58, label %59, label %67
59: ; preds = %51
%60 = load i8*, i8** %6
%61 = load i32, i32* %7
%62 = sub nsw i32 %61, 1
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %60, i64 %63
%65 = load i8, i8* %64
%66 = call i32 @putchar(i8 signext %65)
br label %70
67: ; preds = %51
%68 = load i8, i8* %9
%69 = call i32 @putchar(i8 signext %68)
br label %70
70: ; preds = %67, %59
br label %71
71: ; preds = %70, %41
br label %72
72: ; preds = %71
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
store i32 %74, i32* %7
br label %37
75: ; preds = %37
%76 = call signext i8 (...) @getchar()
store i8 %76, i8* %9
br label %17
77: ; preds = %27
%78 = call i32 @putchar(i8 signext 10)
%79 = load i32, i32* @EXIT_SUCCESS
ret i32 %79
}

LLVM IR (-O2):
@.str = [47 x i8] c"`134567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./\00"
@.str.1 = [33 x i8] c"\E5\AD\97\E7\AC\A6\E5\8F\82\E8\80\83\E8\A1\A8:%s\EF\BC\8C\E9\95\BF\E5\BA\A6:%d \0A\00"
@.str.2 = [50 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E8\A1\8C\E5\AD\97\E7\AC\A6\E4\B8\B2\EF\BC\8C\E6\8C\89\E5\9B\9E\E8\BD\A6\E7\BB\93\E6\9D\9F\E8\BE\93\E5\85\A5:\00"
@EOF = global i8 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call signext i8 (...) @getchar()
%7 = load i8, i8* @EOF
%8 = icmp ne i8 %6, %7
%9 = icmp ne i8 %6, 10
%10 = and i1 %9, %8
br i1 %10, label %11, label %45
11: ; preds = %2
%12 = icmp sgt i32 %3, 0
%13 = zext i32 %3 to i64
br label %14
14: ; preds = %11, %20
%15 = phi i8 [ %6, %11 ], [ %21, %20 ]
%16 = icmp eq i8 %15, 32
br i1 %16, label %18, label %17
17: ; preds = %14
br i1 %12, label %26, label %43
18: ; preds = %14
%19 = tail call i32 @putchar(i8 signext 32)
br label %20
20: ; preds = %18, %43
%21 = phi i8 [ 32, %18 ], [ %44, %43 ]
%22 = load i8, i8* @EOF
%23 = icmp ne i8 %21, %22
%24 = icmp ne i8 %21, 10
%25 = and i1 %24, %23
br i1 %25, label %14, label %45
26: ; preds = %17, %40
%27 = phi i64 [ %41, %40 ], [ 0, %17 ]
%28 = getelementptr inbounds [47 x i8], [47 x i8]* @.str, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, %15
br i1 %30, label %31, label %40
31: ; preds = %26
%32 = add nsw i64 %27, -1
%33 = icmp eq i64 %32, 46
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = getelementptr inbounds [47 x i8], [47 x i8]* @.str, i64 0, i64 %32
%36 = load i8, i8* %35
br label %37
37: ; preds = %31, %34
%38 = phi i8 [ %36, %34 ], [ %15, %31 ]
%39 = tail call i32 @putchar(i8 signext %38)
br label %40
40: ; preds = %37, %26
%41 = add nuw nsw i64 %27, 1
%42 = icmp eq i64 %41, %13
br i1 %42, label %43, label %26
43: ; preds = %40, %17
%44 = tail call signext i8 (...) @getchar()
br label %20
45: ; preds = %20, %2
%46 = tail call i32 @putchar(i8 signext 10)
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}