#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 ar_peek(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ is_eof(int /*<<< orphan*/ *);
void scan_to_eol(FILE *f) {
  char c;
  while (!is_eof(f) && ((c = ar_peek(f)) != -1 && (c != '\n'))) {
    c = fgetc(f);
  }
}


x86 assembly (clang, -O0):
<scan_to_eol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <is_eof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xa(%rbp)
jne    1185 <scan_to_eol+0x55>
mov    -0x8(%rbp),%rdi
call   1030 <ar_peek@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0xb(%rbp)
je     117f <scan_to_eol+0x4f>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0xb(%rbp)
mov    -0xb(%rbp),%al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    1195 <scan_to_eol+0x65>
jmp    11a6 <scan_to_eol+0x76>
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x9(%rbp)
jmp    113c <scan_to_eol+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_to_eol>:
push   %rbx
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1040 <is_eof@plt>
test   %eax,%eax
jne    1166 <scan_to_eol+0x36>
mov    %rbx,%rdi
call   1030 <ar_peek@plt>
cmp    $0xff,%al
je     1166 <scan_to_eol+0x36>
cmp    $0xa,%al
je     1166 <scan_to_eol+0x36>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %rbx,%rdi
jmp    1140 <scan_to_eol+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @scan_to_eol(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
store i32* %0, i32** %2
br label %4
4: ; preds = %21, %1
%5 = load i32*, i32** %2
%6 = call i32 @is_eof(i32* %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %4
%9 = load i32*, i32** %2
%10 = call signext i8 @ar_peek(i32* %9)
store i8 %10, i8* %3
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 10
br label %17
17: ; preds = %13, %8
%18 = phi i1 [ false, %8 ], [ %16, %13 ]
br label %19
19: ; preds = %17, %4
%20 = phi i1 [ false, %4 ], [ %18, %17 ]
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = load i32*, i32** %2
%23 = call signext i8 @fgetc(i32* %22)
store i8 %23, i8* %3
br label %4
24: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @scan_to_eol(i32* %0) {
%2 = tail call i32 @is_eof(i32* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %10
4: ; preds = %1, %6
%5 = tail call signext i8 @ar_peek(i32* %0)
switch i8 %5, label %6 [
i8 -1, label %10
i8 10, label %10
]
6: ; preds = %4
%7 = tail call signext i8 @fgetc(i32* %0)
%8 = tail call i32 @is_eof(i32* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %4, label %10
10: ; preds = %6, %4, %4, %1
ret void
}