#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 NSIG;
int /*<<< orphan*/ __libclog_printf(char *, char const *, int);
int *sys_siglist;
void psignal(int sig, const char *msg) {
  if (sig >= 0 && sig < NSIG)
    __libclog_printf("%s: %s\n", msg, sys_siglist[sig]);
  else
    __libclog_printf("%s: signal %d\n", msg, sig);
}


x86 assembly (clang, -O0):
<psignal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1161 <psignal+0x51>
mov    -0x4(%rbp),%eax
mov    0x2ea5(%rip),%rcx
cmp    (%rcx),%eax
jge    1161 <psignal+0x51>
mov    -0x10(%rbp),%rsi
mov    0x2ea2(%rip),%rax
mov    (%rax),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xea9(%rip),%rdi
call   1030 <__libclog_printf@plt>
jmp    1174 <psignal+0x64>
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%edx
lea    0xe99(%rip),%rdi
call   1030 <__libclog_printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psignal>:
mov    %edi,%edx
test   %edi,%edi
js     113c <psignal+0x2c>
mov    0x2ebb(%rip),%rax
cmp    %edx,(%rax)
jle    113c <psignal+0x2c>
mov    0x2ec0(%rip),%rax
mov    (%rax),%rax
mov    %edx,%ecx
mov    (%rax,%rcx,4),%edx
lea    0xec9(%rip),%rdi
jmp    1030 <__libclog_printf@plt>
lea    0xec5(%rip),%rdi
jmp    1030 <__libclog_printf@plt>

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

LLVM IR (-O2):
@NSIG = global i32 0
@.str = [8 x i8] c"%s: %s\0A\00"
@sys_siglist = global i32* null
@.str.1 = [15 x i8] c"%s: signal %d\0A\00"
define void @psignal(i32 %0, i8* %1) {
%3 = icmp sgt i32 %0, -1
%4 = load i32, i32* @NSIG
%5 = icmp sgt i32 %4, %0
%6 = select i1 %3, i1 %5, i1 false
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = load i32*, i32** @sys_siglist
%9 = zext i32 %0 to i64
%10 = getelementptr inbounds i32, i32* %8, i64 %9
%11 = load i32, i32* %10
%12 = tail call i32 @__libclog_printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %11)
br label %15
13: ; preds = %2
%14 = tail call i32 @__libclog_printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %0)
br label %15
15: ; preds = %13, %7
ret void
}