#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 *, ...);
int /*<<< orphan*/ printf(char *, char *);
void read_fraction(char file[400], float FR1[500][500], int rows, int cols) {
  FILE *fp;
  int i, j;
  char junk[50];
  if ((fp = fopen(file, "r")) == NULL) {
    printf("Cannot open file maskfile %s \n", file);
    exit(0);
  }
  for (j = 0; j < 12; j++)
    fscanf(fp, "%s", junk);
  for (i = 0; i < rows; i++)
    for (j = 0; j < cols; j++)
      fscanf(fp, "%f", &FR1[i][j]);
  fclose(fp);
}


x86 assembly (clang, -O0):
<read_fraction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    119b <read_fraction+0x4b>
mov    -0x8(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0xc,-0x28(%rbp)
jge    11d0 <read_fraction+0x80>
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a2 <read_fraction+0x52>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1246 <read_fraction+0xf6>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1233 <read_fraction+0xe3>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x24(%rbp),%rax
imul   $0x7d0,%rax,%rax
add    %rax,%rdx
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ea <read_fraction+0x9a>
jmp    1238 <read_fraction+0xe8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d7 <read_fraction+0x87>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_fraction>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %ecx,0xc(%rsp)
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0xe8f(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     12d3 <read_fraction+0x183>
mov    %rax,%r12
lea    0xe98(%rip),%rbp
lea    0x20(%rsp),%r13
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
test   %ebx,%ebx
jle    12bc <read_fraction+0x16c>
mov    %ebx,%eax
mov    %rax,0x18(%rsp)
mov    0xc(%rsp),%eax
mov    %rax,0x10(%rsp)
lea    0xdbb(%rip),%rbx
xor    %r14d,%r14d
jmp    1282 <read_fraction+0x132>
xchg   %ax,%ax
add    $0x1,%r14
add    $0x7d0,%r15
cmp    0x18(%rsp),%r14
je     12bc <read_fraction+0x16c>
cmpl   $0x0,0xc(%rsp)
jle    1270 <read_fraction+0x120>
mov    0x10(%rsp),%r13
mov    %r15,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
add    $0x4,%rbp
add    $0xffffffffffffffff,%r13
jne    12a0 <read_fraction+0x150>
jmp    1270 <read_fraction+0x120>
mov    %r12,%rdi
call   1030 <fclose@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd28(%rip),%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

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

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