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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ isdigit(char);
int kill(scalar_t__, int);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv, char **envp) {
  int err, sig, pidi;
  sig = 9;
  pidi = 1;
  err = 0;
  if (argc <= 1)
    do {
      printf("kill: [-signal] pid...\n");
      exit(1);
    } while (0);
  if (argv[1][0] == '-') {
    if (!isdigit(argv[1][1]))
      do {
        printf("kill: [-signal] pid...\n");
        exit(1);
      } while (0);
    pidi++;
    sig = atoi(argv[1] + 1);
  }
  if (pidi == argc)
    do {
      printf("kill: [-signal] pid...\n");
      exit(1);
    } while (0);
  for (; pidi < argc; pidi++) {
    pid_t pid = (pid_t)atoi(argv[pidi]);
    err = kill(pid, sig);
    if (err)
      printf("kill: failed to kill pid %d: %s\n", (int)pid, strerror(errno));
  }
  return err ? EXIT_FAILURE : EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x9,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     11b6 <main+0x56>
jmp    119e <main+0x3e>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    121e <main+0xbe>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1201 <main+0xa1>
jmp    11e9 <main+0x89>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
add    $0x1,%rdi
call   1060 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1247 <main+0xe7>
jmp    122f <main+0xcf>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    124c <main+0xec>
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c4 <main+0x164>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <atoi@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1050 <kill@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     12b1 <main+0x151>
mov    -0x30(%rbp),%rax
mov    %eax,-0x34(%rbp)
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x34(%rbp),%esi
mov    %rax,%rdx
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b6 <main+0x156>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    124c <main+0xec>
cmpl   $0x0,-0x1c(%rbp)
je     12df <main+0x17f>
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
jmp    12eb <main+0x18b>
mov    0x2cea(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    125a <main+0xea>
mov    %rsi,%r15
mov    %edi,%r14d
mov    0x8(%rsi),%rax
cmpb   $0x2d,(%rax)
jne    11bb <main+0x4b>
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     125a <main+0xea>
mov    0x8(%r15),%rdi
add    $0x1,%rdi
call   1070 <atoi@plt>
mov    %eax,%r13d
mov    $0x2,%eax
jmp    11c6 <main+0x56>
mov    $0x1,%eax
mov    $0x9,%r13d
cmp    %r14d,%eax
je     125a <main+0xea>
mov    0x2dfa(%rip),%rcx
jae    1249 <main+0xd9>
mov    %eax,%ebp
mov    %r14d,%r12d
lea    0xe1c(%rip),%r14
jmp    11f9 <main+0x89>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %r12,%rbp
je     1242 <main+0xd2>
mov    (%r15,%rbp,8),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
movslq %eax,%rdi
mov    %r13d,%esi
call   1060 <kill@plt>
test   %eax,%eax
je     11f0 <main+0x80>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %r12,%rbp
jne    11f9 <main+0x89>
mov    0x2d98(%rip),%rcx
jmp    1249 <main+0xd9>
mov    0x2d87(%rip),%rcx
mov    (%rcx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdc0(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"kill: [-signal] pid...\0A\00"
@.str.1 = [33 x i8] c"kill: failed to kill pid %d: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 9, i32* %9
store i32 1, i32* %10
store i32 0, i32* %8
%12 = load i32, i32* %5
%13 = icmp sle i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %3
br label %15
15: ; preds = %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; No predecessors!
br label %19
19: ; preds = %18, %3
%20 = load i8**, i8*** %6
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 45
br i1 %26, label %27, label %48
27: ; preds = %19
%28 = load i8**, i8*** %6
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = call i32 @isdigit(i8 signext %32)
%34 = icmp ne i32 %33, 0
br i1 %34, label %40, label %35
35: ; preds = %27
br label %36
36: ; preds = %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; No predecessors!
br label %40
40: ; preds = %39, %27
%41 = load i32, i32* %10
%42 = add nsw i32 %41, 1
store i32 %42, i32* %10
%43 = load i8**, i8*** %6
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = call i32 @atoi(i8* %46)
store i32 %47, i32* %9
br label %48
48: ; preds = %40, %19
%49 = load i32, i32* %10
%50 = load i32, i32* %5
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %57
52: ; preds = %48
br label %53
53: ; preds = %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; No predecessors!
br label %57
57: ; preds = %56, %48
br label %58
58: ; preds = %82, %57
%59 = load i32, i32* %10
%60 = load i32, i32* %5
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %85
62: ; preds = %58
%63 = load i8**, i8*** %6
%64 = load i32, i32* %10
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 @atoi(i8* %67)
%69 = sext i32 %68 to i64
store i64 %69, i64* %11
%70 = load i64, i64* %11
%71 = load i32, i32* %9
%72 = call i32 @kill(i64 %70, i32 %71)
store i32 %72, i32* %8
%73 = load i32, i32* %8
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %81
75: ; preds = %62
%76 = load i64, i64* %11
%77 = trunc i64 %76 to i32
%78 = load i32, i32* @errno
%79 = call i8* @strerror(i32 %78)
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %77, i8* %79)
br label %81
81: ; preds = %75, %62
br label %82
82: ; preds = %81
%83 = load i32, i32* %10
%84 = add nsw i32 %83, 1
store i32 %84, i32* %10
br label %58
85: ; preds = %58
%86 = load i32, i32* %8
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %85
%89 = load i32, i32* @EXIT_FAILURE
br label %92
90: ; preds = %85
%91 = load i32, i32* @EXIT_SUCCESS
br label %92
92: ; preds = %90, %88
%93 = phi i32 [ %89, %88 ], [ %91, %90 ]
ret i32 %93
}

LLVM IR (-O2):
@.str.1 = [33 x i8] c"kill: failed to kill pid %d: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str.3 = [23 x i8] c"kill: [-signal] pid...\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.3, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %3
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %25
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = load i8, i8* %14
%16 = tail call i32 @isdigit(i8 signext %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.3, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %13
%22 = load i8*, i8** %9
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = tail call i32 @atoi(i8* %23)
br label %25
25: ; preds = %21, %8
%26 = phi i32 [ %24, %21 ], [ 9, %8 ]
%27 = phi i32 [ 2, %21 ], [ 1, %8 ]
%28 = icmp eq i32 %27, %0
br i1 %28, label %34, label %29
29: ; preds = %25
%30 = icmp ult i32 %27, %0
br i1 %30, label %31, label %56
31: ; preds = %29
%32 = zext i32 %27 to i64
%33 = zext i32 %0 to i64
br label %37
34: ; preds = %25
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.3, i64 0, i64 0))
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %51, %31
%38 = phi i64 [ %32, %31 ], [ %52, %51 ]
%39 = getelementptr inbounds i8*, i8** %1, i64 %38
%40 = load i8*, i8** %39
%41 = tail call i32 @atoi(i8* %40)
%42 = sext i32 %41 to i64
%43 = tail call i32 @kill(i64 %42, i32 %26)
%44 = icmp eq i32 %43, 0
br i1 %44, label %53, label %45
45: ; preds = %37
%46 = load i32, i32* @errno
%47 = tail call i8* @strerror(i32 %46)
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %41, i8* %47)
%49 = add nuw nsw i64 %38, 1
%50 = icmp eq i64 %49, %33
br i1 %50, label %56, label %51
51: ; preds = %45, %53
%52 = phi i64 [ %49, %45 ], [ %54, %53 ]
br label %37
53: ; preds = %37
%54 = add nuw nsw i64 %38, 1
%55 = icmp eq i64 %54, %33
br i1 %55, label %56, label %51
56: ; preds = %45, %53, %29
%57 = phi i32* [ @EXIT_SUCCESS, %29 ], [ @EXIT_SUCCESS, %53 ], [ @EXIT_FAILURE, %45 ]
%58 = load i32, i32* %57
ret i32 %58
}