#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 fscanf(int /*<<< orphan*/ *, char *, int *);
int read_arr(FILE *f, int *arr, int *size) {
  if ((fscanf(f, "%i", size) != 1) || (*size < 1) || (*size > 20)) {
    return -1;
  }
  for (int i = 0; i < *size; i++) {
    if (fscanf(f, "%i", &(arr[i])) != 1) {
      return -4;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<read_arr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xecd(%rip),%rsi
call   1030 <fscanf@plt>
cmp    $0x1,%eax
jne    115b <read_arr+0x4b>
mov    -0x20(%rbp),%rax
cmpl   $0x1,(%rax)
jl     115b <read_arr+0x4b>
mov    -0x20(%rbp),%rax
cmpl   $0x14,(%rax)
jle    1167 <read_arr+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cb <read_arr+0xbb>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    11c4 <read_arr+0xb4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe69(%rip),%rsi
call   1030 <fscanf@plt>
cmp    $0x1,%eax
je     11b1 <read_arr+0xa1>
movl   $0xfffffffc,-0x4(%rbp)
jmp    11cb <read_arr+0xbb>
jmp    11b6 <read_arr+0xa6>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116e <read_arr+0x5e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_arr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r15
lea    0xed7(%rip),%rsi
call   1030 <fscanf@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x1,%ecx
jne    117c <read_arr+0x6c>
mov    (%r14),%ecx
add    $0xffffffeb,%ecx
cmp    $0xffffffec,%ecx
jb     117c <read_arr+0x6c>
xor    %ebx,%ebx
lea    0xeb2(%rip),%r12
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <fscanf@plt>
cmp    $0x1,%eax
jne    1177 <read_arr+0x67>
add    $0x1,%rbx
movslq (%r14),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     1150 <read_arr+0x40>
xor    %eax,%eax
jmp    117c <read_arr+0x6c>
mov    $0xfffffffc,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
define i32 @read_arr(i32* nocapture %0, i32* %1, i32* %2) {
%4 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %20
6: ; preds = %3
%7 = load i32, i32* %2
%8 = add i32 %7, -21
%9 = icmp ult i32 %8, -20
br i1 %9, label %20, label %14
10: ; preds = %14
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = icmp slt i64 %19, %12
br i1 %13, label %14, label %20
14: ; preds = %6, %10
%15 = phi i64 [ %19, %10 ], [ 0, %6 ]
%16 = getelementptr inbounds i32, i32* %1, i64 %15
%17 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %16)
%18 = icmp eq i32 %17, 1
%19 = add nuw nsw i64 %15, 1
br i1 %18, label %10, label %20
20: ; preds = %14, %10, %3, %6
%21 = phi i32 [ -1, %6 ], [ -1, %3 ], [ -4, %14 ], [ 0, %10 ]
ret i32 %21
}