#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(int);
int fscanf(int /*<<< orphan*/ *, char *, double *);
int pow(int, int);
int /*<<< orphan*/ printf(char *);
void getBeliefs(FILE *file, double **node_array, int size) {
  int i, j;
  int result;
  for (i = 0; i < size; i++) {
    for (j = 0; j < pow(4, (size - i) - 1); j++) {
      result = fscanf(file, "%lf", &node_array[i][j]);
      if (!result) {
        printf("Error reading beliefs.  File ended without expected number of "
               "beliefs reached.\n");
        exit(-1);
      }
    }
  }
}


x86 assembly (clang, -O0):
<getBeliefs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1203 <getBeliefs+0xc3>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%esi
sub    -0x18(%rbp),%esi
sub    $0x1,%esi
mov    $0x4,%edi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11f0 <getBeliefs+0xb0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe4b(%rip),%rsi
call   1040 <fscanf@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11dd <getBeliefs+0x9d>
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
jmp    11e2 <getBeliefs+0xa2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116d <getBeliefs+0x2d>
jmp    11f5 <getBeliefs+0xb5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115a <getBeliefs+0x1a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getBeliefs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0xc(%rsp)
test   %edx,%edx
jle    11d7 <getBeliefs+0x97>
mov    %rsi,%r12
mov    %rdi,%rbp
mov    0xc(%rsp),%eax
mov    %rax,0x10(%rsp)
xor    %r13d,%r13d
jmp    117b <getBeliefs+0x3b>
xchg   %ax,%ax
add    $0x1,%r13
cmp    0x10(%rsp),%r13
je     11d7 <getBeliefs+0x97>
mov    %r13d,%ebx
not    %ebx
add    0xc(%rsp),%ebx
mov    $0x4,%edi
mov    %ebx,%esi
call   1050 <pow@plt>
test   %eax,%eax
jle    1170 <getBeliefs+0x30>
xor    %r14d,%r14d
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    (%r12,%r13,8),%rdx
add    %r14,%rdx
mov    %rbp,%rdi
lea    0xe4f(%rip),%rsi
call   1040 <fscanf@plt>
test   %eax,%eax
je     11e6 <getBeliefs+0xa6>
add    $0x1,%r15
mov    $0x4,%edi
mov    %ebx,%esi
call   1050 <pow@plt>
cltq
add    $0x8,%r14
cmp    %rax,%r15
jl     11a0 <getBeliefs+0x60>
jmp    1170 <getBeliefs+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe17(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [80 x i8] c"Error reading beliefs. File ended without expected number of beliefs reached.\0A\00"
define void @getBeliefs(i32* %0, double** %1, i32 %2) {
%4 = alloca i32*
%5 = alloca double**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store double** %1, double*** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %10
10: ; preds = %44, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %47
14: ; preds = %10
store i32 0, i32* %8
br label %15
15: ; preds = %40, %14
%16 = load i32, i32* %8
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = sub nsw i32 %17, %18
%20 = sub nsw i32 %19, 1
%21 = call i32 @pow(i32 4, i32 %20)
%22 = icmp slt i32 %16, %21
br i1 %22, label %23, label %43
23: ; preds = %15
%24 = load i32*, i32** %4
%25 = load double**, double*** %5
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double*, double** %25, i64 %27
%29 = load double*, double** %28
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = call i32 @fscanf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %32)
store i32 %33, i32* %9
%34 = load i32, i32* %9
%35 = icmp ne i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %23
%37 = call i32 @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.1, i64 0, i64 0))
%38 = call i32 @exit(i32 -1)
unreachable
39: ; preds = %23
br label %40
40: ; preds = %39
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %15
43: ; preds = %15
br label %44
44: ; preds = %43
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %10
47: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@str = [79 x i8] c"Error reading beliefs. File ended without expected number of beliefs reached.\00"
define void @getBeliefs(i32* nocapture %0, double** nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %33
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %30
%8 = phi i64 [ 0, %5 ], [ %31, %30 ]
%9 = trunc i64 %8 to i32
%10 = xor i32 %9, -1
%11 = add i32 %10, %2
%12 = tail call i32 @pow(i32 4, i32 %11)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %7
%15 = getelementptr inbounds double*, double** %1, i64 %8
br label %20
16: ; preds = %20
%17 = tail call i32 @pow(i32 4, i32 %11)
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %26, %18
br i1 %19, label %20, label %30
20: ; preds = %14, %16
%21 = phi i64 [ 0, %14 ], [ %26, %16 ]
%22 = load double*, double** %15
%23 = getelementptr inbounds double, double* %22, i64 %21
%24 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %23)
%25 = icmp eq i32 %24, 0
%26 = add nuw nsw i64 %21, 1
br i1 %25, label %27, label %16
27: ; preds = %20
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @str, i64 0, i64 0))
%29 = tail call i32 @exit(i32 -1)
unreachable
30: ; preds = %16, %7
%31 = add nuw nsw i64 %8, 1
%32 = icmp eq i64 %31, %6
br i1 %32, label %33, label %7
33: ; preds = %30, %3
ret void
}