#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ system(char *);
void decrypt(unsigned int llav) {
  int i;
  FILE *arch, *nue;
  if ((arch = fopen("obf.txt", "r")) != NULL) {
    if ((nue = fopen("decrypted.txt", "w")) != NULL) {
    } else {
      perror("Error:");
      exit(-1);
    }
    do {
      char temp;
      temp = fgetc(arch);
      temp = temp - llav;
      if (temp > 8 && temp < 128) {
        fputc(temp, nue);
      }
    } while (!feof(arch));
    rewind(arch);
    rewind(nue);
    fclose(arch);
    fclose(nue);
  } else {
    FILE *hello;
    printf("The file 'hello.txt' doesn't exist or there was a problem while "
           "opening it.\nTherefore a new 'hello' file will be created so you "
           "can include\nyour text-to-crypt in it.\n\n");
    hello = fopen("hello.txt", "w");
    fclose(hello);
    exit(-1);
  }
  system("clear;echo 'done'");
}


x86 assembly (clang, -O0):
<decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe4e(%rip),%rdi
lea    0xe4f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1295 <decrypt+0xf5>
lea    0xe37(%rip),%rdi
lea    0xe3e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11f2 <decrypt+0x52>
jmp    1208 <decrypt+0x68>
lea    0xe21(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
jmp    120d <decrypt+0x6d>
mov    -0x10(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x8,%eax
jle    124e <decrypt+0xae>
movsbl -0x19(%rbp),%eax
cmp    $0x80,%eax
jge    124e <decrypt+0xae>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1080 <fputc@plt>
jmp    1253 <decrypt+0xb3>
mov    -0x10(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    120d <decrypt+0x6d>
mov    -0x10(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x18(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    12cb <decrypt+0x12b>
lea    0xd85(%rip),%rdi
call   1050 <printf@plt>
lea    0xe21(%rip),%rdi
lea    0xd69(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    0xe01(%rip),%rdi
call   1040 <system@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
lea    0xe53(%rip),%rdi
lea    0xe54(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1248 <decrypt+0xa8>
mov    %rax,%rbx
lea    0xe3e(%rip),%rdi
lea    0xe45(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1279 <decrypt+0xd9>
mov    %rax,%r14
jmp    11fc <decrypt+0x5c>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    1218 <decrypt+0x78>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
sub    %bpl,%al
cmp    $0x9,%al
jl     11f0 <decrypt+0x50>
movsbl %al,%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
jmp    11f0 <decrypt+0x50>
mov    %rbx,%rdi
call   1060 <rewind@plt>
mov    %r14,%rdi
call   1060 <rewind@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0xdec(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <system@plt>
lea    0xdee(%rip),%rdi
call   1030 <puts@plt>
lea    0xdc6(%rip),%rdi
lea    0xdb6(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rdi
call   1040 <fclose@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    0xd9a(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"obf.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"decrypted.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [7 x i8] c"Error:\00"
@.str.5 = [168 x i8] c"The file 'hello.txt' doesn't exist or there was a problem while opening it.\0ATherefore a new 'hello' file will be created so you can include\0Ayour text-to-crypt in it.\0A\0A\00"
@.str.6 = [10 x i8] c"hello.txt\00"
@.str.7 = [18 x i8] c"clear;echo 'done'\00"
define void @decrypt(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8
%7 = alloca i32*
store i32 %0, i32* %2
%8 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %52
10: ; preds = %1
%11 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %11, i32** %5
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %14
13: ; preds = %10
br label %17
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %13
br label %18
18: ; preds = %38, %17
%19 = load i32*, i32** %4
%20 = call signext i8 @fgetc(i32* %19)
store i8 %20, i8* %6
%21 = load i8, i8* %6
%22 = sext i8 %21 to i32
%23 = load i32, i32* %2
%24 = sub i32 %22, %23
%25 = trunc i32 %24 to i8
store i8 %25, i8* %6
%26 = load i8, i8* %6
%27 = sext i8 %26 to i32
%28 = icmp sgt i32 %27, 8
br i1 %28, label %29, label %37
29: ; preds = %18
%30 = load i8, i8* %6
%31 = sext i8 %30 to i32
%32 = icmp slt i32 %31, 128
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i8, i8* %6
%35 = load i32*, i32** %5
%36 = call i32 @fputc(i8 signext %34, i32* %35)
br label %37
37: ; preds = %33, %29, %18
br label %38
38: ; preds = %37
%39 = load i32*, i32** %4
%40 = call i32 @feof(i32* %39)
%41 = icmp ne i32 %40, 0
%42 = xor i1 %41, true
br i1 %42, label %18, label %43
43: ; preds = %38
%44 = load i32*, i32** %4
%45 = call i32 @rewind(i32* %44)
%46 = load i32*, i32** %5
%47 = call i32 @rewind(i32* %46)
%48 = load i32*, i32** %4
%49 = call i32 @fclose(i32* %48)
%50 = load i32*, i32** %5
%51 = call i32 @fclose(i32* %50)
br label %58
52: ; preds = %1
%53 = call i32 @printf(i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.5, i64 0, i64 0))
%54 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %54, i32** %7
%55 = load i32*, i32** %7
%56 = call i32 @fclose(i32* %55)
%57 = call i32 @exit(i32 -1)
unreachable
58: ; preds = %43
%59 = call i32 @system(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"obf.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"decrypted.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [7 x i8] c"Error:\00"
@.str.6 = [10 x i8] c"hello.txt\00"
@.str.7 = [18 x i8] c"clear;echo 'done'\00"
@str = [167 x i8] c"The file 'hello.txt' doesn't exist or there was a problem while opening it.\0ATherefore a new 'hello' file will be created so you can include\0Ayour text-to-crypt in it.\0A\00"
define void @decrypt(i32 %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %27, label %4
4: ; preds = %1
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = trunc i32 %0 to i8
br label %12
9: ; preds = %4
%10 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %7, %18
%13 = tail call signext i8 @fgetc(i32* %2)
%14 = sub i8 %13, %8
%15 = icmp sgt i8 %14, 8
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = tail call i32 @fputc(i8 signext %14, i32* %5)
br label %18
18: ; preds = %16, %12
%19 = tail call i32 @feof(i32* %2)
%20 = icmp eq i32 %19, 0
br i1 %20, label %12, label %21
21: ; preds = %18
%22 = tail call i32 @rewind(i32* %2)
%23 = tail call i32 @rewind(i32* %5)
%24 = tail call i32 @fclose(i32* %2)
%25 = tail call i32 @fclose(i32* %5)
%26 = tail call i32 @system(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
ret void
27: ; preds = %1
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([167 x i8], [167 x i8]* @str, i64 0, i64 0))
%29 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = tail call i32 @fclose(i32* %29)
%31 = tail call i32 @exit(i32 -1)
unreachable
}