#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_dev;
  scalar_t__ st_ino;
};

/* Variables and functions */
scalar_t__ stat(char const *, struct stat *);
int file_cmp(const char *a, const char *b) {
  struct stat sa, sb;
  if (stat(a, &sa) < 0 || stat(b, &sb) < 0)
    return 0;
  return sa.st_dev == sb.st_dev && sa.st_ino == sb.st_ino;
}


x86 assembly (clang, -O0):
<file_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0x0,%rax
jl     114e <file_cmp+0x3e>
mov    -0x18(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0x0,%rax
jge    115a <file_cmp+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    1186 <file_cmp+0x76>
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
cmp    -0x38(%rbp),%rcx
mov    %al,-0x39(%rbp)
jne    117b <file_cmp+0x6b>
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
sete   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_cmp>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
lea    0x18(%rsp),%rsi
call   1030 <stat@plt>
xor    %ebx,%ebx
test   %rax,%rax
js     1159 <file_cmp+0x49>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1030 <stat@plt>
test   %rax,%rax
js     1159 <file_cmp+0x49>
mov    0x18(%rsp),%rax
mov    0x20(%rsp),%rcx
xor    0x8(%rsp),%rax
xor    0x10(%rsp),%rcx
xor    %ebx,%ebx
or     %rax,%rcx
sete   %bl
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.stat = type { i64, i64 }
define i32 @file_cmp(i8* %0, i8* %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 i64 @stat(i8* %0, %struct.stat* %3)
%8 = icmp slt i64 %7, 0
br i1 %8, label %25, label %9
9: ; preds = %2
%10 = call i64 @stat(i8* %1, %struct.stat* %4)
%11 = icmp slt i64 %10, 0
br i1 %11, label %25, 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 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%19 = load i64, i64* %18
%20 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%21 = load i64, i64* %20
%22 = icmp eq i64 %19, %21
%23 = select i1 %17, i1 %22, i1 false
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %2, %9, %12
%26 = phi i32 [ %24, %12 ], [ 0, %9 ], [ 0, %2 ]
ret i32 %26
}