#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  FILE *arquivo;
  int n;
  int x = 0;
  char t[51];
  scanf("%s", t);
  arquivo = fopen(t, "r");
  while (!feof(arquivo)) {
    if (fscanf(arquivo, "%i", &n) == 1) {
      x = x + 1;
    }
  }
  printf("%i\n", x);
  fclose(arquivo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x50(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b8 <main+0x58>
jmp    11e3 <main+0x83>
mov    -0x10(%rbp),%rdi
lea    0xe42(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <fscanf@plt>
cmp    $0x1,%eax
jne    11de <main+0x7e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119a <main+0x3a>
mov    -0x18(%rbp),%esi
lea    0xe1b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0xe8f(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
jne    11d4 <main+0x74>
xor    %ebp,%ebp
lea    0xe5e(%rip),%r14
lea    0xc(%rsp),%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <fscanf@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
add    %ecx,%ebp
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11b0 <main+0x50>
lea    0xe2d(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [51 x i8]
store i32 0, i32* %1
store i32 0, i32* %4
%6 = getelementptr inbounds [51 x i8], [51 x i8]* %5, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [51 x i8], [51 x i8]* %5, i64 0, i64 0
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %2
br label %10
10: ; preds = %22, %0
%11 = load i32*, i32** %2
%12 = call i32 @feof(i32* %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %23
15: ; preds = %10
%16 = load i32*, i32** %2
%17 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %22
22: ; preds = %19, %15
br label %10
23: ; preds = %10
%24 = load i32, i32* %4
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32*, i32** %2
%27 = call i32 @fclose(i32* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [51 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [51 x i8], [51 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @feof(i32* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %0, %9
%10 = phi i32 [ %14, %9 ], [ 0, %0 ]
%11 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i32
%14 = add nuw nsw i32 %10, %13
%15 = call i32 @feof(i32* %6)
%16 = icmp eq i32 %15, 0
br i1 %16, label %9, label %17
17: ; preds = %9, %0
%18 = phi i32 [ 0, %0 ], [ %14, %9 ]
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = call i32 @fclose(i32* %6)
ret i32 0
}