#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 */

/* Variables and functions */
scalar_t__ scanf(char *, double *);
int read2darr(int n, int m, double ar[n][m]) {
  int READ_SUCCESS = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 5; j++)
      if (scanf("%lf", &ar[i][j]))
        READ_SUCCESS++;
  return READ_SUCCESS;
}


x86 assembly (clang, -O0):
<read2darr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11bb <read2darr+0xab>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    11a8 <read2darr+0x98>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
imul   %rcx,%rax
shl    $0x3,%rax
add    %rax,%rsi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe83(%rip),%rdi
call   1030 <scanf@plt>
cmp    $0x0,%rax
je     1195 <read2darr+0x85>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119a <read2darr+0x8a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <read2darr+0x3a>
jmp    11ad <read2darr+0x9d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1137 <read2darr+0x27>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read2darr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
jle    11a9 <read2darr+0x99>
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %edi,%r12d
shl    $0x3,%r15
xor    %ebp,%ebp
lea    0xeca(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
lea    0x8(%rbx),%rsi
mov    %r14,%rdi
call   1030 <scanf@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
lea    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1030 <scanf@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
lea    0x18(%rbx),%rsi
mov    %r14,%rdi
call   1030 <scanf@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
lea    0x20(%rbx),%rsi
mov    %r14,%rdi
call   1030 <scanf@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
add    %r15,%rbx
add    $0xffffffffffffffff,%r12
jne    1140 <read2darr+0x30>
jmp    11ab <read2darr+0x9b>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
define i32 @read2darr(i32 %0, i32 %1, double* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store double* %2, double** %6
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = load i32, i32* %5
%13 = zext i32 %12 to i64
store i32 0, i32* %7
store i32 0, i32* %8
br label %14
14: ; preds = %41, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %44
18: ; preds = %14
store i32 0, i32* %9
br label %19
19: ; preds = %37, %18
%20 = load i32, i32* %9
%21 = icmp slt i32 %20, 5
br i1 %21, label %22, label %40
22: ; preds = %19
%23 = load double*, double** %6
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = mul nsw i64 %25, %13
%27 = getelementptr inbounds double, double* %23, i64 %26
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %22
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %36
36: ; preds = %33, %22
br label %37
37: ; preds = %36
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %19
40: ; preds = %19
br label %41
41: ; preds = %40
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %14
44: ; preds = %14
%45 = load i32, i32* %7
ret i32 %45
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
define i32 @read2darr(i32 %0, i32 %1, double* %2) {
%4 = zext i32 %1 to i64
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %39
6: ; preds = %3
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %37, %8 ]
%10 = phi i32 [ 0, %6 ], [ %36, %8 ]
%11 = mul nuw nsw i64 %9, %4
%12 = getelementptr inbounds double, double* %2, i64 %11
%13 = tail call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %12)
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
%16 = add nsw i32 %10, %15
%17 = getelementptr inbounds double, double* %12, i64 1
%18 = tail call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %17)
%19 = icmp ne i64 %18, 0
%20 = zext i1 %19 to i32
%21 = add nsw i32 %16, %20
%22 = getelementptr inbounds double, double* %12, i64 2
%23 = tail call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %22)
%24 = icmp ne i64 %23, 0
%25 = zext i1 %24 to i32
%26 = add nsw i32 %21, %25
%27 = getelementptr inbounds double, double* %12, i64 3
%28 = tail call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %27)
%29 = icmp ne i64 %28, 0
%30 = zext i1 %29 to i32
%31 = add nsw i32 %26, %30
%32 = getelementptr inbounds double, double* %12, i64 4
%33 = tail call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %32)
%34 = icmp ne i64 %33, 0
%35 = zext i1 %34 to i32
%36 = add nsw i32 %31, %35
%37 = add nuw nsw i64 %9, 1
%38 = icmp eq i64 %37, %7
br i1 %38, label %39, label %8
39: ; preds = %8, %3
%40 = phi i32 [ 0, %3 ], [ %36, %8 ]
ret i32 %40
}