#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*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int stat(char *, struct stat *);
int main(int argc, char **argv) {
  struct stat root, proc_root;
  if (stat("/", &root) == -1) {
    perror("stat");
    exit(1);
  }
  if (stat("/proc/1/root", &proc_root) == -1) {
    perror("stat");
    exit(1);
  }
  if (root.st_dev == proc_root.st_dev && root.st_ino == proc_root.st_ino) {
    printf("proc path test success\n");
  } else {
    printf("proc path test failure\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0xffffffff,%eax
jne    1185 <main+0x45>
lea    0xe8c(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xe7b(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0xffffffff,%eax
jne    11b4 <main+0x74>
lea    0xe5d(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    11e1 <main+0xa1>
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    11e1 <main+0xa1>
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
jmp    11ed <main+0xad>
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xeb5(%rip),%rdi
lea    0x18(%rsp),%rsi
call   1040 <stat@plt>
cmp    $0xffffffff,%eax
je     11a4 <main+0x64>
lea    0xea6(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <stat@plt>
cmp    $0xffffffff,%eax
je     11a4 <main+0x64>
mov    0x18(%rsp),%rax
cmp    0x8(%rsp),%rax
jne    1191 <main+0x51>
mov    0x20(%rsp),%rax
cmp    0x10(%rsp),%rax
jne    1191 <main+0x51>
lea    0xe9c(%rip),%rdi
jmp    1198 <main+0x58>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret
lea    0xe57(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i64, i64 }
@.str = [2 x i8] c"/\00"
@.str.1 = [5 x i8] c"stat\00"
@.str.2 = [13 x i8] c"/proc/1/root\00"
@.str.3 = [24 x i8] c"proc path test success\0A\00"
@.str.4 = [24 x i8] c"proc path test failure\0A\00"
define i32 @main(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* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @stat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.stat* %6)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = call i32 @stat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %struct.stat* %7)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %13
%20 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%21 = load i64, i64* %20
%22 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%23 = load i64, i64* %22
%24 = icmp eq i64 %21, %23
br i1 %24, label %25, label %33
25: ; preds = %19
%26 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%27 = load i64, i64* %26
%28 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%29 = load i64, i64* %28
%30 = icmp eq i64 %27, %29
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %35
33: ; preds = %25, %19
%34 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64, i64 }
@.str = [2 x i8] c"/\00"
@.str.1 = [5 x i8] c"stat\00"
@.str.2 = [13 x i8] c"/proc/1/root\00"
@str = [23 x i8] c"proc path test failure\00"
@str.5 = [23 x i8] c"proc path test success\00"
define i32 @main(i32 %0, i8** nocapture readnone %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 @stat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.stat* %3)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = call i32 @stat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %struct.stat* %4)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %12
%19 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%20 = load i64, i64* %19
%21 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%22 = load i64, i64* %21
%23 = icmp eq i64 %20, %22
br i1 %23, label %24, label %30
24: ; preds = %18
%25 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%26 = load i64, i64* %25
%27 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%28 = load i64, i64* %27
%29 = icmp eq i64 %26, %28
br i1 %29, label %31, label %30
30: ; preds = %24, %18
br label %31
31: ; preds = %24, %30
%32 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0), %30 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0), %24 ]
%33 = tail call i32 @puts(i8* dereferenceable(1) %32)
ret i32 0
}