#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 /*<<< orphan*/ printf(char *);
int reading(FILE *f, int *arr, int *size) {
  *size = 0;
  int buf;
  while (fscanf(f, "%i", &buf) == 1) {
    if (*size == 20) {
      printf("Too many numbers in file; pass\n");
      return 0;
    }
    arr[*size] = buf;
    (*size)++;
  }
  if (*size == 0) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<reading>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xeb7(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11a1 <reading+0x81>
mov    -0x20(%rbp),%rax
cmpl   $0x14,(%rax)
jne    1180 <reading+0x60>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <reading+0xa1>
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    113e <reading+0x1e>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11ba <reading+0x9a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c1 <reading+0xa1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reading>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
movl   $0x0,(%rdx)
lea    0xebd(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    1187 <reading+0x67>
lea    0xea7(%rip),%r12
lea    0xc(%rsp),%r13
xchg   %ax,%ax
movslq (%rbx),%rax
cmp    $0x14,%rax
je     118e <reading+0x6e>
mov    0xc(%rsp),%ecx
mov    %ecx,(%r14,%rax,4)
addl   $0x1,(%rbx)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
je     1160 <reading+0x40>
cmpl   $0x1,(%rbx)
sbb    %eax,%eax
jmp    119c <reading+0x7c>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [32 x i8] c"Too many numbers in file; pass\0A\00"
define i32 @reading(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** %7
store i32 0, i32* %9
br label %10
10: ; preds = %20, %3
%11 = load i32*, i32** %5
%12 = call i32 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = load i32*, i32** %7
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 20
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %36
20: ; preds = %14
%21 = load i32, i32* %8
%22 = load i32*, i32** %6
%23 = load i32*, i32** %7
%24 = load i32, i32* %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %22, i64 %25
store i32 %21, i32* %26
%27 = load i32*, i32** %7
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 1
store i32 %29, i32* %27
br label %10
30: ; preds = %10
%31 = load i32*, i32** %7
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 -1, i32* %4
br label %36
35: ; preds = %30
store i32 0, i32* %4
br label %36
36: ; preds = %35, %34, %18
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@str = [31 x i8] c"Too many numbers in file; pass\00"
define i32 @reading(i32* nocapture %0, i32* nocapture writeonly %1, i32* nocapture %2) {
%4 = alloca i32
store i32 0, i32* %2
%5 = bitcast i32* %4 to i8*
%6 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %21
8: ; preds = %3, %13
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 20
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %25
13: ; preds = %8
%14 = load i32, i32* %4
%15 = sext i32 %9 to i64
%16 = getelementptr inbounds i32, i32* %1, i64 %15
store i32 %14, i32* %16
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
%19 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%20 = icmp eq i32 %19, 1
br i1 %20, label %8, label %21
21: ; preds = %13, %3
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 0
%24 = sext i1 %23 to i32
br label %25
25: ; preds = %21, %11
%26 = phi i32 [ 0, %11 ], [ %24, %21 ]
ret i32 %26
}