#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 {
  int /*<<< orphan*/ st_ino;
};
typedef int /*<<< orphan*/ st;
typedef int /*<<< orphan*/ ino_t;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ memset(struct stat *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
int stat(char *, struct stat *);
char *strerror(int /*<<< orphan*/);
ino_t eslib_file_getino(char *path) {
  struct stat st;
  int ret;
  if (path == NULL)
    return 0;
  memset(&st, 0, sizeof(st));
  ret = stat(path, &st);
  if (ret) {
    printf("getino stat: %s\n", strerror(errno));
    return 0;
  }
  return st.st_ino;
}


x86 assembly (clang, -O0):
<eslib_file_getino>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1163 <eslib_file_getino+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11bc <eslib_file_getino+0x7c>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <stat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11b6 <eslib_file_getino+0x76>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bc <eslib_file_getino+0x7c>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eslib_file_getino>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     1194 <eslib_file_getino+0x54>
mov    %rdi,%rbx
lea    0x8(%rsp),%r14
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <stat@plt>
test   %eax,%eax
je     1198 <eslib_file_getino+0x58>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe76(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
jmp    119c <eslib_file_getino+0x5c>
xor    %ebp,%ebp
jmp    119c <eslib_file_getino+0x5c>
mov    0x8(%rsp),%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [17 x i8] c"getino stat: %s\0A\00"
@errno = global i32 0
define i32 @eslib_file_getino(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.stat
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %22
9: ; preds = %1
%10 = call i32 @memset(%struct.stat* %4, i32 0, i32 4)
%11 = load i8*, i8** %3
%12 = call i32 @stat(i8* %11, %struct.stat* %4)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 0, i32* %2
br label %22
19: ; preds = %9
%20 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%21 = load i32, i32* %20
store i32 %21, i32* %2
br label %22
22: ; preds = %19, %15, %8
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [17 x i8] c"getino stat: %s\0A\00"
@errno = global i32 0
define i32 @eslib_file_getino(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %16, label %5
5: ; preds = %1
%6 = call i32 @memset(%struct.stat* %2, i32 0, i32 4)
%7 = call i32 @stat(i8* %0, %struct.stat* %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %16
13: ; preds = %5
%14 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%15 = load i32, i32* %14
br label %16
16: ; preds = %1, %13, %9
%17 = phi i32 [ 0, %9 ], [ %15, %13 ], [ 0, %1 ]
ret i32 %17
}