#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 */
scalar_t__ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_error(char *, int);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int end_of_file_test(FILE *file_pointer) {
  int c;
  c = fgetc(file_pointer);
  if (c == '\n') {
    c = fgetc(file_pointer);
  } else
    print_error(
        "Database file is incorrectly formatted, the program will now exit.\n",
        1);
  if (feof(file_pointer))
    return 0;
  ungetc(c, file_pointer);
  return 1;
}


x86 assembly (clang, -O0):
<end_of_file_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    1173 <end_of_file_test+0x33>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
jmp    1184 <end_of_file_test+0x44>
lea    0xe86(%rip),%rdi
mov    $0x1,%esi
call   1030 <print_error@plt>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     11a3 <end_of_file_test+0x63>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <end_of_file_test+0x76>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <ungetc@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<end_of_file_test>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <fgetc@plt>
cmp    $0xa,%eax
jne    115c <end_of_file_test+0x1c>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebp
jmp    116f <end_of_file_test+0x2f>
mov    %eax,%ebp
lea    0xe9b(%rip),%rdi
mov    $0x1,%esi
call   1030 <print_error@plt>
mov    %rbx,%rdi
call   1050 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1190 <end_of_file_test+0x50>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <ungetc@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [68 x i8] c"Database file is incorrectly formatted, the program will now exit.\0A\00"
define i32 @end_of_file_test(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = call i32 @fgetc(i32* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 10
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32*, i32** %3
%11 = call i32 @fgetc(i32* %10)
store i32 %11, i32* %4
br label %14
12: ; preds = %1
%13 = call i32 @print_error(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i32 1)
br label %14
14: ; preds = %12, %9
%15 = load i32*, i32** %3
%16 = call i64 @feof(i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 0, i32* %2
br label %23
19: ; preds = %14
%20 = load i32, i32* %4
%21 = load i32*, i32** %3
%22 = call i32 @ungetc(i32 %20, i32* %21)
store i32 1, i32* %2
br label %23
23: ; preds = %19, %18
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [68 x i8] c"Database file is incorrectly formatted, the program will now exit.\0A\00"
define i32 @end_of_file_test(i32* nocapture %0) {
%2 = tail call i32 @fgetc(i32* %0)
%3 = icmp eq i32 %2, 10
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @fgetc(i32* %0)
br label %8
6: ; preds = %1
%7 = tail call i32 @print_error(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i32 1)
br label %8
8: ; preds = %6, %4
%9 = phi i32 [ %5, %4 ], [ %2, %6 ]
%10 = tail call i64 @feof(i32* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @ungetc(i32 %9, i32* %0)
br label %14
14: ; preds = %8, %12
%15 = phi i32 [ 1, %12 ], [ 0, %8 ]
ret i32 %15
}