#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 /*<<< orphan*/ pid_t;

/* Variables and functions */
int _kill_error(int /*<<< orphan*/, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *);
scalar_t__ kill(int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strtol(char *, char **, int);
int _kill(int sig, int argc, char *argv[]) {
  int ret = 0;
  int i;
  pid_t pid;
  char *p;
  for (i = 0; i < argc; i++) {
    pid = strtol(argv[i], &p, 10);
    if (argv[i][0] == '\0' || *p != '\0') {
      fprintf(stderr, "%s%s%s",
              "kill"
              ": ",
              argv[i], ": Invalid process number\n");
      ret |= 1;
      continue;
    }
    if (kill(pid, sig) != 0)
      ret |= _kill_error(strerror(errno), 1);
  }
  return ret;
}


x86 assembly (clang, -O0):
<_kill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1246 <_kill+0xf6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c1 <_kill+0x71>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11fe <_kill+0xae>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe23(%rip),%rsi
lea    0xe23(%rip),%rdx
lea    0xe23(%rip),%r8
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1238 <_kill+0xe8>
mov    -0x1c(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1060 <kill@plt>
cmp    $0x0,%rax
je     1233 <_kill+0xe3>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <_kill_error@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1238 <_kill+0xe8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1170 <_kill+0x20>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_kill>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,0xc(%rsp)
test   %esi,%esi
jle    120d <_kill+0xbd>
mov    %rdx,%rbx
mov    %esi,%r15d
xor    %r13d,%r13d
lea    0x10(%rsp),%r12
lea    0xe8f(%rip),%r14
xor    %ebp,%ebp
jmp    11bb <_kill+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
lea    0xe60(%rip),%rdx
mov    %r14,%r8
call   1040 <fprintf@plt>
or     $0x1,%ebp
add    $0x1,%r13
cmp    %r13,%r15
je     120f <_kill+0xbf>
mov    (%rbx,%r13,8),%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    (%rbx,%r13,8),%rcx
cmpb   $0x0,(%rcx)
je     1190 <_kill+0x40>
mov    0x10(%rsp),%rdx
cmpb   $0x0,(%rdx)
jne    1190 <_kill+0x40>
mov    %eax,%edi
mov    0xc(%rsp),%esi
call   1060 <kill@plt>
test   %rax,%rax
je     11b2 <_kill+0x62>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <_kill_error@plt>
or     %eax,%ebp
jmp    11b2 <_kill+0x62>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [7 x i8] c"kill: \00"
@.str.2 = [26 x i8] c": Invalid process number\0A\00"
@errno = global i32 0
define i32 @_kill(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %11
11: ; preds = %58, %3
%12 = load i32, i32* %8
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %61
15: ; preds = %11
%16 = load i8**, i8*** %6
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @strtol(i8* %20, i8** %10, i32 10)
store i32 %21, i32* %9
%22 = load i8**, i8*** %6
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %15
%32 = load i8*, i8** %10
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %46
36: ; preds = %31, %15
%37 = load i32, i32* @stderr
%38 = load i8**, i8*** %6
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %42, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%44 = load i32, i32* %7
%45 = or i32 %44, 1
store i32 %45, i32* %7
br label %58
46: ; preds = %31
%47 = load i32, i32* %9
%48 = load i32, i32* %4
%49 = call i64 @kill(i32 %47, i32 %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %57
51: ; preds = %46
%52 = load i32, i32* @errno
%53 = call i32 @strerror(i32 %52)
%54 = call i32 @_kill_error(i32 %53, i32 1)
%55 = load i32, i32* %7
%56 = or i32 %55, %54
store i32 %56, i32* %7
br label %57
57: ; preds = %51, %46
br label %58
58: ; preds = %57, %36
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
br label %11
61: ; preds = %11
%62 = load i32, i32* %7
ret i32 %62
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [7 x i8] c"kill: \00"
@.str.2 = [26 x i8] c": Invalid process number\0A\00"
@errno = global i32 0
define i32 @_kill(i32 %0, i32 %1, i8** nocapture %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %38
7: ; preds = %3
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %34
%10 = phi i64 [ 0, %7 ], [ %36, %34 ]
%11 = phi i32 [ 0, %7 ], [ %35, %34 ]
%12 = getelementptr inbounds i8*, i8** %2, i64 %10
%13 = load i8*, i8** %12
%14 = call i32 @strtol(i8* %13, i8** %4, i32 10)
%15 = load i8*, i8** %12
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %9
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %18, %9
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%25 = or i32 %11, 1
br label %34
26: ; preds = %18
%27 = tail call i64 @kill(i32 %14, i32 %0)
%28 = icmp eq i64 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %26
%30 = load i32, i32* @errno
%31 = tail call i32 @strerror(i32 %30)
%32 = tail call i32 @_kill_error(i32 %31, i32 1)
%33 = or i32 %32, %11
br label %34
34: ; preds = %26, %29, %22
%35 = phi i32 [ %25, %22 ], [ %33, %29 ], [ %11, %26 ]
%36 = add nuw nsw i64 %10, 1
%37 = icmp eq i64 %36, %8
br i1 %37, label %38, label %9
38: ; preds = %34, %3
%39 = phi i32 [ 0, %3 ], [ %35, %34 ]
ret i32 %39
}