#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_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ remove_all_chars(char *, char);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
char *strchr(char *, char);
scalar_t__ strtoul(char *, char **, int);
unsigned char *data_from_file(const char *filename, int *data_size) {
  FILE *data_file = fopen(filename, "r");
  fseek(data_file, 0L, SEEK_END);
  int file_size = ftell(data_file);
  rewind(data_file);
  char *file_content = (char *)malloc(file_size + 1);
  fread(file_content, 1, file_size, data_file);
  file_content[file_size] = '\0';
  fclose(data_file);
  char *data_string = strchr(file_content, '\\');
  strchr(data_string, ';')[1] = '\0';
  remove_all_chars(data_string, '\n');
  remove_all_chars(data_string, '"');
  int i = 0;
  *data_size = 0;
  while (data_string[i] == '\\') {
    (*data_size)++;
    i = i + 4;
  }
  unsigned char *data = (unsigned char *)malloc(*data_size);
  int j = 0;
  char current_hex[5] = "0xaa";
  char *endptr;
  for (int i = 0; i < *data_size; i++) {
    memcpy(&(current_hex[2]), &(data_string[(4 * i) + 2]), 2);
    data[j] = (unsigned char)strtoul(current_hex, &endptr, 16);
    j++;
  }
  free(file_content);
  return data;
}


x86 assembly (clang, -O0):
<data_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe25(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2df9(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x28(%rbp),%rdi
mov    $0x5c,%esi
call   1060 <strchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x3b,%esi
call   1060 <strchr@plt>
movb   $0x0,0x1(%rax)
mov    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   10e0 <remove_all_chars@plt>
mov    -0x30(%rbp),%rdi
mov    $0x22,%esi
call   10e0 <remove_all_chars@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    12c7 <data_from_file+0x107>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x34(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x34(%rbp)
jmp    1299 <data_from_file+0xd9>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    0xd1f(%rip),%eax
mov    %eax,-0x49(%rbp)
mov    0xd1a(%rip),%al
mov    %al,-0x45(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    135f <data_from_file+0x19f>
lea    -0x49(%rbp),%rdi
add    $0x2,%rdi
mov    -0x30(%rbp),%rsi
mov    -0x5c(%rbp),%eax
shl    $0x2,%eax
add    $0x2,%eax
cltq
add    %rax,%rsi
mov    $0x2,%edx
call   1090 <memcpy@plt>
lea    -0x49(%rbp),%rdi
lea    -0x58(%rbp),%rsi
mov    $0x10,%edx
call   10d0 <strtoul@plt>
mov    %al,%dl
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12f6 <data_from_file+0x136>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_from_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
lea    0xe28(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
mov    0x2e01(%rip),%rax
mov    (%rax),%edx
xor    %r12d,%r12d
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %rbx,%rdi
call   1080 <ftell@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1070 <rewind@plt>
lea    0x1(%r14),%edi
call   10a0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
movslq %r14d,%rax
movb   $0x0,0x0(%rbp,%rax,1)
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %rbp,0x8(%rsp)
mov    %rbp,%rdi
mov    $0x5c,%esi
call   1060 <strchr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x3b,%esi
call   1060 <strchr@plt>
movb   $0x0,0x1(%rax)
mov    %rbx,%rdi
mov    $0xa,%esi
call   10e0 <remove_all_chars@plt>
mov    %rbx,%rdi
mov    $0x22,%esi
call   10e0 <remove_all_chars@plt>
movl   $0x0,(%r15)
cmpb   $0x5c,(%rbx)
jne    12a1 <data_from_file+0xe1>
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    %r12,%rax
add    $0x1,%r12
mov    %r12d,(%r15)
cmpb   $0x5c,0x4(%rbx,%rax,4)
je     1290 <data_from_file+0xd0>
mov    %r12d,%edi
call   10a0 <malloc@plt>
mov    %rax,%r12
movb   $0x0,0x4(%rsp)
movl   $0x61617830,(%rsp)
cmpl   $0x0,(%r15)
jle    1306 <data_from_file+0x146>
add    $0x2,%rbx
xor    %r13d,%r13d
mov    %rsp,%rbp
lea    0x10(%rsp),%r14
nopl   (%rax)
lea    0x2(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1090 <memcpy@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   10d0 <strtoul@plt>
mov    %al,(%r12,%r13,1)
add    $0x1,%r13
movslq (%r15),%rax
add    $0x4,%rbx
cmp    %rax,%r13
jl     12d0 <data_from_file+0x110>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@__const.data_from_file.current_hex = [5 x i8] c"0xaa\00"
define i8* @data_from_file(i8* nocapture %0, i32* nocapture %1) {
%3 = alloca [5 x i8]
%4 = alloca i8*
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @SEEK_END
%7 = tail call i32 @fseek(i32* %5, i64 0, i32 %6)
%8 = tail call i32 @ftell(i32* %5)
%9 = tail call i32 @rewind(i32* %5)
%10 = add nsw i32 %8, 1
%11 = tail call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
%13 = tail call i32 @fread(i8* %12, i32 1, i32 %8, i32* %5)
%14 = sext i32 %8 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 0, i8* %15
%16 = tail call i32 @fclose(i32* %5)
%17 = tail call i8* @strchr(i8* dereferenceable(1) %12, i8 signext 92)
%18 = tail call i8* @strchr(i8* dereferenceable(1) %17, i8 signext 59)
%19 = getelementptr inbounds i8, i8* %18, i64 1
store i8 0, i8* %19
%20 = tail call i32 @remove_all_chars(i8* %17, i8 signext 10)
%21 = tail call i32 @remove_all_chars(i8* %17, i8 signext 34)
store i32 0, i32* %1
%22 = load i8, i8* %17
%23 = icmp eq i8 %22, 92
br i1 %23, label %24, label %32
24: ; preds = %2, %24
%25 = phi i32 [ %27, %24 ], [ 0, %2 ]
%26 = phi i64 [ %28, %24 ], [ 0, %2 ]
%27 = add nuw nsw i32 %25, 1
store i32 %27, i32* %1
%28 = add nuw nsw i64 %26, 4
%29 = getelementptr inbounds i8, i8* %17, i64 %28
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 92
br i1 %31, label %24, label %32
32: ; preds = %24, %2
%33 = phi i32 [ 0, %2 ], [ %27, %24 ]
%34 = tail call i64 @malloc(i32 %33)
%35 = inttoptr i64 %34 to i8*
%36 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%37 = bitcast i8** %4 to i8*
%38 = load i32, i32* %1
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %32
%41 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 2
br label %44
42: ; preds = %44, %32
%43 = call i32 @free(i8* %12)
ret i8* %35
44: ; preds = %40, %44
%45 = phi i64 [ 0, %40 ], [ %53, %44 ]
%46 = shl nsw i64 %45, 2
%47 = or i64 %46, 2
%48 = getelementptr inbounds i8, i8* %17, i64 %47
%49 = call i32 @memcpy(i8* %41, i8* %48, i32 2)
%50 = call i64 @strtoul(i8* %36, i8** %4, i32 16)
%51 = trunc i64 %50 to i8
%52 = getelementptr inbounds i8, i8* %35, i64 %45
store i8 %51, i8* %52
%53 = add nuw nsw i64 %45, 1
%54 = load i32, i32* %1
%55 = sext i32 %54 to i64
%56 = icmp slt i64 %53, %55
br i1 %56, label %44, label %42
}