#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_SET;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int fread(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
void load_float_dataset(const char *dir, const char *file, int nbp, int s,
                        int bla, float *into) {
  int i;
  FILE *fid;
  char *filename = (char *)malloc(strlen(dir) + strlen(file) + 4);
  do {
    if (!(filename))
      do {
        fprintf(stderr, "Assertion failed: %s:%d\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/szagoruyko/infimnist.torch/"
                "refs/heads/master/infimnist.c",
                84);
        abort();
      } while (0);
  } while (0);
  strcpy(filename, dir);
  strcat(filename, "/");
  strcat(filename, file);
  fid = fopen(filename, "rb");
  do {
    if (!(fid)) {
      fprintf(stderr, "Cannot open file \"%s\"\n", filename);
      do {
        fprintf(stderr, "Assertion failed: %s:%d\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/szagoruyko/infimnist.torch/"
                "refs/heads/master/infimnist.c",
                89);
        abort();
      } while (0);
    }
  } while (0);
  fseek(fid, bla, SEEK_SET);
  for (i = 0; i < nbp; i++) {
    int r = fread(into, sizeof(float), s, fid);
    do {
      if (!(r == s))
        do {
          fprintf(stderr, "Assertion failed: %s:%d\n",
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/szagoruyko/"
                  "infimnist.torch/refs/heads/master/infimnist.c",
                  94);
          abort();
        } while (0);
    } while (0);
    into += s;
  }
  fclose(fid);
  free(filename);
}


