#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_int(char *file_data, int N, int M, int *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, "%d ", &dat[i * M + j]);
    }
    tmp *= fscanf(file, "%d", &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_int>:
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_int+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    1310 <read_data_int+0x1c0>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    120f <read_data_int+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_int+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    1288 <read_data_int+0x138>
mov    -0x2c(%rbp),%eax
shl    $0x0,%eax
mov    %eax,-0x2c(%rbp)
jmp    12fd <read_data_int+0x1ad>
lea    0xd7a(%rip),%rsi
lea    -0x2d(%rbp),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12f1 <read_data_int+0x1a1>
mov    -0x20(%rbp),%rdi
lea    0xd62(%rip),%rsi
lea    -0x2d(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
imul   -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xd4c(%rip),%rsi
lea    -0x2d(%rbp),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12e5 <read_data_int+0x195>
mov    -0x2c(%rbp),%eax
shl    $0x0,%eax
mov    %eax,-0x2c(%rbp)
jmp    12ec <read_data_int+0x19c>
imul   $0x0,-0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    12f8 <read_data_int+0x1a8>
imul   $0x0,-0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    12fd <read_data_int+0x1ad>
jmp    1302 <read_data_int+0x1b2>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ad <read_data_int+0x5d>
mov    -0x20(%rbp),%rdi
lea    0xcf8(%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    134e <read_data_int+0x1fe>
mov    -0x8(%rbp),%rsi
lea    0xcd0(%rip),%rdi
xor    %edx,%edx
call   1070 <print_error_global@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_data_int>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rcx,0x10(%rsp)
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xe8e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
jne    1190 <read_data_int+0x40>
lea    0xe7c(%rip),%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1070 <print_error_global@plt>
mov    %rbx,0x28(%rsp)
test   %ebp,%ebp
jle    1308 <read_data_int+0x1b8>
movslq %r14d,%rax
add    $0xffffffff,%r14d
mov    %r14,0x30(%rsp)
movslq %r14d,%rcx
mov    %rcx,0x48(%rsp)
mov    %ebp,%ecx
mov    %rcx,0x40(%rsp)
mov    %rax,0x50(%rsp)
lea    0x0(,%rax,4),%rax
mov    %rax,0x38(%rsp)
mov    $0x1,%r14d
mov    0x10(%rsp),%rbp
xor    %ebx,%ebx
jmp    1201 <read_data_int+0xb1>
nopl   0x0(%rax)
mov    %r12d,%r14d
mov    0x20(%rsp),%rbp
mov    0x18(%rsp),%rbx
add    $0x1,%rbx
add    0x38(%rsp),%rbp
cmp    0x40(%rsp),%rbx
je     130e <read_data_int+0x1be>
mov    %rbx,0x18(%rsp)
mov    %rbx,%r12
mov    0x50(%rsp),%rax
imul   %rax,%r12
cmp    $0x2,%eax
mov    %rbp,0x20(%rsp)
jl     124e <read_data_int+0xfe>
mov    0x30(%rsp),%rbx
lea    0xddf(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
imul   %eax,%r14d
add    $0x4,%rbp
add    $0xffffffffffffffff,%rbx
jne    1230 <read_data_int+0xe0>
add    0x48(%rsp),%r12
mov    0x10(%rsp),%rax
lea    (%rax,%r12,4),%rdx
mov    %r13,%rdi
lea    0xda5(%rip),%rsi
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %eax,%ebp
mov    %r13,%rdi
lea    0xd95(%rip),%rsi
lea    0xf(%rsp),%r15
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %eax,%r12d
imul   %r14d,%r12d
imul   %ebp,%r12d
mov    %r15,%rdi
lea    0xd74(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11e0 <read_data_int+0x90>
mov    %r15,%rdi
lea    0xd55(%rip),%rsi
call   1050 <strcmp@plt>
xor    %r14d,%r14d
test   %eax,%eax
mov    0x20(%rsp),%rbp
mov    0x18(%rsp),%rbx
jne    11ed <read_data_int+0x9d>
mov    %r13,%rdi
lea    0xd36(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %eax,%r14d
mov    %r15,%rdi
lea    0xd22(%rip),%rsi
call   1050 <strcmp@plt>
imul   %r12d,%r14d
test   %eax,%eax
mov    $0x0,%eax
cmovne %eax,%r14d
jmp    11ed <read_data_int+0x9d>
mov    $0x1,%r14d
lea    0xcfe(%rip),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %eax,%ebp
imul   %r14d,%ebp
mov    %r13,%rdi
call   1030 <fclose@plt>
test   %ebp,%ebp
jne    1344 <read_data_int+0x1f4>
lea    0xcdf(%rip),%rdi
mov    0x28(%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"%d \00"
@.str.3 = [3 x i8] c"%d\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_int(i8* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%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 i32* %3, i32** %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 = %93, %21
%23 = load i32, i32* %10
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %96
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 i32*, i32** %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 i32, i32* %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), i32* %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 i32*, i32** %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 i32, i32* %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), i32* %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 %71, label %68
68: ; preds = %48
%69 = load i32, i32* %12
%70 = mul nsw i32 %69, 1
store i32 %70, i32* %12
br label %92
71: ; preds = %48
%72 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%73 = icmp ne i32 %72, 0
br i1 %73, label %88, label %74
74: ; preds = %71
%75 = load i32*, i32** %9
%76 = call i32 (i32*, i8*, ...) @fscanf(i32* %75, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%77 = load i32, i32* %12
%78 = mul nsw i32 %77, %76
store i32 %78, i32* %12
%79 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%80 = icmp ne i32 %79, 0
br i1 %80, label %84, label %81
81: ; preds = %74
%82 = load i32, i32* %12
%83 = mul nsw i32 %82, 1
store i32 %83, i32* %12
br label %87
84: ; preds = %74
%85 = load i32, i32* %12
%86 = mul nsw i32 %85, 0
store i32 %86, i32* %12
br label %87
87: ; preds = %84, %81
br label %91
88: ; preds = %71
%89 = load i32, i32* %12
%90 = mul nsw i32 %89, 0
store i32 %90, i32* %12
br label %91
91: ; preds = %88, %87
br label %92
92: ; preds = %91, %68
br label %93
93: ; preds = %92
%94 = load i32, i32* %10
%95 = add nsw i32 %94, 1
store i32 %95, i32* %10
br label %22
96: ; preds = %22
%97 = load i32*, i32** %9
%98 = call i32 (i32*, i8*, ...) @fscanf(i32* %97, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%99 = load i32, i32* %12
%100 = mul nsw i32 %99, %98
store i32 %100, i32* %12
%101 = load i32*, i32** %9
%102 = call i32 @fclose(i32* %101)
%103 = load i32, i32* %12
%104 = icmp ne i32 %103, 0
br i1 %104, label %108, label %105
105: ; preds = %96
%106 = load i8*, i8** %5
%107 = call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %106, i32 0)
br label %108
108: ; preds = %105, %96
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"%d \00"
@.str.3 = [3 x i8] c"%d\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_int(i8* %0, i32 %1, i32 %2, i32* %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 %55
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, %51
%20 = phi i64 [ 0, %12 ], [ %53, %51 ]
%21 = phi i32 [ 1, %12 ], [ %52, %51 ]
%22 = mul nsw i64 %20, %15
br i1 %14, label %23, label %32
23: ; preds = %19, %23
%24 = phi i64 [ %30, %23 ], [ 0, %19 ]
%25 = phi i32 [ %29, %23 ], [ %21, %19 ]
%26 = add nsw i64 %24, %22
%27 = getelementptr inbounds i32, i32* %3, i64 %26
%28 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %27)
%29 = mul nsw i32 %28, %25
%30 = add nuw nsw i64 %24, 1
%31 = icmp eq i64 %30, %18
br i1 %31, label %32, label %23
32: ; preds = %23, %19
%33 = phi i32 [ %21, %19 ], [ %29, %23 ]
%34 = add nsw i64 %22, %16
%35 = getelementptr inbounds i32, i32* %3, i64 %34
%36 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %35)
%37 = mul nsw i32 %36, %33
%38 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%39 = mul nsw i32 %37, %38
%40 = call i32 @strcmp(i8* %5, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%41 = icmp eq i32 %40, 0
br i1 %41, label %51, label %42
42: ; preds = %32
%43 = call i32 @strcmp(i8* %5, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%47 = call i32 @strcmp(i8* %5, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp eq i32 %47, 0
%49 = mul nsw i32 %46, %39
%50 = select i1 %48, i32 %49, i32 0
br label %51
51: ; preds = %45, %42, %32
%52 = phi i32 [ %39, %32 ], [ 0, %42 ], [ %50, %45 ]
%53 = add nuw nsw i64 %20, 1
%54 = icmp eq i64 %53, %17
br i1 %54, label %55, label %19
55: ; preds = %51, %10
%56 = phi i32 [ 1, %10 ], [ %52, %51 ]
%57 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%58 = mul nsw i32 %57, %56
%59 = call i32 @fclose(i32* %6)
%60 = icmp eq i32 %58, 0
br i1 %60, label %61, label %63
61: ; preds = %55
%62 = 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 %63
63: ; preds = %61, %55
ret void
}