#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 */
scalar_t__ kill(int, int);
int /*<<< orphan*/ printstr(char *, ...);
int /*<<< orphan*/ *sys_siglist;
void send_signal(int pid, int signal) {
  printstr("%s >>>> %d    ", sys_siglist[signal], pid);
  if (kill(pid, signal) < 0)
    printstr("(Fail!)\n");
  else
    printstr("(Hit!)\n");
}


x86 assembly (clang, -O0):
<send_signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2eb3(%rip),%rax
mov    (%rax),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x4(%rbp),%edx
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printstr@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <kill@plt>
cmp    $0x0,%rax
jge    1178 <send_signal+0x58>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printstr@plt>
jmp    1186 <send_signal+0x66>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printstr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_signal>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    0x2ebc(%rip),%rax
mov    (%rax),%rax
movslq %esi,%rbx
mov    (%rax,%rbx,4),%esi
lea    0xec4(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printstr@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <kill@plt>
test   %rax,%rax
lea    0xeb7(%rip),%rax
lea    0xeb9(%rip),%rdi
cmovs  %rax,%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printstr@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"%s >>>> %d \00"
@sys_siglist = global i32* null
@.str.1 = [9 x i8] c"(Fail!)\0A\00"
@.str.2 = [8 x i8] c"(Hit!)\0A\00"
define void @send_signal(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32*, i32** @sys_siglist
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i32, i32* %5, i64 %7
%9 = load i32, i32* %8
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printstr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = call i64 @kill(i32 %12, i32 %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printstr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %20
18: ; preds = %2
%19 = call i32 (i8*, ...) @printstr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"%s >>>> %d \00"
@sys_siglist = global i32* null
@.str.1 = [9 x i8] c"(Fail!)\0A\00"
@.str.2 = [8 x i8] c"(Hit!)\0A\00"
define void @send_signal(i32 %0, i32 %1) {
%3 = load i32*, i32** @sys_siglist
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds i32, i32* %3, i64 %4
%6 = load i32, i32* %5
%7 = tail call i32 (i8*, ...) @printstr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %0)
%8 = tail call i64 @kill(i32 %0, i32 %1)
%9 = icmp slt i64 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%11 = tail call i32 (i8*, ...) @printstr(i8* %10)
ret void
}