#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 */
struct stat {
  scalar_t__ st_rdev;
};

/* Variables and functions */
int fstat(int, struct stat *);
int stat(char const *, struct stat *);
int evf_input_compare(int fd, const char *path) {
  struct stat st1, st2;
  if (fstat(fd, &st1) == -1)
    return -1;
  if (stat(path, &st2) == -1)
    return -1;
  return st1.st_rdev == st2.st_rdev;
}


x86 assembly (clang, -O0):
<evf_input_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1040 <fstat@plt>
cmp    $0xffffffff,%eax
jne    1150 <evf_input_compare+0x30>
movl   $0xffffffff,-0x4(%rbp)
jmp    1185 <evf_input_compare+0x65>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0xffffffff,%eax
jne    1172 <evf_input_compare+0x52>
movl   $0xffffffff,-0x4(%rbp)
jmp    1185 <evf_input_compare+0x65>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evf_input_compare>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
lea    0x10(%rsp),%rsi
call   1040 <fstat@plt>
mov    $0xffffffff,%ebx
cmp    $0xffffffff,%eax
je     115f <evf_input_compare+0x3f>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1030 <stat@plt>
cmp    $0xffffffff,%eax
je     115f <evf_input_compare+0x3f>
mov    0x10(%rsp),%rax
xor    %ebx,%ebx
cmp    0x8(%rsp),%rax
sete   %bl
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
define i32 @evf_input_compare(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.stat
%7 = alloca %struct.stat
store i32 %0, i32* %4
store i8* %1, i8** %5
%8 = load i32, i32* %4
%9 = call i32 @fstat(i32 %8, %struct.stat* %6)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %24
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = call i32 @stat(i8* %13, %struct.stat* %7)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 -1, i32* %3
br label %24
17: ; preds = %12
%18 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%19 = load i64, i64* %18
%20 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%21 = load i64, i64* %20
%22 = icmp eq i64 %19, %21
%23 = zext i1 %22 to i32
store i32 %23, i32* %3
br label %24
24: ; preds = %17, %16, %11
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
%struct.stat = type { i64 }
define i32 @evf_input_compare(i32 %0, i8* nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast %struct.stat* %4 to i8*
%7 = call i32 @fstat(i32 %0, %struct.stat* %3)
%8 = icmp eq i32 %7, -1
br i1 %8, label %19, label %9
9: ; preds = %2
%10 = call i32 @stat(i8* %1, %struct.stat* %4)
%11 = icmp eq i32 %10, -1
br i1 %11, label %19, label %12
12: ; preds = %9
%13 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%14 = load i64, i64* %13
%15 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%16 = load i64, i64* %15
%17 = icmp eq i64 %14, %16
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %9, %2, %12
%20 = phi i32 [ %18, %12 ], [ -1, %2 ], [ -1, %9 ]
ret i32 %20
}