#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 EOF;
int getc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  int c;
  c = 0;
  printf(
      "enter some text, I will change the tabs and spaces and backslashes.\n");
  printf("press control-d to exit.\n\n");
  while ((c = getc(stdin)) != EOF) {
    if (c == 0x9)
      printf("\\t");
    else if (c == 0x5C)
      printf("\\\\");
    else
      printf("%c", c);
  }
  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    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e76(%rip),%rcx
cmp    (%rcx),%eax
je     11c7 <main+0xa7>
cmpl   $0x9,-0x8(%rbp)
jne    118f <main+0x6f>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c2 <main+0xa2>
cmpl   $0x5c,-0x8(%rbp)
jne    11ac <main+0x8c>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bd <main+0x9d>
mov    -0x8(%rbp),%esi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c2 <main+0xa2>
jmp    1152 <main+0x32>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <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    0xec7(%rip),%rdi
call   1040 <puts@plt>
lea    0xeff(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e81(%rip),%r12
mov    (%r12),%edi
call   1060 <getc@plt>
mov    0x2e69(%rip),%rbx
cmp    (%rbx),%eax
jne    1197 <main+0x57>
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe65(%rip),%r14
lea    0xe5b(%rip),%r15
jmp    11c4 <main+0x84>
nopw   0x0(%rax,%rax,1)
mov    %eax,%edi
call   1030 <putchar@plt>
mov    (%r12),%edi
call   1060 <getc@plt>
cmp    (%rbx),%eax
je     117b <main+0x3b>
cmp    $0x5c,%eax
je     11e0 <main+0xa0>
cmp    $0x9,%eax
jne    11b0 <main+0x70>
mov    %r15,%rdi
jmp    11e3 <main+0xa3>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b7 <main+0x77>

LLVM IR (-O0):
@.str = [69 x i8] c"enter some text, I will change the tabs and spaces and backslashes.\0A\00"
@.str.1 = [27 x i8] c"press control-d to exit.\0A\0A\00"
@stdin = global i32 0
@EOF = global i32 0
@.str.2 = [3 x i8] c"\\t\00"
@.str.3 = [3 x i8] c"\\\\\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [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 ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %24, %0
%6 = load i32, i32* @stdin
%7 = call i32 @getc(i32 %6)
store i32 %7, i32* %2
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %25
10: ; preds = %5
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 9
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %24
15: ; preds = %10
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 92
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %23
20: ; preds = %15
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %18
br label %24
24: ; preds = %23, %13
br label %5
25: ; preds = %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@.str.2 = [3 x i8] c"\\t\00"
@.str.3 = [3 x i8] c"\\\\\00"
@.str.5 = [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.6 = [26 x i8] c"press control-d 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 ([26 x i8], [26 x i8]* @str.6, i64 0, i64 0))
%3 = load i32, i32* @stdin
%4 = tail call i32 @getc(i32 %3)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %20, label %7
7: ; preds = %0, %15
%8 = phi i32 [ %17, %15 ], [ %4, %0 ]
switch i32 %8, label %13 [
i32 9, label %9
i32 92, label %11
]
9: ; preds = %7
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %15
11: ; preds = %7
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %15
13: ; preds = %7
%14 = tail call i32 @putchar(i32 %8)
br label %15
15: ; preds = %11, %13, %9
%16 = load i32, i32* @stdin
%17 = tail call i32 @getc(i32 %16)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %7
20: ; preds = %15, %0
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}