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

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int add_media_extention(int /*<<< orphan*/ *, unsigned char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
unsigned char *malloc(int);
int add_coulton(X509 *cert) {
  unsigned char *data;
  int datalen;
  int ret;
  FILE *f;
  f = fopen("Mandelbrot_Set.mp3", "rb");
  if (!f)
    return -1;
  fseek(f, 0, SEEK_END);
  datalen = ftell(f);
  fseek(f, 0, SEEK_SET);
  data = malloc(datalen);
  if (!data)
    return -1;
  fread(data, 1, datalen, f);
  fclose(f);
  ret = add_media_extention(cert, data, datalen);
  free(data);
  return ret;
}


x86 assembly (clang, -O0):
<add_coulton>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe6d(%rip),%rdi
lea    0xe79(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ba <add_coulton+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1251 <add_coulton+0xd1>
mov    -0x28(%rbp),%rdi
mov    0x2e23(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x28(%rbp),%rdi
call   1070 <ftell@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2df3(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x1c(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1211 <add_coulton+0x91>
movl   $0xffffffff,-0x4(%rbp)
jmp    1251 <add_coulton+0xd1>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1060 <add_media_extention@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_coulton>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe6f(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     121d <add_coulton+0x9d>
mov    %rax,%rbx
mov    0x2e3c(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %eax,%r15d
mov    0x2e0e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r15d,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     121d <add_coulton+0x9d>
mov    %rax,%rbp
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r15d,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   1060 <add_media_extention@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
jmp    1222 <add_coulton+0xa2>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Mandelbrot_Set.mp3\00"
@.str.1 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @add_coulton(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32* %0, i32** %3
%8 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %7
%9 = load i32*, i32** %7
%10 = icmp ne i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %1
store i32 -1, i32* %2
br label %40
12: ; preds = %1
%13 = load i32*, i32** %7
%14 = load i32, i32* @SEEK_END
%15 = call i32 @fseek(i32* %13, i32 0, i32 %14)
%16 = load i32*, i32** %7
%17 = call i32 @ftell(i32* %16)
store i32 %17, i32* %5
%18 = load i32*, i32** %7
%19 = load i32, i32* @SEEK_SET
%20 = call i32 @fseek(i32* %18, i32 0, i32 %19)
%21 = load i32, i32* %5
%22 = call i8* @malloc(i32 %21)
store i8* %22, i8** %4
%23 = load i8*, i8** %4
%24 = icmp ne i8* %23, null
br i1 %24, label %26, label %25
25: ; preds = %12
store i32 -1, i32* %2
br label %40
26: ; preds = %12
%27 = load i8*, i8** %4
%28 = load i32, i32* %5
%29 = load i32*, i32** %7
%30 = call i32 @fread(i8* %27, i32 1, i32 %28, i32* %29)
%31 = load i32*, i32** %7
%32 = call i32 @fclose(i32* %31)
%33 = load i32*, i32** %3
%34 = load i8*, i8** %4
%35 = load i32, i32* %5
%36 = call i32 @add_media_extention(i32* %33, i8* %34, i32 %35)
store i32 %36, i32* %6
%37 = load i8*, i8** %4
%38 = call i32 @free(i8* %37)
%39 = load i32, i32* %6
store i32 %39, i32* %2
br label %40
40: ; preds = %26, %25, %11
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@.str = [19 x i8] c"Mandelbrot_Set.mp3\00"
@.str.1 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @add_coulton(i32* %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = load i32, i32* @SEEK_END
%6 = tail call i32 @fseek(i32* %2, i32 0, i32 %5)
%7 = tail call i32 @ftell(i32* %2)
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %2, i32 0, i32 %8)
%10 = tail call i8* @malloc(i32 %7)
%11 = icmp eq i8* %10, null
br i1 %11, label %17, label %12
12: ; preds = %4
%13 = tail call i32 @fread(i8* %10, i32 1, i32 %7, i32* %2)
%14 = tail call i32 @fclose(i32* %2)
%15 = tail call i32 @add_media_extention(i32* %0, i8* %10, i32 %7)
%16 = tail call i32 @free(i8* %10)
br label %17
17: ; preds = %4, %1, %12
%18 = phi i32 [ %15, %12 ], [ -1, %1 ], [ -1, %4 ]
ret i32 %18
}