#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 SIGABRT;
int SIGILL;
int SIGSEGV;
int /*<<< orphan*/ printf(char *, char *);
char *strsignal(int);
int bad_signal(int sig) {
  int ret = (sig == SIGSEGV || sig == SIGILL || sig == SIGABRT);
  if (ret) {
    printf("[+] oops, we received %s\n", strsignal(sig));
  }
  return ret;
}


x86 assembly (clang, -O0):
<bad_signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0x1,%al
mov    0x2eb1(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x9(%rbp)
je     116b <bad_signal+0x4b>
mov    -0x4(%rbp),%ecx
mov    $0x1,%al
mov    0x2e92(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x9(%rbp)
je     116b <bad_signal+0x4b>
mov    -0x4(%rbp),%eax
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1197 <bad_signal+0x77>
mov    -0x4(%rbp),%edi
call   1040 <strsignal@plt>
mov    %rax,%rsi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bad_signal>:
push   %rbx
mov    0x2ec0(%rip),%rax
cmp    %edi,(%rax)
sete   %al
mov    0x2eac(%rip),%rcx
cmp    %edi,(%rcx)
sete   %cl
or     %al,%cl
mov    0x2e8e(%rip),%rax
cmp    %edi,(%rax)
sete   %bl
or     %cl,%bl
cmp    $0x1,%bl
jne    1162 <bad_signal+0x42>
call   1040 <strsignal@plt>
lea    0xea6(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
movzbl %bl,%eax
pop    %rbx
ret

LLVM IR (-O0):
@SIGSEGV = global i32 0
@SIGILL = global i32 0
@SIGABRT = global i32 0
@.str = [26 x i8] c"[+] oops, we received %s\0A\00"
define i32 @bad_signal(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = load i32, i32* @SIGSEGV
%6 = icmp eq i32 %4, %5
br i1 %6, label %15, label %7
7: ; preds = %1
%8 = load i32, i32* %2
%9 = load i32, i32* @SIGILL
%10 = icmp eq i32 %8, %9
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* @SIGABRT
%14 = icmp eq i32 %12, %13
br label %15
15: ; preds = %11, %7, %1
%16 = phi i1 [ true, %7 ], [ true, %1 ], [ %14, %11 ]
%17 = zext i1 %16 to i32
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* %2
%22 = call i8* @strsignal(i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %20, %15
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@SIGSEGV = global i32 0
@SIGILL = global i32 0
@SIGABRT = global i32 0
@.str = [26 x i8] c"[+] oops, we received %s\0A\00"
define i32 @bad_signal(i32 %0) {
%2 = load i32, i32* @SIGSEGV
%3 = icmp eq i32 %2, %0
%4 = load i32, i32* @SIGILL
%5 = icmp eq i32 %4, %0
%6 = select i1 %3, i1 true, i1 %5
%7 = load i32, i32* @SIGABRT
%8 = icmp eq i32 %7, %0
%9 = select i1 %6, i1 true, i1 %8
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = tail call i8* @strsignal(i32 %0)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %1, %10
%14 = zext i1 %9 to i32
ret i32 %14
}