#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 */
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int sival_int;
};
struct TYPE_5__ {
  TYPE_1__ si_value;
};
typedef TYPE_2__ siginfo_t;

/* Variables and functions */
int SIGALRM;
int /*<<< orphan*/ printf(char *, ...);
char *strsignal(int);
void sig_handler(int sig, siginfo_t *sinfo,
                 __attribute((unused)) void *ucontext) {
  if (sig != SIGALRM) {
    printf(
        "Received signal %d (%s). Please send only SIGALRM to this program.\n",
        sig, strsignal(sig));
    return;
  }
  int _tid = sinfo->si_value.sival_int;
  printf("\tSIGALRM received\n");
  printf("This means the alarm is set with sigev_notify = SIGEV_SIGNAL and "
         "sigev_signo = SIGALRM\n");
  printf("sival_int = %d\n", _tid);
}


x86 assembly (clang, -O0):
<sig_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eab(%rip),%rcx
cmp    (%rcx),%eax
je     116c <sig_handler+0x4c>
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <strsignal@plt>
mov    -0x20(%rbp),%esi
mov    %rax,%rdx
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a2 <sig_handler+0x82>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xf14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_handler>:
push   %rbx
mov    0x2eb0(%rip),%rax
cmp    %edi,(%rax)
jne    1167 <sig_handler+0x37>
mov    (%rsi),%ebx
lea    0xf0f(%rip),%rdi
call   1030 <puts@plt>
lea    0xf15(%rip),%rdi
call   1030 <puts@plt>
lea    0xee7(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>
mov    %edi,%ebx
call   1050 <strsignal@plt>
lea    0xe8b(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.TYPE_5__ = type { %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
@SIGALRM = global i32 0
@.str = [68 x i8] c"Received signal %d (%s). Please send only SIGALRM to this program.\0A\00"
@.str.1 = [19 x i8] c"\09SIGALRM received\0A\00"
@.str.2 = [88 x i8] c"This means the alarm is set with sigev_notify = SIGEV_SIGNAL and sigev_signo = SIGALRM\0A\00"
@.str.3 = [16 x i8] c"sival_int = %d\0A\00"
define void @sig_handler(i32 %0, %struct.TYPE_5__* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_5__*
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store %struct.TYPE_5__* %1, %struct.TYPE_5__** %5
store i8* %2, i8** %6
%8 = load i32, i32* %4
%9 = load i32, i32* @SIGALRM
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load i32, i32* %4
%13 = load i32, i32* %4
%14 = call i8* @strsignal(i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %14)
br label %25
16: ; preds = %3
%17 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %17, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %18, i32 0, i32 0
%20 = load i32, i32* %19
store i32 %20, i32* %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* %7
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %16, %11
ret void
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
@SIGALRM = global i32 0
@.str = [68 x i8] c"Received signal %d (%s). Please send only SIGALRM to this program.\0A\00"
@.str.3 = [16 x i8] c"sival_int = %d\0A\00"
@str = [18 x i8] c"\09SIGALRM received\00"
@str.4 = [87 x i8] c"This means the alarm is set with sigev_notify = SIGEV_SIGNAL and sigev_signo = SIGALRM\00"
define void @sig_handler(i32 %0, %struct.TYPE_5__* nocapture %1, i8* nocapture readnone %2) {
%4 = load i32, i32* @SIGALRM
%5 = icmp eq i32 %4, %0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i8* @strsignal(i32 %0)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %7)
br label %15
9: ; preds = %3
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 0, i32 0
%11 = load i32, i32* %10
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([87 x i8], [87 x i8]* @str.4, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %11)
br label %15
15: ; preds = %9, %6
ret void
}