#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 */
#define EOF 128
int async_getc(int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int async_fnextc(register FILE *f, register int flags) {
  register int c;
  c = async_getc(f);
  for (;;) {
    switch (c) {
    case EOF:
    case (-2):
      return (c);
    case ' ':
    case '\t':
      break;
    case '#':
      if (flags & 2)
        goto fim;
      while ((c = getc(f)) != '\n' && c != EOF)
        ;
      continue;
    case '\n':
      if (!(flags & 1))
        break;
    default:
    fim:
      ungetc(c, f);
      return (c);
    }
    c = async_getc(f);
  }
}


x86 assembly (clang, -O0):
<async_fnextc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <async_getc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0xfffffffe,%eax
je     11b6 <async_fnextc+0x86>
jmp    115f <async_fnextc+0x2f>
mov    -0x1c(%rbp),%eax
sub    $0x9,%eax
je     11c1 <async_fnextc+0x91>
jmp    1170 <async_fnextc+0x40>
mov    -0x1c(%rbp),%eax
sub    $0xa,%eax
je     1222 <async_fnextc+0xf2>
jmp    1181 <async_fnextc+0x51>
mov    -0x1c(%rbp),%eax
sub    $0x20,%eax
je     11c1 <async_fnextc+0x91>
jmp    1192 <async_fnextc+0x62>
mov    -0x1c(%rbp),%eax
sub    $0x23,%eax
je     11c6 <async_fnextc+0x96>
jmp    11a3 <async_fnextc+0x73>
mov    -0x1c(%rbp),%eax
sub    $0x80,%eax
jne    123b <async_fnextc+0x10b>
jmp    11b6 <async_fnextc+0x86>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1268 <async_fnextc+0x138>
jmp    1257 <async_fnextc+0x127>
mov    -0x14(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11da <async_fnextc+0xaa>
jmp    1240 <async_fnextc+0x110>
jmp    11df <async_fnextc+0xaf>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1d(%rbp)
je     1208 <async_fnextc+0xd8>
cmpl   $0x80,-0x18(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1218 <async_fnextc+0xe8>
jmp    121d <async_fnextc+0xed>
jmp    11df <async_fnextc+0xaf>
jmp    114b <async_fnextc+0x1b>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1236 <async_fnextc+0x106>
jmp    1257 <async_fnextc+0x127>
jmp    123b <async_fnextc+0x10b>
jmp    1240 <async_fnextc+0x110>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <ungetc@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1268 <async_fnextc+0x138>
mov    -0x10(%rbp),%rdi
call   1030 <async_getc@plt>
mov    %eax,-0x18(%rbp)
jmp    114b <async_fnextc+0x1b>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<async_fnextc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
call   1030 <async_getc@plt>
mov    %eax,%ebp
lea    0xeb5(%rip),%r15
jmp    1160 <async_fnextc+0x30>
nopl   (%rax)
test   $0x1,%r14b
jne    11a1 <async_fnextc+0x71>
mov    %rbx,%rdi
call   1030 <async_getc@plt>
mov    %eax,%ebp
lea    0x2(%rbp),%eax
cmp    $0x25,%eax
ja     1199 <async_fnextc+0x69>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
test   $0x2,%r14b
jne    11a1 <async_fnextc+0x71>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <getc@plt>
mov    %eax,%ebp
cmp    $0xa,%eax
je     1160 <async_fnextc+0x30>
cmp    $0x80,%ebp
jne    1180 <async_fnextc+0x50>
jmp    1160 <async_fnextc+0x30>
cmp    $0x80,%ebp
je     11ab <async_fnextc+0x7b>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <ungetc@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @async_fnextc(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%7 = load i32*, i32** %4
%8 = call i32 @async_getc(i32* %7)
store i32 %8, i32* %6
br label %9
9: ; preds = %43, %30, %2
%10 = load i32, i32* %6
switch i32 %10, label %37 [
i32 128, label %11
i32 -2, label %11
i32 32, label %13
i32 9, label %13
i32 35, label %14
i32 10, label %31
]
11: ; preds = %9, %9
%12 = load i32, i32* %6
store i32 %12, i32* %3
br label %46
13: ; preds = %9, %9
br label %43
14: ; preds = %9
%15 = load i32, i32* %5
%16 = and i32 %15, 2
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
br label %38
19: ; preds = %14
br label %20
20: ; preds = %29, %19
%21 = load i32*, i32** %4
%22 = call i32 @getc(i32* %21)
store i32 %22, i32* %6
%23 = icmp ne i32 %22, 10
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %6
%26 = icmp ne i32 %25, 128
br label %27
27: ; preds = %24, %20
%28 = phi i1 [ false, %20 ], [ %26, %24 ]
br i1 %28, label %29, label %30
29: ; preds = %27
br label %20
30: ; preds = %27
br label %9
31: ; preds = %9
%32 = load i32, i32* %5
%33 = and i32 %32, 1
%34 = icmp ne i32 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %31
br label %43
36: ; preds = %31
br label %37
37: ; preds = %9, %36
br label %38
38: ; preds = %37, %18
%39 = load i32, i32* %6
%40 = load i32*, i32** %4
%41 = call i32 @ungetc(i32 %39, i32* %40)
%42 = load i32, i32* %6
store i32 %42, i32* %3
br label %46
43: ; preds = %35, %13
%44 = load i32*, i32** %4
%45 = call i32 @async_getc(i32* %44)
store i32 %45, i32* %6
br label %9
46: ; preds = %38, %11
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
define i32 @async_fnextc(i32* %0, i32 %1) {
%3 = tail call i32 @async_getc(i32* %0)
%4 = and i32 %1, 1
%5 = icmp eq i32 %4, 0
%6 = and i32 %1, 2
%7 = icmp eq i32 %6, 0
br label %8
8: ; preds = %18, %2
%9 = phi i32 [ %3, %2 ], [ %19, %18 ]
switch i32 %9, label %14 [
i32 128, label %20
i32 -2, label %20
i32 32, label %16
i32 9, label %16
i32 35, label %10
i32 10, label %13
]
10: ; preds = %8
br i1 %7, label %11, label %14
11: ; preds = %10, %11
%12 = tail call i32 @getc(i32* %0)
switch i32 %12, label %11 [
i32 128, label %18
i32 10, label %18
]
13: ; preds = %8
br i1 %5, label %16, label %14
14: ; preds = %8, %13, %10
%15 = tail call i32 @ungetc(i32 %9, i32* %0)
br label %20
16: ; preds = %13, %8, %8
%17 = tail call i32 @async_getc(i32* %0)
br label %18
18: ; preds = %11, %11, %16
%19 = phi i32 [ %17, %16 ], [ %12, %11 ], [ %12, %11 ]
br label %8
20: ; preds = %8, %8, %14
ret i32 %9
}