#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 SIGCONT;
int SIGUSR1;
int SIGUSR2;
int atoi(char *);
int get_process_id(char *);
int /*<<< orphan*/ kill(int, int);
int main(int argc, char **argv) {
  int pid, idx;
  int sig[] = {SIGUSR1, SIGUSR2, SIGCONT};
  if (argc > 2) {
    idx = atoi(argv[2]);
    while (1) {
      pid = get_process_id(argv[1]);
      if (pid > 0 && idx >= 0 && idx < 3) {
        kill(pid, sig[idx]);
      } else
        break;
    }
  }
  return 0;
}


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)
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11d6 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <get_process_id@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11c7 <main+0x97>
cmpl   $0x0,-0x18(%rbp)
jl     11c7 <main+0x97>
cmpl   $0x3,-0x18(%rbp)
jge    11c7 <main+0x97>
mov    -0x14(%rbp),%edi
movslq -0x18(%rbp),%rax
mov    -0x24(%rbp,%rax,4),%esi
call   1030 <kill@plt>
jmp    11cc <main+0x9c>
jmp    11d1 <main+0xa1>
jmp    1184 <main+0x54>
jmp    11d6 <main+0xa6>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
cmp    $0x3,%edi
jl     11a6 <main+0x76>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
call   1040 <get_process_id@plt>
test   %eax,%eax
jle    11a6 <main+0x76>
test   %ebp,%ebp
js     11a6 <main+0x76>
cmp    $0x2,%ebp
jg     11a6 <main+0x76>
mov    %ebp,%ecx
mov    0xc(%rsp,%rcx,4),%ebp
nopl   0x0(%rax)
mov    %eax,%edi
mov    %ebp,%esi
call   1030 <kill@plt>
mov    0x8(%rbx),%rdi
call   1040 <get_process_id@plt>
test   %eax,%eax
jg     1190 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@SIGCONT = 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 [3 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%10 = load i32, i32* @SIGUSR1
store i32 %10, i32* %9
%11 = getelementptr inbounds i32, i32* %9, i64 1
%12 = load i32, i32* @SIGUSR2
store i32 %12, i32* %11
%13 = getelementptr inbounds i32, i32* %11, i64 1
%14 = load i32, i32* @SIGCONT
store i32 %14, i32* %13
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 2
br i1 %16, label %17, label %45
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %7
br label %22
22: ; preds = %17, %43
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @get_process_id(i8* %25)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %42
29: ; preds = %22
%30 = load i32, i32* %7
%31 = icmp sge i32 %30, 0
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = load i32, i32* %7
%34 = icmp slt i32 %33, 3
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = call i32 @kill(i32 %36, i32 %40)
br label %43
42: ; preds = %32, %29, %22
br label %44
43: ; preds = %35
br label %22
44: ; preds = %42
br label %45
45: ; preds = %44, %2
ret i32 0
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@SIGCONT = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x i32]
%4 = bitcast [3 x i32]* %3 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%6 = load i32, i32* @SIGUSR1
store i32 %6, i32* %5
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
%8 = load i32, i32* @SIGUSR2
store i32 %8, i32* %7
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
%10 = load i32, i32* @SIGCONT
store i32 %10, i32* %9
%11 = icmp sgt i32 %0, 2
br i1 %11, label %12, label %34
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @get_process_id(i8* %17)
%19 = icmp sgt i32 %18, 0
%20 = icmp sgt i32 %15, -1
%21 = select i1 %19, i1 %20, i1 false
%22 = icmp slt i32 %15, 3
%23 = select i1 %21, i1 %22, i1 false
br i1 %23, label %24, label %34
24: ; preds = %12
%25 = zext i32 %15 to i64
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 %25
%27 = load i32, i32* %26
br label %28
28: ; preds = %24, %28
%29 = phi i32 [ %18, %24 ], [ %32, %28 ]
%30 = tail call i32 @kill(i32 %29, i32 %27)
%31 = load i8*, i8** %16
%32 = tail call i32 @get_process_id(i8* %31)
%33 = icmp sgt i32 %32, 0
br i1 %33, label %28, label %34
34: ; preds = %28, %12, %2
ret i32 0
}