#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
cuenta_lineas(FILE *pf) {
  char linea_buf[81];
  int c = 0;
  while (!ferror(pf) && !feof(pf)) {
    fgets(linea_buf, 81, pf);
    c++;
    (c % 2) ? printf("\\\r") : printf("/\r");
  }
  if (ferror(pf)) {
    printf("Ha ocurrido un error de lectura.");
    fclose(pf);
    exit(3);
  }
  putchar('\n');
  fclose(pf);
  return c;
}


x86 assembly (clang, -O0):
<cuenta_lineas>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <ferror@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x65(%rbp)
jne    11b2 <cuenta_lineas+0x42>
mov    -0x8(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x65(%rbp)
mov    -0x65(%rbp),%al
test   $0x1,%al
jne    11c2 <cuenta_lineas+0x52>
jmp    1213 <cuenta_lineas+0xa3>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x51,%esi
call   1070 <fgets@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1202 <cuenta_lineas+0x92>
lea    0xe08(%rip),%rdi
call   1060 <printf@plt>
jmp    120e <cuenta_lineas+0x9e>
lea    0xdfa(%rip),%rdi
call   1060 <printf@plt>
jmp    1183 <cuenta_lineas+0x13>
mov    -0x8(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     1245 <cuenta_lineas+0xd5>
lea    0xdd9(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x3,%edi
call   1090 <exit@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x64(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cuenta_lineas>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
mov    %rdi,%rbx
call   1040 <ferror@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11dc <cuenta_lineas+0x6c>
xor    %ebp,%ebp
mov    %rsp,%r14
lea    0xe6c(%rip),%r15
lea    0xe62(%rip),%r12
xchg   %ax,%ax
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11dc <cuenta_lineas+0x6c>
mov    %r14,%rdi
mov    $0x51,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
add    $0x1,%ebp
test   $0x1,%bpl
mov    %r12,%rdi
cmove  %r15,%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
je     11a0 <cuenta_lineas+0x30>
mov    %rbx,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    120a <cuenta_lineas+0x9a>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %ebp,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf5(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    $0x3,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\\\0D\00"
@.str.1 = [3 x i8] c"/\0D\00"
@.str.2 = [33 x i8] c"Ha ocurrido un error de lectura.\00"
define i32 @cuenta_lineas(i32* %0) {
%2 = alloca i32*
%3 = alloca [81 x i8]
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %4
br label %5
5: ; preds = %29, %1
%6 = load i32*, i32** %2
%7 = call i64 @ferror(i32* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %5
%10 = load i32*, i32** %2
%11 = call i32 @feof(i32* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br label %14
14: ; preds = %9, %5
%15 = phi i1 [ false, %5 ], [ %13, %9 ]
br i1 %15, label %16, label %31
16: ; preds = %14
%17 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%18 = load i32*, i32** %2
%19 = call i32 @fgets(i8* %17, i32 81, i32* %18)
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = srem i32 %22, 2
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %16
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %29
27: ; preds = %16
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
%30 = phi i32 [ %26, %25 ], [ %28, %27 ]
br label %5
31: ; preds = %14
%32 = load i32*, i32** %2
%33 = call i64 @ferror(i32* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32*, i32** %2
%38 = call i32 @fclose(i32* %37)
%39 = call i32 @exit(i32 3)
unreachable
40: ; preds = %31
%41 = call i32 @putchar(i8 signext 10)
%42 = load i32*, i32** %2
%43 = call i32 @fclose(i32* %42)
%44 = load i32, i32* %4
ret i32 %44
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\\0D\00"
@.str.1 = [3 x i8] c"/\0D\00"
@.str.2 = [33 x i8] c"Ha ocurrido un error de lectura.\00"
define i32 @cuenta_lineas(i32* nocapture %0) {
%2 = alloca [81 x i8]
%3 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%4 = call i64 @ferror(i32* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %1, %10
%7 = phi i32 [ %12, %10 ], [ 0, %1 ]
%8 = call i32 @feof(i32* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = call i32 @fgets(i8* %3, i32 81, i32* %0)
%12 = add nuw nsw i32 %7, 1
%13 = and i32 %12, 1
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%16 = call i32 @printf(i8* dereferenceable(1) %15)
%17 = call i64 @ferror(i32* %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %6, label %19
19: ; preds = %6, %10, %1
%20 = phi i32 [ 0, %1 ], [ %12, %10 ], [ %7, %6 ]
%21 = call i64 @ferror(i32* %0)
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @fclose(i32* %0)
%26 = call i32 @exit(i32 3)
unreachable
27: ; preds = %19
%28 = call i32 @putchar(i8 signext 10)
%29 = call i32 @fclose(i32* %0)
ret i32 %20
}