#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 getc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ system(char *);
int main() {
  int c;
  c = 0;
  printf(
      "enter some text, I will change the tabs and spaces and backslashes.\n");
  printf("press . to exit\n\n");
  printf("setting /bin/stty to raw...");
  system("/bin/stty raw");
  printf("\ndone.");
  while ((c = getc(stdin)) != '.') {
    if (c == 0x9)
      printf("\\t");
    else if (c == 0x7F || c == 0x8)
      printf("\\bbackspace");
    else if (c == 0x5C)
      printf("\\\\");
    else
      printf("%c", c);
  }
  printf("\n\nsetting /bin/stty to cooked...");
  system("/bin/stty cooked");
  printf("\ndone.");
  printf("\n\nexiting, bye!");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xefc(%rip),%rdi
call   1030 <system@plt>
lea    0xefe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1050 <getc@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x2e,%eax
je     1225 <main+0xf5>
cmpl   $0x9,-0x8(%rbp)
jne    11c1 <main+0x91>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1220 <main+0xf0>
cmpl   $0x7f,-0x8(%rbp)
je     11d5 <main+0xa5>
cmpl   $0x8,-0x8(%rbp)
jne    11e8 <main+0xb8>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121b <main+0xeb>
cmpl   $0x5c,-0x8(%rbp)
jne    1205 <main+0xd5>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1216 <main+0xe6>
mov    -0x8(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121b <main+0xeb>
jmp    1220 <main+0xf0>
jmp    118a <main+0x5a>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe84(%rip),%rdi
call   1030 <system@plt>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xf26(%rip),%rdi
call   1040 <puts@plt>
lea    0xf5e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe89(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe97(%rip),%rdi
call   1050 <system@plt>
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e49(%rip),%rbx
lea    0xe8b(%rip),%r14
lea    0xe87(%rip),%r12
lea    0xe8c(%rip),%r15
jmp    11ca <main+0x7a>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rbx),%edi
call   1070 <getc@plt>
cmp    $0x2d,%eax
jle    11f0 <main+0xa0>
cmp    $0x5c,%eax
je     11ff <main+0xaf>
cmp    $0x7f,%eax
je     11c0 <main+0x70>
cmp    $0x2e,%eax
jne    1204 <main+0xb4>
jmp    120d <main+0xbd>
nopw   0x0(%rax,%rax,1)
cmp    $0x8,%eax
je     11c0 <main+0x70>
cmp    $0x9,%eax
jne    1204 <main+0xb4>
mov    %r14,%rdi
jmp    11c3 <main+0x73>
mov    %r15,%rdi
jmp    11c3 <main+0x73>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    11ca <main+0x7a>
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe42(%rip),%rdi
call   1050 <system@plt>
lea    0xdfc(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [69 x i8] c"enter some text, I will change the tabs and spaces and backslashes.\0A\00"
@.str.1 = [18 x i8] c"press . to exit\0A\0A\00"
@.str.2 = [28 x i8] c"setting /bin/stty to raw...\00"
@.str.3 = [14 x i8] c"/bin/stty raw\00"
@.str.4 = [7 x i8] c"\0Adone.\00"
@stdin = global i32 0
@.str.5 = [3 x i8] c"\\t\00"
@.str.6 = [12 x i8] c"\\bbackspace\00"
@.str.7 = [3 x i8] c"\\\\\00"
@.str.8 = [3 x i8] c"%c\00"
@.str.9 = [33 x i8] c"\0A\0Asetting /bin/stty to cooked...\00"
@.str.10 = [17 x i8] c"/bin/stty cooked\00"
@.str.11 = [16 x i8] c"\0A\0Aexiting, bye!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %8
8: ; preds = %35, %0
%9 = load i32, i32* @stdin
%10 = call i32 @getc(i32 %9)
store i32 %10, i32* %2
%11 = icmp ne i32 %10, 46
br i1 %11, label %12, label %36
12: ; preds = %8
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 9
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %35
17: ; preds = %12
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 127
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 8
br i1 %22, label %23, label %25
23: ; preds = %20, %17
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %34
25: ; preds = %20
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 92
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %33
30: ; preds = %25
%31 = load i32, i32* %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %28
br label %34
34: ; preds = %33, %23
br label %35
35: ; preds = %34, %15
br label %8
36: ; preds = %8
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
%38 = call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [28 x i8] c"setting /bin/stty to raw...\00"
@.str.3 = [14 x i8] c"/bin/stty raw\00"
@.str.4 = [7 x i8] c"\0Adone.\00"
@stdin = global i32 0
@.str.5 = [3 x i8] c"\\t\00"
@.str.6 = [12 x i8] c"\\bbackspace\00"
@.str.7 = [3 x i8] c"\\\\\00"
@.str.9 = [33 x i8] c"\0A\0Asetting /bin/stty to cooked...\00"
@.str.10 = [17 x i8] c"/bin/stty cooked\00"
@.str.11 = [16 x i8] c"\0A\0Aexiting, bye!\00"
@str = [68 x i8] c"enter some text, I will change the tabs and spaces and backslashes.\00"
@str.12 = [17 x i8] c"press . to exit\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* @stdin
%8 = tail call i32 @getc(i32 %7)
switch i32 %8, label %16 [
i32 46, label %18
i32 9, label %9
i32 127, label %11
i32 8, label %11
i32 92, label %14
]
9: ; preds = %6
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %13
11: ; preds = %6, %6
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %13
13: ; preds = %11, %16, %14, %9
br label %6
14: ; preds = %6
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %13
16: ; preds = %6
%17 = tail call i32 @putchar(i32 %8)
br label %13
18: ; preds = %6
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
%20 = tail call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}