#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_data(char file[400], float FR4[5000][3], int cells) {
  FILE *fp;
  int i;
  if ((fp = fopen(file, "r")) == NULL) {
    printf("Cannot open file %s \n", file);
    exit(0);
  }
  for (i = 0; i < cells; i++)
    fscanf(fp, "%f %f %f", &FR4[i][0], &FR4[i][1], &FR4[i][2]);
  fclose(fp);
}


x86 assembly (clang, -O0):
<read_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1198 <read_data+0x48>
mov    -0x8(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fe <read_data+0xae>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x24(%rbp),%rax
imul   $0xc,%rax,%rax
add    %rax,%rdx
mov    -0x10(%rbp),%rcx
movslq -0x24(%rbp),%rax
imul   $0xc,%rax,%rax
add    %rax,%rcx
add    $0x4,%rcx
mov    -0x10(%rbp),%r8
movslq -0x24(%rbp),%rax
imul   $0xc,%rax,%rax
add    %rax,%r8
add    $0x8,%r8
lea    0xe2d(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119f <read_data+0x4f>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_data>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xe9a(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11b2 <read_data+0x62>
mov    %rax,%r14
test   %ebp,%ebp
jle    11a0 <read_data+0x50>
mov    %ebp,%ebp
lea    0xe98(%rip),%r15
lea    0x4(%rbx),%rcx
lea    0x8(%rbx),%r8
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <fscanf@plt>
add    $0xc,%rbx
add    $0xffffffffffffffff,%rbp
jne    1180 <read_data+0x30>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
lea    0xe49(%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_data(i8* %0, [3 x float]* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca [3 x float]*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
store i8* %0, i8** %4
store [3 x float]* %1, [3 x float]** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %7
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i8*, i8** %4
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %3
store i32 0, i32* %8
br label %17
17: ; preds = %39, %16
%18 = load i32, i32* %8
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %42
21: ; preds = %17
%22 = load i32*, i32** %7
%23 = load [3 x float]*, [3 x float]** %5
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 %25
%27 = getelementptr inbounds [3 x float], [3 x float]* %26, i64 0, i64 0
%28 = load [3 x float]*, [3 x float]** %5
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [3 x float], [3 x float]* %28, i64 %30
%32 = getelementptr inbounds [3 x float], [3 x float]* %31, i64 0, i64 1
%33 = load [3 x float]*, [3 x float]** %5
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [3 x float], [3 x float]* %33, i64 %35
%37 = getelementptr inbounds [3 x float], [3 x float]* %36, i64 0, i64 2
%38 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), float* %27, float* %32, float* %37)
br label %39
39: ; preds = %21
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %17
42: ; preds = %17
%43 = load i32*, i32** %7
%44 = call i32 @fclose(i32* %43)
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_data(i8* %0, [3 x float]* %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 %10, label %6
6: ; preds = %3
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %21
8: ; preds = %6
%9 = zext i32 %2 to i64
br label %13
10: ; preds = %3
%11 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %8, %13
%14 = phi i64 [ 0, %8 ], [ %19, %13 ]
%15 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 %14, i64 0
%16 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 %14, i64 1
%17 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 %14, i64 2
%18 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), float* %15, float* %16, float* %17)
%19 = add nuw nsw i64 %14, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %21, label %13
21: ; preds = %13, %6
%22 = tail call i32 @fclose(i32* %4)
ret void
}