#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 */
char EOF;
char fgetc(int /*<<< orphan*/ *);
int longest_line(FILE *archivo) {
  int n_line = 0;
  int max_line = 0;
  char c;
  while ((c = fgetc(archivo)) != EOF) {
    if (c == '\n') {
      if (n_line > max_line)
        max_line = n_line;
      n_line = 0;
    } else {
      n_line++;
    }
  }
  return max_line;
}


x86 assembly (clang, -O0):
<longest_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2ea8(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1184 <longest_line+0x74>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jne    1176 <longest_line+0x66>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    116a <longest_line+0x5a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    117f <longest_line+0x6f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112a <longest_line+0x1a>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<longest_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
call   1030 <fgetc@plt>
mov    0x2ec1(%rip),%r14
xor    %ebp,%ebp
cmp    (%r14),%al
je     1160 <longest_line+0x50>
xor    %r15d,%r15d
xor    %ecx,%ecx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rcx),%ebx
cmp    %ebp,%ecx
cmovle %ebp,%ecx
cmp    $0xa,%al
cmove  %ecx,%ebp
cmove  %r15d,%ebx
mov    %r12,%rdi
call   1030 <fgetc@plt>
mov    %ebx,%ecx
cmp    (%r14),%al
jne    1140 <longest_line+0x30>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @longest_line(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %27, %1
%7 = load i32*, i32** %2
%8 = call signext i8 @fgetc(i32* %7)
store i8 %8, i8* %5
%9 = sext i8 %8 to i32
%10 = load i8, i8* @EOF
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %9, %11
br i1 %12, label %13, label %28
13: ; preds = %6
%14 = load i8, i8* %5
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %24
17: ; preds = %13
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32, i32* %3
store i32 %22, i32* %4
br label %23
23: ; preds = %21, %17
store i32 0, i32* %3
br label %27
24: ; preds = %13
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %27
27: ; preds = %24, %23
br label %6
28: ; preds = %6
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @longest_line(i32* nocapture %0) {
%2 = tail call signext i8 @fgetc(i32* %0)
%3 = load i8, i8* @EOF
%4 = icmp eq i8 %2, %3
br i1 %4, label %18, label %5
5: ; preds = %1, %5
%6 = phi i8 [ %15, %5 ], [ %2, %1 ]
%7 = phi i32 [ %14, %5 ], [ 0, %1 ]
%8 = phi i32 [ %13, %5 ], [ 0, %1 ]
%9 = icmp eq i8 %6, 10
%10 = icmp sgt i32 %7, %8
%11 = add nsw i32 %7, 1
%12 = select i1 %9, i1 %10, i1 false
%13 = select i1 %12, i32 %7, i32 %8
%14 = select i1 %9, i32 0, i32 %11
%15 = tail call signext i8 @fgetc(i32* %0)
%16 = load i8, i8* @EOF
%17 = icmp eq i8 %15, %16
br i1 %17, label %18, label %5
18: ; preds = %5, %1
%19 = phi i32 [ 0, %1 ], [ %13, %5 ]
ret i32 %19
}