#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(float *, int, int const, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int __p3dReadRaw32(char *filename, float *out_im, const int dimx,
                   const int dimy, const int dimz) {
  FILE *fvol;
  if ((fvol = fopen(filename, "rb")) == NULL) {
    printf("Cannot open input file %s.", filename);
    out_im = NULL;
    return -1;
  }
  fread(out_im, sizeof(float), dimx * dimy * dimz, fvol);
  fclose(fvol);
  return 0;
}


x86 assembly (clang, -O0):
<__p3dReadRaw32>:
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    %r8d,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    119c <__p3dReadRaw32+0x5c>
mov    -0x10(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1050 <printf@plt>
movq   $0x0,-0x18(%rbp)
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <__p3dReadRaw32+0x89>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
imul   -0x20(%rbp),%edx
imul   -0x24(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    $0x4,%esi
call   1030 <fread@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__p3dReadRaw32>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %ecx,%ebx
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r13
lea    0xea0(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1193 <__p3dReadRaw32+0x53>
mov    %rax,%rbp
imul   %r12d,%ebx
imul   %r15d,%ebx
mov    %r14,%rdi
mov    $0x4,%esi
mov    %ebx,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11a7 <__p3dReadRaw32+0x67>
lea    0xe69(%rip),%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [27 x i8] c"Cannot open input file %s.\00"
define i32 @__p3dReadRaw32(i8* %0, float* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca float*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
store i8* %0, i8** %7
store float* %1, float** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%13 = load i8*, i8** %7
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %12
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %5
%17 = load i8*, i8** %7
%18 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store float* null, float** %8
store i32 -1, i32* %6
br label %30
19: ; preds = %5
%20 = load float*, float** %8
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = mul nsw i32 %21, %22
%24 = load i32, i32* %11
%25 = mul nsw i32 %23, %24
%26 = load i32*, i32** %12
%27 = call i32 @fread(float* %20, i32 4, i32 %25, i32* %26)
%28 = load i32*, i32** %12
%29 = call i32 @fclose(i32* %28)
store i32 0, i32* %6
br label %30
30: ; preds = %19, %16
%31 = load i32, i32* %6
ret i32 %31
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [27 x i8] c"Cannot open input file %s.\00"
define i32 @__p3dReadRaw32(i8* %0, float* nocapture %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %15
10: ; preds = %5
%11 = mul nsw i32 %3, %2
%12 = mul nsw i32 %11, %4
%13 = tail call i32 @fread(float* %1, i32 4, i32 %12, i32* %6)
%14 = tail call i32 @fclose(i32* %6)
br label %15
15: ; preds = %10, %8
%16 = phi i32 [ -1, %8 ], [ 0, %10 ]
ret i32 %16
}