#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int kill(int, int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int p_id, sig;
  if (argc != 3) {
    fprintf(stderr,
            "Invalid number of arguments, use: mikill <num signal> <pid>\n");
    _exit(EXIT_FAILURE);
  }
  if ((sig = atoi(argv[1])) <= 0) {
    fprintf(stderr, "Invalid signal, try again\n");
    _exit(EXIT_FAILURE);
  }
  if ((p_id = atoi(argv[2])) <= 1) {
    fprintf(stderr, "Invalid pid, try again\n");
    _exit(EXIT_FAILURE);
  }
  if (kill(p_id, sig) == -1) {
    fprintf(stderr, "Can't kill pid %d\n", p_id);
    _exit(EXIT_FAILURE);
  }
  printf("Killed pid - %d - with signal - %d -\n", p_id, sig);
  return 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     1195 <main+0x45>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jg     11d3 <main+0x83>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x1,%eax
jg     1211 <main+0xc1>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
jne    124d <main+0xfd>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe29(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d6a(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    11a8 <main+0x58>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
test   %eax,%eax
jle    11ba <main+0x6a>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
call   1070 <atoi@plt>
cmp    $0x1,%eax
jle    11cc <main+0x7c>
mov    %eax,%ebp
mov    %eax,%edi
mov    %ebx,%esi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
je     11e5 <main+0x95>
lea    0xef4(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <printf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
jmp    11dc <main+0x8c>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
jmp    11dc <main+0x8c>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11fe <main+0xae>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [61 x i8] c"Invalid number of arguments, use: mikill <num signal> <pid>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [27 x i8] c"Invalid signal, try again\0A\00"
@.str.2 = [24 x i8] c"Invalid pid, try again\0A\00"
@.str.3 = [19 x i8] c"Can't kill pid %d\0A\00"
@.str.4 = [38 x i8] c"Killed pid - %d - with signal - %d -\0A\00"
@EXIT_SUCCESS = 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 %15
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @_exit(i32 %13)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %7
%20 = icmp sle i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @_exit(i32 %24)
unreachable
26: ; preds = %15
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %6
%31 = icmp sle i32 %30, 1
br i1 %31, label %32, label %37
32: ; preds = %26
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @_exit(i32 %35)
unreachable
37: ; preds = %26
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = call i32 @kill(i32 %38, i32 %39)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %48
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = load i32, i32* %6
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %44)
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @_exit(i32 %46)
unreachable
48: ; preds = %37
%49 = load i32, i32* %6
%50 = load i32, i32* %7
%51 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %49, i32 %50)
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [61 x i8] c"Invalid number of arguments, use: mikill <num signal> <pid>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [27 x i8] c"Invalid signal, try again\0A\00"
@.str.2 = [24 x i8] c"Invalid pid, try again\0A\00"
@.str.3 = [19 x i8] c"Can't kill pid %d\0A\00"
@.str.4 = [38 x i8] c"Killed pid - %d - with signal - %d -\0A\00"
@EXIT_SUCCESS = 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 i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%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 = icmp slt i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = tail call i32 @_exit(i32 %17)
unreachable
19: ; preds = %9
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = icmp slt i32 %22, 2
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @_exit(i32 %27)
unreachable
29: ; preds = %19
%30 = tail call i32 @kill(i32 %22, i32 %12)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%35 = load i32, i32* @EXIT_FAILURE
%36 = tail call i32 @_exit(i32 %35)
unreachable
37: ; preds = %29
%38 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %22, i32 %12)
%39 = load i32, i32* @EXIT_SUCCESS
ret i32 %39
}