#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 sd_booted(void) {
  struct stat a, b;
  if (lstat("/sys/fs/cgroup", &a) < 0)
    return 0;
  if (lstat("/sys/fs/cgroup/systemd", &b) < 0)
    return 0;
  return a.st_dev != b.st_dev;
}


x86 assembly (clang, -O0):
<sd_booted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xee1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <lstat@plt>
cmp    $0x0,%rax
jge    113e <sd_booted+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    1177 <sd_booted+0x67>
lea    0xeca(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <lstat@plt>
cmp    $0x0,%rax
jge    1164 <sd_booted+0x54>
movl   $0x0,-0x4(%rbp)
jmp    1177 <sd_booted+0x67>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sd_booted>:
push   %rbx
sub    $0x10,%rsp
lea    0xee4(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <lstat@plt>
xor    %ebx,%ebx
test   %rax,%rax
js     114f <sd_booted+0x3f>
lea    0xedb(%rip),%rdi
mov    %rsp,%rsi
call   1030 <lstat@plt>
test   %rax,%rax
js     114f <sd_booted+0x3f>
mov    0x8(%rsp),%rax
xor    %ebx,%ebx
cmp    (%rsp),%rax
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 @sd_booted() {
%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 %18
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 %18
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 ne i64 %13, %15
%17 = zext i1 %16 to i32
store i32 %17, i32* %1
br label %18
18: ; preds = %11, %10, %6
%19 = load i32, i32* %1
ret i32 %19
}

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 @sd_booted() {
%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 %17, 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 %17, 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 ne i64 %12, %14
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %7, %0, %10
%18 = phi i32 [ %16, %10 ], [ 0, %0 ], [ 0, %7 ]
ret i32 %18
}