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

/* Variables and functions */
scalar_t__ EPERM;
scalar_t__ ESRCH;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ atoi(char *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ kill(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  int sig, r;
  if (argc != 3) {
    printf("Usage: %s <process id> <signal num>\n", argv[0]);
    exit(EXIT_SUCCESS);
  }
  if (kill(atoi(argv[1]), atoi(argv[2])) < 0) {
    if (errno == EPERM)
      perror("kill() ");
    else if (errno == ESRCH)
      perror("kill() ");
    exit(EXIT_FAILURE);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1191 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   1040 <kill@plt>
cmp    $0x0,%rax
jge    1226 <main+0xd6>
mov    0x2e17(%rip),%rax
mov    (%rax),%rax
mov    0x2ded(%rip),%rcx
cmp    (%rcx),%rax
jne    11ed <main+0x9d>
lea    0xe42(%rip),%rdi
call   1050 <perror@plt>
jmp    1218 <main+0xc8>
mov    0x2dec(%rip),%rax
mov    (%rax),%rax
mov    0x2dba(%rip),%rcx
cmp    (%rcx),%rax
jne    1213 <main+0xc3>
lea    0xe17(%rip),%rdi
call   1050 <perror@plt>
jmp    1218 <main+0xc8>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11b9 <main+0x69>
mov    0x8(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <kill@plt>
test   %rax,%rax
jns    11c8 <main+0x78>
mov    0x2e5c(%rip),%rax
mov    (%rax),%rax
mov    0x2e32(%rip),%rcx
cmp    (%rcx),%rax
je     119f <main+0x4f>
mov    0x2e1e(%rip),%rcx
cmp    (%rcx),%rax
jne    11ab <main+0x5b>
lea    0xe7f(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    (%rbx),%rsi
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"Usage: %s <process id> <signal num>\0A\00"
@EXIT_SUCCESS = global i32 0
@errno = global i64 0
@EPERM = global i64 0
@.str.1 = [8 x i8] c"kill() \00"
@ESRCH = global i64 0
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_SUCCESS
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
%26 = call i64 @kill(i32 %21, i32 %25)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %44
28: ; preds = %17
%29 = load i64, i64* @errno
%30 = load i64, i64* @EPERM
%31 = icmp eq i64 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %41
34: ; preds = %28
%35 = load i64, i64* @errno
%36 = load i64, i64* @ESRCH
%37 = icmp eq i64 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
br label %41
41: ; preds = %40, %32
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %17
%45 = load i32, i32* @EXIT_SUCCESS
%46 = call i32 @exit(i32 %45)
unreachable
}

LLVM IR (-O2):
@.str = [37 x i8] c"Usage: %s <process id> <signal num>\0A\00"
@EXIT_SUCCESS = global i32 0
@errno = global i64 0
@EPERM = global i64 0
@.str.1 = [8 x i8] c"kill() \00"
@ESRCH = global i64 0
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i32, i32* @EXIT_SUCCESS
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = tail call i64 @kill(i32 %12, i32 %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %9
%19 = load i64, i64* @errno
%20 = load i64, i64* @EPERM
%21 = icmp eq i64 %19, %20
%22 = load i64, i64* @ESRCH
%23 = icmp eq i64 %19, %22
%24 = select i1 %21, i1 true, i1 %23
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %18, %25
%28 = load i32, i32* @EXIT_FAILURE
%29 = tail call i32 @exit(i32 %28)
unreachable
30: ; preds = %9
%31 = load i32, i32* @EXIT_SUCCESS
%32 = tail call i32 @exit(i32 %31)
unreachable
}