#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;
char getchar();
int /*<<< orphan*/ putchar(char);
char *strchr(char const *, char);
int main() {
  const char *key_layout[4] = {"`1234567890-=", "QWERTYUIOP[]\\", "ASDFGHJKL;'",
                               "ZXCVBNM,./"};
  char ch;
  int i;
  char *pos;
  char decode_ok;
  while ((ch = getchar()) != EOF) {
    for (decode_ok = 0, i = 0; i < 4; i++) {
      pos = strchr(key_layout[i], ch);
      if (pos != NULL) {
        putchar(*--pos);
        decode_ok = 1;
        break;
      }
    }
    if (!decode_ok)
      putchar(ch);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2caa(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2ca7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2ca4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2ca1(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x31(%rbp)
movsbl %al,%eax
mov    0x2e61(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     120c <main+0xdc>
movb   $0x0,-0x41(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x4,-0x38(%rbp)
jge    11f4 <main+0xc4>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
movsbl -0x31(%rbp),%esi
call   1040 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     11e1 <main+0xb1>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x40(%rbp)
movsbl -0x1(%rax),%edi
call   1030 <putchar@plt>
movb   $0x1,-0x41(%rbp)
jmp    11f4 <main+0xc4>
jmp    11e6 <main+0xb6>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1195 <main+0x65>
cmpb   $0x0,-0x41(%rbp)
jne    1207 <main+0xd7>
movsbl -0x31(%rbp),%edi
call   1030 <putchar@plt>
jmp    116b <main+0x3b>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9f(%rip),%r12
cmp    (%r12),%al
je     11db <main+0xab>
mov    %eax,%ebx
lea    0xea4(%rip),%r13
lea    0xeab(%rip),%r14
lea    0xeb2(%rip),%r15
nopw   0x0(%rax,%rax,1)
movsbl %bl,%ebp
mov    %r13,%rdi
mov    %ebp,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11c0 <main+0x90>
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11c0 <main+0x90>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11c0 <main+0x90>
lea    0xe81(%rip),%rdi
mov    %ebp,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11c4 <main+0x94>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl -0x1(%rax),%ebx
movsbl %bl,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    (%r12),%al
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"`1234567890-=\00"
@.str.1 = [14 x i8] c"QWERTYUIOP[]\\\00"
@.str.2 = [12 x i8] c"ASDFGHJKL;'\00"
@.str.3 = [11 x i8] c"ZXCVBNM,./\00"
@__const.main.key_layout = [4 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0)]
@EOF = global i8 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8*]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
store i32 0, i32* %1
%7 = bitcast [4 x i8*]* %2 to i8*
br label %8
8: ; preds = %42, %0
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %3
%10 = sext i8 %9 to i32
%11 = load i8, i8* @EOF
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %10, %12
br i1 %13, label %14, label %43
14: ; preds = %8
store i8 0, i8* %6
store i32 0, i32* %4
br label %15
15: ; preds = %33, %14
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %36
18: ; preds = %15
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 %20
%22 = load i8*, i8** %21
%23 = load i8, i8* %3
%24 = call i8* @strchr(i8* %22, i8 signext %23)
store i8* %24, i8** %5
%25 = load i8*, i8** %5
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %32
27: ; preds = %18
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 -1
store i8* %29, i8** %5
%30 = load i8, i8* %29
%31 = call i32 @putchar(i8 signext %30)
store i8 1, i8* %6
br label %36
32: ; preds = %18
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %15
36: ; preds = %27, %15
%37 = load i8, i8* %6
%38 = icmp ne i8 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = load i8, i8* %3
%41 = call i32 @putchar(i8 signext %40)
br label %42
42: ; preds = %39, %36
br label %8
43: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"`1234567890-=\00"
@.str.1 = [14 x i8] c"QWERTYUIOP[]\\\00"
@.str.2 = [12 x i8] c"ASDFGHJKL;'\00"
@.str.3 = [11 x i8] c"ZXCVBNM,./\00"
@EOF = global i8 0
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %27, label %4
4: ; preds = %0, %21
%5 = phi i8 [ %24, %21 ], [ %1, %0 ]
%6 = tail call i8* @strchr(i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8 signext %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %17
8: ; preds = %4
%9 = tail call i8* @strchr(i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8 signext %5)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = tail call i8* @strchr(i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8 signext %5)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = tail call i8* @strchr(i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8 signext %5)
%16 = icmp eq i8* %15, null
br i1 %16, label %21, label %17
17: ; preds = %14, %11, %8, %4
%18 = phi i8* [ %6, %4 ], [ %9, %8 ], [ %12, %11 ], [ %15, %14 ]
%19 = getelementptr inbounds i8, i8* %18, i64 -1
%20 = load i8, i8* %19
br label %21
21: ; preds = %14, %17
%22 = phi i8 [ %20, %17 ], [ %5, %14 ]
%23 = tail call i32 @putchar(i8 signext %22)
%24 = tail call signext i8 (...) @getchar()
%25 = load i8, i8* @EOF
%26 = icmp eq i8 %24, %25
br i1 %26, label %27, label %4
27: ; preds = %21, %0
ret i32 0
}