#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 Load_N_Values(int /*<<< orphan*/ *, int, int *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int Load_Mem(char *InputFileName, int Candidates[], int Pattern[]) {
  int Nc, Np;
  FILE *FP;
  FP = fopen(InputFileName, "r");
  if (FP == NULL) {
    printf("%s could not be opened; check the filename\n", InputFileName);
    return 0;
  } else {
    Nc = Load_N_Values(FP, ((12 * 12) * 8), Candidates);
    if (Nc == ((12 * 12) * 8))
      Np = Load_N_Values(FP, (12 * 12), Pattern);
    fclose(FP);
    return Nc + Np;
  }
}


x86 assembly (clang, -O0):
<Load_Mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    118f <Load_Mem+0x4f>
mov    -0x10(%rbp),%rsi
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d8 <Load_Mem+0x98>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x480,%esi
call   1050 <Load_N_Values@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x480,-0x24(%rbp)
jne    11c6 <Load_Mem+0x86>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x90,%esi
call   1050 <Load_N_Values@plt>
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Load_Mem>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     119d <Load_Mem+0x5d>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x480,%esi
mov    %r15,%rdx
call   1050 <Load_N_Values@plt>
mov    %eax,%r15d
cmp    $0x480,%eax
jne    1190 <Load_Mem+0x50>
mov    %rbx,%rdi
mov    $0x90,%esi
mov    %r14,%rdx
call   1050 <Load_N_Values@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    %r15d,%ebp
jmp    11ae <Load_Mem+0x6e>
lea    0xe5e(%rip),%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [44 x i8] c"%s could not be opened; check the filename\0A\00"
define i32 @Load_Mem(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%11 = load i8*, i8** %5
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %10
%13 = load i32*, i32** %10
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %16)
store i32 0, i32* %4
br label %34
18: ; preds = %3
%19 = load i32*, i32** %10
%20 = load i32*, i32** %6
%21 = call i32 @Load_N_Values(i32* %19, i32 1152, i32* %20)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp eq i32 %22, 1152
br i1 %23, label %24, label %28
24: ; preds = %18
%25 = load i32*, i32** %10
%26 = load i32*, i32** %7
%27 = call i32 @Load_N_Values(i32* %25, i32 144, i32* %26)
store i32 %27, i32* %9
br label %28
28: ; preds = %24, %18
%29 = load i32*, i32** %10
%30 = call i32 @fclose(i32* %29)
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = add nsw i32 %31, %32
store i32 %33, i32* %4
br label %34
34: ; preds = %28, %15
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [44 x i8] c"%s could not be opened; check the filename\0A\00"
define i32 @Load_Mem(i8* %0, i32* %1, i32* %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %17
8: ; preds = %3
%9 = tail call i32 @Load_N_Values(i32* %4, i32 1152, i32* %1)
%10 = icmp eq i32 %9, 1152
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @Load_N_Values(i32* %4, i32 144, i32* %2)
br label %13
13: ; preds = %11, %8
%14 = phi i32 [ %12, %11 ], [ undef, %8 ]
%15 = tail call i32 @fclose(i32* %4)
%16 = add nsw i32 %14, %9
br label %17
17: ; preds = %13, %6
%18 = phi i32 [ 0, %6 ], [ %16, %13 ]
ret i32 %18
}