#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 *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
char *strrev(char *);
int main(int argc, char *argv[]) {
  if (argc == 2) {
    int i;
    char *word = (char *)malloc(sizeof(char) * 100);
    FILE *fp = fopen(argv[1], "r");
    FILE *out = fopen("final_data.txt", "w");
    if (fp) {
      while (fscanf(fp, "%s", word) != EOF) {
        for (i = 0; i < strlen(word); i++) {
          word[i] = ~word[i];
        }
        word = strrev(word);
        fprintf(out, "%s ", word);
      }
    } else
      printf("%s does not exist\n", argv[1]);
  } else
    printf("Usage: encrypt input_file_name\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1294 <main+0x124>
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe53(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
lea    0xe45(%rip),%rdi
lea    0xe4d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1279 <main+0x109>
jmp    11dd <main+0x6d>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe27(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2df0(%rip),%rcx
cmp    (%rcx),%rax
je     1274 <main+0x104>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    124e <main+0xde>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
xor    $0xffffffff,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1208 <main+0x98>
mov    -0x20(%rbp),%rdi
call   1080 <strrev@plt>
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xdac(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11dd <main+0x6d>
jmp    128f <main+0x11f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a2 <main+0x132>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1278 <main+0xf8>
mov    %rsi,%r12
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    0x8(%r12),%rdi
lea    0xe50(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
lea    0xe43(%rip),%rdi
lea    0xe4b(%rip),%rsi
call   10a0 <fopen@plt>
test   %r14,%r14
je     1286 <main+0x106>
mov    %rax,%r15
lea    0xe35(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
mov    0x2df8(%rip),%rcx
cmp    (%rcx),%rax
je     1299 <main+0x119>
lea    0xe16(%rip),%r12
lea    0xe0c(%rip),%r13
jmp    1243 <main+0xc3>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1090 <strrev@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
mov    0x2daa(%rip),%rcx
cmp    (%rcx),%rax
je     1299 <main+0x119>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1210 <main+0x90>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
notb   (%rbx,%rbp,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1260 <main+0xe0>
jmp    1210 <main+0x90>
lea    0xdae(%rip),%rdi
call   1030 <puts@plt>
jmp    1299 <main+0x119>
mov    0x8(%r12),%rsi
lea    0xd88(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [15 x i8] c"final_data.txt\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.4 = [4 x i8] c"%s \00"
@.str.5 = [19 x i8] c"%s does not exist\0A\00"
@.str.6 = [32 x i8] c"Usage: encrypt input_file_name\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %64
12: ; preds = %2
%13 = call i64 @malloc(i32 100)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %7
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %8
%19 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %19, i32** %9
%20 = load i32*, i32** %8
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %58
22: ; preds = %12
br label %23
23: ; preds = %51, %22
%24 = load i32*, i32** %8
%25 = load i8*, i8** %7
%26 = call i64 @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %25)
%27 = load i64, i64* @EOF
%28 = icmp ne i64 %26, %27
br i1 %28, label %29, label %57
29: ; preds = %23
store i32 0, i32* %6
br label %30
30: ; preds = %48, %29
%31 = load i32, i32* %6
%32 = load i8*, i8** %7
%33 = call i32 @strlen(i8* %32)
%34 = icmp slt i32 %31, %33
br i1 %34, label %35, label %51
35: ; preds = %30
%36 = load i8*, i8** %7
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = xor i32 %41, -1
%43 = trunc i32 %42 to i8
%44 = load i8*, i8** %7
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
store i8 %43, i8* %47
br label %48
48: ; preds = %35
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %30
51: ; preds = %30
%52 = load i8*, i8** %7
%53 = call i8* @strrev(i8* %52)
store i8* %53, i8** %7
%54 = load i32*, i32** %9
%55 = load i8*, i8** %7
%56 = call i32 @fprintf(i32* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %55)
br label %23
57: ; preds = %23
br label %63
58: ; preds = %12
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %61)
br label %63
63: ; preds = %58, %57
br label %66
64: ; preds = %2
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
br label %66
66: ; preds = %64, %63
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [15 x i8] c"final_data.txt\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.4 = [4 x i8] c"%s \00"
@.str.5 = [19 x i8] c"%s does not exist\0A\00"
@str = [31 x i8] c"Usage: encrypt input_file_name\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %38
4: ; preds = %2
%5 = tail call i64 @malloc(i32 100)
%6 = inttoptr i64 %5 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32* %9, null
br i1 %11, label %35, label %12
12: ; preds = %4
%13 = tail call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %40, label %16
16: ; preds = %12, %29
%17 = phi i8* [ %30, %29 ], [ %6, %12 ]
%18 = tail call i32 @strlen(i8* %17)
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %16, %20
%21 = phi i64 [ %25, %20 ], [ 0, %16 ]
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = load i8, i8* %22
%24 = xor i8 %23, -1
store i8 %24, i8* %22
%25 = add nuw nsw i64 %21, 1
%26 = tail call i32 @strlen(i8* %17)
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %20, label %29
29: ; preds = %20, %16
%30 = tail call i8* @strrev(i8* %17)
%31 = tail call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %30)
%32 = tail call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%33 = load i64, i64* @EOF
%34 = icmp eq i64 %32, %33
br i1 %34, label %40, label %16
35: ; preds = %4
%36 = load i8*, i8** %7
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %36)
br label %40
38: ; preds = %2
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %40
40: ; preds = %29, %12, %35, %38
ret i32 0
}