#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*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char const *);
int read_b64_file(const char *fname, int header_size, unsigned char **data,
                  int *data_size) {
  int i;
  FILE *in = fopen(fname, "rb");
  if (!in) {
    printf("\nCan't read file %s\n", fname);
    return -2;
  }
  fseek(in, 0, SEEK_END);
  *data_size = ftell(in) - header_size - 2;
  fseek(in, header_size + 2, SEEK_SET);
  *data_size -= ((*data_size) / 78) * 2;
  *data = (unsigned char *)malloc((*data_size) * sizeof(unsigned char));
  if (!(*data)) {
    return -1;
  }
  for (i = 0; i < (*data_size) / 76; i++) {
    fread(*data + 76 * i * sizeof(unsigned char), 1, 76 * sizeof(unsigned char),
          in);
    fseek(in, 2, SEEK_CUR);
  }
  fread(*data + 76 * ((*data_size) / 76) * sizeof(unsigned char), 1,
        ((*data_size) % 76), in);
  fclose(in);
  return 1;
}


x86 assembly (clang, -O0):
<read_b64_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11c2 <read_b64_file+0x52>
mov    -0x10(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1319 <read_b64_file+0x1a9>
mov    -0x38(%rbp),%rdi
mov    0x2e1b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x38(%rbp),%rdi
call   1060 <ftell@plt>
mov    %eax,%ecx
sub    -0x14(%rbp),%ecx
sub    $0x2,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x2,%esi
mov    0x2dd2(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    $0x4e,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
shl    $0x1,%edx
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
movslq (%rax),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1258 <read_b64_file+0xe8>
movl   $0xffffffff,-0x4(%rbp)
jmp    1319 <read_b64_file+0x1a9>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    $0x4c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jge    12cc <read_b64_file+0x15c>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
imul   $0x4c,-0x2c(%rbp),%eax
cltq
shl    $0x0,%rax
add    %rax,%rdi
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4c,%edx
call   1030 <fread@plt>
mov    -0x38(%rbp),%rdi
mov    0x2d2e(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%esi
call   1080 <fseek@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    125f <read_b64_file+0xef>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    $0x4c,%ecx
cltd
idiv   %ecx
imul   $0x4c,%eax,%eax
cltq
shl    $0x0,%rax
add    %rax,%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    $0x4c,%ecx
cltd
idiv   %ecx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_b64_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%r12d
mov    %rdi,%rbp
lea    0xe72(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1282 <read_b64_file+0x112>
mov    %rax,%r13
mov    0x2e42(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %r13,%rdi
call   1060 <ftell@plt>
sub    %r12d,%eax
add    $0xfffffffe,%eax
mov    %eax,(%r14)
add    $0x2,%r12d
mov    0x2e02(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r12d,%esi
call   1080 <fseek@plt>
movslq (%r14),%rax
imul   $0x2df2df2d,%rax,%rcx
shr    $0x20,%rcx
sub    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x6,%ecx
add    %edx,%ecx
lea    (%rax,%rcx,2),%edi
mov    %edi,(%r14)
call   1070 <malloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     1298 <read_b64_file+0x128>
mov    %rax,%rdi
movslq (%r14),%rcx
cmp    $0x4c,%rcx
jl     129f <read_b64_file+0x12f>
xor    %ebp,%ebp
mov    0x2dbb(%rip),%r12
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
add    %rbp,%rdi
mov    $0x1,%esi
mov    $0x4c,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
mov    (%r12),%edx
mov    %r13,%rdi
mov    $0x2,%esi
call   1080 <fseek@plt>
add    $0x1,%rbx
movslq (%r14),%rcx
imul   $0x6bca1af3,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rax
add    %edx,%eax
movslq %eax,%rdx
mov    (%r15),%rdi
add    $0x4c,%rbp
cmp    %rdx,%rbx
jl     1230 <read_b64_file+0xc0>
jmp    12b3 <read_b64_file+0x143>
lea    0xd7a(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    $0xfffffffe,%ebp
jmp    12f4 <read_b64_file+0x184>
mov    $0xffffffff,%ebp
jmp    12f4 <read_b64_file+0x184>
imul   $0x6bca1af3,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rax
add    %edx,%eax
imul   $0x4c,%eax,%eax
cltq
add    %rdi,%rax
movslq %ecx,%rdx
imul   $0x6bca1af3,%rdx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x25,%rcx
add    %esi,%ecx
imul   $0x4c,%ecx,%ecx
sub    %ecx,%edx
mov    $0x1,%ebp
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r13,%rcx
call   1030 <fread@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [21 x i8] c"\0ACan't read file %s\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
define i32 @read_b64_file(i8* %0, i32 %1, i8** %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8** %2, i8*** %8
store i32* %3, i32** %9
%12 = load i8*, i8** %6
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %11
%14 = load i32*, i32** %11
%15 = icmp ne i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %4
%17 = load i8*, i8** %6
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 -2, i32* %5
br label %93
19: ; preds = %4
%20 = load i32*, i32** %11
%21 = load i32, i32* @SEEK_END
%22 = call i32 @fseek(i32* %20, i32 0, i32 %21)
%23 = load i32*, i32** %11
%24 = call i32 @ftell(i32* %23)
%25 = load i32, i32* %7
%26 = sub nsw i32 %24, %25
%27 = sub nsw i32 %26, 2
%28 = load i32*, i32** %9
store i32 %27, i32* %28
%29 = load i32*, i32** %11
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 2
%32 = load i32, i32* @SEEK_SET
%33 = call i32 @fseek(i32* %29, i32 %31, i32 %32)
%34 = load i32*, i32** %9
%35 = load i32, i32* %34
%36 = sdiv i32 %35, 78
%37 = mul nsw i32 %36, 2
%38 = load i32*, i32** %9
%39 = load i32, i32* %38
%40 = sub nsw i32 %39, %37
store i32 %40, i32* %38
%41 = load i32*, i32** %9
%42 = load i32, i32* %41
%43 = sext i32 %42 to i64
%44 = mul i64 %43, 1
%45 = trunc i64 %44 to i32
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to i8*
%48 = load i8**, i8*** %8
store i8* %47, i8** %48
%49 = load i8**, i8*** %8
%50 = load i8*, i8** %49
%51 = icmp ne i8* %50, null
br i1 %51, label %53, label %52
52: ; preds = %19
store i32 -1, i32* %5
br label %93
53: ; preds = %19
store i32 0, i32* %10
br label %54
54: ; preds = %73, %53
%55 = load i32, i32* %10
%56 = load i32*, i32** %9
%57 = load i32, i32* %56
%58 = sdiv i32 %57, 76
%59 = icmp slt i32 %55, %58
br i1 %59, label %60, label %76
60: ; preds = %54
%61 = load i8**, i8*** %8
%62 = load i8*, i8** %61
%63 = load i32, i32* %10
%64 = mul nsw i32 76, %63
%65 = sext i32 %64 to i64
%66 = mul i64 %65, 1
%67 = getelementptr inbounds i8, i8* %62, i64 %66
%68 = load i32*, i32** %11
%69 = call i32 @fread(i8* %67, i32 1, i32 76, i32* %68)
%70 = load i32*, i32** %11
%71 = load i32, i32* @SEEK_CUR
%72 = call i32 @fseek(i32* %70, i32 2, i32 %71)
br label %73
73: ; preds = %60
%74 = load i32, i32* %10
%75 = add nsw i32 %74, 1
store i32 %75, i32* %10
br label %54
76: ; preds = %54
%77 = load i8**, i8*** %8
%78 = load i8*, i8** %77
%79 = load i32*, i32** %9
%80 = load i32, i32* %79
%81 = sdiv i32 %80, 76
%82 = mul nsw i32 76, %81
%83 = sext i32 %82 to i64
%84 = mul i64 %83, 1
%85 = getelementptr inbounds i8, i8* %78, i64 %84
%86 = load i32*, i32** %9
%87 = load i32, i32* %86
%88 = srem i32 %87, 76
%89 = load i32*, i32** %11
%90 = call i32 @fread(i8* %85, i32 1, i32 %88, i32* %89)
%91 = load i32*, i32** %11
%92 = call i32 @fclose(i32* %91)
store i32 1, i32* %5
br label %93
93: ; preds = %76, %52, %16
%94 = load i32, i32* %5
ret i32 %94
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [21 x i8] c"\0ACan't read file %s\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
define i32 @read_b64_file(i8* %0, i32 %1, i8** nocapture %2, i32* nocapture %3) {
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %53
9: ; preds = %4
%10 = load i32, i32* @SEEK_END
%11 = tail call i32 @fseek(i32* %5, i32 0, i32 %10)
%12 = tail call i32 @ftell(i32* %5)
%13 = sub i32 -2, %1
%14 = add i32 %13, %12
store i32 %14, i32* %3
%15 = add nsw i32 %1, 2
%16 = load i32, i32* @SEEK_SET
%17 = tail call i32 @fseek(i32* %5, i32 %15, i32 %16)
%18 = load i32, i32* %3
%19 = sdiv i32 %18, -78
%20 = shl nsw i32 %19, 1
%21 = add i32 %20, %18
store i32 %21, i32* %3
%22 = tail call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %2
%24 = icmp eq i64 %22, 0
br i1 %24, label %53, label %25
25: ; preds = %9
%26 = load i32, i32* %3
%27 = sdiv i32 %26, 76
%28 = icmp sgt i32 %26, 75
br i1 %28, label %29, label %43
29: ; preds = %25, %29
%30 = phi i8* [ %42, %29 ], [ %23, %25 ]
%31 = phi i64 [ %37, %29 ], [ 0, %25 ]
%32 = mul nuw nsw i64 %31, 76
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = tail call i32 @fread(i8* %33, i32 1, i32 76, i32* %5)
%35 = load i32, i32* @SEEK_CUR
%36 = tail call i32 @fseek(i32* %5, i32 2, i32 %35)
%37 = add nuw nsw i64 %31, 1
%38 = load i32, i32* %3
%39 = sdiv i32 %38, 76
%40 = sext i32 %39 to i64
%41 = icmp slt i64 %37, %40
%42 = load i8*, i8** %2
br i1 %41, label %29, label %43
43: ; preds = %29, %25
%44 = phi i8* [ %23, %25 ], [ %42, %29 ]
%45 = phi i32 [ %26, %25 ], [ %38, %29 ]
%46 = phi i32 [ %27, %25 ], [ %39, %29 ]
%47 = mul nsw i32 %46, 76
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %44, i64 %48
%50 = srem i32 %45, 76
%51 = tail call i32 @fread(i8* %49, i32 1, i32 %50, i32* %5)
%52 = tail call i32 @fclose(i32* %5)
br label %53
53: ; preds = %9, %43, %7
%54 = phi i32 [ 1, %43 ], [ -2, %7 ], [ -1, %9 ]
ret i32 %54
}