#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
void read_analyze_header(int num_voxels[3], double voxel_size[3],
                         char *input_path) {
  FILE *file;
  int dim_i;
  char header[348];
  if ((file = fopen(input_path, "rb")) == NULL) {
    printf("\nCould not open file %s.!\n", input_path);
    exit(EXIT_FAILURE);
  }
  if (!fread(header, sizeof(char), 348, file)) {
    printf("\nNo elements were read from file %s.!\n", input_path);
    exit(EXIT_FAILURE);
  }
  fclose(file);
  for (dim_i = 0; dim_i < 3; dim_i++) {
    num_voxels[dim_i] = *((int *)(header + 42 + 2 * dim_i));
    voxel_size[dim_i] = *((double *)(header + 80 + 4 * dim_i));
  }
  return;
}


x86 assembly (clang, -O0):
<read_analyze_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11a3 <read_analyze_header+0x53>
mov    -0x18(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    -0x180(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x15c,%edx
call   1030 <fread@plt>
cmp    $0x0,%eax
jne    11e4 <read_analyze_header+0x94>
mov    -0x18(%rbp),%rsi
lea    0xe4d(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    1244 <read_analyze_header+0xf4>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
cltq
mov    -0x156(%rbp,%rax,1),%edx
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
shl    $0x2,%eax
cltq
movsd  -0x130(%rbp,%rax,1),%xmm0
ff ff
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f4 <read_analyze_header+0xa4>
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_analyze_header>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x168,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xe92(%rip),%rsi
mov    %rdx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11eb <read_analyze_header+0x9b>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x15c,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
test   %eax,%eax
je     11f4 <read_analyze_header+0xa4>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2a(%rsp),%eax
mov    %eax,(%r12)
movsd  0x50(%rsp),%xmm0
movsd  %xmm0,(%r14)
mov    0x2c(%rsp),%eax
mov    %eax,0x4(%r12)
movsd  0x54(%rsp),%xmm0
movsd  %xmm0,0x8(%r14)
mov    0x2e(%rsp),%eax
mov    %eax,0x8(%r12)
movsd  0x58(%rsp),%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x168,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe11(%rip),%rdi
jmp    11fb <read_analyze_header+0xab>
lea    0xe23(%rip),%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [27 x i8] c"\0ACould not open file %s.!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [39 x i8] c"\0ANo elements were read from file %s.!\0A\00"
define void @read_analyze_header(i32* %0, double* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca double*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [348 x i8]
store i32* %0, i32** %4
store double* %1, double** %5
store i8* %2, i8** %6
%10 = load i8*, i8** %6
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %7
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %3
%19 = getelementptr inbounds [348 x i8], [348 x i8]* %9, i64 0, i64 0
%20 = load i32*, i32** %7
%21 = call i32 @fread(i8* %19, i32 1, i32 348, i32* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = load i8*, i8** %6
%25 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %18
%29 = load i32*, i32** %7
%30 = call i32 @fclose(i32* %29)
store i32 0, i32* %8
br label %31
31: ; preds = %59, %28
%32 = load i32, i32* %8
%33 = icmp slt i32 %32, 3
br i1 %33, label %34, label %62
34: ; preds = %31
%35 = getelementptr inbounds [348 x i8], [348 x i8]* %9, i64 0, i64 0
%36 = getelementptr inbounds i8, i8* %35, i64 42
%37 = load i32, i32* %8
%38 = mul nsw i32 2, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
%41 = bitcast i8* %40 to i32*
%42 = load i32, i32* %41
%43 = load i32*, i32** %4
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
store i32 %42, i32* %46
%47 = getelementptr inbounds [348 x i8], [348 x i8]* %9, i64 0, i64 0
%48 = getelementptr inbounds i8, i8* %47, i64 80
%49 = load i32, i32* %8
%50 = mul nsw i32 4, %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
%53 = bitcast i8* %52 to double*
%54 = load double, double* %53
%55 = load double*, double** %5
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
store double %54, double* %58
br label %59
59: ; preds = %34
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %31
62: ; preds = %31
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [27 x i8] c"\0ACould not open file %s.!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [39 x i8] c"\0ANo elements were read from file %s.!\0A\00"
define void @read_analyze_header(i32* nocapture writeonly %0, double* nocapture writeonly %1, i8* %2) {
%4 = alloca [348 x i8]
%5 = getelementptr inbounds [348 x i8], [348 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %2, 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 %12
8: ; preds = %3
%9 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %3
%13 = call i32 @fread(i8* %5, i32 1, i32 348, i32* %6)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%17 = load i32, i32* @EXIT_FAILURE
%18 = tail call i32 @exit(i32 %17)
unreachable
19: ; preds = %12
%20 = tail call i32 @fclose(i32* %6)
%21 = getelementptr inbounds [348 x i8], [348 x i8]* %4, i64 0, i64 42
%22 = getelementptr inbounds [348 x i8], [348 x i8]* %4, i64 0, i64 80
%23 = bitcast i8* %21 to i32*
%24 = load i32, i32* %23
store i32 %24, i32* %0
%25 = bitcast i8* %22 to double*
%26 = load double, double* %25
store double %26, double* %1
%27 = getelementptr inbounds [348 x i8], [348 x i8]* %4, i64 0, i64 44
%28 = bitcast i8* %27 to i32*
%29 = load i32, i32* %28
%30 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %29, i32* %30
%31 = getelementptr inbounds [348 x i8], [348 x i8]* %4, i64 0, i64 84
%32 = bitcast i8* %31 to double*
%33 = load double, double* %32
%34 = getelementptr inbounds double, double* %1, i64 1
store double %33, double* %34
%35 = getelementptr inbounds [348 x i8], [348 x i8]* %4, i64 0, i64 46
%36 = bitcast i8* %35 to i32*
%37 = load i32, i32* %36
%38 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %37, i32* %38
%39 = getelementptr inbounds [348 x i8], [348 x i8]* %4, i64 0, i64 88
%40 = bitcast i8* %39 to double*
%41 = load double, double* %40
%42 = getelementptr inbounds double, double* %1, i64 2
store double %41, double* %42
ret void
}