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

/* Variables and functions */
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ systemd_is_init();
int systemd_active() {
  struct stat a, b;
  if (lstat("/sys/fs/cgroup", &a) < 0)
    return 0;
  if (lstat("/sys/fs/cgroup/systemd", &b) < 0)
    return 0;
  if (a.st_dev == b.st_dev)
    return 0;
  if (!systemd_is_init())
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<systemd_active>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <lstat@plt>
cmp    $0x0,%rax
jge    114e <systemd_active+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11b1 <systemd_active+0x91>
lea    0xeba(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <lstat@plt>
cmp    $0x0,%rax
jge    1174 <systemd_active+0x54>
movl   $0x0,-0x4(%rbp)
jmp    11b1 <systemd_active+0x91>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    118e <systemd_active+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    11b1 <systemd_active+0x91>
mov    $0x0,%al
call   1040 <systemd_is_init@plt>
cmp    $0x0,%eax
jne    11aa <systemd_active+0x8a>
movl   $0x0,-0x4(%rbp)
jmp    11b1 <systemd_active+0x91>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<systemd_active>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <lstat@plt>
xor    %ebx,%ebx
test   %rax,%rax
js     116a <systemd_active+0x4a>
lea    0xecb(%rip),%rdi
mov    %rsp,%rsi
call   1030 <lstat@plt>
test   %rax,%rax
js     116a <systemd_active+0x4a>
mov    0x8(%rsp),%rax
cmp    (%rsp),%rax
je     116a <systemd_active+0x4a>
xor    %eax,%eax
call   1040 <systemd_is_init@plt>
xor    %ebx,%ebx
test   %eax,%eax
setne  %bl
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [15 x i8] c"/sys/fs/cgroup\00"
@.str.1 = [23 x i8] c"/sys/fs/cgroup/systemd\00"
define i32 @systemd_active() {
%1 = alloca %struct.stat
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %1 to i8*
%4 = bitcast %struct.stat* %2 to i8*
%5 = call i64 @lstat(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%6 = icmp slt i64 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %0
%8 = call i64 @lstat(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), %struct.stat* %2)
%9 = icmp slt i64 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%12 = load i64, i64* %11
%13 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%14 = load i64, i64* %13
%15 = icmp eq i64 %12, %14
br i1 %15, label %20, label %16
16: ; preds = %10
%17 = tail call i32 (...) @systemd_is_init()
%18 = icmp ne i32 %17, 0
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %16, %10, %7, %0
%21 = phi i32 [ 0, %0 ], [ 0, %7 ], [ 0, %10 ], [ %19, %16 ]
ret i32 %21
}