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

/* Variables and functions */
int check(int /*<<< orphan*/, int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ dec(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ realloc(char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char *argv[]) {
  int v3, v4, v7, v8, v9, v10, v12, v14, v15, v16, v17, v18, v19, v20, v21;
  unsigned int v13;
  char v11;
  signed int v5;
  char path[50];
  if (argc < 2) {
    printf("Usage: ultra_rev [path]\n");
    exit(0);
  }
  strncpy(path, argv[1], 30);
  strcat(path + strlen(path), "/execute_me_enc");
  printf("path : %s\n", path);
  FILE *fp = fopen(path, "r");
  char *allData;
  int cnt = 0;
  int arraySize;
  if (fp == NULL) {
    printf("*** File open error ***\n");
    exit(1);
  }
  allData = (char *)malloc(1);
  while (!feof(fp)) {
    allData = (char *)realloc(allData, cnt + 1);
    fscanf(fp, "%c", &allData[cnt]);
    cnt++;
  }
  arraySize = cnt;
  v3 = 0x60271070;
  v4 = 0;
  v5 = arraySize;
  v8 = v5;
  v9 = v5 - 3;
  v10 = 1;
  if (*(char *)(allData) == 0x62) {
    if (*(allData) + *(allData + 1) == 210) {
      if (check(0, 0, v8, allData) == 0xdead) {
        printf("Correct File!\n\n");
        dec(argv[1], allData);
        return 0;
      }
    }
  }
  printf("Not Correct File\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11f8 <main+0x38>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x90(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xb0(%rbp),%rdi
cltq
add    %rax,%rdi
lea    0xddb(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x90(%rbp),%rsi
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x98(%rbp)
movl   $0x0,-0xa4(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    12a2 <main+0xe2>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,-0xa0(%rbp)
mov    -0x98(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12d4 <main+0x114>
jmp    1328 <main+0x168>
mov    -0xa0(%rbp),%rdi
mov    -0xa4(%rbp),%esi
add    $0x1,%esi
call   10a0 <realloc@plt>
mov    %rax,-0xa0(%rbp)
mov    -0x98(%rbp),%rdi
mov    -0xa0(%rbp),%rdx
movslq -0xa4(%rbp),%rax
add    %rax,%rdx
lea    0xd40(%rip),%rsi
call   1070 <fscanf@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    12b3 <main+0xf3>
mov    -0xa4(%rbp),%eax
mov    %eax,-0xa8(%rbp)
movl   $0x60271070,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0xa8(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x58(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0xa0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
jne    13ec <main+0x22c>
mov    -0xa0(%rbp),%rax
movsbl (%rax),%eax
mov    -0xa0(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
add    %ecx,%eax
cmp    $0xd2,%eax
jne    13e7 <main+0x227>
mov    -0x20(%rbp),%edx
mov    -0xa0(%rbp),%rcx
xor    %esi,%esi
mov    %esi,%edi
call   10c0 <check@plt>
cmp    $0xdead,%eax
jne    13e2 <main+0x222>
lea    0xc97(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0xa0(%rbp),%rsi
call   1040 <dec@plt>
movl   $0x0,-0x4(%rbp)
jmp    1401 <main+0x241>
jmp    13e7 <main+0x227>
jmp    13ec <main+0x22c>
lea    0xc6f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x1,%edi
jle    12fa <main+0x12a>
mov    %rsi,%r14
mov    0x8(%rsi),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rdi
lea    0xded(%rip),%rsi
call   10e0 <strcat@plt>
lea    0xdf1(%rip),%rdi
xor    %r15d,%r15d
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xde8(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     130d <main+0x13d>
mov    %rax,%r12
mov    $0x1,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    12a2 <main+0xd2>
xor    %r15d,%r15d
lea    0xdb3(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    %r15,%rbp
add    $0x1,%r15
mov    %rbx,%rdi
mov    %r15d,%esi
call   10b0 <realloc@plt>
mov    %rax,%rbx
add    %rax,%rbp
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1080 <fscanf@plt>
mov    %r12,%rdi
call   1090 <feof@plt>
test   %eax,%eax
je     1270 <main+0xa0>
cmpb   $0x62,(%rbx)
jne    12dd <main+0x10d>
cmpb   $0x70,0x1(%rbx)
jne    12dd <main+0x10d>
xor    %edi,%edi
xor    %esi,%esi
mov    %r15d,%edx
mov    %rbx,%rcx
call   10d0 <check@plt>
cmp    $0xdead,%eax
jne    12dd <main+0x10d>
lea    0xd67(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%r14),%rdi
mov    %rbx,%rsi
call   1050 <dec@plt>
jmp    12e9 <main+0x119>
lea    0xd3c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd57(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
lea    0xd2c(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Usage: ultra_rev [path]\0A\00"
@.str.1 = [16 x i8] c"/execute_me_enc\00"
@.str.2 = [11 x i8] c"path : %s\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [25 x i8] c"*** File open error ***\0A\00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [16 x i8] c"Correct File!\0A\0A\00"
@.str.7 = [18 x i8] c"Not Correct File\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i8
%23 = alloca i32
%24 = alloca [50 x i8]
%25 = alloca i32*
%26 = alloca i8*
%27 = alloca i32
%28 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 2
br i1 %30, label %31, label %34
31: ; preds = %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %2
%35 = getelementptr inbounds [50 x i8], [50 x i8]* %24, i64 0, i64 0
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @strncpy(i8* %35, i8* %38, i32 30)
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %24, i64 0, i64 0
%41 = getelementptr inbounds [50 x i8], [50 x i8]* %24, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %40, i64 %43
%45 = call i32 @strcat(i8* %44, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%46 = getelementptr inbounds [50 x i8], [50 x i8]* %24, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %46)
%48 = getelementptr inbounds [50 x i8], [50 x i8]* %24, i64 0, i64 0
%49 = call i32* @fopen(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %49, i32** %25
store i32 0, i32* %27
%50 = load i32*, i32** %25
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %55
52: ; preds = %34
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %34
%56 = call i64 @malloc(i32 1)
%57 = inttoptr i64 %56 to i8*
store i8* %57, i8** %26
br label %58
58: ; preds = %63, %55
%59 = load i32*, i32** %25
%60 = call i32 @feof(i32* %59)
%61 = icmp ne i32 %60, 0
%62 = xor i1 %61, true
br i1 %62, label %63, label %77
63: ; preds = %58
%64 = load i8*, i8** %26
%65 = load i32, i32* %27
%66 = add nsw i32 %65, 1
%67 = call i64 @realloc(i8* %64, i32 %66)
%68 = inttoptr i64 %67 to i8*
store i8* %68, i8** %26
%69 = load i32*, i32** %25
%70 = load i8*, i8** %26
%71 = load i32, i32* %27
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %70, i64 %72
%74 = call i32 @fscanf(i32* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %73)
%75 = load i32, i32* %27
%76 = add nsw i32 %75, 1
store i32 %76, i32* %27
br label %58
77: ; preds = %58
%78 = load i32, i32* %27
store i32 %78, i32* %28
store i32 1613172848, i32* %6
store i32 0, i32* %7
%79 = load i32, i32* %28
store i32 %79, i32* %23
%80 = load i32, i32* %23
store i32 %80, i32* %9
%81 = load i32, i32* %23
%82 = sub nsw i32 %81, 3
store i32 %82, i32* %10
store i32 1, i32* %11
%83 = load i8*, i8** %26
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = icmp eq i32 %85, 98
br i1 %86, label %87, label %111
87: ; preds = %77
%88 = load i8*, i8** %26
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
%91 = load i8*, i8** %26
%92 = getelementptr inbounds i8, i8* %91, i64 1
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = add nsw i32 %90, %94
%96 = icmp eq i32 %95, 210
br i1 %96, label %97, label %110
97: ; preds = %87
%98 = load i32, i32* %9
%99 = load i8*, i8** %26
%100 = call i32 @check(i32 0, i32 0, i32 %98, i8* %99)
%101 = icmp eq i32 %100, 57005
br i1 %101, label %102, label %109
102: ; preds = %97
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%104 = load i8**, i8*** %5
%105 = getelementptr inbounds i8*, i8** %104, i64 1
%106 = load i8*, i8** %105
%107 = load i8*, i8** %26
%108 = call i32 @dec(i8* %106, i8* %107)
store i32 0, i32* %3
br label %113
109: ; preds = %97
br label %110
110: ; preds = %109, %87
br label %111
111: ; preds = %110, %77
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
br label %113
113: ; preds = %111, %102
%114 = load i32, i32* %3
ret i32 %114
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"/execute_me_enc\00"
@.str.2 = [11 x i8] c"path : %s\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.5 = [3 x i8] c"%c\00"
@str = [17 x i8] c"Not Correct File\00"
@str.8 = [15 x i8] c"Correct File!\0A\00"
@str.9 = [24 x i8] c"*** File open error ***\00"
@str.10 = [24 x i8] c"Usage: ultra_rev [path]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.10, i64 0, i64 0))
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strncpy(i8* %4, i8* %11, i32 30)
%13 = call i32 @strlen(i8* %4)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %14
%16 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%18 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %9
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %9
%24 = call i64 @malloc(i32 1)
%25 = inttoptr i64 %24 to i8*
%26 = call i32 @feof(i32* %18)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %42
28: ; preds = %23, %28
%29 = phi i64 [ %31, %28 ], [ 0, %23 ]
%30 = phi i8* [ %34, %28 ], [ %25, %23 ]
%31 = add nuw i64 %29, 1
%32 = trunc i64 %31 to i32
%33 = call i64 @realloc(i8* %30, i32 %32)
%34 = inttoptr i64 %33 to i8*
%35 = getelementptr inbounds i8, i8* %34, i64 %29
%36 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %35)
%37 = call i32 @feof(i32* %18)
%38 = icmp eq i32 %37, 0
br i1 %38, label %28, label %39
39: ; preds = %28
%40 = trunc i64 %31 to i32
%41 = inttoptr i64 %33 to i8*
br label %42
42: ; preds = %39, %23
%43 = phi i8* [ %25, %23 ], [ %41, %39 ]
%44 = phi i32 [ 0, %23 ], [ %40, %39 ]
%45 = load i8, i8* %43
%46 = icmp eq i8 %45, 98
br i1 %46, label %47, label %58
47: ; preds = %42
%48 = getelementptr inbounds i8, i8* %43, i64 1
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 112
br i1 %50, label %51, label %58
51: ; preds = %47
%52 = call i32 @check(i32 0, i32 0, i32 %44, i8* %43)
%53 = icmp eq i32 %52, 57005
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.8, i64 0, i64 0))
%56 = load i8*, i8** %10
%57 = call i32 @dec(i8* %56, i8* %43)
br label %60
58: ; preds = %47, %51, %42
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %60
60: ; preds = %58, %54
ret i32 0
}