#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 stat64 {
  int dummy;
};
struct stat {
  int dummy;
};

/* Variables and functions */
scalar_t__ ENOSYS;
scalar_t__ __dietlibc_lstat64(char const *, struct stat64 *);
int /*<<< orphan*/ __stat64_cvt(struct stat *, struct stat64 *);
scalar_t__ errno;
scalar_t__ lstat(char const *, struct stat *);
int lstat64(const char *__file, struct stat64 *__buf) {
  if (__dietlibc_lstat64(__file, __buf)) {
    struct stat temp;
    if (errno != ENOSYS)
      return -1;
    if (lstat(__file, &temp))
      return -1;
    __stat64_cvt(&temp, __buf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<lstat64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <__dietlibc_lstat64@plt>
cmp    $0x0,%rax
je     11ad <lstat64+0x7d>
mov    0x2e7a(%rip),%rax
mov    (%rax),%rax
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%rax
je     117d <lstat64+0x4d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <lstat64+0x84>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <lstat@plt>
cmp    $0x0,%rax
je     11a0 <lstat64+0x70>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <lstat64+0x84>
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdi
call   1030 <__stat64_cvt@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lstat64>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <__dietlibc_lstat64@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1186 <lstat64+0x56>
mov    0x2e87(%rip),%rax
mov    (%rax),%rax
mov    0x2e8d(%rip),%rcx
cmp    (%rcx),%rax
jne    1172 <lstat64+0x42>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <lstat@plt>
test   %rax,%rax
je     1179 <lstat64+0x49>
mov    $0xffffffff,%ebp
jmp    1186 <lstat64+0x56>
lea    0x8(%rsp),%rdi
mov    %r14,%rsi
call   1030 <__stat64_cvt@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat64 = type { i32 }
%struct.stat = type { i32 }
@errno = global i64 0
@ENOSYS = global i64 0
define i32 @lstat64(i8* %0, %struct.stat64* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.stat64*
%6 = alloca %struct.stat
store i8* %0, i8** %4
store %struct.stat64* %1, %struct.stat64** %5
%7 = load i8*, i8** %4
%8 = load %struct.stat64*, %struct.stat64** %5
%9 = call i64 @__dietlibc_lstat64(i8* %7, %struct.stat64* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = load i64, i64* @errno
%13 = load i64, i64* @ENOSYS
%14 = icmp ne i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 -1, i32* %3
br label %25
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = call i64 @lstat(i8* %17, %struct.stat* %6)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 -1, i32* %3
br label %25
21: ; preds = %16
%22 = load %struct.stat64*, %struct.stat64** %5
%23 = call i32 @__stat64_cvt(%struct.stat* %6, %struct.stat64* %22)
br label %24
24: ; preds = %21, %2
store i32 0, i32* %3
br label %25
25: ; preds = %24, %20, %15
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
%struct.stat64 = type { i32 }
%struct.stat = type { i32 }
@errno = global i64 0
@ENOSYS = global i64 0
define i32 @lstat64(i8* %0, %struct.stat64* %1) {
%3 = alloca %struct.stat
%4 = tail call i64 @__dietlibc_lstat64(i8* %0, %struct.stat64* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = bitcast %struct.stat* %3 to i8*
%8 = load i64, i64* @errno
%9 = load i64, i64* @ENOSYS
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = call i64 @lstat(i8* %0, %struct.stat* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %6, %11
br label %17
15: ; preds = %11
%16 = call i32 @__stat64_cvt(%struct.stat* %3, %struct.stat64* %1)
br label %17
17: ; preds = %2, %15, %14
%18 = phi i32 [ -1, %14 ], [ 0, %15 ], [ 0, %2 ]
ret i32 %18
}