#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int main() {
  char filein[100], fileout[100], key[100], word[100];
  printf("Enter the Name of Input file with extension: ");
  scanf("%s", filein);
  printf("Enter the Name of Output file with extension: ");
  scanf("%s", fileout);
  printf("Enter the Word to pe Removed: ");
  scanf("%s", key);
  FILE *f1, *f2;
  f1 = fopen(filein, "r");
  f2 = fopen(fileout, "w");
  while (fscanf(f1, "%s", word) != EOF) {
    if (strcmp(key, word) != 0)
      fprintf(f2, "%s", word);
    char ch = getc(f1);
    putc(ch, f2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1080 <scanf@plt>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1080 <scanf@plt>
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x150(%rbp),%rsi
lea    0xe47(%rip),%rdi
call   1080 <scanf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x1c8(%rbp)
lea    -0xe0(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x1d0(%rbp)
mov    -0x1c8(%rbp),%rdi
lea    -0x1c0(%rbp),%rdx
lea    0xdfc(%rip),%rsi
call   1040 <fscanf@plt>
mov    0x2daa(%rip),%rcx
cmp    (%rcx),%rax
je     12aa <main+0x12a>
lea    -0x150(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     127e <main+0xfe>
mov    -0x1d0(%rbp),%rdi
lea    -0x1c0(%rbp),%rdx
lea    0xdb5(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x1c8(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,-0x1d1(%rbp)
mov    -0x1d1(%rbp),%al
mov    -0x1d0(%rbp),%rsi
movsbl %al,%edi
call   1060 <putc@plt>
jmp    121d <main+0x9d>
xor    %eax,%eax
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1b8,%rsp
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8a(%rip),%r15
lea    0x150(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
lea    0xe0(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
lea    0x70(%rsp),%rsi
mov    %r15,%rdi
call   1080 <scanf@plt>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0xe79(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
mov    %rax,%r14
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <fscanf@plt>
mov    0x2dc0(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    1242 <main+0xc2>
xor    %eax,%eax
add    $0x1b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x70(%rsp),%r15
mov    %rsp,%r12
lea    0xddd(%rip),%r13
jmp    1287 <main+0x107>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   10a0 <getc@plt>
movsbl %al,%edi
mov    %r14,%rsi
call   1070 <putc@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1050 <fscanf@plt>
cmp    0x0(%rbp),%rax
je     122e <main+0xae>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1260 <main+0xe0>
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <fputs@plt>
jmp    1260 <main+0xe0>

LLVM IR (-O0):
@.str = [46 x i8] c"Enter the Name of Input file with extension: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [47 x i8] c"Enter the Name of Output file with extension: \00"
@.str.3 = [31 x i8] c"Enter the Word to pe Removed: \00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [2 x i8] c"w\00"
@EOF = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8
store i32 0, i32* %1
%9 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %19, i32** %6
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %21, i32** %7
br label %22
22: ; preds = %37, %0
%23 = load i32*, i32** %6
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%25 = call i64 @fscanf(i32* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i64, i64* @EOF
%27 = icmp ne i64 %25, %26
br i1 %27, label %28, label %43
28: ; preds = %22
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%31 = call i64 @strcmp(i8* %29, i8* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i32*, i32** %7
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%36 = call i32 @fprintf(i32* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %33, %28
%38 = load i32*, i32** %6
%39 = call signext i8 @getc(i32* %38)
store i8 %39, i8* %8
%40 = load i8, i8* %8
%41 = load i32*, i32** %7
%42 = call i32 @putc(i8 signext %40, i32* %41)
br label %22
43: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"Enter the Name of Input file with extension: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [47 x i8] c"Enter the Name of Output file with extension: \00"
@.str.3 = [31 x i8] c"Enter the Word to pe Removed: \00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [2 x i8] c"w\00"
@EOF = global i64 0
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%15 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%17 = call i64 @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %31, label %20
20: ; preds = %0, %25
%21 = call i64 @strcmp(i8* %7, i8* %8)
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 @fputs(i8* %8, i32* %16)
br label %25
25: ; preds = %23, %20
%26 = call signext i8 @getc(i32* %15)
%27 = call i32 @putc(i8 signext %26, i32* %16)
%28 = call i64 @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%29 = load i64, i64* @EOF
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %20
31: ; preds = %25, %0
ret i32 0
}