#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 /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *, float *,
                          float *);
int /*<<< orphan*/ printf(char *, char *);
void read_metdata(char file[200], float METDATA[4749][4]) {
  FILE *fp;
  int i;
  if ((fp = fopen(file, "r")) == NULL) {
    printf("Cannot open file %s \n", file);
    exit(0);
  }
  for (i = 0; i < 4749; i++) {
    fscanf(fp, "%f %f %f", &METDATA[i][0], &METDATA[i][1], &METDATA[i][2]);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<read_metdata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1195 <read_metdata+0x45>
mov    -0x8(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x128d,-0x1c(%rbp)
jge    11fc <read_metdata+0xac>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x4,%rax
add    %rax,%rdx
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rax
shl    $0x4,%rax
add    %rax,%rcx
add    $0x4,%rcx
mov    -0x10(%rbp),%r8
movslq -0x1c(%rbp),%rax
shl    $0x4,%rax
add    %rax,%r8
add    $0x8,%r8
lea    0xe2f(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119c <read_metdata+0x4c>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_metdata>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11b3 <read_metdata+0x63>
mov    %rax,%r14
mov    $0x128d,%r12d
lea    0xe99(%rip),%r15
nop
lea    0x4(%rbx),%rcx
lea    0x8(%rbx),%r8
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <fscanf@plt>
add    $0x10,%rbx
add    $0xffffffffffffffff,%r12
jne    1180 <read_metdata+0x30>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
lea    0xe48(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [22 x i8] c"Cannot open file %s \0A\00"
@.str.2 = [9 x i8] c"%f %f %f\00"
define void @read_metdata(i8* %0, [4 x float]* %1) {
%3 = alloca i8*
%4 = alloca [4 x float]*
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %3
store [4 x float]* %1, [4 x float]** %4
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %5
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %2
store i32 0, i32* %6
br label %15
15: ; preds = %36, %14
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 4749
br i1 %17, label %18, label %39
18: ; preds = %15
%19 = load i32*, i32** %5
%20 = load [4 x float]*, [4 x float]** %4
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4 x float], [4 x float]* %20, i64 %22
%24 = getelementptr inbounds [4 x float], [4 x float]* %23, i64 0, i64 0
%25 = load [4 x float]*, [4 x float]** %4
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [4 x float], [4 x float]* %25, i64 %27
%29 = getelementptr inbounds [4 x float], [4 x float]* %28, i64 0, i64 1
%30 = load [4 x float]*, [4 x float]** %4
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [4 x float], [4 x float]* %30, i64 %32
%34 = getelementptr inbounds [4 x float], [4 x float]* %33, i64 0, i64 2
%35 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), float* %24, float* %29, float* %34)
br label %36
36: ; preds = %18
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %15
39: ; preds = %15
%40 = load i32*, i32** %5
%41 = call i32 @fclose(i32* %40)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [22 x i8] c"Cannot open file %s \0A\00"
@.str.2 = [9 x i8] c"%f %f %f\00"
define void @read_metdata(i8* %0, [4 x float]* %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2, %8
%9 = phi i64 [ %14, %8 ], [ 0, %2 ]
%10 = getelementptr inbounds [4 x float], [4 x float]* %1, i64 %9, i64 0
%11 = getelementptr inbounds [4 x float], [4 x float]* %1, i64 %9, i64 1
%12 = getelementptr inbounds [4 x float], [4 x float]* %1, i64 %9, i64 2
%13 = tail call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), float* %10, float* %11, float* %12)
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, 4749
br i1 %15, label %16, label %8
16: ; preds = %8
%17 = tail call i32 @fclose(i32* %3)
ret void
}