#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 {
  size_t st_ino;
};

/* Variables and functions */
int MAXPATHLEN;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
char *realpath(char const *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
size_t get_Inode(const char *pathname) {
  char *path_status = NULL;
  char resolved[MAXPATHLEN];
  struct stat fileStat;
  if ((path_status = realpath(pathname, resolved)) == NULL) {
    fprintf(stderr, "get_Inode: Probleme avec le path=%s\n", pathname);
    return (-1);
  }
  if (stat(resolved, &fileStat) < 0) {
    fprintf(stderr, "get_Inode: Cannot stat on path=%s\n", resolved);
    return (-1);
  }
  return (fileStat.st_ino);
}


x86 assembly (clang, -O0):
<get_Inode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x40(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <realpath@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11b4 <get_Inode+0x84>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe65(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
movl   $0x1,-0x34(%rbp)
jmp    1207 <get_Inode+0xd7>
mov    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
jge    11f8 <get_Inode+0xc8>
mov    -0x40(%rbp),%rdx
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
movl   $0x1,-0x34(%rbp)
jmp    1207 <get_Inode+0xd7>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_Inode>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    0x2ea3(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rsi
call   1050 <realpath@plt>
test   %rax,%rax
je     117c <get_Inode+0x4c>
lea    -0x18(%rbp),%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
test   %rax,%rax
js     1191 <get_Inode+0x61>
mov    -0x18(%rbp),%rax
jmp    11b0 <get_Inode+0x80>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
mov    %r14,%rdx
jmp    11a4 <get_Inode+0x74>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    $0xffffffffffffffff,%rax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
@MAXPATHLEN = global i32 0
@stderr = global i32 0
@.str = [37 x i8] c"get_Inode: Probleme avec le path=%s\0A\00"
@.str.1 = [35 x i8] c"get_Inode: Cannot stat on path=%s\0A\00"
define i64 @get_Inode(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca %struct.stat
%8 = alloca i32
store i8* %0, i8** %3
store i8* null, i8** %4
%9 = load i32, i32* @MAXPATHLEN
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %5
%12 = alloca i8, i64 %10
store i64 %10, i64* %6
%13 = load i8*, i8** %3
%14 = call i8* @realpath(i8* %13, i8* %12)
store i8* %14, i8** %4
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %20
16: ; preds = %1
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %3
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %18)
store i64 -1, i64* %2
store i32 1, i32* %8
br label %29
20: ; preds = %1
%21 = call i64 @stat(i8* %12, %struct.stat* %7)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i64 -1, i64* %2
store i32 1, i32* %8
br label %29
26: ; preds = %20
%27 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%28 = load i64, i64* %27
store i64 %28, i64* %2
store i32 1, i32* %8
br label %29
29: ; preds = %26, %23, %16
%30 = load i8*, i8** %5
%31 = load i64, i64* %2
ret i64 %31
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@MAXPATHLEN = global i32 0
@stderr = global i32 0
@.str = [37 x i8] c"get_Inode: Probleme avec le path=%s\0A\00"
@.str.1 = [35 x i8] c"get_Inode: Cannot stat on path=%s\0A\00"
define i64 @get_Inode(i8* %0) {
%2 = alloca %struct.stat
%3 = load i32, i32* @MAXPATHLEN
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = bitcast %struct.stat* %2 to i8*
%7 = call i8* @realpath(i8* %0, i8* %5)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %21
12: ; preds = %1
%13 = call i64 @stat(i8* %5, %struct.stat* %2)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %21
18: ; preds = %12
%19 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%20 = load i64, i64* %19
br label %21
21: ; preds = %18, %15, %9
%22 = phi i64 [ -1, %9 ], [ -1, %15 ], [ %20, %18 ]
ret i64 %22
}