#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__ EOF;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ ferror(int /*<<< orphan*/ *);
scalar_t__ fgetc(int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int /*<<< orphan*/ warn(char *, char const *);
int is_empty_fp(FILE *fp, const char *fp_name) {
  if (fgetc(fp) == EOF && !ferror(fp)) {
    if (fseek(fp, 0L, SEEK_SET)) {
      goto err;
    }
    if (fgetc(fp) == EOF && !ferror(fp)) {
      return 1;
    } else if (!ferror(fp)) {
      if (fseek(fp, 0L, SEEK_END)) {
        goto err;
      }
    }
  } else if (!ferror(fp)) {
    if (fseek(fp, -1L, SEEK_CUR)) {
      goto err;
    }
  }
  if (!ferror(fp)) {
    return 0;
  }
err:
  warn("%s", fp_name);
  return -1;
}


x86 assembly (clang, -O0):
<is_empty_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%rax
jne    121d <is_empty_fp+0xdd>
mov    -0x10(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%eax
jne    121d <is_empty_fp+0xdd>
mov    -0x10(%rbp),%rdi
mov    0x2e42(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1060 <fseek@plt>
cmp    $0x0,%rax
je     11a0 <is_empty_fp+0x60>
jmp    1284 <is_empty_fp+0x144>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    0x2e28(%rip),%rcx
cmp    (%rcx),%rax
jne    11d7 <is_empty_fp+0x97>
mov    -0x10(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%eax
jne    11d7 <is_empty_fp+0x97>
movl   $0x1,-0x4(%rbp)
jmp    129b <is_empty_fp+0x15b>
mov    -0x10(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%eax
jne    1213 <is_empty_fp+0xd3>
mov    -0x10(%rbp),%rdi
mov    0x2df4(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1060 <fseek@plt>
cmp    $0x0,%rax
je     120e <is_empty_fp+0xce>
jmp    1284 <is_empty_fp+0x144>
jmp    1213 <is_empty_fp+0xd3>
jmp    1218 <is_empty_fp+0xd8>
jmp    1261 <is_empty_fp+0x121>
mov    -0x10(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%eax
jne    125c <is_empty_fp+0x11c>
mov    -0x10(%rbp),%rdi
mov    0x2da6(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffffffffffff,%rsi
call   1060 <fseek@plt>
cmp    $0x0,%rax
je     1257 <is_empty_fp+0x117>
jmp    1284 <is_empty_fp+0x144>
jmp    125c <is_empty_fp+0x11c>
jmp    1261 <is_empty_fp+0x121>
mov    -0x10(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%eax
jne    127f <is_empty_fp+0x13f>
movl   $0x0,-0x4(%rbp)
jmp    129b <is_empty_fp+0x15b>
jmp    1284 <is_empty_fp+0x144>
mov    -0x18(%rbp),%rsi
lea    0xd71(%rip),%rdi
call   1030 <warn@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_empty_fp>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <fgetc@plt>
mov    0x2e81(%rip),%r15
cmp    (%r15),%rax
jne    1168 <is_empty_fp+0x28>
mov    %rbx,%rdi
call   1040 <ferror@plt>
test   %eax,%eax
je     11a3 <is_empty_fp+0x63>
mov    %rbx,%rdi
call   1040 <ferror@plt>
test   %eax,%eax
je     1184 <is_empty_fp+0x44>
mov    %rbx,%rdi
call   1040 <ferror@plt>
test   %eax,%eax
jne    11bb <is_empty_fp+0x7b>
xor    %eax,%eax
jmp    11cf <is_empty_fp+0x8f>
mov    0x2e55(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffffffffffffffff,%rsi
call   1060 <fseek@plt>
test   %rax,%rax
jne    11bb <is_empty_fp+0x7b>
jmp    1174 <is_empty_fp+0x34>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <fseek@plt>
test   %rax,%rax
je     11d5 <is_empty_fp+0x95>
lea    0xe3e(%rip),%rdi
mov    %r14,%rsi
call   1030 <warn@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    (%r15),%rax
jne    11ee <is_empty_fp+0xae>
mov    %rbx,%rdi
call   1040 <ferror@plt>
test   %eax,%eax
je     120e <is_empty_fp+0xce>
mov    %rbx,%rdi
call   1040 <ferror@plt>
test   %eax,%eax
jne    1174 <is_empty_fp+0x34>
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
jmp    1197 <is_empty_fp+0x57>
mov    $0x1,%eax
jmp    11cf <is_empty_fp+0x8f>

LLVM IR (-O0):
@EOF = global i64 0
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
@SEEK_CUR = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @is_empty_fp(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
%6 = load i32*, i32** %4
%7 = call i64 @fgetc(i32* %6)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %43
10: ; preds = %2
%11 = load i32*, i32** %4
%12 = call i32 @ferror(i32* %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %43, label %14
14: ; preds = %10
%15 = load i32*, i32** %4
%16 = load i32, i32* @SEEK_SET
%17 = call i64 @fseek(i32* %15, i64 0, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
br label %61
20: ; preds = %14
%21 = load i32*, i32** %4
%22 = call i64 @fgetc(i32* %21)
%23 = load i64, i64* @EOF
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i32*, i32** %4
%27 = call i32 @ferror(i32* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %25
store i32 1, i32* %3
br label %64
30: ; preds = %25, %20
%31 = load i32*, i32** %4
%32 = call i32 @ferror(i32* %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %41, label %34
34: ; preds = %30
%35 = load i32*, i32** %4
%36 = load i32, i32* @SEEK_END
%37 = call i64 @fseek(i32* %35, i64 0, i32 %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %34
br label %61
40: ; preds = %34
br label %41
41: ; preds = %40, %30
br label %42
42: ; preds = %41
br label %55
43: ; preds = %10, %2
%44 = load i32*, i32** %4
%45 = call i32 @ferror(i32* %44)
%46 = icmp ne i32 %45, 0
br i1 %46, label %54, label %47
47: ; preds = %43
%48 = load i32*, i32** %4
%49 = load i32, i32* @SEEK_CUR
%50 = call i64 @fseek(i32* %48, i64 -1, i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %47
br label %61
53: ; preds = %47
br label %54
54: ; preds = %53, %43
br label %55
55: ; preds = %54, %42
%56 = load i32*, i32** %4
%57 = call i32 @ferror(i32* %56)
%58 = icmp ne i32 %57, 0
br i1 %58, label %60, label %59
59: ; preds = %55
store i32 0, i32* %3
br label %64
60: ; preds = %55
br label %61
61: ; preds = %60, %52, %39, %19
%62 = load i8*, i8** %5
%63 = call i32 @warn(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %62)
store i32 -1, i32* %3
br label %64
64: ; preds = %61, %59, %29
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@EOF = global i64 0
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
@SEEK_CUR = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @is_empty_fp(i32* nocapture %0, i8* %1) {
%3 = tail call i64 @fgetc(i32* %0)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %27
6: ; preds = %2
%7 = tail call i32 @ferror(i32* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = load i32, i32* @SEEK_SET
%11 = tail call i64 @fseek(i32* %0, i64 0, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %37
13: ; preds = %9
%14 = tail call i64 @fgetc(i32* %0)
%15 = load i64, i64* @EOF
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = tail call i32 @ferror(i32* %0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %39, label %20
20: ; preds = %17, %13
%21 = tail call i32 @ferror(i32* %0)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = load i32, i32* @SEEK_END
%25 = tail call i64 @fseek(i32* %0, i64 0, i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %34, label %37
27: ; preds = %6, %2
%28 = tail call i32 @ferror(i32* %0)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i32, i32* @SEEK_CUR
%32 = tail call i64 @fseek(i32* %0, i64 -1, i32 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %27, %30, %23, %20
%35 = tail call i32 @ferror(i32* %0)
%36 = icmp eq i32 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %34, %30, %23, %9
%38 = tail call i32 @warn(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %39
39: ; preds = %34, %17, %37
%40 = phi i32 [ -1, %37 ], [ 1, %17 ], [ 0, %34 ]
ret i32 %40
}