#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ free(scalar_t__ *);
int kill(scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ proc_group_refresh(scalar_t__ *, int);
int /*<<< orphan*/ proc_obsolete(scalar_t__);
scalar_t__ procfs_proc_enum(scalar_t__ **, int *);
void proc_enum_update(pid_t pid) {
  pid_t *procs_new;
  int nproc_new;
  if (pid > 0) {
    if (kill(pid, 0) == -1) {
      proc_obsolete(pid);
    }
  } else {
    if (procfs_proc_enum(&procs_new, &nproc_new) == 0) {
      proc_group_refresh(procs_new, nproc_new);
      free(procs_new);
    }
  }
}


x86 assembly (clang, -O0):
<proc_enum_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jle    1189 <proc_enum_update+0x39>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
jne    1184 <proc_enum_update+0x34>
mov    -0x8(%rbp),%rdi
call   1040 <proc_obsolete@plt>
jmp    11ba <proc_enum_update+0x6a>
lea    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <procfs_proc_enum@plt>
cmp    $0x0,%rax
jne    11b5 <proc_enum_update+0x65>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <proc_group_refresh@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    11ba <proc_enum_update+0x6a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proc_enum_update>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
jle    1176 <proc_enum_update+0x26>
mov    %rdi,%rbx
xor    %esi,%esi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
jne    11a2 <proc_enum_update+0x52>
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <proc_obsolete@plt>
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1050 <procfs_proc_enum@plt>
test   %rax,%rax
jne    11a2 <proc_enum_update+0x52>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%esi
call   1070 <proc_group_refresh@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @proc_enum_update(i64 %0) {
%2 = alloca i64
%3 = alloca i64*
%4 = alloca i32
store i64 %0, i64* %2
%5 = load i64, i64* %2
%6 = icmp sgt i64 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = load i64, i64* %2
%9 = call i32 @kill(i64 %8, i32 0)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i64, i64* %2
%13 = call i32 @proc_obsolete(i64 %12)
br label %14
14: ; preds = %11, %7
br label %25
15: ; preds = %1
%16 = call i64 @procfs_proc_enum(i64** %3, i32* %4)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i64*, i64** %3
%20 = load i32, i32* %4
%21 = call i32 @proc_group_refresh(i64* %19, i32 %20)
%22 = load i64*, i64** %3
%23 = call i32 @free(i64* %22)
br label %24
24: ; preds = %18, %15
br label %25
25: ; preds = %24, %14
ret void
}

LLVM IR (-O2):
define void @proc_enum_update(i64 %0) {
%2 = alloca i64*
%3 = alloca i32
%4 = bitcast i64** %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = icmp sgt i64 %0, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = tail call i32 @kill(i64 %0, i32 0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = tail call i32 @proc_obsolete(i64 %0)
br label %21
12: ; preds = %1
%13 = call i64 @procfs_proc_enum(i64** %2, i32* %3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i64*, i64** %2
%17 = load i32, i32* %3
%18 = call i32 @proc_group_refresh(i64* %16, i32 %17)
%19 = load i64*, i64** %2
%20 = call i32 @free(i64* %19)
br label %21
21: ; preds = %12, %15, %7, %10
ret void
}