#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_double(char *file_data, int N, int M, double *dat) {
  FILE *file = NULL;
  int i, j, tmp = 1;
  float tmp2;
  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 ", &tmp2);
      dat[i * M + j] = (double)tmp2;
    }
    tmp *= fscanf(file, "%g", &tmp2);
    dat[i * M + (M - 1)] = (double)tmp2;
    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_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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_double+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    1328 <read_data_double+0x1d8>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    121b <read_data_double+0xcb>
mov    -0x20(%rbp),%rdi
lea    0xe2b(%rip),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
imul   -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c0 <read_data_double+0x70>
mov    -0x20(%rbp),%rdi
lea    0xde5(%rip),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
imul   -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdi
lea    0xda7(%rip),%rsi
lea    -0x31(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
imul   -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xd91(%rip),%rsi
lea    -0x31(%rbp),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12a0 <read_data_double+0x150>
mov    -0x2c(%rbp),%eax
shl    $0x0,%eax
mov    %eax,-0x2c(%rbp)
jmp    1315 <read_data_double+0x1c5>
lea    0xd62(%rip),%rsi
lea    -0x31(%rbp),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1309 <read_data_double+0x1b9>
mov    -0x20(%rbp),%rdi
lea    0xd4a(%rip),%rsi
lea    -0x31(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
imul   -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xd34(%rip),%rsi
lea    -0x31(%rbp),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12fd <read_data_double+0x1ad>
mov    -0x2c(%rbp),%eax
shl    $0x0,%eax
mov    %eax,-0x2c(%rbp)
jmp    1304 <read_data_double+0x1b4>
imul   $0x0,-0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1310 <read_data_double+0x1c0>
imul   $0x0,-0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1315 <read_data_double+0x1c5>
jmp    131a <read_data_double+0x1ca>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ad <read_data_double+0x5d>
mov    -0x20(%rbp),%rdi
lea    0xce0(%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    1366 <read_data_double+0x216>
mov    -0x8(%rbp),%rsi
lea    0xcb8(%rip),%rdi
xor    %edx,%edx
call   1070 <print_error_global@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_data_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rcx,0x18(%rsp)
mov    %edx,%r13d
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xe8d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1191 <read_data_double+0x41>
lea    0xe7b(%rip),%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1070 <print_error_global@plt>
mov    %rbp,0x8(%rsp)
mov    %rbx,0x20(%rsp)
test   %r14d,%r14d
jle    134b <read_data_double+0x1fb>
movslq %r13d,%rax
add    $0xffffffff,%r13d
movslq %r13d,%rcx
mov    %rcx,0x38(%rsp)
mov    %r14d,%ecx
mov    %rcx,0x30(%rsp)
mov    %rax,0x40(%rsp)
lea    0x0(,%rax,8),%rax
mov    %rax,0x28(%rsp)
mov    $0x1,%r15d
lea    0xe2d(%rip),%rbp
mov    %rsp,%rdx
mov    0x18(%rsp),%r12
xor    %eax,%eax
mov    %r13,0x10(%rsp)
jmp    1214 <read_data_double+0xc4>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%r15d
mov    0x10(%rsp),%r13
mov    0x50(%rsp),%rax
add    $0x1,%rax
add    0x28(%rsp),%r12
cmp    0x30(%rsp),%rax
mov    %rsp,%rdx
je     1351 <read_data_double+0x201>
mov    %rax,0x50(%rsp)
mov    %rax,%rcx
mov    0x40(%rsp),%rax
imul   %rax,%rcx
mov    %rcx,0x48(%rsp)
cmp    $0x2,%eax
jl     1280 <read_data_double+0x130>
xor    %ebx,%ebx
mov    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %rsp,%rdx
imul   %eax,%r15d
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1240 <read_data_double+0xf0>
jmp    1285 <read_data_double+0x135>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%r14
mov    %r14,%rdi
lea    0xd7c(%rip),%rsi
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %eax,%r13d
imul   %r15d,%r13d
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    0x48(%rsp),%rcx
add    0x38(%rsp),%rcx
mov    0x18(%rsp),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    %r14,%rdi
lea    0xd4a(%rip),%rsi
lea    0x7(%rsp),%r14
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %eax,%ebx
imul   %r13d,%ebx
mov    %r14,%rdi
lea    0xd2e(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11f0 <read_data_double+0xa0>
mov    %r14,%rdi
lea    0xd0f(%rip),%rsi
call   1050 <strcmp@plt>
xor    %r15d,%r15d
test   %eax,%eax
mov    0x10(%rsp),%r13
jne    11f8 <read_data_double+0xa8>
mov    0x8(%rsp),%rdi
lea    0xcf3(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %eax,%r15d
mov    %r14,%rdi
lea    0xcdf(%rip),%rsi
call   1050 <strcmp@plt>
imul   %ebx,%r15d
test   %eax,%eax
mov    $0x0,%eax
cmovne %eax,%r15d
jmp    11f8 <read_data_double+0xa8>
mov    $0x1,%r15d
lea    0xcbb(%rip),%rsi
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %eax,%ebp
imul   %r15d,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
test   %ebp,%ebp
jne    138c <read_data_double+0x23c>
lea    0xc97(%rip),%rdi
mov    0x20(%rsp),%rsi
xor    %edx,%edx
call   1070 <print_error_global@plt>
add    $0x58,%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_double(i8* %0, i32 %1, i32 %2, double* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca float
%14 = alloca i8
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store double* %3, double** %8
store i32* null, i32** %9
store i32 1, i32* %12
%15 = load i8*, i8** %5
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %9
%17 = load i32*, i32** %9
%18 = icmp ne i32* %17, null
br i1 %18, label %22, label %19
19: ; preds = %4
%20 = load i8*, i8** %5
%21 = call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %20, i32 0)
br label %22
22: ; preds = %19, %4
store i32 0, i32* %10
br label %23
23: ; preds = %98, %22
%24 = load i32, i32* %10
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %101
27: ; preds = %23
store i32 0, i32* %11
br label %28
28: ; preds = %48, %27
%29 = load i32, i32* %11
%30 = load i32, i32* %7
%31 = sub nsw i32 %30, 1
%32 = icmp slt i32 %29, %31
br i1 %32, label %33, label %51
33: ; preds = %28
%34 = load i32*, i32** %9
%35 = call i32 (i32*, i8*, ...) @fscanf(i32* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %13)
%36 = load i32, i32* %12
%37 = mul nsw i32 %36, %35
store i32 %37, i32* %12
%38 = load float, float* %13
%39 = fpext float %38 to double
%40 = load double*, double** %8
%41 = load i32, i32* %10
%42 = load i32, i32* %7
%43 = mul nsw i32 %41, %42
%44 = load i32, i32* %11
%45 = add nsw i32 %43, %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %40, i64 %46
store double %39, double* %47
br label %48
48: ; preds = %33
%49 = load i32, i32* %11
%50 = add nsw i32 %49, 1
store i32 %50, i32* %11
br label %28
51: ; preds = %28
%52 = load i32*, i32** %9
%53 = call i32 (i32*, i8*, ...) @fscanf(i32* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %13)
%54 = load i32, i32* %12
%55 = mul nsw i32 %54, %53
store i32 %55, i32* %12
%56 = load float, float* %13
%57 = fpext float %56 to double
%58 = load double*, double** %8
%59 = load i32, i32* %10
%60 = load i32, i32* %7
%61 = mul nsw i32 %59, %60
%62 = load i32, i32* %7
%63 = sub nsw i32 %62, 1
%64 = add nsw i32 %61, %63
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %58, i64 %65
store double %57, double* %66
%67 = load i32*, i32** %9
%68 = call i32 (i32*, i8*, ...) @fscanf(i32* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%69 = load i32, i32* %12
%70 = mul nsw i32 %69, %68
store i32 %70, i32* %12
%71 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%72 = icmp ne i32 %71, 0
br i1 %72, label %76, label %73
73: ; preds = %51
%74 = load i32, i32* %12
%75 = mul nsw i32 %74, 1
store i32 %75, i32* %12
br label %97
76: ; preds = %51
%77 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%78 = icmp ne i32 %77, 0
br i1 %78, label %93, label %79
79: ; preds = %76
%80 = load i32*, i32** %9
%81 = call i32 (i32*, i8*, ...) @fscanf(i32* %80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%82 = load i32, i32* %12
%83 = mul nsw i32 %82, %81
store i32 %83, i32* %12
%84 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%85 = icmp ne i32 %84, 0
br i1 %85, label %89, label %86
86: ; preds = %79
%87 = load i32, i32* %12
%88 = mul nsw i32 %87, 1
store i32 %88, i32* %12
br label %92
89: ; preds = %79
%90 = load i32, i32* %12
%91 = mul nsw i32 %90, 0
store i32 %91, i32* %12
br label %92
92: ; preds = %89, %86
br label %96
93: ; preds = %76
%94 = load i32, i32* %12
%95 = mul nsw i32 %94, 0
store i32 %95, i32* %12
br label %96
96: ; preds = %93, %92
br label %97
97: ; preds = %96, %73
br label %98
98: ; preds = %97
%99 = load i32, i32* %10
%100 = add nsw i32 %99, 1
store i32 %100, i32* %10
br label %23
101: ; preds = %23
%102 = load i32*, i32** %9
%103 = call i32 (i32*, i8*, ...) @fscanf(i32* %102, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%104 = load i32, i32* %12
%105 = mul nsw i32 %104, %103
store i32 %105, i32* %12
%106 = load i32*, i32** %9
%107 = call i32 @fclose(i32* %106)
%108 = load i32, i32* %12
%109 = icmp ne i32 %108, 0
br i1 %109, label %113, label %110
110: ; preds = %101
%111 = load i8*, i8** %5
%112 = call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %111, i32 0)
br label %113
113: ; preds = %110, %101
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_double(i8* %0, i32 %1, i32 %2, double* nocapture writeonly %3) {
%5 = alloca float
%6 = alloca i8
%7 = bitcast float* %5 to i8*
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = 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 %12
12: ; preds = %10, %4
%13 = icmp sgt i32 %1, 0
br i1 %13, label %14, label %61
14: ; preds = %12
%15 = add i32 %2, -1
%16 = icmp sgt i32 %2, 1
%17 = sext i32 %2 to i64
%18 = sext i32 %15 to i64
%19 = zext i32 %1 to i64
%20 = zext i32 %15 to i64
br label %21
21: ; preds = %14, %57
%22 = phi i64 [ 0, %14 ], [ %59, %57 ]
%23 = phi i32 [ 1, %14 ], [ %58, %57 ]
%24 = mul nsw i64 %22, %17
br i1 %16, label %25, label %36
25: ; preds = %21, %25
%26 = phi i64 [ %34, %25 ], [ 0, %21 ]
%27 = phi i32 [ %29, %25 ], [ %23, %21 ]
%28 = call i32 (i32*, i8*, ...) @fscanf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %5)
%29 = mul nsw i32 %28, %27
%30 = load float, float* %5
%31 = fpext float %30 to double
%32 = add nsw i64 %26, %24
%33 = getelementptr inbounds double, double* %3, i64 %32
store double %31, double* %33
%34 = add nuw nsw i64 %26, 1
%35 = icmp eq i64 %34, %20
br i1 %35, label %36, label %25
36: ; preds = %25, %21
%37 = phi i32 [ %23, %21 ], [ %29, %25 ]
%38 = call i32 (i32*, i8*, ...) @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%39 = mul nsw i32 %38, %37
%40 = load float, float* %5
%41 = fpext float %40 to double
%42 = add nsw i64 %24, %18
%43 = getelementptr inbounds double, double* %3, i64 %42
store double %41, double* %43
%44 = call i32 (i32*, i8*, ...) @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%45 = mul nsw i32 %39, %44
%46 = call i32 @strcmp(i8* %6, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%47 = icmp eq i32 %46, 0
br i1 %47, label %57, label %48
48: ; preds = %36
%49 = call i32 @strcmp(i8* %6, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %57
51: ; preds = %48
%52 = call i32 (i32*, i8*, ...) @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%53 = call i32 @strcmp(i8* %6, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%54 = icmp eq i32 %53, 0
%55 = mul nsw i32 %52, %45
%56 = select i1 %54, i32 %55, i32 0
br label %57
57: ; preds = %51, %48, %36
%58 = phi i32 [ %45, %36 ], [ 0, %48 ], [ %56, %51 ]
%59 = add nuw nsw i64 %22, 1
%60 = icmp eq i64 %59, %19
br i1 %60, label %61, label %21
61: ; preds = %57, %12
%62 = phi i32 [ 1, %12 ], [ %58, %57 ]
%63 = call i32 (i32*, i8*, ...) @fscanf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%64 = mul nsw i32 %63, %62
%65 = call i32 @fclose(i32* %8)
%66 = icmp eq i32 %64, 0
br i1 %66, label %67, label %69
67: ; preds = %61
%68 = 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 %69
69: ; preds = %67, %61
ret void
}