#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 /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
char is_task(int /*<<< orphan*/ *);
char ungetc(int, int /*<<< orphan*/ *);
char next_task(FILE *file, bool *space) {
  *space = false;
  while (!feof(file)) {
    if (!*space)
      *space = ungetc(getc(file), file) == '\n';
    char x;
    if ((x = is_task(file)))
      return x;
    int c;
    while ((c = getc(file)) != EOF && c != '\n')
      ;
  }
  return 0;
}


x86 assembly (clang, -O0):
<next_task>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1178 <next_task+0x38>
jmp    1217 <next_task+0xd7>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11ad <next_task+0x6d>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1040 <ungetc@plt>
movsbl %al,%eax
cmp    $0xa,%eax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <is_task@plt>
mov    %al,-0x19(%rbp)
cmp    $0x0,%al
je     11cc <next_task+0x8c>
mov    -0x19(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    121b <next_task+0xdb>
jmp    11d1 <next_task+0x91>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%ecx
mov    %ecx,-0x20(%rbp)
xor    %eax,%eax
mov    0x2e00(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x21(%rbp)
je     11fd <next_task+0xbd>
cmpl   $0xa,-0x20(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    120d <next_task+0xcd>
jmp    1212 <next_task+0xd2>
jmp    11d1 <next_task+0x91>
jmp    115a <next_task+0x1a>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_task>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,(%rsi)
call   1030 <feof@plt>
test   %eax,%eax
je     1162 <next_task+0x22>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e7f(%rip),%r15
jmp    117c <next_task+0x3c>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <feof@plt>
test   %eax,%eax
jne    115a <next_task+0x1a>
cmpl   $0x0,(%r14)
jne    119e <next_task+0x5e>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <ungetc@plt>
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %cl
mov    %ecx,(%r14)
mov    %rbx,%rdi
call   1050 <is_task@plt>
test   %al,%al
jne    115c <next_task+0x1c>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    $0xa,%eax
je     1170 <next_task+0x30>
cmp    (%r15),%eax
jne    11b0 <next_task+0x70>
jmp    1170 <next_task+0x30>

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

LLVM IR (-O2):
@EOF = global i32 0
define signext i8 @next_task(i32* %0, i32* nocapture %1) {
store i32 0, i32* %1
%3 = tail call i32 @feof(i32* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %8, label %25
5: ; preds = %19
%6 = tail call i32 @feof(i32* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %25
8: ; preds = %2, %5
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = tail call i32 @getc(i32* %0)
%13 = tail call signext i8 @ungetc(i32 %12, i32* %0)
%14 = icmp eq i8 %13, 10
%15 = zext i1 %14 to i32
store i32 %15, i32* %1
br label %16
16: ; preds = %11, %8
%17 = tail call signext i8 @is_task(i32* %0)
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16, %19
%20 = tail call i32 @getc(i32* %0)
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %20, %21
%23 = icmp ne i32 %20, 10
%24 = and i1 %23, %22
br i1 %24, label %19, label %5
25: ; preds = %5, %16, %2
%26 = phi i8 [ 0, %2 ], [ 0, %5 ], [ %17, %16 ]
ret i8 %26
}