#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*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int pre_process(char);
int /*<<< orphan*/ printf(char *, char *);
char process(char);
int scanf(char *, char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char str[4096];
  freopen("./sample.txt", "r", stdin);
  while (scanf("%[^\n]", str) == 1) {
    getchar();
    int len = strlen(str);
    int i = 0;
    while (str[i] != '\0') {
      int is_ok = pre_process(str[i]);
      if (is_ok) {
        char ch;
        ch = process(str[i]);
        if (ch != '\0')
          str[i] = ch;
      }
      ++i;
    }
    printf("%s\n", str);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%edx
lea    0xe6e(%rip),%rdi
lea    0xe74(%rip),%rsi
call   1050 <freopen@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe63(%rip),%rdi
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    128b <main+0x11b>
mov    $0x0,%al
call   1070 <getchar@plt>
lea    -0x1010(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1014(%rbp)
movl   $0x0,-0x1018(%rbp)
movslq -0x1018(%rbp),%rax
movsbl -0x1010(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1273 <main+0x103>
movslq -0x1018(%rbp),%rax
movsbl -0x1010(%rbp,%rax,1),%edi
ff
call   1080 <pre_process@plt>
mov    %eax,-0x101c(%rbp)
cmpl   $0x0,-0x101c(%rbp)
je     125f <main+0xef>
movslq -0x1018(%rbp),%rax
movsbl -0x1010(%rbp,%rax,1),%edi
ff
call   1060 <process@plt>
mov    %al,-0x101d(%rbp)
movsbl -0x101d(%rbp),%eax
cmp    $0x0,%eax
je     125a <main+0xea>
mov    -0x101d(%rbp),%cl
movslq -0x1018(%rbp),%rax
mov    %cl,-0x1010(%rbp,%rax,1)
jmp    125f <main+0xef>
mov    -0x1018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1018(%rbp)
jmp    11dd <main+0x6d>
lea    -0x1010(%rbp),%rsi
lea    0xd94(%rip),%rdi
call   1040 <printf@plt>
jmp    119e <main+0x2e>
xor    %eax,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
lea    0xe72(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1050 <freopen@plt>
lea    0xe6e(%rip),%rdi
mov    %rsp,%r12
mov    %r12,%rsi
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    1238 <main+0xc8>
lea    0xe59(%rip),%r14
lea    0xe4c(%rip),%r15
jmp    11eb <main+0x7b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    1238 <main+0xc8>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    (%rsp),%al
test   %al,%al
je     11d0 <main+0x60>
mov    %r12,%rbx
jmp    121c <main+0xac>
cs nopw 0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11d0 <main+0x60>
movsbl %al,%edi
call   1080 <pre_process@plt>
test   %eax,%eax
je     1210 <main+0xa0>
movsbl (%rbx),%edi
call   1060 <process@plt>
test   %al,%al
je     1210 <main+0xa0>
mov    %al,(%rbx)
jmp    1210 <main+0xa0>
xor    %eax,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"./sample.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [6 x i8] c"%[^\0A]\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4096 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 0, i32* %1
%7 = load i32, i32* @stdin
%8 = call i32 @freopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %50, %0
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %53
13: ; preds = %9
%14 = call i32 (...) @getchar()
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %3
store i32 0, i32* %4
br label %17
17: ; preds = %47, %13
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %50
24: ; preds = %17
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = call i32 @pre_process(i8 signext %28)
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %47
32: ; preds = %24
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = call signext i8 @process(i8 signext %36)
store i8 %37, i8* %6
%38 = load i8, i8* %6
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %32
%42 = load i8, i8* %6
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 %44
store i8 %42, i8* %45
br label %46
46: ; preds = %41, %32
br label %47
47: ; preds = %46, %24
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %17
50: ; preds = %17
%51 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%52 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %51)
br label %9
53: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"./sample.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [6 x i8] c"%[^\0A]\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = tail call i32 @freopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %32
7: ; preds = %0, %28
%8 = call i32 (...) @getchar()
%9 = call i32 @strlen(i8* %2)
%10 = load i8, i8* %2
%11 = icmp eq i8 %10, 0
br i1 %11, label %28, label %12
12: ; preds = %7, %23
%13 = phi i64 [ %24, %23 ], [ 0, %7 ]
%14 = phi i8 [ %26, %23 ], [ %10, %7 ]
%15 = phi i8* [ %25, %23 ], [ %2, %7 ]
%16 = call i32 @pre_process(i8 signext %14)
%17 = icmp eq i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %12
%19 = load i8, i8* %15
%20 = call signext i8 @process(i8 signext %19)
%21 = icmp eq i8 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i8 %20, i8* %15
br label %23
23: ; preds = %18, %22, %12
%24 = add nuw i64 %13, 1
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %12
28: ; preds = %23, %7
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%30 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%31 = icmp eq i32 %30, 1
br i1 %31, label %7, label %32
32: ; preds = %28, %0
ret i32 0
}