#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 */
struct parser {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ isspace(int);
int /*<<< orphan*/ next(struct parser *);
int peek(struct parser *);
int expect_eol(struct parser *p) {
  int allblank = 1;
  int comment = 0;
  int ch;
  while ((ch = peek(p)) != (-1) && ch != '\n') {
    if (ch == '#' && allblank)
      comment = 1;
    else if (!isspace(ch))
      allblank = 0;
    next(p);
  }
  return allblank || comment;
}


x86 assembly (clang, -O0):
<expect_eol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <peek@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x15(%rbp)
je     1170 <expect_eol+0x40>
cmpl   $0xa,-0x14(%rbp)
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1180 <expect_eol+0x50>
jmp    11cb <expect_eol+0x9b>
cmpl   $0x23,-0x14(%rbp)
jne    11a0 <expect_eol+0x70>
cmpl   $0x0,-0xc(%rbp)
je     11a0 <expect_eol+0x70>
movl   $0x1,-0x10(%rbp)
jmp    11bd <expect_eol+0x8d>
mov    -0x14(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
jne    11b8 <expect_eol+0x88>
movl   $0x0,-0xc(%rbp)
jmp    11bd <expect_eol+0x8d>
mov    -0x8(%rbp),%rdi
call   1050 <next@plt>
jmp    114a <expect_eol+0x1a>
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x16(%rbp)
jne    11e4 <expect_eol+0xb4>
cmpl   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expect_eol>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
mov    $0x1,%r12d
xor    %r14d,%r14d
jmp    1171 <expect_eol+0x41>
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%edi
call   1040 <isspace@plt>
test   %eax,%eax
cmove  %eax,%r12d
mov    %r14d,%ebx
mov    %r12d,%ebp
mov    %r15,%rdi
call   1050 <next@plt>
mov    %ebx,%r14d
mov    %ebp,%r12d
mov    %r15,%rdi
call   1030 <peek@plt>
cmp    $0xffffffff,%eax
je     1199 <expect_eol+0x69>
cmp    $0xa,%eax
je     1199 <expect_eol+0x69>
cmp    $0x23,%eax
jne    1150 <expect_eol+0x20>
mov    $0x1,%ebx
mov    $0x1,%ebp
test   %r12d,%r12d
jne    1163 <expect_eol+0x33>
jmp    1150 <expect_eol+0x20>
xor    %eax,%eax
or     %r14d,%r12d
setne  %al
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.parser = type { i32 }
define i32 @expect_eol(%struct.parser* %0) {
%2 = alloca %struct.parser*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store %struct.parser* %0, %struct.parser** %2
store i32 1, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %28, %1
%7 = load %struct.parser*, %struct.parser** %2
%8 = call i32 @peek(%struct.parser* %7)
store i32 %8, i32* %5
%9 = icmp ne i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i32, i32* %5
%12 = icmp ne i32 %11, 10
br label %13
13: ; preds = %10, %6
%14 = phi i1 [ false, %6 ], [ %12, %10 ]
br i1 %14, label %15, label %31
15: ; preds = %13
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 35
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 1, i32* %4
br label %28
22: ; preds = %18, %15
%23 = load i32, i32* %5
%24 = call i32 @isspace(i32 %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %22
store i32 0, i32* %3
br label %27
27: ; preds = %26, %22
br label %28
28: ; preds = %27, %21
%29 = load %struct.parser*, %struct.parser** %2
%30 = call i32 @next(%struct.parser* %29)
br label %6
31: ; preds = %13
%32 = load i32, i32* %3
%33 = icmp ne i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i32, i32* %4
%36 = icmp ne i32 %35, 0
br label %37
37: ; preds = %34, %31
%38 = phi i1 [ true, %31 ], [ %36, %34 ]
%39 = zext i1 %38 to i32
ret i32 %39
}

LLVM IR (-O2):
%struct.parser = type { i32 }
define i32 @expect_eol(%struct.parser* %0) {
br label %2
2: ; preds = %14, %1
%3 = phi i32 [ 0, %1 ], [ %15, %14 ]
%4 = phi i32 [ 1, %1 ], [ %16, %14 ]
%5 = tail call i32 @peek(%struct.parser* %0)
switch i32 %5, label %6 [
i32 -1, label %18
i32 10, label %18
]
6: ; preds = %2
%7 = icmp eq i32 %5, 35
%8 = icmp ne i32 %4, 0
%9 = select i1 %7, i1 %8, i1 false
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = tail call i32 @isspace(i32 %5)
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 0, i32 %4
br label %14
14: ; preds = %10, %6
%15 = phi i32 [ 1, %6 ], [ %3, %10 ]
%16 = phi i32 [ 1, %6 ], [ %13, %10 ]
%17 = tail call i32 @next(%struct.parser* %0)
br label %2
18: ; preds = %2, %2
%19 = icmp ne i32 %4, 0
%20 = icmp ne i32 %3, 0
%21 = select i1 %19, i1 true, i1 %20
%22 = zext i1 %21 to i32
ret i32 %22
}