#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ print_error_global(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strcmp(char *, char *);
void read_data_float(char *file_data, int N, int M, float *dat) {
  FILE *file = NULL;
  int i, j, tmp = 1;
  char st;
  file = fopen(file_data, "r");
  if (!file)
    print_error_global("open", file_data, 0);
  for (i = 0; i < N; i++) {
    for (j = 0; j < M - 1; j++) {
      tmp *= fscanf(file, "%g ", &dat[i * M + j]);
    }
    tmp *= fscanf(file, "%g", &dat[i * M + (M - 1)]);
    tmp *= fscanf(file, "%c", &st);
    if (!strcmp(&st, "\n")) {
      tmp = 1;
    } else if (!strcmp(&st, " ")) {
      tmp *= fscanf(file, "%c", &st);
      if (!strcmp(&st, "\n"))
        tmp = 1;
      else
        tmp = 0;
    } else {
      tmp = 0;
    }
  }
  tmp *= fscanf(file, "EOF");
  fclose(file);
  if (!tmp)
    print_error_global("read", file_data, 0);
}


x86 assembly (clang, -O0):
<read_data_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a6 <read_data_float+0x56>
mov    -0x8(%rbp),%rsi
lea    0xe63(%rip),%rdi
xor    %edx,%edx
call   1070 <print_error_global@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    130c <read_data_float+0x1bc>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    120f <read_data_float+0xbf>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%eax
imul   -0x10(%rbp),%eax
add    -0x28(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe14(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
imul   -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c0 <read_data_float+0x70>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
add    %ecx,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdd5(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
imul   -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdbf(%rip),%rsi
lea    -0x2d(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
imul   -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xda9(%rip),%rsi
lea    -0x2d(%rbp),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1286 <read_data_float+0x136>
movl   $0x1,-0x2c(%rbp)
jmp    12f9 <read_data_float+0x1a9>
lea    0xd7c(%rip),%rsi
lea    -0x2d(%rbp),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12ed <read_data_float+0x19d>
mov    -0x20(%rbp),%rdi
lea    0xd64(%rip),%rsi
lea    -0x2d(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
imul   -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xd4e(%rip),%rsi
lea    -0x2d(%rbp),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12e1 <read_data_float+0x191>
movl   $0x1,-0x2c(%rbp)
jmp    12e8 <read_data_float+0x198>
movl   $0x0,-0x2c(%rbp)
jmp    12f4 <read_data_float+0x1a4>
movl   $0x0,-0x2c(%rbp)
jmp    12f9 <read_data_float+0x1a9>
jmp    12fe <read_data_float+0x1ae>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ad <read_data_float+0x5d>
mov    -0x20(%rbp),%rdi
lea    0xcfc(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
imul   -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    134a <read_data_float+0x1fa>
mov    -0x8(%rbp),%rsi
lea    0xcd4(%rip),%rdi
xor    %edx,%edx
call   1070 <print_error_global@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_data_float>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,0x10(%rsp)
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xe8d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1191 <read_data_float+0x41>
lea    0xe7b(%rip),%rdi
mov    %rbp,%rsi
xor    %edx,%edx
call   1070 <print_error_global@plt>
mov    %rbp,0x18(%rsp)
test   %r14d,%r14d
jle    12e4 <read_data_float+0x194>
movslq %r15d,%rax
add    $0xffffffff,%r15d
mov    %r15,0x20(%rsp)
movslq %r15d,%rcx
mov    %rcx,0x38(%rsp)
mov    %r14d,%ecx
mov    %rcx,0x30(%rsp)
mov    %rax,0x40(%rsp)
lea    0x0(,%rax,4),%rax
mov    %rax,0x28(%rsp)
lea    0xe33(%rip),%r13
mov    0x10(%rsp),%rax
mov    %rax,0x8(%rsp)
xor    %r12d,%r12d
jmp    1214 <read_data_float+0xc4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%r14d
add    $0x1,%r12
mov    0x8(%rsp),%rax
add    0x28(%rsp),%rax
mov    %rax,0x8(%rsp)
cmp    0x30(%rsp),%r12
je     12ea <read_data_float+0x19a>
mov    %r12,%rbp
mov    0x40(%rsp),%rax
imul   %rax,%rbp
cmp    $0x2,%eax
jl     124a <read_data_float+0xfa>
mov    0x20(%rsp),%r15
mov    0x8(%rsp),%r14
nop
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
add    $0x4,%r14
add    $0xffffffffffffffff,%r15
jne    1230 <read_data_float+0xe0>
add    0x38(%rsp),%rbp
mov    0x10(%rsp),%rax
lea    (%rax,%rbp,4),%rdx
mov    %rbx,%rdi
lea    0xda9(%rip),%rsi
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %rbx,%rdi
lea    0xd9b(%rip),%rsi
lea    0x7(%rsp),%rbp
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %rbp,%rdi
lea    0xd85(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11f0 <read_data_float+0xa0>
mov    %rbp,%rdi
lea    0xd66(%rip),%rsi
call   1050 <strcmp@plt>
xor    %r14d,%r14d
test   %eax,%eax
jne    11f6 <read_data_float+0xa6>
mov    %rbx,%rdi
lea    0xd51(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %rbp,%rdi
lea    0xd40(%rip),%rsi
call   1050 <strcmp@plt>
xor    %r14d,%r14d
test   %eax,%eax
sete   %r14b
jmp    11f6 <read_data_float+0xa6>
mov    $0x1,%r14d
lea    0xd22(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %eax,%ebp
imul   %r14d,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
test   %ebp,%ebp
jne    1320 <read_data_float+0x1d0>
lea    0xd03(%rip),%rdi
mov    0x18(%rsp),%rsi
xor    %edx,%edx
call   1070 <print_error_global@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [4 x i8] c"%g \00"
@.str.3 = [3 x i8] c"%g\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [2 x i8] c" \00"
@.str.7 = [4 x i8] c"EOF\00"
@.str.8 = [5 x i8] c"read\00"
define void @read_data_float(i8* %0, i32 %1, i32 %2, float* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca float*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store float* %3, float** %8
store i32* null, i32** %9
store i32 1, i32* %12
%14 = load i8*, i8** %5
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %9
%16 = load i32*, i32** %9
%17 = icmp ne i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %4
%19 = load i8*, i8** %5
%20 = call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %19, i32 0)
br label %21
21: ; preds = %18, %4
store i32 0, i32* %10
br label %22
22: ; preds = %85, %21
%23 = load i32, i32* %10
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %88
26: ; preds = %22
store i32 0, i32* %11
br label %27
27: ; preds = %45, %26
%28 = load i32, i32* %11
%29 = load i32, i32* %7
%30 = sub nsw i32 %29, 1
%31 = icmp slt i32 %28, %30
br i1 %31, label %32, label %48
32: ; preds = %27
%33 = load i32*, i32** %9
%34 = load float*, float** %8
%35 = load i32, i32* %10
%36 = load i32, i32* %7
%37 = mul nsw i32 %35, %36
%38 = load i32, i32* %11
%39 = add nsw i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %34, i64 %40
%42 = call i32 (i32*, i8*, ...) @fscanf(i32* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %41)
%43 = load i32, i32* %12
%44 = mul nsw i32 %43, %42
store i32 %44, i32* %12
br label %45
45: ; preds = %32
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 1
store i32 %47, i32* %11
br label %27
48: ; preds = %27
%49 = load i32*, i32** %9
%50 = load float*, float** %8
%51 = load i32, i32* %10
%52 = load i32, i32* %7
%53 = mul nsw i32 %51, %52
%54 = load i32, i32* %7
%55 = sub nsw i32 %54, 1
%56 = add nsw i32 %53, %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds float, float* %50, i64 %57
%59 = call i32 (i32*, i8*, ...) @fscanf(i32* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %58)
%60 = load i32, i32* %12
%61 = mul nsw i32 %60, %59
store i32 %61, i32* %12
%62 = load i32*, i32** %9
%63 = call i32 (i32*, i8*, ...) @fscanf(i32* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%64 = load i32, i32* %12
%65 = mul nsw i32 %64, %63
store i32 %65, i32* %12
%66 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%67 = icmp ne i32 %66, 0
br i1 %67, label %69, label %68
68: ; preds = %48
store i32 1, i32* %12
br label %84
69: ; preds = %48
%70 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%71 = icmp ne i32 %70, 0
br i1 %71, label %82, label %72
72: ; preds = %69
%73 = load i32*, i32** %9
%74 = call i32 (i32*, i8*, ...) @fscanf(i32* %73, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%75 = load i32, i32* %12
%76 = mul nsw i32 %75, %74
store i32 %76, i32* %12
%77 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%78 = icmp ne i32 %77, 0
br i1 %78, label %80, label %79
79: ; preds = %72
store i32 1, i32* %12
br label %81
80: ; preds = %72
store i32 0, i32* %12
br label %81
81: ; preds = %80, %79
br label %83
82: ; preds = %69
store i32 0, i32* %12
br label %83
83: ; preds = %82, %81
br label %84
84: ; preds = %83, %68
br label %85
85: ; preds = %84
%86 = load i32, i32* %10
%87 = add nsw i32 %86, 1
store i32 %87, i32* %10
br label %22
88: ; preds = %22
%89 = load i32*, i32** %9
%90 = call i32 (i32*, i8*, ...) @fscanf(i32* %89, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%91 = load i32, i32* %12
%92 = mul nsw i32 %91, %90
store i32 %92, i32* %12
%93 = load i32*, i32** %9
%94 = call i32 @fclose(i32* %93)
%95 = load i32, i32* %12
%96 = icmp ne i32 %95, 0
br i1 %96, label %100, label %97
97: ; preds = %88
%98 = load i8*, i8** %5
%99 = call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %98, i32 0)
br label %100
100: ; preds = %97, %88
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [4 x i8] c"%g \00"
@.str.3 = [3 x i8] c"%g\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [2 x i8] c" \00"
@.str.7 = [4 x i8] c"EOF\00"
@.str.8 = [5 x i8] c"read\00"
define void @read_data_float(i8* %0, i32 %1, i32 %2, float* %3) {
%5 = alloca i8
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 0)
br label %10
10: ; preds = %8, %4
%11 = icmp sgt i32 %1, 0
br i1 %11, label %12, label %48
12: ; preds = %10
%13 = add i32 %2, -1
%14 = icmp sgt i32 %2, 1
%15 = sext i32 %2 to i64
%16 = sext i32 %13 to i64
%17 = zext i32 %1 to i64
%18 = zext i32 %13 to i64
br label %19
19: ; preds = %12, %44
%20 = phi i64 [ 0, %12 ], [ %46, %44 ]
%21 = mul nsw i64 %20, %15
br i1 %14, label %22, label %29
22: ; preds = %19, %22
%23 = phi i64 [ %27, %22 ], [ 0, %19 ]
%24 = add nsw i64 %23, %21
%25 = getelementptr inbounds float, float* %3, i64 %24
%26 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %25)
%27 = add nuw nsw i64 %23, 1
%28 = icmp eq i64 %27, %18
br i1 %28, label %29, label %22
29: ; preds = %22, %19
%30 = add nsw i64 %21, %16
%31 = getelementptr inbounds float, float* %3, i64 %30
%32 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %31)
%33 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%34 = call i32 @strcmp(i8* %5, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %44, label %36
36: ; preds = %29
%37 = call i32 @strcmp(i8* %5, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%41 = call i32 @strcmp(i8* %5, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%42 = icmp eq i32 %41, 0
%43 = zext i1 %42 to i32
br label %44
44: ; preds = %36, %39, %29
%45 = phi i32 [ 1, %29 ], [ %43, %39 ], [ 0, %36 ]
%46 = add nuw nsw i64 %20, 1
%47 = icmp eq i64 %46, %17
br i1 %47, label %48, label %19
48: ; preds = %44, %10
%49 = phi i32 [ 1, %10 ], [ %45, %44 ]
%50 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%51 = mul nuw nsw i32 %50, %49
%52 = call i32 @fclose(i32* %6)
%53 = icmp eq i32 %51, 0
br i1 %53, label %54, label %56
54: ; preds = %48
%55 = call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %0, i32 0)
br label %56
56: ; preds = %54, %48
ret void
}