#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*/ atoi(char *, int *, int);
int kill(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[], char *envp[]) {
  int pid = 0;
  if (argc < 3) {
    printf("kill: Too few arguments\n");
    return 0;
  }
  if (argc > 3) {
    printf("kill: Too many arguments\n");
  }
  if (strcmp(argv[1], "-9") != 0) {
    printf("Usage: kill -9 <pid>\n");
    return 0;
  }
  atoi(argv[2], &pid, 10);
  if (kill(pid) == -1) {
    printf("%s: No such process\n", argv[2]);
  }
  return 0;
}


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)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1185 <main+0x45>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1219 <main+0xd9>
cmpl   $0x3,-0x8(%rbp)
jle    119d <main+0x5d>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe87(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11d5 <main+0x95>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1219 <main+0xd9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0xa,%edx
call   1060 <atoi@plt>
mov    -0x1c(%rbp),%edi
call   1050 <kill@plt>
cmp    $0xffffffff,%eax
jne    1212 <main+0xd2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
cmp    $0x2,%edi
jg     1170 <main+0x20>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
jmp    11da <main+0x8a>
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1184 <main+0x34>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rbx),%rdi
lea    0xe71(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11a7 <main+0x57>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
jmp    11da <main+0x8a>
mov    0x10(%rbx),%rdi
lea    0xc(%rsp),%rsi
mov    $0xa,%edx
call   1070 <atoi@plt>
mov    0xc(%rsp),%edi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
jne    11da <main+0x8a>
mov    0x10(%rbx),%rsi
lea    0xe30(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"kill: Too few arguments\0A\00"
@.str.1 = [26 x i8] c"kill: Too many arguments\0A\00"
@.str.2 = [3 x i8] c"-9\00"
@.str.3 = [22 x i8] c"Usage: kill -9 <pid>\0A\00"
@.str.4 = [21 x i8] c"%s: No such process\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 0, i32* %8
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %40
13: ; preds = %3
%14 = load i32, i32* %5
%15 = icmp sgt i32 %14, 3
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = load i8**, i8*** %6
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %40
26: ; preds = %18
%27 = load i8**, i8*** %6
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29, i32* %8, i32 10)
%31 = load i32, i32* %8
%32 = call i32 @kill(i32 %31)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %39
34: ; preds = %26
%35 = load i8**, i8*** %6
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %34, %26
store i32 0, i32* %4
br label %40
40: ; preds = %39, %24, %11
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"-9\00"
@.str.4 = [21 x i8] c"%s: No such process\0A\00"
@str = [21 x i8] c"Usage: kill -9 <pid>\00"
@str.5 = [25 x i8] c"kill: Too many arguments\00"
@str.6 = [24 x i8] c"kill: Too few arguments\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = icmp slt i32 %0, 3
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
br label %30
9: ; preds = %3
%10 = icmp eq i32 %0, 3
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %30
20: ; preds = %13
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22, i32* %4, i32 10)
%24 = load i32, i32* %4
%25 = call i32 @kill(i32 %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = load i8*, i8** %21
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %20, %27, %18, %7
ret i32 0
}