#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int atoi(char *);
scalar_t__ atol(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int kill(scalar_t__, int);
int /*<<< orphan*/ printf(char *, char *, ...);
scalar_t__ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int num_sigs, sig, j;
  pid_t pid;
  if (argc < 4 || strcmp(argv[1], "--help") == 0) {
    printf("Usage %s pid num-sigs sig-num [sig-num-2]\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  pid = atol(argv[1]);
  num_sigs = atoi(argv[2]);
  sig = atoi(argv[3]);
  printf("%s: sending signal %d to process %ld %d times\n", argv[0], sig,
         (long)pid, num_sigs);
  for (j = 0; j < num_sigs; j++) {
    if (kill(pid, sig) == -1) {
      printf("Error on kill, %s", strerror(errno));
      exit(EXIT_FAILURE);
    }
  }
  if (argc > 4) {
    if (kill(pid, atoi(argv[4])) == -1) {
      printf("Error on kill, %s", strerror(errno));
      exit(EXIT_FAILURE);
    }
  }
  printf("%s: exiting\n", argv[0]);
  exit(EXIT_SUCCESS);
}


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)
cmpl   $0x4,-0x8(%rbp)
jl     11ae <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe61(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d1 <main+0x61>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    128a <main+0x11a>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <kill@plt>
cmp    $0xffffffff,%eax
jne    1277 <main+0x107>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %rax,%rsi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    127c <main+0x10c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1229 <main+0xb9>
cmpl   $0x4,-0x8(%rbp)
jle    12ef <main+0x17f>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1070 <atoi@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1050 <kill@plt>
cmp    $0xffffffff,%eax
jne    12ea <main+0x17a>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %rax,%rsi
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    12ef <main+0x17f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
cmp    $0x4,%edi
jl     1198 <main+0x28>
mov    %edi,%r14d
mov    0x8(%r15),%rdi
lea    0xe72(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11b7 <main+0x47>
mov    (%r15),%rsi
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x8(%r15),%rdi
call   1060 <atol@plt>
mov    %rax,%r12
mov    0x10(%r15),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    0x18(%r15),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    (%r15),%rsi
lea    0xe4f(%rip),%rdi
mov    %eax,%edx
mov    %r12,%rcx
mov    %ebx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
jle    1214 <main+0xa4>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebp,%esi
call   1050 <kill@plt>
cmp    $0xffffffff,%eax
je     1232 <main+0xc2>
add    $0xffffffff,%ebx
jne    1200 <main+0x90>
cmp    $0x5,%r14d
jl     124f <main+0xdf>
mov    0x20(%r15),%rdi
call   1070 <atoi@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1050 <kill@plt>
cmp    $0xffffffff,%eax
jne    124f <main+0xdf>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe1a(%rip),%rdi
mov    %rax,%rsi
jmp    11a2 <main+0x32>
mov    (%r15),%rsi
lea    0xe1a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [43 x i8] c"Usage %s pid num-sigs sig-num [sig-num-2]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [47 x i8] c"%s: sending signal %d to process %ld %d times\0A\00"
@.str.3 = [18 x i8] c"Error on kill, %s\00"
@errno = global i32 0
@.str.4 = [13 x i8] c"%s: exiting\0A\00"
@EXIT_SUCCESS = 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
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %18, label %12
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %12, %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %12
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @atol(i8* %28)
store i64 %29, i64* %9
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %6
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 3
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %7
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = load i32, i32* %7
%42 = load i64, i64* %9
%43 = load i32, i32* %6
%44 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i8* %40, i32 %41, i64 %42, i32 %43)
store i32 0, i32* %8
br label %45
45: ; preds = %61, %25
%46 = load i32, i32* %8
%47 = load i32, i32* %6
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %64
49: ; preds = %45
%50 = load i64, i64* %9
%51 = load i32, i32* %7
%52 = call i32 @kill(i64 %50, i32 %51)
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %60
54: ; preds = %49
%55 = load i32, i32* @errno
%56 = call i8* @strerror(i32 %55)
%57 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %56)
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %49
br label %61
61: ; preds = %60
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %45
64: ; preds = %45
%65 = load i32, i32* %4
%66 = icmp sgt i32 %65, 4
br i1 %66, label %67, label %82
67: ; preds = %64
%68 = load i64, i64* %9
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 4
%71 = load i8*, i8** %70
%72 = call i32 @atoi(i8* %71)
%73 = call i32 @kill(i64 %68, i32 %72)
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %81
75: ; preds = %67
%76 = load i32, i32* @errno
%77 = call i8* @strerror(i32 %76)
%78 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %77)
%79 = load i32, i32* @EXIT_FAILURE
%80 = call i32 @exit(i32 %79)
unreachable
81: ; preds = %67
br label %82
82: ; preds = %81, %64
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 0
%85 = load i8*, i8** %84
%86 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %85)
%87 = load i32, i32* @EXIT_SUCCESS
%88 = call i32 @exit(i32 %87)
unreachable
}

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