#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 *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
char *strstr(char *, char *);
int es_dirigida() {
  int result = 0;
  char *ptr;
  char linea[1000];
  reset_buffer();
  while (siguiente_linea(linea) == 0) {
    ptr = strstr(linea, "directed");
    if (ptr == NULL)
      continue;
    sscanf(ptr, "directed %i", &result);
    break;
  }
  return result;
}


x86 assembly (clang, -O0):
<es_dirigida>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <reset_buffer@plt>
lea    -0x400(%rbp),%rdi
call   1040 <siguiente_linea@plt>
cmp    $0x0,%rax
jne    11aa <es_dirigida+0x6a>
lea    -0x400(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1196 <es_dirigida+0x56>
jmp    1159 <es_dirigida+0x19>
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<es_dirigida>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
movl   $0x0,0xc(%rsp)
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <reset_buffer@plt>
lea    0x10(%rsp),%rbx
lea    0xe97(%rip),%rbp
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <siguiente_linea@plt>
test   %rax,%rax
jne    11a6 <es_dirigida+0x66>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1170 <es_dirigida+0x30>
lea    0xe75(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1050 <sscanf@plt>
mov    0xc(%rsp),%r14d
mov    %r14d,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"directed\00"
@.str.1 = [12 x i8] c"directed %i\00"
define i32 @es_dirigida() {
%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 = %14, %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 %18
9: ; preds = %5
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%11 = call i8* @strstr(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %9
br label %5
15: ; preds = %9
%16 = load i8*, i8** %2
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %18
18: ; preds = %15, %5
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [9 x i8] c"directed\00"
@.str.1 = [12 x i8] c"directed %i\00"
define i32 @es_dirigida() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @reset_buffer()
br label %6
6: ; preds = %9, %0
%7 = call i64 @siguiente_linea(i8* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %6, label %12
12: ; preds = %9
%13 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
br label %15
15: ; preds = %6, %12
%16 = phi i32 [ %14, %12 ], [ 0, %6 ]
ret i32 %16
}