#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_mode;
};

/* Variables and functions */
int /*<<< orphan*/ S_IFDIR;
int libc_lxstat(int, char const *, struct stat *);
int /*<<< orphan*/ strcmp(char const *, char *);
int __lxstat(int ver, const char *path, struct stat *stat) {
  int ret = libc_lxstat(ver, path, stat);
  if (ret == -1 && !strcmp(path, "/run/systemd/system/")) {
    stat->st_mode = S_IFDIR;
    ret = 0;
  }
  return ret;
}


x86 assembly (clang, -O0):
<__lxstat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <libc_lxstat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    117f <__lxstat+0x5f>
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    117f <__lxstat+0x5f>
mov    0x2e68(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__lxstat>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
call   1030 <libc_lxstat@plt>
cmp    $0xffffffff,%eax
jne    115c <__lxstat+0x3c>
lea    0xec5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
jne    115c <__lxstat+0x3c>
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [21 x i8] c"/run/systemd/system/\00"
@S_IFDIR = global i32 0
define i32 @__lxstat(i32 %0, i8* %1, %struct.stat* %2) {
%4 = tail call i32 @libc_lxstat(i32 %0, i8* %1, %struct.stat* %2)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(21) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* @S_IFDIR
%11 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
store i32 %10, i32* %11
br label %12
12: ; preds = %9, %6, %3
%13 = phi i32 [ -1, %6 ], [ 0, %9 ], [ %4, %3 ]
ret i32 %13
}