#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 /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ strcmp(char *, char *);
int check_for_done(FILE *in) {
  char buf[1024];
  int done = 0;
  while (!feof(in)) {
    fgets(buf, 1024, in);
    if (!feof(in)) {
      done = !strcmp(buf, "Scheduler: done!\n");
    }
  }
  return done;
}


x86 assembly (clang, -O0):
<check_for_done>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x414(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1167 <check_for_done+0x37>
jmp    11b9 <check_for_done+0x89>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1030 <fgets@plt>
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
jne    11b4 <check_for_done+0x84>
lea    -0x410(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x414(%rbp)
jmp    1149 <check_for_done+0x19>
mov    -0x414(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_for_done>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rbx
call   1040 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1147 <check_for_done+0x27>
mov    %ebp,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebp,%ebp
mov    %rsp,%r14
jmp    115c <check_for_done+0x3c>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %eax,%eax
jne    1139 <check_for_done+0x19>
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1030 <fgets@plt>
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %eax,%eax
jne    1150 <check_for_done+0x30>
movzwl 0x10(%rsp),%eax
movd   %eax,%xmm0
pcmpeqb 0xe87(%rip),%xmm0
movdqa (%rsp),%xmm1
pcmpeqb 0xe6a(%rip),%xmm1
pand   %xmm0,%xmm1
pmovmskb %xmm1,%eax
xor    %ebp,%ebp
cmp    $0xffff,%eax
sete   %bpl
jmp    1150 <check_for_done+0x30>

LLVM IR (-O0):
@.str = [18 x i8] c"Scheduler: done!\0A\00"
define i32 @check_for_done(i32* %0) {
%2 = alloca i32*
%3 = alloca [1024 x i8]
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %4
br label %5
5: ; preds = %23, %1
%6 = load i32*, i32** %2
%7 = call i32 @feof(i32* %6)
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
br i1 %9, label %10, label %24
10: ; preds = %5
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%12 = load i32*, i32** %2
%13 = call i32 @fgets(i8* %11, i32 1024, i32* %12)
%14 = load i32*, i32** %2
%15 = call i32 @feof(i32* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %10
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
%22 = zext i1 %21 to i32
store i32 %22, i32* %4
br label %23
23: ; preds = %17, %10
br label %5
24: ; preds = %5
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
@.str = [18 x i8] c"Scheduler: done!\0A\00"
define i32 @check_for_done(i32* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @feof(i32* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %1, %15
%7 = phi i32 [ %16, %15 ], [ 0, %1 ]
%8 = call i32 @fgets(i8* %3, i32 1024, i32* %0)
%9 = call i32 @feof(i32* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = call i32 @bcmp(i8* dereferenceable(18) %3, i8* dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 18)
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %11, %6
%16 = phi i32 [ %7, %6 ], [ %14, %11 ]
%17 = call i32 @feof(i32* %0)
%18 = icmp eq i32 %17, 0
br i1 %18, label %6, label %19
19: ; preds = %15, %1
%20 = phi i32 [ 0, %1 ], [ %16, %15 ]
ret i32 %20
}