#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 data_set_t {
  int dummy;
};

/* Variables and functions */
scalar_t__ file_load(char *, char **, size_t *);
int /*<<< orphan*/ load_data_from_buf(struct data_set_t *, char *, size_t, int,
                                      int);
int /*<<< orphan*/ perror(char *);
extern int load_data_from_file(struct data_set_t *data, char *filename,
                               int shortname, int verbose) {
  char *filebuf;
  size_t fsize;
  if (file_load(filename, &filebuf, &fsize)) {
    perror("Error opening dataset file");
    return -1;
  }
  load_data_from_buf(data, filebuf, fsize, shortname, verbose);
  return 0;
}


x86 assembly (clang, -O0):
<load_data_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <file_load@plt>
cmp    $0x0,%rax
je     1179 <load_data_from_file+0x49>
lea    0xe98(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1198 <load_data_from_file+0x68>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1030 <load_data_from_buf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_data_from_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1050 <file_load@plt>
test   %rax,%rax
jne    1179 <load_data_from_file+0x49>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rdx
mov    %rbx,%rdi
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1030 <load_data_from_buf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe80(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%eax
jmp    1170 <load_data_from_file+0x40>

LLVM IR (-O0):
%struct.data_set_t = type { i32 }
@.str = [27 x i8] c"Error opening dataset file\00"
define i32 @load_data_from_file(%struct.data_set_t* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.data_set_t*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
store %struct.data_set_t* %0, %struct.data_set_t** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%12 = load i8*, i8** %7
%13 = call i64 @file_load(i8* %12, i8** %10, i64* %11)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %4
%16 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %24
17: ; preds = %4
%18 = load %struct.data_set_t*, %struct.data_set_t** %6
%19 = load i8*, i8** %10
%20 = load i64, i64* %11
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = call i32 @load_data_from_buf(%struct.data_set_t* %18, i8* %19, i64 %20, i32 %21, i32 %22)
store i32 0, i32* %5
br label %24
24: ; preds = %17, %15
%25 = load i32, i32* %5
ret i32 %25
}

LLVM IR (-O2):
%struct.data_set_t = type { i32 }
@.str = [27 x i8] c"Error opening dataset file\00"
define i32 @load_data_from_file(%struct.data_set_t* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = bitcast i8** %5 to i8*
%8 = bitcast i64* %6 to i8*
%9 = call i64 @file_load(i8* %1, i8** %5, i64* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %4
%12 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %17
13: ; preds = %4
%14 = load i8*, i8** %5
%15 = load i64, i64* %6
%16 = call i32 @load_data_from_buf(%struct.data_set_t* %0, i8* %14, i64 %15, i32 %2, i32 %3)
br label %17
17: ; preds = %13, %11
%18 = phi i32 [ -1, %11 ], [ 0, %13 ]
ret i32 %18
}