#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 */
struct Tri {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ process_tri_data(struct Tri *, float ***, int *);
struct Tri *read_tri_file(int /*<<< orphan*/ *);
void parse_file(char *fname, float ***J, int *N) {
  char c;
  struct Tri *root;
  printf("Parsing file: %s... \n", fname);
  FILE *fp = fopen(fname, "r");
  if (fp == NULL) {
    printf("Failed to open file: %s...\n", fname);
    return;
  } else {
    root = read_tri_file(fp);
  }
  fclose(fp);
  process_tri_data(root, J, N);
}


x86 assembly (clang, -O0):
<parse_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11a8 <parse_file+0x58>
mov    -0x8(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
jmp    11cf <parse_file+0x7f>
mov    -0x30(%rbp),%rdi
call   1050 <read_tri_file@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <process_tri_data@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_file>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xe98(%rip),%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
lea    0xe9f(%rip),%rsi
mov    %r12,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b3 <parse_file+0x63>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <read_tri_file@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <process_tri_data@plt>
lea    0xe5e(%rip),%rdi
mov    %r12,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.Tri = type { i32 }
@.str = [22 x i8] c"Parsing file: %s... \0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"Failed to open file: %s...\0A\00"
define void @parse_file(i8* %0, float*** %1, i32* %2) {
%4 = alloca i8*
%5 = alloca float***
%6 = alloca i32*
%7 = alloca i8
%8 = alloca %struct.Tri*
%9 = alloca i32*
store i8* %0, i8** %4
store float*** %1, float**** %5
store i32* %2, i32** %6
%10 = load i8*, i8** %4
%11 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %4
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %9
%14 = load i32*, i32** %9
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %29
19: ; preds = %3
%20 = load i32*, i32** %9
%21 = call %struct.Tri* @read_tri_file(i32* %20)
store %struct.Tri* %21, %struct.Tri** %8
br label %22
22: ; preds = %19
%23 = load i32*, i32** %9
%24 = call i32 @fclose(i32* %23)
%25 = load %struct.Tri*, %struct.Tri** %8
%26 = load float***, float**** %5
%27 = load i32*, i32** %6
%28 = call i32 @process_tri_data(%struct.Tri* %25, float*** %26, i32* %27)
br label %29
29: ; preds = %22, %16
ret void
}

LLVM IR (-O2):
%struct.Tri = type { i32 }
@.str = [22 x i8] c"Parsing file: %s... \0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"Failed to open file: %s...\0A\00"
define void @parse_file(i8* %0, float*** %1, i32* %2) {
%4 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %13
9: ; preds = %3
%10 = tail call %struct.Tri* @read_tri_file(i32* %5)
%11 = tail call i32 @fclose(i32* %5)
%12 = tail call i32 @process_tri_data(%struct.Tri* %10, float*** %1, i32* %2)
br label %13
13: ; preds = %9, %7
ret void
}