#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;
scalar_t__ feof(int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int P_eof(FILE *f) {
  register int ch;
  if (feof(f))
    return 1;
  if (f == stdin)
    return 0;
  ch = getc(f);
  if (ch == EOF)
    return 1;
  ungetc(ch, f);
  return 0;
}


x86 assembly (clang, -O0):
<P_eof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <feof@plt>
cmp    $0x0,%rax
je     115b <P_eof+0x2b>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <P_eof+0x88>
mov    -0x10(%rbp),%rax
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%rax
jne    117b <P_eof+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <P_eof+0x88>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e4f(%rip),%rcx
cmp    (%rcx),%eax
jne    11a5 <P_eof+0x75>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <P_eof+0x88>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <ungetc@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<P_eof>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <feof@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1170 <P_eof+0x40>
mov    0x2e9c(%rip),%rax
cmp    %rbx,(%rax)
je     116e <P_eof+0x3e>
mov    %rbx,%rdi
call   1050 <getc@plt>
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%eax
je     1170 <P_eof+0x40>
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <ungetc@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@stdin = global i32* null
@EOF = global i32 0
define i32 @P_eof(i32* nocapture %0) {
%2 = tail call i64 @feof(i32* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = load i32*, i32** @stdin
%6 = icmp eq i32* %5, %0
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = tail call i32 @getc(i32* %0)
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @ungetc(i32 %8, i32* %0)
br label %13
13: ; preds = %7, %4, %1, %11
%14 = phi i32 [ 0, %11 ], [ 1, %1 ], [ 0, %4 ], [ 1, %7 ]
ret i32 %14
}