#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 EINVAL;
int SIGKILL;
int errno;
int getopt(int, char **, char *);
int /*<<< orphan*/ getopt_init();
int kill(int, int);
char *optarg;
int optind;
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ printf(char *, int);
int strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int opt, sig = SIGKILL;
  int tid;
  getopt_init();
  while (-1 != (opt = getopt(argc, argv, "s:"))) {
    switch (opt) {
    case 's':
      sig = strtol(optarg, NULL, 0);
      break;
    default:
      printf("Unrecognized option: %c\n", opt);
      print_usage();
      return -EINVAL;
    }
  }
  if (sig <= 0) {
    printf("Invalid signal number: %d\n", sig);
    return -EINVAL;
  }
  if (optind == argc) {
    print_usage();
    return -EINVAL;
  }
  if (0 > (tid = strtol(argv[optind], NULL, 0))) {
    print_usage();
    return -EINVAL;
  }
  if (-1 == kill(tid, sig)) {
    return -errno;
  }
  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    0x2e43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getopt_init@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe69(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
je     120a <main+0xaa>
mov    -0x14(%rbp),%eax
sub    $0x73,%eax
jne    11dc <main+0x7c>
jmp    11bf <main+0x5f>
mov    0x2e32(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x18(%rbp)
jmp    1205 <main+0xa5>
mov    -0x14(%rbp),%esi
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <print_usage@plt>
xor    %eax,%eax
mov    0x2dcd(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    12dc <main+0x17c>
jmp    1189 <main+0x29>
cmpl   $0x0,-0x18(%rbp)
jg     1236 <main+0xd6>
mov    -0x18(%rbp),%esi
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    0x2d9c(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    12dc <main+0x17c>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    1262 <main+0x102>
mov    $0x0,%al
call   1080 <print_usage@plt>
xor    %eax,%eax
mov    0x2d70(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    12dc <main+0x17c>
mov    -0x10(%rbp),%rax
mov    0x2d73(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
jle    12a8 <main+0x148>
mov    $0x0,%al
call   1080 <print_usage@plt>
xor    %eax,%eax
mov    0x2d2a(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    12dc <main+0x17c>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1060 <kill@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    12d5 <main+0x175>
xor    %eax,%eax
mov    0x2d05(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    12dc <main+0x17c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e4c(%rip),%rax
mov    (%rax),%r14d
xor    %eax,%eax
call   1040 <getopt_init@plt>
lea    0xe7b(%rip),%r15
mov    0x2e6c(%rip),%r12
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
cmp    $0x73,%eax
jne    11b4 <main+0x54>
mov    (%r12),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,%r14d
jmp    1190 <main+0x30>
cmp    $0xffffffff,%eax
jne    11f7 <main+0x97>
test   %r14d,%r14d
jle    1217 <main+0xb7>
mov    0x2e1b(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
je     1205 <main+0xa5>
mov    (%rbx,%rax,8),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
test   %eax,%eax
js     1205 <main+0xa5>
mov    %eax,%edi
mov    %r14d,%esi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
jne    1231 <main+0xd1>
mov    0x2ddb(%rip),%rax
jmp    122d <main+0xcd>
lea    0xe05(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <print_usage@plt>
mov    0x2db3(%rip),%rax
jmp    122f <main+0xcf>
lea    0xdfe(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
mov    0x2d9b(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SIGKILL = global i32 0
@.str = [3 x i8] c"s:\00"
@optarg = global i8* null
@.str.1 = [25 x i8] c"Unrecognized option: %c\0A\00"
@EINVAL = global i32 0
@.str.2 = [27 x i8] c"Invalid signal number: %d\0A\00"
@optind = global i32 0
@errno = 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
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @SIGKILL
store i32 %9, i32* %7
%10 = call i32 (...) @getopt_init()
br label %11
11: ; preds = %27, %2
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %6
%15 = icmp ne i32 -1, %14
br i1 %15, label %16, label %28
16: ; preds = %11
%17 = load i32, i32* %6
switch i32 %17, label %21 [
i32 115, label %18
]
18: ; preds = %16
%19 = load i8*, i8** @optarg
%20 = call i32 @strtol(i8* %19, i32* null, i32 0)
store i32 %20, i32* %7
br label %27
21: ; preds = %16
%22 = load i32, i32* %6
%23 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = call i32 (...) @print_usage()
%25 = load i32, i32* @EINVAL
%26 = sub nsw i32 0, %25
store i32 %26, i32* %3
br label %65
27: ; preds = %18
br label %11
28: ; preds = %11
%29 = load i32, i32* %7
%30 = icmp sle i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i32, i32* %7
%33 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32, i32* @EINVAL
%35 = sub nsw i32 0, %34
store i32 %35, i32* %3
br label %65
36: ; preds = %28
%37 = load i32, i32* @optind
%38 = load i32, i32* %4
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = call i32 (...) @print_usage()
%42 = load i32, i32* @EINVAL
%43 = sub nsw i32 0, %42
store i32 %43, i32* %3
br label %65
44: ; preds = %36
%45 = load i8**, i8*** %5
%46 = load i32, i32* @optind
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 @strtol(i8* %49, i32* null, i32 0)
store i32 %50, i32* %8
%51 = icmp sgt i32 0, %50
br i1 %51, label %52, label %56
52: ; preds = %44
%53 = call i32 (...) @print_usage()
%54 = load i32, i32* @EINVAL
%55 = sub nsw i32 0, %54
store i32 %55, i32* %3
br label %65
56: ; preds = %44
%57 = load i32, i32* %8
%58 = load i32, i32* %7
%59 = call i32 @kill(i32 %57, i32 %58)
%60 = icmp eq i32 -1, %59
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = load i32, i32* @errno
%63 = sub nsw i32 0, %62
store i32 %63, i32* %3
br label %65
64: ; preds = %56
store i32 0, i32* %3
br label %65
65: ; preds = %64, %61, %52, %40, %31, %21
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@SIGKILL = global i32 0
@.str = [3 x i8] c"s:\00"
@optarg = global i8* null
@.str.1 = [25 x i8] c"Unrecognized option: %c\0A\00"
@EINVAL = global i32 0
@.str.2 = [27 x i8] c"Invalid signal number: %d\0A\00"
@optind = global i32 0
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @SIGKILL
%4 = tail call i32 (...) @getopt_init()
br label %5
5: ; preds = %8, %2
%6 = phi i32 [ %3, %2 ], [ %10, %8 ]
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %7, label %11 [
i32 -1, label %16
i32 115, label %8
]
8: ; preds = %5
%9 = load i8*, i8** @optarg
%10 = tail call i32 @strtol(i8* nocapture %9, i32* null, i32 0)
br label %5
11: ; preds = %5
%12 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%13 = tail call i32 (...) @print_usage()
%14 = load i32, i32* @EINVAL
%15 = sub nsw i32 0, %14
br label %45
16: ; preds = %5
%17 = icmp slt i32 %6, 1
br i1 %17, label %18, label %22
18: ; preds = %16
%19 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%20 = load i32, i32* @EINVAL
%21 = sub nsw i32 0, %20
br label %45
22: ; preds = %16
%23 = load i32, i32* @optind
%24 = icmp eq i32 %23, %0
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = tail call i32 (...) @print_usage()
%27 = load i32, i32* @EINVAL
%28 = sub nsw i32 0, %27
br label %45
29: ; preds = %22
%30 = sext i32 %23 to i64
%31 = getelementptr inbounds i8*, i8** %1, i64 %30
%32 = load i8*, i8** %31
%33 = tail call i32 @strtol(i8* nocapture %32, i32* null, i32 0)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %29
%36 = tail call i32 (...) @print_usage()
%37 = load i32, i32* @EINVAL
%38 = sub nsw i32 0, %37
br label %45
39: ; preds = %29
%40 = tail call i32 @kill(i32 %33, i32 %6)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* @errno
%44 = sub nsw i32 0, %43
br label %45
45: ; preds = %39, %42, %35, %25, %18, %11
%46 = phi i32 [ %15, %11 ], [ %21, %18 ], [ %28, %25 ], [ %38, %35 ], [ %44, %42 ], [ 0, %39 ]
ret i32 %46
}