#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 */
int /*<<< orphan*/ errx(int, char *, char const *);
void samefile(const char *test, struct stat *sb1, struct stat *sb2) {
  if (sb1->st_dev != sb2->st_dev)
    errx(-1, "%s: samefile: different device", test);
  if (sb1->st_ino != sb2->st_ino)
    errx(-1, "%s: samefile: different inode", test);
}


x86 assembly (clang, -O0):
<samefile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
je     114d <samefile+0x3d>
mov    -0x8(%rbp),%rdx
mov    $0xffffffff,%edi
lea    0xeb8(%rip),%rsi
call   1030 <errx@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    0x8(%rcx),%rax
je     1178 <samefile+0x68>
mov    -0x8(%rbp),%rdx
mov    $0xffffffff,%edi
lea    0xeac(%rip),%rsi
call   1030 <errx@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<samefile>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%rax
cmp    (%rdx),%rax
je     113a <samefile+0x2a>
lea    0xed3(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r14,%rdx
call   1030 <errx@plt>
mov    0x8(%rbx),%rax
cmp    0x8(%r15),%rax
jne    114a <samefile+0x3a>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xece(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <errx@plt>

LLVM IR (-O0):
%struct.stat = type { i64, i64 }
@.str = [31 x i8] c"%s: samefile: different device\00"
@.str.1 = [30 x i8] c"%s: samefile: different inode\00"
define void @samefile(i8* %0, %struct.stat* %1, %struct.stat* %2) {
%4 = alloca i8*
%5 = alloca %struct.stat*
%6 = alloca %struct.stat*
store i8* %0, i8** %4
store %struct.stat* %1, %struct.stat** %5
store %struct.stat* %2, %struct.stat** %6
%7 = load %struct.stat*, %struct.stat** %5
%8 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%9 = load i64, i64* %8
%10 = load %struct.stat*, %struct.stat** %6
%11 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%12 = load i64, i64* %11
%13 = icmp ne i64 %9, %12
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i32 @errx(i32 -1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %3
%18 = load %struct.stat*, %struct.stat** %5
%19 = getelementptr inbounds %struct.stat, %struct.stat* %18, i32 0, i32 1
%20 = load i64, i64* %19
%21 = load %struct.stat*, %struct.stat** %6
%22 = getelementptr inbounds %struct.stat, %struct.stat* %21, i32 0, i32 1
%23 = load i64, i64* %22
%24 = icmp ne i64 %20, %23
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = load i8*, i8** %4
%27 = call i32 @errx(i32 -1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %25, %17
ret void
}

LLVM IR (-O2):
%struct.stat = type { i64, i64 }
@.str = [31 x i8] c"%s: samefile: different device\00"
@.str.1 = [30 x i8] c"%s: samefile: different inode\00"
define void @samefile(i8* %0, %struct.stat* nocapture %1, %struct.stat* nocapture %2) {
%4 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%5 = load i64, i64* %4
%6 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%7 = load i64, i64* %6
%8 = icmp eq i64 %5, %7
br i1 %8, label %11, label %9
9: ; preds = %3
%10 = tail call i32 @errx(i32 -1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %9, %3
%12 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%13 = load i64, i64* %12
%14 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%15 = load i64, i64* %14
%16 = icmp eq i64 %13, %15
br i1 %16, label %19, label %17
17: ; preds = %11
%18 = tail call i32 @errx(i32 -1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %19
19: ; preds = %17, %11
ret void
}