#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 */
int /*<<< orphan*/ reset_buffer();
scalar_t__ siguiente_linea(char *);
scalar_t__ strncmp(char *, char *, int);
int count_nodos() {
  int result = 0;
  char *nonspace;
  char linea[1000];
  reset_buffer();
  while (siguiente_linea(linea) == 0) {
    for (nonspace = linea; *nonspace == ' '; nonspace++)
      ;
    if (strncmp(nonspace, "node", 4) == 0)
      result++;
  }
  return result;
}


x86 assembly (clang, -O0):
<count_nodos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <reset_buffer@plt>
lea    -0x400(%rbp),%rdi
call   1050 <siguiente_linea@plt>
cmp    $0x0,%rax
jne    11bd <count_nodos+0x8d>
lea    -0x400(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1190 <count_nodos+0x60>
jmp    117f <count_nodos+0x4f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    116a <count_nodos+0x3a>
mov    -0x10(%rbp),%rdi
lea    0xe65(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11b8 <count_nodos+0x88>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1149 <count_nodos+0x19>
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_nodos>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3e8,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <reset_buffer@plt>
mov    %rsp,%rdi
call   1050 <siguiente_linea@plt>
test   %rax,%rax
jne    11ab <count_nodos+0x7b>
xor    %ebx,%ebx
lea    -0x1(%rsp),%r12
lea    0xe9e(%rip),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x20,0x1(%rdi)
lea    0x1(%rdi),%rdi
je     1180 <count_nodos+0x50>
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x1,%rax
adc    $0x0,%ebx
mov    %r15,%rdi
call   1050 <siguiente_linea@plt>
test   %rax,%rax
je     1170 <count_nodos+0x40>
mov    %ebx,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"node\00"
define i32 @count_nodos() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [1000 x i8]
store i32 0, i32* %1
%4 = call i32 (...) @reset_buffer()
br label %5
5: ; preds = %27, %0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%7 = call i64 @siguiente_linea(i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %28
9: ; preds = %5
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
store i8* %10, i8** %2
br label %11
11: ; preds = %17, %9
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 32
br i1 %15, label %16, label %20
16: ; preds = %11
br label %17
17: ; preds = %16
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %2
br label %11
20: ; preds = %11
%21 = load i8*, i8** %2
%22 = call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %1
%26 = add nsw i32 %25, 1
store i32 %26, i32* %1
br label %27
27: ; preds = %24, %20
br label %5
28: ; preds = %5
%29 = load i32, i32* %1
ret i32 %29
}

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