#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(double ar[][5], int n) {
  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    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a9 <read2darr+0x99>
movl   $0x0,-0x18(%rbp)
cmpl   $0x5,-0x18(%rbp)
jge    1196 <read2darr+0x86>
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
imul   $0x28,%rax,%rax
add    %rax,%rsi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe95(%rip),%rdi
call   1030 <scanf@plt>
cmp    $0x0,%rax
je     1183 <read2darr+0x73>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1188 <read2darr+0x78>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1140 <read2darr+0x30>
jmp    119b <read2darr+0x8b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <read2darr+0x1d>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read2darr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    119a <read2darr+0x8a>
mov    %rdi,%rbx
mov    %esi,%r15d
xor    %ebp,%ebp
lea    0xed6(%rip),%r14
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    $0x28,%rbx
add    $0xffffffffffffffff,%r15
jne    1130 <read2darr+0x20>
jmp    119c <read2darr+0x8c>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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