#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*/ pid_t;

/* Variables and functions */
scalar_t__ ESRCH;
int /*<<< orphan*/ debugf(char *, int, ...);
int /*<<< orphan*/ die(int);
scalar_t__ errno;
scalar_t__ kill(int /*<<< orphan*/, int);
bool signal_process(pid_t pid, int signum) {
  if (pid == 0) {
    debugf("executor: no pid (signal %d)", signum);
    return false;
  }
  if (kill(pid, signum) != 0) {
    if (errno == ESRCH) {
      debugf("executor: pid %d does not exist (signal %d)", pid, signum);
      return false;
    }
    die(17);
  }
  debugf("executor: pid %d signaled (%d)", pid, signum);
  return true;
}


x86 assembly (clang, -O0):
<signal_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1165 <signal_process+0x35>
mov    -0xc(%rbp),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <debugf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d9 <signal_process+0xa9>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <kill@plt>
cmp    $0x0,%rax
je     11be <signal_process+0x8e>
mov    0x2e5f(%rip),%rax
mov    (%rax),%rax
mov    0x2e45(%rip),%rcx
cmp    (%rcx),%rax
jne    11b4 <signal_process+0x84>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <debugf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d9 <signal_process+0xa9>
mov    $0x11,%edi
call   1050 <die@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <debugf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_process>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
test   %edi,%edi
je     1177 <signal_process+0x47>
mov    %edi,%ebp
mov    %r14d,%esi
call   1040 <kill@plt>
test   %rax,%rax
je     1196 <signal_process+0x66>
mov    0x2e8f(%rip),%rax
mov    (%rax),%rax
mov    0x2e75(%rip),%rcx
cmp    (%rcx),%rax
jne    118c <signal_process+0x5c>
lea    0xeb6(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <debugf@plt>
jmp    11ae <signal_process+0x7e>
lea    0xe82(%rip),%rdi
xor    %ebx,%ebx
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <debugf@plt>
jmp    11ae <signal_process+0x7e>
mov    $0x11,%edi
call   1050 <die@plt>
lea    0xeac(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <debugf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"executor: no pid (signal %d)\00"
@errno = global i64 0
@ESRCH = global i64 0
@.str.1 = [44 x i8] c"executor: pid %d does not exist (signal %d)\00"
@.str.2 = [31 x i8] c"executor: pid %d signaled (%d)\00"
define i32 @signal_process(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %5
%10 = call i32 (i8*, i32, ...) @debugf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 0, i32* %3
br label %30
11: ; preds = %2
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = call i64 @kill(i32 %12, i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %11
%17 = load i64, i64* @errno
%18 = load i64, i64* @ESRCH
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = call i32 (i8*, i32, ...) @debugf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22)
store i32 0, i32* %3
br label %30
24: ; preds = %16
%25 = call i32 @die(i32 17)
br label %26
26: ; preds = %24, %11
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = call i32 (i8*, i32, ...) @debugf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %28)
store i32 1, i32* %3
br label %30
30: ; preds = %26, %20, %8
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [29 x i8] c"executor: no pid (signal %d)\00"
@errno = global i64 0
@ESRCH = global i64 0
@.str.1 = [44 x i8] c"executor: pid %d does not exist (signal %d)\00"
@.str.2 = [31 x i8] c"executor: pid %d signaled (%d)\00"
define i32 @signal_process(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8*, i32, ...) @debugf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %19
6: ; preds = %2
%7 = tail call i64 @kill(i32 %0, i32 %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = load i64, i64* @errno
%11 = load i64, i64* @ESRCH
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 (i8*, i32, ...) @debugf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1)
br label %19
15: ; preds = %9
%16 = tail call i32 @die(i32 17)
br label %17
17: ; preds = %15, %6
%18 = tail call i32 (i8*, i32, ...) @debugf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %1)
br label %19
19: ; preds = %17, %13, %4
%20 = phi i32 [ 0, %4 ], [ 0, %13 ], [ 1, %17 ]
ret i32 %20
}