#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 crypt(unsigned int llav) {
  int i;
  int carac;
  FILE *arch, *nue;
  if ((arch = fopen("hello.txt", "r")) != NULL) {
    if ((nue = fopen("obf.txt", "a")) != NULL) {
    } else {
      perror("Error:");
      exit(-1);
    }
    do {
      char temp;
      temp = fgetc(arch);
      carac = temp;
      if (carac > 8 && carac < 128) {
        temp = temp + llav;
        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):
<crypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe4e(%rip),%rdi
lea    0xe51(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1297 <crypt+0xf7>
lea    0xe39(%rip),%rdi
lea    0xe3a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11f2 <crypt+0x52>
jmp    1208 <crypt+0x68>
lea    0xe1d(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
jmp    120d <crypt+0x6d>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jle    1250 <crypt+0xb0>
cmpl   $0x80,-0xc(%rbp)
jge    1250 <crypt+0xb0>
movsbl -0x21(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1080 <fputc@plt>
jmp    1255 <crypt+0xb5>
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    120d <crypt+0x6d>
mov    -0x18(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x20(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    12cd <crypt+0x12d>
lea    0xd7f(%rip),%rdi
call   1050 <printf@plt>
lea    0xd56(%rip),%rdi
lea    0xe14(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    0xdf3(%rip),%rdi
call   1040 <system@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypt>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
lea    0xe52(%rip),%rdi
lea    0xe55(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1248 <crypt+0xa8>
mov    %rax,%rbx
lea    0xe3f(%rip),%rdi
lea    0xe40(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1279 <crypt+0xd9>
mov    %rax,%rbp
jmp    11fc <crypt+0x5c>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    1218 <crypt+0x78>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    $0x9,%al
jl     11f0 <crypt+0x50>
add    %r14b,%al
movsbl %al,%edi
mov    %rbp,%rsi
call   1080 <fputc@plt>
jmp    11f0 <crypt+0x50>
mov    %rbx,%rdi
call   1060 <rewind@plt>
mov    %rbp,%rdi
call   1060 <rewind@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0xde0(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <system@plt>
lea    0xde2(%rip),%rdi
call   1030 <puts@plt>
lea    0xda5(%rip),%rdi
lea    0xdbb(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rdi
call   1040 <fclose@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    0xd96(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"hello.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"obf.txt\00"
@.str.3 = [2 x i8] c"a\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 = [2 x i8] c"w\00"
@.str.7 = [18 x i8] c"clear;echo 'done'\00"
define void @crypt(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8
%8 = alloca i32*
store i32 %0, i32* %2
%9 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %5
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %53
11: ; preds = %1
%12 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 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* %12, i32** %6
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %11
br label %18
15: ; preds = %11
%16 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %14
br label %19
19: ; preds = %39, %18
%20 = load i32*, i32** %5
%21 = call signext i8 @fgetc(i32* %20)
store i8 %21, i8* %7
%22 = load i8, i8* %7
%23 = sext i8 %22 to i32
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = icmp sgt i32 %24, 8
br i1 %25, label %26, label %38
26: ; preds = %19
%27 = load i32, i32* %4
%28 = icmp slt i32 %27, 128
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load i8, i8* %7
%31 = sext i8 %30 to i32
%32 = load i32, i32* %2
%33 = add i32 %31, %32
%34 = trunc i32 %33 to i8
store i8 %34, i8* %7
%35 = load i8, i8* %7
%36 = load i32*, i32** %6
%37 = call i32 @fputc(i8 signext %35, i32* %36)
br label %38
38: ; preds = %29, %26, %19
br label %39
39: ; preds = %38
%40 = load i32*, i32** %5
%41 = call i32 @feof(i32* %40)
%42 = icmp ne i32 %41, 0
%43 = xor i1 %42, true
br i1 %43, label %19, label %44
44: ; preds = %39
%45 = load i32*, i32** %5
%46 = call i32 @rewind(i32* %45)
%47 = load i32*, i32** %6
%48 = call i32 @rewind(i32* %47)
%49 = load i32*, i32** %5
%50 = call i32 @fclose(i32* %49)
%51 = load i32*, i32** %6
%52 = call i32 @fclose(i32* %51)
br label %59
53: ; preds = %1
%54 = call i32 @printf(i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.5, i64 0, i64 0))
%55 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %55, i32** %8
%56 = load i32*, i32** %8
%57 = call i32 @fclose(i32* %56)
%58 = call i32 @exit(i32 -1)
unreachable
59: ; preds = %44
%60 = call i32 @system(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"hello.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"obf.txt\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [7 x i8] c"Error:\00"
@.str.6 = [2 x i8] c"w\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 @crypt(i32 %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 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 ([8 x i8], [8 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 = icmp sgt i8 %13, 8
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = add i8 %13, %8
%17 = tail call i32 @fputc(i8 signext %16, i32* %5)
br label %18
18: ; preds = %15, %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, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%30 = tail call i32 @fclose(i32* %29)
%31 = tail call i32 @exit(i32 -1)
unreachable
}