#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 EOF;
char fgetc(int /*<<< orphan*/ *);
int DiscardLineOfInput(FILE *stream) {
  if (!stream) {
    return 1;
  }
  char c = '\0';
  while ((c = fgetc(stream)) != '\n') {
    if (c == EOF) {
      return EOF;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<DiscardLineOfInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <DiscardLineOfInput+0x23>
movl   $0x1,-0x4(%rbp)
jmp    1183 <DiscardLineOfInput+0x73>
movb   $0x0,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     117c <DiscardLineOfInput+0x6c>
movsbl -0x11(%rbp),%eax
mov    0x2e8e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1177 <DiscardLineOfInput+0x67>
mov    0x2e7c(%rip),%rax
movsbl (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1183 <DiscardLineOfInput+0x73>
jmp    1137 <DiscardLineOfInput+0x27>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DiscardLineOfInput>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1146 <DiscardLineOfInput+0x36>
mov    %rdi,%rbx
mov    0x2ec5(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0xa,%al
je     114d <DiscardLineOfInput+0x3d>
cmp    (%r14),%al
jne    1130 <DiscardLineOfInput+0x20>
movsbl %al,%eax
jmp    114f <DiscardLineOfInput+0x3f>
mov    $0x1,%eax
jmp    114f <DiscardLineOfInput+0x3f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @DiscardLineOfInput(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = icmp ne i32* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 1, i32* %2
br label %25
8: ; preds = %1
store i8 0, i8* %4
br label %9
9: ; preds = %23, %8
%10 = load i32*, i32** %3
%11 = call signext i8 @fgetc(i32* %10)
store i8 %11, i8* %4
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %24
14: ; preds = %9
%15 = load i8, i8* %4
%16 = sext i8 %15 to i32
%17 = load i8, i8* @EOF
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i8, i8* @EOF
%22 = sext i8 %21 to i32
store i32 %22, i32* %2
br label %25
23: ; preds = %14
br label %9
24: ; preds = %9
store i32 0, i32* %2
br label %25
25: ; preds = %24, %20, %7
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @DiscardLineOfInput(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %11, label %3
3: ; preds = %1, %6
%4 = tail call signext i8 @fgetc(i32* %0)
%5 = icmp eq i8 %4, 10
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = load i8, i8* @EOF
%8 = icmp eq i8 %4, %7
br i1 %8, label %9, label %3
9: ; preds = %6
%10 = sext i8 %4 to i32
br label %11
11: ; preds = %3, %9, %1
%12 = phi i32 [ 1, %1 ], [ %10, %9 ], [ 0, %3 ]
ret i32 %12
}