#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 */
struct edges_collector_t {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, size_t, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
char *malloc(size_t);
struct edges_collector_t *pmc_api_learn_model(char *, int /*<<< orphan*/, int,
                                              int /*<<< orphan*/, int, int, int,
                                              int /*<<< orphan*/);
int main(int argc, char **argv) {
  size_t f_size;
  FILE *f;
  char *data_buf;
  struct edges_collector_t *ed_coll;
  f = fopen("../datasets/2dchess_1000p_1000v_10dim_0err.float", "r");
  if (!f)
    return -1;
  fseek(f, 0, SEEK_END);
  f_size = ftell(f);
  fseek(f, 0, SEEK_SET);
  data_buf = malloc(f_size);
  if (fread(data_buf, f_size, 1, f) != 1)
    return -1;
  fclose(f);
  ed_coll = pmc_api_learn_model(data_buf, 0, 10, 0, 5, 10, 1, 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b4 <main+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    1260 <main+0xf0>
mov    -0x20(%rbp),%rdi
mov    0x2e29(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2df8(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1221 <main+0xb1>
movl   $0xffffffff,-0x4(%rbp)
jmp    1260 <main+0xf0>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
xor    %ecx,%ecx
mov    $0xa,%r9d
mov    $0x5,%r8d
mov    %ecx,%esi
mov    %r9d,%edx
movl   $0x1,(%rsp)
movl   $0x0,0x8(%rsp)
call   1090 <pmc_api_learn_model@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xe82(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1080 <fopen@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
je     1220 <main+0xb0>
mov    %rax,%rbx
mov    0x2e45(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
mov    %rax,%rbp
mov    0x2e17(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %rbp,%rdi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1220 <main+0xb0>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xa,%edx
xor    %ecx,%ecx
mov    $0x5,%r8d
mov    $0xa,%r9d
push   $0x0
push   $0x1
call   1090 <pmc_api_learn_model@plt>
add    $0x10,%rsp
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.edges_collector_t = type { i32 }
@.str = [49 x i8] c"../datasets/2dchess_1000p_1000v_10dim_0err.float\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %17, label %5
5: ; preds = %2
%6 = load i32, i32* @SEEK_END
%7 = tail call i32 @fseek(i32* %3, i32 0, i32 %6)
%8 = tail call i64 @ftell(i32* %3)
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @fseek(i32* %3, i32 0, i32 %9)
%11 = tail call i8* @malloc(i64 %8)
%12 = tail call i32 @fread(i8* %11, i64 %8, i32 1, i32* %3)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %5
%15 = tail call i32 @fclose(i32* %3)
%16 = tail call %struct.edges_collector_t* @pmc_api_learn_model(i8* %11, i32 0, i32 10, i32 0, i32 5, i32 10, i32 1, i32 0)
br label %17
17: ; preds = %5, %2, %14
%18 = phi i32 [ 0, %14 ], [ -1, %2 ], [ -1, %5 ]
ret i32 %18
}