#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*/ hFich;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int buscarHora(FILE *calendar, char h[], char nFich[]) {
  bool enc = false;
  int posHora = 354;
  char hFich[6];
  calendar = fopen("ENERO2017.txt", "r");
  if (calendar == NULL) {
    printf("CALENDARIO NO ENCONTRADO.\n");
  } else {
    while (!enc && !feof(calendar)) {
      memset(hFich, 0, sizeof(hFich));
      fseek(calendar, posHora, SEEK_SET);
      fgets(hFich, 6, calendar);
      if (strcmp(hFich, h) == 0) {
        enc = true;
      } else {
        posHora = posHora + 1064;
      }
    }
  }
  if (!enc)
    posHora = 0;
  return posHora;
}


x86 assembly (clang, -O0):
<buscarHora>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x162,-0x20(%rbp)
lea    0xe67(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11c5 <buscarHora+0x55>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
jmp    126c <buscarHora+0xfc>
jmp    11ca <buscarHora+0x5a>
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x27(%rbp)
jne    11ed <buscarHora+0x7d>
mov    -0x8(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x27(%rbp)
mov    -0x27(%rbp),%al
test   $0x1,%al
jne    11fd <buscarHora+0x8d>
jmp    1267 <buscarHora+0xf7>
lea    -0x26(%rbp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    0x2dc5(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
lea    -0x26(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x6,%esi
call   1050 <fgets@plt>
lea    -0x26(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1257 <buscarHora+0xe7>
movl   $0x1,-0x1c(%rbp)
jmp    1262 <buscarHora+0xf2>
mov    -0x20(%rbp),%eax
add    $0x428,%eax
mov    %eax,-0x20(%rbp)
jmp    11ca <buscarHora+0x5a>
jmp    126c <buscarHora+0xfc>
cmpl   $0x0,-0x1c(%rbp)
jne    127d <buscarHora+0x10d>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buscarHora>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
lea    0xe7a(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1201 <buscarHora+0x91>
mov    %rax,%rbx
mov    $0xfffffd3a,%ebp
lea    0xa(%rsp),%r15
mov    0x2e35(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    120d <buscarHora+0x9d>
add    $0x428,%ebp
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1040 <memset@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1080 <fseek@plt>
mov    %r15,%rdi
mov    $0x6,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11b0 <buscarHora+0x40>
jmp    120f <buscarHora+0x9f>
lea    0xe08(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"ENERO2017.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [27 x i8] c"CALENDARIO NO ENCONTRADO.\0A\00"
@SEEK_SET = global i32 0
define i32 @buscarHora(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [6 x i8]
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
store i32 354, i32* %8
%10 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %4
%11 = load i32*, i32** %4
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %46
15: ; preds = %3
br label %16
16: ; preds = %44, %15
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %16
%20 = load i32*, i32** %4
%21 = call i32 @feof(i32* %20)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br label %24
24: ; preds = %19, %16
%25 = phi i1 [ false, %16 ], [ %23, %19 ]
br i1 %25, label %26, label %45
26: ; preds = %24
%27 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 0
%28 = call i32 @memset(i8* %27, i32 0, i32 6)
%29 = load i32*, i32** %4
%30 = load i32, i32* %8
%31 = load i32, i32* @SEEK_SET
%32 = call i32 @fseek(i32* %29, i32 %30, i32 %31)
%33 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 0
%34 = load i32*, i32** %4
%35 = call i32 @fgets(i8* %33, i32 6, i32* %34)
%36 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 0
%37 = load i8*, i8** %5
%38 = call i64 @strcmp(i8* %36, i8* %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %26
store i32 1, i32* %7
br label %44
41: ; preds = %26
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1064
store i32 %43, i32* %8
br label %44
44: ; preds = %41, %40
br label %16
45: ; preds = %24
br label %46
46: ; preds = %45, %13
%47 = load i32, i32* %7
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %46
store i32 0, i32* %8
br label %50
50: ; preds = %49, %46
%51 = load i32, i32* %8
ret i32 %51
}

LLVM IR (-O2):
@.str = [14 x i8] c"ENERO2017.txt\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_SET = global i32 0
@str = [26 x i8] c"CALENDARIO NO ENCONTRADO.\00"
define i32 @buscarHora(i32* nocapture readnone %0, i8* %1, i8* nocapture readnone %2) {
%4 = alloca [6 x i8]
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %22
10: ; preds = %3, %14
%11 = phi i32 [ %21, %14 ], [ 354, %3 ]
%12 = call i32 @feof(i32* %6)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = call i32 @memset(i8* %5, i32 0, i32 6)
%16 = load i32, i32* @SEEK_SET
%17 = call i32 @fseek(i32* %6, i32 %11, i32 %16)
%18 = call i32 @fgets(i8* %5, i32 6, i32* %6)
%19 = call i64 @strcmp(i8* %5, i8* %1)
%20 = icmp eq i64 %19, 0
%21 = add nuw nsw i32 %11, 1064
br i1 %20, label %22, label %10
22: ; preds = %10, %14, %8
%23 = phi i32 [ 0, %8 ], [ 0, %10 ], [ %11, %14 ]
ret i32 %23
}