#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__ evutil_socket_t;

/* Variables and functions */
short EV_SIGNAL;
scalar_t__ SIGUSR1;
scalar_t__ SIGUSR2;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ printf(char *, long);
void signal_handler(evutil_socket_t sig, short what, void *arg) {
  assert(sig == SIGUSR1 || sig == SIGUSR2);
  assert(what == EV_SIGNAL);
  if (sig == SIGUSR1) {
    assert(arg == (void *)0x1);
  } else if (sig == SIGUSR2) {
    assert(arg == (void *)0x2);
  }
  printf("arg: %ld\n", (long)arg);
}


x86 assembly (clang, -O0):
<signal_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rcx
mov    $0x1,%al
mov    0x2ea4(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x19(%rbp)
je     1164 <signal_handler+0x44>
mov    -0x8(%rbp),%rax
mov    0x2e7d(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movswl -0xa(%rbp),%eax
mov    0x2e54(%rip),%rcx
movswl (%rcx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    0x2e4f(%rip),%rcx
cmp    (%rcx),%rax
jne    11bd <signal_handler+0x9d>
mov    $0x1,%eax
cmp    %rax,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
jmp    11ec <signal_handler+0xcc>
mov    -0x8(%rbp),%rax
mov    0x2e10(%rip),%rcx
cmp    (%rcx),%rax
jne    11e7 <signal_handler+0xc7>
mov    $0x2,%eax
cmp    %rax,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
jmp    11ec <signal_handler+0xcc>
mov    -0x18(%rbp),%rsi
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_handler>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
mov    0x2eb6(%rip),%r12
cmp    %rdi,(%r12)
sete   %al
mov    0x2e98(%rip),%r15
cmp    %rdi,(%r15)
mov    %rdx,%r14
mov    %esi,%ebp
sete   %cl
or     %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
mov    0x2e74(%rip),%rax
xor    %edi,%edi
cmp    %bp,(%rax)
sete   %dil
call   1040 <assert@plt>
mov    $0x1,%eax
cmp    %rbx,(%r12)
je     117f <signal_handler+0x5f>
mov    $0x2,%eax
cmp    %rbx,(%r15)
jne    118d <signal_handler+0x6d>
xor    %edi,%edi
cmp    %r14,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe6c(%rip),%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@SIGUSR1 = global i64 0
@SIGUSR2 = global i64 0
@EV_SIGNAL = global i16 0
@.str = [10 x i8] c"arg: %ld\0A\00"
define void @signal_handler(i64 %0, i16 signext %1, i8* %2) {
%4 = alloca i64
%5 = alloca i16
%6 = alloca i8*
store i64 %0, i64* %4
store i16 %1, i16* %5
store i8* %2, i8** %6
%7 = load i64, i64* %4
%8 = load i64, i64* @SIGUSR1
%9 = icmp eq i64 %7, %8
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = load i64, i64* %4
%12 = load i64, i64* @SIGUSR2
%13 = icmp eq i64 %11, %12
br label %14
14: ; preds = %10, %3
%15 = phi i1 [ true, %3 ], [ %13, %10 ]
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i16, i16* %5
%19 = sext i16 %18 to i32
%20 = load i16, i16* @EV_SIGNAL
%21 = sext i16 %20 to i32
%22 = icmp eq i32 %19, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i64, i64* %4
%26 = load i64, i64* @SIGUSR1
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %14
%29 = load i8*, i8** %6
%30 = icmp eq i8* %29, inttoptr (i64 1 to i8*)
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
br label %43
33: ; preds = %14
%34 = load i64, i64* %4
%35 = load i64, i64* @SIGUSR2
%36 = icmp eq i64 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i8*, i8** %6
%39 = icmp eq i8* %38, inttoptr (i64 2 to i8*)
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
br label %42
42: ; preds = %37, %33
br label %43
43: ; preds = %42, %28
%44 = load i8*, i8** %6
%45 = ptrtoint i8* %44 to i64
%46 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %45)
ret void
}

LLVM IR (-O2):
@SIGUSR1 = global i64 0
@SIGUSR2 = global i64 0
@EV_SIGNAL = global i16 0
@.str = [10 x i8] c"arg: %ld\0A\00"
define void @signal_handler(i64 %0, i16 signext %1, i8* %2) {
%4 = load i64, i64* @SIGUSR1
%5 = icmp eq i64 %4, %0
%6 = load i64, i64* @SIGUSR2
%7 = icmp eq i64 %6, %0
%8 = select i1 %5, i1 true, i1 %7
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = load i16, i16* @EV_SIGNAL
%12 = icmp eq i16 %11, %1
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = load i64, i64* @SIGUSR1
%16 = icmp eq i64 %15, %0
br i1 %16, label %20, label %17
17: ; preds = %3
%18 = load i64, i64* @SIGUSR2
%19 = icmp eq i64 %18, %0
br i1 %19, label %20, label %25
20: ; preds = %17, %3
%21 = phi i8* [ inttoptr (i64 1 to i8*), %3 ], [ inttoptr (i64 2 to i8*), %17 ]
%22 = icmp eq i8* %21, %2
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
br label %25
25: ; preds = %20, %17
%26 = ptrtoint i8* %2 to i64
%27 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %26)
ret void
}