#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 fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
void _flush_stream(FILE *f) {
  for (int res = 0; (res != EOF) && (res != 0xc0U); res = fgetc(f)) {
    if (res == 0x0aU) {
      ungetc(res, f);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<_flush_stream>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
mov    0x2ea9(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0xd(%rbp)
je     1157 <_flush_stream+0x37>
cmpl   $0xc0,-0xc(%rbp)
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1167 <_flush_stream+0x47>
jmp    1198 <_flush_stream+0x78>
cmpl   $0xa,-0xc(%rbp)
jne    1182 <_flush_stream+0x62>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <ungetc@plt>
jmp    1198 <_flush_stream+0x78>
jmp    1187 <_flush_stream+0x67>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0xc(%rbp)
jmp    1133 <_flush_stream+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_flush_stream>:
push   %r14
push   %rbx
push   %rax
mov    0x2ebd(%rip),%r14
cmpl   $0x0,(%r14)
je     1159 <_flush_stream+0x39>
mov    %rdi,%rbx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
cmp    $0xa,%eax
je     1161 <_flush_stream+0x41>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0xc0,%eax
je     1159 <_flush_stream+0x39>
cmp    (%r14),%eax
jne    1140 <_flush_stream+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0xa,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <ungetc@plt>

LLVM IR (-O0):
@EOF = global i32 0
define void @_flush_stream(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %4
4: ; preds = %21, %1
%5 = load i32, i32* %3
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 192
br label %11
11: ; preds = %8, %4
%12 = phi i1 [ false, %4 ], [ %10, %8 ]
br i1 %12, label %13, label %24
13: ; preds = %11
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* %3
%18 = load i32*, i32** %2
%19 = call i32 @ungetc(i32 %17, i32* %18)
br label %24
20: ; preds = %13
br label %21
21: ; preds = %20
%22 = load i32*, i32** %2
%23 = call i32 @fgetc(i32* %22)
store i32 %23, i32* %3
br label %4
24: ; preds = %16, %11
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @_flush_stream(i32* nocapture %0) {
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %2, 0
br i1 %3, label %15, label %4
4: ; preds = %1, %9
%5 = phi i32 [ %10, %9 ], [ 0, %1 ]
%6 = icmp eq i32 %5, 10
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @ungetc(i32 10, i32* %0)
br label %15
9: ; preds = %4
%10 = tail call i32 @fgetc(i32* %0)
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
%13 = icmp ne i32 %10, 192
%14 = and i1 %13, %12
br i1 %14, label %4, label %15
15: ; preds = %9, %1, %7
ret void
}