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

/* Variables and functions */
scalar_t__ EINVAL;
scalar_t__ EPERM;
scalar_t__ ESRCH;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ kill(int, int);
int /*<<< orphan*/ stderr;
int strtol(char *, char **, int);
int strtoumax(char *, char **, int);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char **argp, *endp;
  pid_t pid;
  int sig;
  argp = argv + 1;
  if (argc < 2) {
    usage();
    return 1;
  }
  sig = 15;
  if (**argp == '-') {
    sig = strtol(*argp + 1, &endp, 10);
    if (*endp != 0) {
      fprintf(stderr, "kill: '%s' not valid SIG\n", *argp + 1);
      return 1;
    }
    argp++;
  }
  if (!*argp) {
    usage();
    return 1;
  }
  pid = strtoumax(*argp, &endp, 10);
  if (*endp != 0) {
    fprintf(stderr, "kill: '%s' not valid PID\n", *argp + 1);
    return 1;
  }
  if (kill(pid, sig)) {
    if (errno == EINVAL)
      fprintf(stderr, "kill: '%i' not valid SIG\n", sig);
    else if (errno == EPERM)
      fprintf(stderr, "kill: can't kill %i\n", pid);
    else if (errno == ESRCH)
      fprintf(stderr, "kill: no proc %i\n", pid);
    else
      fputs("kill: WTF\n", stderr);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119f <main+0x3f>
mov    $0x0,%al
call   1070 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1388 <main+0x228>
movl   $0xf,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    121f <main+0xbf>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1213 <main+0xb3>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
add    $0x1,%rdx
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1388 <main+0x228>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1240 <main+0xe0>
mov    $0x0,%al
call   1070 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1388 <main+0x228>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1080 <strtoumax@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1296 <main+0x136>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
add    $0x1,%rdx
lea    0xd97(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1388 <main+0x228>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1060 <kill@plt>
cmp    $0x0,%rax
je     1381 <main+0x221>
mov    0x2d26(%rip),%rax
mov    (%rax),%rax
mov    0x2d14(%rip),%rcx
cmp    (%rcx),%rax
jne    12e4 <main+0x184>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%edx
lea    0xd5c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1375 <main+0x215>
mov    0x2ced(%rip),%rax
mov    (%rax),%rax
mov    0x2ccb(%rip),%rcx
cmp    (%rcx),%rax
jne    131d <main+0x1bd>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
lea    0xd3d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1370 <main+0x210>
mov    0x2cb4(%rip),%rax
mov    (%rax),%rax
mov    0x2c8a(%rip),%rcx
cmp    (%rcx),%rax
jne    1356 <main+0x1f6>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
lea    0xd19(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    136b <main+0x20b>
mov    0x2c83(%rip),%rax
mov    (%rax),%esi
lea    0xd0f(%rip),%rdi
call   1030 <fputs@plt>
jmp    1370 <main+0x210>
jmp    1375 <main+0x215>
movl   $0x1,-0x4(%rbp)
jmp    1388 <main+0x228>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jg     1179 <main+0x19>
xor    %eax,%eax
call   1070 <usage@plt>
jmp    1210 <main+0xb0>
mov    %rsi,%rbp
lea    0x8(%rsi),%rbx
mov    (%rbx),%rdi
mov    $0xf,%r14d
cmpb   $0x2d,(%rdi)
jne    11d7 <main+0x77>
add    $0x1,%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     11c7 <main+0x67>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
add    $0x1,%rdx
lea    0xe3b(%rip),%rsi
jmp    1209 <main+0xa9>
mov    0x10(%rbp),%rdi
test   %rdi,%rdi
je     116d <main+0xd>
add    $0x10,%rbp
mov    %rbp,%rbx
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1080 <strtoumax@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     121e <main+0xbe>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
add    $0x1,%rdx
lea    0xe11(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %ebp,%edi
mov    %r14d,%esi
call   1060 <kill@plt>
test   %rax,%rax
je     1258 <main+0xf8>
mov    0x2da4(%rip),%rax
mov    (%rax),%rcx
mov    0x2d92(%rip),%rax
cmp    (%rax),%rcx
jne    125c <main+0xfc>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
mov    %r14d,%edx
jmp    129a <main+0x13a>
xor    %eax,%eax
jmp    1215 <main+0xb5>
mov    0x2d5d(%rip),%rax
cmp    (%rax),%rcx
jne    127a <main+0x11a>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
lea    0xdd6(%rip),%rsi
jmp    1298 <main+0x138>
mov    0x2d37(%rip),%rdx
mov    0x2d58(%rip),%rax
mov    (%rax),%eax
cmp    (%rdx),%rcx
jne    12a6 <main+0x146>
lea    0xdcd(%rip),%rsi
mov    %eax,%edi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1210 <main+0xb0>
lea    0xdc8(%rip),%rdi
mov    %eax,%esi
call   1030 <fputs@plt>
jmp    1210 <main+0xb0>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"kill: '%s' not valid SIG\0A\00"
@.str.1 = [26 x i8] c"kill: '%s' not valid PID\0A\00"
@errno = global i64 0
@EINVAL = global i64 0
@.str.2 = [26 x i8] c"kill: '%i' not valid SIG\0A\00"
@EPERM = global i64 0
@.str.3 = [21 x i8] c"kill: can't kill %i\0A\00"
@ESRCH = global i64 0
@.str.4 = [18 x i8] c"kill: no proc %i\0A\00"
@.str.5 = [11 x i8] c"kill: WTF\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
store i8** %11, i8*** %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (...) @usage()
store i32 1, i32* %3
br label %96
16: ; preds = %2
store i32 15, i32* %9
%17 = load i8**, i8*** %6
%18 = load i8*, i8** %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 45
br i1 %21, label %22, label %40
22: ; preds = %16
%23 = load i8**, i8*** %6
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = call i32 @strtol(i8* %25, i8** %7, i32 10)
store i32 %26, i32* %9
%27 = load i8*, i8** %7
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %22
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %6
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %35)
store i32 1, i32* %3
br label %96
37: ; preds = %22
%38 = load i8**, i8*** %6
%39 = getelementptr inbounds i8*, i8** %38, i32 1
store i8** %39, i8*** %6
br label %40
40: ; preds = %37, %16
%41 = load i8**, i8*** %6
%42 = load i8*, i8** %41
%43 = icmp ne i8* %42, null
br i1 %43, label %46, label %44
44: ; preds = %40
%45 = call i32 (...) @usage()
store i32 1, i32* %3
br label %96
46: ; preds = %40
%47 = load i8**, i8*** %6
%48 = load i8*, i8** %47
%49 = call i32 @strtoumax(i8* %48, i8** %7, i32 10)
store i32 %49, i32* %8
%50 = load i8*, i8** %7
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %60
54: ; preds = %46
%55 = load i32, i32* @stderr
%56 = load i8**, i8*** %6
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i64 1
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %58)
store i32 1, i32* %3
br label %96
60: ; preds = %46
%61 = load i32, i32* %8
%62 = load i32, i32* %9
%63 = call i64 @kill(i32 %61, i32 %62)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %95
65: ; preds = %60
%66 = load i64, i64* @errno
%67 = load i64, i64* @EINVAL
%68 = icmp eq i64 %66, %67
br i1 %68, label %69, label %73
69: ; preds = %65
%70 = load i32, i32* @stderr
%71 = load i32, i32* %9
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %71)
br label %94
73: ; preds = %65
%74 = load i64, i64* @errno
%75 = load i64, i64* @EPERM
%76 = icmp eq i64 %74, %75
br i1 %76, label %77, label %81
77: ; preds = %73
%78 = load i32, i32* @stderr
%79 = load i32, i32* %8
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %79)
br label %93
81: ; preds = %73
%82 = load i64, i64* @errno
%83 = load i64, i64* @ESRCH
%84 = icmp eq i64 %82, %83
br i1 %84, label %85, label %89
85: ; preds = %81
%86 = load i32, i32* @stderr
%87 = load i32, i32* %8
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %87)
br label %92
89: ; preds = %81
%90 = load i32, i32* @stderr
%91 = call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %90)
br label %92
92: ; preds = %89, %85
br label %93
93: ; preds = %92, %77
br label %94
94: ; preds = %93, %69
store i32 1, i32* %3
br label %96
95: ; preds = %60
store i32 0, i32* %3
br label %96
96: ; preds = %95, %94, %54, %44, %31, %14
%97 = load i32, i32* %3
ret i32 %97
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"kill: '%s' not valid SIG\0A\00"
@.str.1 = [26 x i8] c"kill: '%s' not valid PID\0A\00"
@errno = global i64 0
@EINVAL = global i64 0
@.str.2 = [26 x i8] c"kill: '%i' not valid SIG\0A\00"
@EPERM = global i64 0
@.str.3 = [21 x i8] c"kill: can't kill %i\0A\00"
@ESRCH = global i64 0
@.str.4 = [18 x i8] c"kill: no proc %i\0A\00"
@.str.5 = [11 x i8] c"kill: WTF\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (...) @usage()
br label %67
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = call i32 @strtol(i8* %14, i8** %3, i32 10)
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %67
24: ; preds = %13
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = tail call i32 (...) @usage()
br label %67
30: ; preds = %9, %24
%31 = phi i32 [ %15, %24 ], [ 15, %9 ]
%32 = phi i8** [ %25, %24 ], [ %5, %9 ]
%33 = phi i8* [ %26, %24 ], [ %10, %9 ]
%34 = call i32 @strtoumax(i8* %33, i8** %3, i32 10)
%35 = load i8*, i8** %3
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
br i1 %37, label %43, label %38
38: ; preds = %30
%39 = load i32, i32* @stderr
%40 = load i8*, i8** %32
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %41)
br label %67
43: ; preds = %30
%44 = call i64 @kill(i32 %34, i32 %31)
%45 = icmp eq i64 %44, 0
br i1 %45, label %67, label %46
46: ; preds = %43
%47 = load i64, i64* @errno
%48 = load i64, i64* @EINVAL
%49 = icmp eq i64 %47, %48
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %31)
br label %67
53: ; preds = %46
%54 = load i64, i64* @EPERM
%55 = icmp eq i64 %47, %54
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %67
59: ; preds = %53
%60 = load i64, i64* @ESRCH
%61 = icmp eq i64 %47, %60
%62 = load i32, i32* @stderr
br i1 %61, label %63, label %65
63: ; preds = %59
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %34)
br label %67
65: ; preds = %59
%66 = call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %62)
br label %67
67: ; preds = %43, %50, %63, %65, %56, %38, %28, %19, %7
%68 = phi i32 [ 1, %7 ], [ 1, %19 ], [ 1, %38 ], [ 1, %28 ], [ 1, %56 ], [ 1, %65 ], [ 1, %63 ], [ 1, %50 ], [ 0, %43 ]
ret i32 %68
}