#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 EOF;
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ token_incline(int *);
int token_nextline(FILE *f, int *linenum) {
  int c;
  while ((c = fgetc(f)) != EOF && c != '\n')
    ;
  if (c == '\n')
    token_incline(linenum);
  return (c != EOF);
}


x86 assembly (clang, -O0):
<token_nextline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
mov    0x2ea1(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x15(%rbp)
je     115c <token_nextline+0x3c>
cmpl   $0xa,-0x14(%rbp)
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    116c <token_nextline+0x4c>
jmp    1171 <token_nextline+0x51>
jmp    1130 <token_nextline+0x10>
cmpl   $0xa,-0x14(%rbp)
jne    1184 <token_nextline+0x64>
mov    -0x10(%rbp),%rdi
call   1030 <token_incline@plt>
mov    -0x14(%rbp),%eax
mov    0x2e5a(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<token_nextline>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2eb4(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebp
mov    (%r15),%ecx
cmp    $0xa,%eax
je     1156 <token_nextline+0x36>
cmp    %ecx,%ebp
jne    1140 <token_nextline+0x20>
cmp    $0xa,%ebp
jne    1166 <token_nextline+0x46>
mov    %r14,%rdi
call   1030 <token_incline@plt>
mov    (%r15),%ecx
xor    %eax,%eax
cmp    %ecx,%ebp
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @token_nextline(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %6
6: ; preds = %16, %2
%7 = load i32*, i32** %3
%8 = call i32 @fgetc(i32* %7)
store i32 %8, i32* %5
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 10
br label %14
14: ; preds = %11, %6
%15 = phi i1 [ false, %6 ], [ %13, %11 ]
br i1 %15, label %16, label %17
16: ; preds = %14
br label %6
17: ; preds = %14
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32*, i32** %4
%22 = call i32 @token_incline(i32* %21)
br label %23
23: ; preds = %20, %17
%24 = load i32, i32* %5
%25 = load i32, i32* @EOF
%26 = icmp ne i32 %24, %25
%27 = zext i1 %26 to i32
ret i32 %27
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @token_nextline(i32* nocapture %0, i32* %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call i32 @fgetc(i32* %0)
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
%7 = icmp ne i32 %4, 10
%8 = and i1 %7, %6
br i1 %8, label %3, label %9
9: ; preds = %3
%10 = icmp eq i32 %4, 10
br i1 %10, label %11, label %14
11: ; preds = %9
%12 = tail call i32 @token_incline(i32* %1)
%13 = load i32, i32* @EOF
br label %14
14: ; preds = %11, %9
%15 = phi i32 [ %13, %11 ], [ %5, %9 ]
%16 = icmp ne i32 %4, %15
%17 = zext i1 %16 to i32
ret i32 %17
}