#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 */
typedef int /*<<< orphan*/ sigset_t;
struct TYPE_4__ {
  int sival_int;
};
struct TYPE_5__ {
  int si_signo;
  int si_code;
  int si_errno;
  TYPE_1__ si_value;
};
typedef TYPE_2__ siginfo_t;

/* Variables and functions */
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ pthread_sigmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *);
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigwaitinfo(int /*<<< orphan*/ *, TYPE_2__ *);
void *signal_waiting_thread(void *param) {
  sigset_t set;
  siginfo_t info;
  sigfillset(&set);
  pthread_sigmask(SIG_BLOCK, &set, NULL);
  printf("Signal waiting thread started\n");
  sigwaitinfo(&set, &info);
  printf("Signal waiting thread got signal:"
         "num=%d, code=%d, errno=%d, si_value=%d\n",
         info.si_signo, info.si_code, info.si_errno, info.si_value.sival_int);
  return NULL;
}


x86 assembly (clang, -O0):
<signal_waiting_thread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <sigfillset@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    -0xc(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <pthread_sigmask@plt>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <sigwaitinfo@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_waiting_thread>:
push   %rbx
sub    $0x20,%rsp
lea    0x1c(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <sigfillset@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1070 <pthread_sigmask@plt>
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <sigwaitinfo@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    0x14(%rsp),%r8d
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i32, i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
@SIG_BLOCK = global i32 0
@.str = [31 x i8] c"Signal waiting thread started\0A\00"
@.str.1 = [73 x i8] c"Signal waiting thread got signal:num=%d, code=%d, errno=%d, si_value=%d\0A\00"
define i8* @signal_waiting_thread(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.TYPE_5__
store i8* %0, i8** %2
%5 = call i32 @sigfillset(i32* %3)
%6 = load i32, i32* @SIG_BLOCK
%7 = call i32 @pthread_sigmask(i32 %6, i32* %3, i32* null)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @sigwaitinfo(i32* %3, %struct.TYPE_5__* %4)
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 2
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 3
%17 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %13, i32 %15, i32 %18)
ret i8* null
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i32, i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
@SIG_BLOCK = global i32 0
@.str.1 = [73 x i8] c"Signal waiting thread got signal:num=%d, code=%d, errno=%d, si_value=%d\0A\00"
@str = [30 x i8] c"Signal waiting thread started\00"
define noalias i8* @signal_waiting_thread(i8* nocapture readnone %0) {
%2 = alloca i32
%3 = alloca %struct.TYPE_5__
%4 = bitcast i32* %2 to i8*
%5 = bitcast %struct.TYPE_5__* %3 to i8*
%6 = call i32 @sigfillset(i32* %2)
%7 = load i32, i32* @SIG_BLOCK
%8 = call i32 @pthread_sigmask(i32 %7, i32* %2, i32* null)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%10 = call i32 @sigwaitinfo(i32* %2, %struct.TYPE_5__* %3)
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 2
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 3, i32 0
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %14, i32 %16, i32 %18)
ret i8* null
}