#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 SIGKILL;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int killall(int);
int /*<<< orphan*/ stderr;
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  int sig = SIGKILL;
  if (argc > 1)
    if (*argv[1]++ == '-') {
      errno = 0;
      sig = strtol(argv[1], NULL, 10);
      if (errno)
        sig = -1;
    }
  if (sig < 1) {
    fprintf(stderr, "killall5: invalid signal: %s\n", argv[1]);
    return 1;
  }
  return killall(sig);
}


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    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11c4 <main+0x94>
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,0x8(%rcx)
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11bf <main+0x8f>
mov    0x2e56(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e2f(%rip),%rax
cmpq   $0x0,(%rax)
je     11ba <main+0x8a>
movl   $0xffffffff,-0x14(%rbp)
jmp    11bf <main+0x8f>
jmp    11c4 <main+0x94>
cmpl   $0x1,-0x14(%rbp)
jge    11f7 <main+0xc7>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe1a(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1202 <main+0xd2>
mov    -0x14(%rbp),%edi
call   1050 <killall@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%eax
mov    0x2e90(%rip),%rcx
mov    (%rcx),%edi
cmp    $0x2,%eax
jl     117d <main+0x4d>
mov    0x8(%rbx),%rcx
lea    0x1(%rcx),%rax
mov    %rax,0x8(%rbx)
cmpb   $0x2d,(%rcx)
jne    117d <main+0x4d>
mov    0x2e79(%rip),%r14
movq   $0x0,(%r14)
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
cmpq   $0x0,(%r14)
jne    118d <main+0x5d>
mov    %eax,%edi
test   %edi,%edi
jle    118d <main+0x5d>
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <killall@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe5f(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@SIGKILL = global i32 0
@errno = global i64 0
@stderr = global i32 0
@.str = [30 x i8] c"killall5: invalid signal: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @SIGKILL
store i32 %7, i32* %6
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %28
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %12
%15 = load i8, i8* %13
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 45
br i1 %17, label %18, label %27
18: ; preds = %10
store i64 0, i64* @errno
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strtol(i8* %21, i32* null, i32 10)
store i32 %22, i32* %6
%23 = load i64, i64* @errno
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %18
store i32 -1, i32* %6
br label %26
26: ; preds = %25, %18
br label %27
27: ; preds = %26, %10
br label %28
28: ; preds = %27, %2
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 1
br i1 %30, label %31, label %37
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %35)
store i32 1, i32* %3
br label %40
37: ; preds = %28
%38 = load i32, i32* %6
%39 = call i32 @killall(i32 %38)
store i32 %39, i32* %3
br label %40
40: ; preds = %37, %31
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@SIGKILL = global i32 0
@errno = global i64 0
@stderr = global i32 0
@.str = [30 x i8] c"killall5: invalid signal: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @SIGKILL
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = getelementptr inbounds i8, i8* %7, i64 1
store i8* %8, i8** %6
%9 = load i8, i8* %7
%10 = icmp eq i8 %9, 45
br i1 %10, label %11, label %15
11: ; preds = %5
store i64 0, i64* @errno
%12 = tail call i32 @strtol(i8* nocapture %8, i32* null, i32 10)
%13 = load i64, i64* @errno
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11, %5, %2
%16 = phi i32 [ %3, %5 ], [ %3, %2 ], [ %12, %11 ]
%17 = icmp slt i32 %16, 1
br i1 %17, label %18, label %23
18: ; preds = %11, %15
%19 = load i32, i32* @stderr
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %25
23: ; preds = %15
%24 = tail call i32 @killall(i32 %16)
br label %25
25: ; preds = %23, %18
%26 = phi i32 [ 1, %18 ], [ %24, %23 ]
ret i32 %26
}