#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 */
typedef int /*<<< orphan*/ time_t;
struct stat {
  int /*<<< orphan*/ st_mtime;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ dirfd(int /*<<< orphan*/ *);
scalar_t__ fstatat(int /*<<< orphan*/, char const *, struct stat *,
                   int /*<<< orphan*/);
int get_proc_start_time(DIR *proc_dir, const char *pid_dir_name,
                        time_t *start_time) {
  struct stat p_dir_stat;
  if (start_time == NULL || pid_dir_name == NULL)
    return -1;
  if (fstatat(dirfd(proc_dir), pid_dir_name, &p_dir_stat, 0) != 0)
    return -1;
  *start_time = p_dir_stat.st_mtime;
  return 0;
}


x86 assembly (clang, -O0):
<get_proc_start_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     114a <get_proc_start_time+0x2a>
cmpq   $0x0,-0x18(%rbp)
jne    1156 <get_proc_start_time+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    1196 <get_proc_start_time+0x76>
mov    -0x10(%rbp),%rdi
call   1030 <dirfd@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdx
xor    %ecx,%ecx
call   1040 <fstatat@plt>
cmp    $0x0,%rax
je     1186 <get_proc_start_time+0x66>
movl   $0xffffffff,-0x4(%rbp)
jmp    1196 <get_proc_start_time+0x76>
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_proc_start_time>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0xffffffff,%ebp
test   %rsi,%rsi
je     1161 <get_proc_start_time+0x41>
mov    %rdx,%r14
test   %rdx,%rdx
je     1161 <get_proc_start_time+0x41>
mov    %rsi,%rbx
call   1030 <dirfd@plt>
lea    0x8(%rsp),%rdx
mov    %eax,%edi
mov    %rbx,%rsi
xor    %ecx,%ecx
call   1040 <fstatat@plt>
test   %rax,%rax
jne    1161 <get_proc_start_time+0x41>
mov    0x8(%rsp),%eax
mov    %eax,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
define i32 @get_proc_start_time(i32* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca %struct.stat
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%9 = load i32*, i32** %7
%10 = icmp eq i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %11, %3
store i32 -1, i32* %4
br label %26
15: ; preds = %11
%16 = load i32*, i32** %5
%17 = call i32 @dirfd(i32* %16)
%18 = load i8*, i8** %6
%19 = call i64 @fstatat(i32 %17, i8* %18, %struct.stat* %8, i32 0)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 -1, i32* %4
br label %26
22: ; preds = %15
%23 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%24 = load i32, i32* %23
%25 = load i32*, i32** %7
store i32 %24, i32* %25
store i32 0, i32* %4
br label %26
26: ; preds = %22, %21, %14
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
%struct.stat = type { i32 }
define i32 @get_proc_start_time(i32* %0, i8* %1, i32* writeonly %2) {
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %4 to i8*
%6 = icmp eq i32* %2, null
%7 = icmp eq i8* %1, null
%8 = or i1 %7, %6
br i1 %8, label %16, label %9
9: ; preds = %3
%10 = tail call i32 @dirfd(i32* %0)
%11 = call i64 @fstatat(i32 %10, i8* %1, %struct.stat* %4, i32 0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%15 = load i32, i32* %14
store i32 %15, i32* %2
br label %16
16: ; preds = %9, %3, %13
%17 = phi i32 [ 0, %13 ], [ -1, %3 ], [ -1, %9 ]
ret i32 %17
}