#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 */
unsigned int base64_to_hex(unsigned char *, unsigned char *, unsigned int,
                           unsigned int);
int /*<<< orphan*/ decrypt(unsigned char *, unsigned int, unsigned char *,
                           unsigned char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned char *, unsigned int, int,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
unsigned int get_file_size(int /*<<< orphan*/ *);
int /*<<< orphan*/ hex_to_str(unsigned char *, unsigned char *, unsigned int,
                              unsigned int);
unsigned char *malloc(int);
int /*<<< orphan*/ printf(char *, unsigned char *);
int main() {
  unsigned char *input_b64 = NULL, *input_hex = NULL, *input_str = NULL,
                *output_str = NULL;
  unsigned int hex_len = 0;
  unsigned int file_size = 0;
  unsigned char *key = "YELLOW SUBMARINE";
  FILE *file = fopen("7.txt", "r");
  file_size = get_file_size(file);
  input_b64 = malloc(sizeof(char) * file_size + 1);
  input_hex = malloc(sizeof(char) * file_size * 1.5);
  input_str = malloc(sizeof(char) * (file_size * 1.5));
  output_str = malloc(sizeof(char) * (file_size * 1.5) / 2 + 1);
  fread(input_b64, file_size, 1, file);
  hex_len = base64_to_hex(input_b64, input_hex, file_size + 1, file_size * 1.5);
  hex_to_str(input_hex, input_str, hex_len, hex_len / 2);
  decrypt(input_str, hex_len / 2, key, output_str);
  output_str[hex_len / 2] = '\0';
  printf("%s", output_str);
  free(input_b64);
  free(input_hex);
  free(input_str);
  free(output_str);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    0xe4b(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe51(%rip),%rdi
lea    0xe50(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   10a0 <get_file_size@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
add    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x28(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xded(%rip),%xmm1
movsd  %xmm1,-0x40(%rbp)
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1090 <malloc@plt>
movsd  -0x40(%rbp),%xmm1
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%eax
cvtsi2sd %rax,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1090 <malloc@plt>
movsd  -0x40(%rbp),%xmm1
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%eax
cvtsi2sd %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xda8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xda4(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x38(%rbp),%rcx
mov    $0x1,%edx
call   1060 <fread@plt>
movsd  -0x40(%rbp),%xmm1
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
cvtsi2sd %rax,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,%ecx
call   1080 <base64_to_hex@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x24(%rbp),%ecx
shr    $0x1,%ecx
call   1050 <hex_to_str@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
shr    $0x1,%esi
mov    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <decrypt@plt>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
shr    $0x1,%ecx
mov    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rsi
lea    0xd2a(%rip),%rdi
call   1070 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <free@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@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
sub    $0x18,%rsp
lea    0xe84(%rip),%rdi
lea    0xe83(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   10a0 <get_file_size@plt>
mov    %eax,%r13d
lea    0x1(%r13),%edi
mov    %edi,0xc(%rsp)
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %r13d,%eax
cvtsi2sd %rax,%xmm0
mulsd  0xe21(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
cvttsd2si %xmm0,%ebx
mov    %ebx,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    %ebx,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
movsd  0xe03(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  0xdfd(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r13d,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1060 <fread@plt>
cvttsd2si 0x10(%rsp),%rcx
mov    %r14,%rdi
mov    %r15,%rsi
mov    0xc(%rsp),%edx
call   1080 <base64_to_hex@plt>
mov    %eax,%ebp
shr    %rbp
mov    %r15,%rdi
mov    %r12,%rsi
mov    %eax,%edx
mov    %ebp,%ecx
call   1050 <hex_to_str@plt>
lea    0xdb5(%rip),%rdx
mov    %r12,%rdi
mov    %ebp,%esi
mov    %rbx,%rcx
call   1030 <decrypt@plt>
movb   $0x0,(%rbx,%rbp,1)
lea    0xdb6(%rip),%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1040 <free@plt>
mov    %r12,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"YELLOW SUBMARINE\00"
@.str.1 = [6 x i8] c"7.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
store i8* null, i8** %1
store i8* null, i8** %2
store i8* null, i8** %3
store i8* null, i8** %4
store i32 0, i32* %5
store i32 0, i32* %6
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %7
%9 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 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* %9, i32** %8
%10 = load i32*, i32** %8
%11 = call i32 @get_file_size(i32* %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = zext i32 %12 to i64
%14 = mul i64 1, %13
%15 = add i64 %14, 1
%16 = trunc i64 %15 to i32
%17 = call i8* @malloc(i32 %16)
store i8* %17, i8** %1
%18 = load i32, i32* %6
%19 = zext i32 %18 to i64
%20 = mul i64 1, %19
%21 = uitofp i64 %20 to double
%22 = fmul double %21, 1.500000e+00
%23 = fptosi double %22 to i32
%24 = call i8* @malloc(i32 %23)
store i8* %24, i8** %2
%25 = load i32, i32* %6
%26 = uitofp i32 %25 to double
%27 = fmul double %26, 1.500000e+00
%28 = fmul double 1.000000e+00, %27
%29 = fptosi double %28 to i32
%30 = call i8* @malloc(i32 %29)
store i8* %30, i8** %3
%31 = load i32, i32* %6
%32 = uitofp i32 %31 to double
%33 = fmul double %32, 1.500000e+00
%34 = fmul double 1.000000e+00, %33
%35 = fdiv double %34, 2.000000e+00
%36 = fadd double %35, 1.000000e+00
%37 = fptosi double %36 to i32
%38 = call i8* @malloc(i32 %37)
store i8* %38, i8** %4
%39 = load i8*, i8** %1
%40 = load i32, i32* %6
%41 = load i32*, i32** %8
%42 = call i32 @fread(i8* %39, i32 %40, i32 1, i32* %41)
%43 = load i8*, i8** %1
%44 = load i8*, i8** %2
%45 = load i32, i32* %6
%46 = add i32 %45, 1
%47 = load i32, i32* %6
%48 = uitofp i32 %47 to double
%49 = fmul double %48, 1.500000e+00
%50 = fptoui double %49 to i32
%51 = call i32 @base64_to_hex(i8* %43, i8* %44, i32 %46, i32 %50)
store i32 %51, i32* %5
%52 = load i8*, i8** %2
%53 = load i8*, i8** %3
%54 = load i32, i32* %5
%55 = load i32, i32* %5
%56 = udiv i32 %55, 2
%57 = call i32 @hex_to_str(i8* %52, i8* %53, i32 %54, i32 %56)
%58 = load i8*, i8** %3
%59 = load i32, i32* %5
%60 = udiv i32 %59, 2
%61 = load i8*, i8** %7
%62 = load i8*, i8** %4
%63 = call i32 @decrypt(i8* %58, i32 %60, i8* %61, i8* %62)
%64 = load i8*, i8** %4
%65 = load i32, i32* %5
%66 = udiv i32 %65, 2
%67 = zext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %64, i64 %67
store i8 0, i8* %68
%69 = load i8*, i8** %4
%70 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %69)
%71 = load i8*, i8** %1
%72 = call i32 @free(i8* %71)
%73 = load i8*, i8** %2
%74 = call i32 @free(i8* %73)
%75 = load i8*, i8** %3
%76 = call i32 @free(i8* %75)
%77 = load i8*, i8** %4
%78 = call i32 @free(i8* %77)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"YELLOW SUBMARINE\00"
@.str.1 = [6 x i8] c"7.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call i32 @get_file_size(i32* %1)
%3 = add i32 %2, 1
%4 = tail call i8* @malloc(i32 %3)
%5 = uitofp i32 %2 to double
%6 = fmul double %5, 1.500000e+00
%7 = fptosi double %6 to i32
%8 = tail call i8* @malloc(i32 %7)
%9 = tail call i8* @malloc(i32 %7)
%10 = fmul double %6, 5.000000e-01
%11 = fadd double %10, 1.000000e+00
%12 = fptosi double %11 to i32
%13 = tail call i8* @malloc(i32 %12)
%14 = tail call i32 @fread(i8* %4, i32 %2, i32 1, i32* %1)
%15 = fptoui double %6 to i32
%16 = tail call i32 @base64_to_hex(i8* %4, i8* %8, i32 %3, i32 %15)
%17 = lshr i32 %16, 1
%18 = tail call i32 @hex_to_str(i8* %8, i8* %9, i32 %16, i32 %17)
%19 = tail call i32 @decrypt(i8* %9, i32 %17, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %13)
%20 = zext i32 %17 to i64
%21 = getelementptr inbounds i8, i8* %13, i64 %20
store i8 0, i8* %21
%22 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%23 = tail call i32 @free(i8* %4)
%24 = tail call i32 @free(i8* %8)
%25 = tail call i32 @free(i8* %9)
%26 = tail call i32 @free(i8* %13)
ret i32 0
}