x86 assembly (clang, -O0):
<load_float_dataset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x50(%rbp),%rdi
add    %rax,%rdi
add    $0x4,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1232 <load_float_dataset+0x82>
jmp    1208 <load_float_dataset+0x58>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
lea    0xde8(%rip),%rsi
lea    0xdfa(%rip),%rdx
mov    $0x54,%ecx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    1237 <load_float_dataset+0x87>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x40(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   10d0 <strcat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10d0 <strcat@plt>
mov    -0x40(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12c5 <load_float_dataset+0x115>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rdx
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
lea    0xd55(%rip),%rsi
lea    0xd67(%rip),%rdx
mov    $0x59,%ecx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    12ca <load_float_dataset+0x11a>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2d00(%rip),%rax
mov    (%rax),%edx
call   10b0 <fseek@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    136d <load_float_dataset+0x1bd>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    $0x4,%esi
call   1060 <fread@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1345 <load_float_dataset+0x195>
jmp    131b <load_float_dataset+0x16b>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
lea    0xcd5(%rip),%rsi
lea    0xce7(%rip),%rdx
mov    $0x5e,%ecx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    134a <load_float_dataset+0x19a>
mov    -0x18(%rbp),%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12e6 <load_float_dataset+0x136>
mov    -0x38(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_float_dataset>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%rbx
mov    %r8d,0x4(%rsp)
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%r13
mov    %rdi,%r12
call   1080 <strlen@plt>
mov    %rax,%r15
mov    %r13,%rdi
call   1080 <strlen@plt>
lea    (%r15,%rax,1),%rdi
add    $0x4,%rdi
call   10a0 <malloc@plt>
test   %rax,%rax
je     12c8 <load_float_dataset+0x118>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r12,%rsi
call   1050 <strcpy@plt>
lea    0xea3(%rip),%rsi
mov    %r15,%rdi
call   10d0 <strcat@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   10d0 <strcat@plt>
lea    0xe8b(%rip),%rsi
mov    %r15,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     12e6 <load_float_dataset+0x136>
mov    %rax,%r13
mov    0x2d9a(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    0x4(%rsp),%esi
call   10b0 <fseek@plt>
test   %ebp,%ebp
jle    1280 <load_float_dataset+0xd0>
movslq %r14d,%r12
shl    $0x2,%r12
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r14d,%edx
mov    %r13,%rcx
call   1060 <fread@plt>
cmp    %r14d,%eax
jne    129e <load_float_dataset+0xee>
add    %r12,%rbx
add    $0xffffffff,%ebp
jne    1260 <load_float_dataset+0xb0>
mov    %r13,%rdi
call   1070 <fclose@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
lea    0xd52(%rip),%rsi
lea    0xd64(%rip),%rdx
mov    $0x5e,%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
xor    %eax,%eax
call   1040 <abort@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
lea    0xd28(%rip),%rsi
lea    0xd3a(%rip),%rdx
mov    $0x54,%ecx
jmp    12ba <load_float_dataset+0x10a>
mov    0x2cf3(%rip),%rbx
mov    (%rbx),%edi
lea    0xdbb(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
lea    0xcf7(%rip),%rsi
lea    0xd09(%rip),%rdx
mov    $0x59,%ecx
jmp    12ba <load_float_dataset+0x10a>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Assertion failed: %s:%d\0A\00"
@.str.1 = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/szagoruyko/infimnist.torch/refs/heads/master/infimnist.c\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [23 x i8] c"Cannot open file \22%s\22\0A\00"
@SEEK_SET = global i32 0
define void @load_float_dataset(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, float* %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float*
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i8*
%16 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store float* %5, float** %12
%17 = load i8*, i8** %7
%18 = call i64 @strlen(i8* %17)
%19 = load i8*, i8** %8
%20 = call i64 @strlen(i8* %19)
%21 = add nsw i64 %18, %20
%22 = add nsw i64 %21, 4
%23 = call i64 @malloc(i64 %22)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %15
br label %25
25: ; preds = %6
%26 = load i8*, i8** %15
%27 = icmp ne i8* %26, null
br i1 %27, label %34, label %28
28: ; preds = %25
br label %29
29: ; preds = %28
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.1, i64 0, i64 0), i32 84)
%32 = call i32 (...) @abort()
unreachable
33: ; No predecessors!
br label %34
34: ; preds = %33, %25
br label %35
35: ; preds = %34
%36 = load i8*, i8** %15
%37 = load i8*, i8** %7
%38 = call i32 @strcpy(i8* %36, i8* %37)
%39 = load i8*, i8** %15
%40 = call i32 @strcat(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%41 = load i8*, i8** %15
%42 = load i8*, i8** %8
%43 = call i32 @strcat(i8* %41, i8* %42)
%44 = load i8*, i8** %15
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %45, i32** %14
br label %46
46: ; preds = %35
%47 = load i32*, i32** %14
%48 = icmp ne i32* %47, null
br i1 %48, label %58, label %49
49: ; preds = %46
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %15
%52 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %49
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.1, i64 0, i64 0), i32 89)
%56 = call i32 (...) @abort()
unreachable
57: ; No predecessors!
br label %58
58: ; preds = %57, %46
br label %59
59: ; preds = %58
%60 = load i32*, i32** %14
%61 = load i32, i32* %11
%62 = load i32, i32* @SEEK_SET
%63 = call i32 @fseek(i32* %60, i32 %61, i32 %62)
store i32 0, i32* %13
br label %64
64: ; preds = %89, %59
%65 = load i32, i32* %13
%66 = load i32, i32* %9
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %92
68: ; preds = %64
%69 = load float*, float** %12
%70 = load i32, i32* %10
%71 = load i32*, i32** %14
%72 = call i32 @fread(float* %69, i32 4, i32 %70, i32* %71)
store i32 %72, i32* %16
br label %73
73: ; preds = %68
%74 = load i32, i32* %16
%75 = load i32, i32* %10
%76 = icmp eq i32 %74, %75
br i1 %76, label %83, label %77
77: ; preds = %73
br label %78
78: ; preds = %77
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.1, i64 0, i64 0), i32 94)
%81 = call i32 (...) @abort()
unreachable
82: ; No predecessors!
br label %83
83: ; preds = %82, %73
br label %84
84: ; preds = %83
%85 = load i32, i32* %10
%86 = load float*, float** %12
%87 = sext i32 %85 to i64
%88 = getelementptr inbounds float, float* %86, i64 %87
store float* %88, float** %12
br label %89
89: ; preds = %84
%90 = load i32, i32* %13
%91 = add nsw i32 %90, 1
store i32 %91, i32* %13
br label %64
92: ; preds = %64
%93 = load i32*, i32** %14
%94 = call i32 @fclose(i32* %93)
%95 = load i8*, i8** %15
%96 = call i32 @free(i8* %95)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Assertion failed: %s:%d\0A\00"
@.str.1 = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/szagoruyko/infimnist.torch/refs/heads/master/infimnist.c\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [23 x i8] c"Cannot open file \22%s\22\0A\00"
@SEEK_SET = global i32 0
define void @load_float_dataset(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, float* nocapture %5) {
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%9 = add i64 %7, 4
%10 = add i64 %9, %8
%11 = tail call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i8*
%13 = icmp eq i64 %11, 0
br i1 %13, label %14, label %18
14: ; preds = %6
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.1, i64 0, i64 0), i32 84)
%17 = tail call i32 (...) @abort()
unreachable
18: ; preds = %6
%19 = tail call i32 @strcpy(i8* %12, i8* %0)
%20 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @strcat(i8* %12, i8* %1)
%22 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %30
24: ; preds = %18
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %12)
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.1, i64 0, i64 0), i32 89)
%29 = tail call i32 (...) @abort()
unreachable
30: ; preds = %18
%31 = load i32, i32* @SEEK_SET
%32 = tail call i32 @fseek(i32* %22, i32 %4, i32 %31)
%33 = icmp sgt i32 %2, 0
br i1 %33, label %34, label %49
34: ; preds = %30
%35 = sext i32 %3 to i64
br label %36
36: ; preds = %34, %45
%37 = phi float* [ %5, %34 ], [ %46, %45 ]
%38 = phi i32 [ 0, %34 ], [ %47, %45 ]
%39 = tail call i32 @fread(float* %37, i32 4, i32 %3, i32* %22)
%40 = icmp eq i32 %39, %3
br i1 %40, label %45, label %41
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.1, i64 0, i64 0), i32 94)
%44 = tail call i32 (...) @abort()
unreachable
45: ; preds = %36
%46 = getelementptr inbounds float, float* %37, i64 %35
%47 = add nuw nsw i32 %38, 1
%48 = icmp eq i32 %47, %2
br i1 %48, label %49, label %36
49: ; preds = %45, %30
%50 = tail call i32 @fclose(i32* %22)
%51 = tail call i32 @free(i8* %12)
ret void
}