#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 int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ pthread_sigmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigwait(int /*<<< orphan*/ *, int *);
void *t_func(void *argv) {
  sigset_t sig;
  sigemptyset(&sig);
  sigaddset(&sig, SIGUSR1);
  pthread_sigmask(SIG_BLOCK, &sig, NULL);
  while (1) {
    int signo;
    sigwait(&sig, &signo);
    printf("Recv signal:%d\n", signo);
  }
}


x86 assembly (clang, -O0):
<t_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1070 <sigaddset@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    -0xc(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <pthread_sigmask@plt>
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <sigwait@plt>
mov    -0x10(%rbp),%esi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
jmp    118d <t_func+0x3d>

x86 assembly (clang, -O2):
<t_func>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1070 <sigaddset@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1050 <pthread_sigmask@plt>
lea    0x8(%rsp),%r15
lea    0xe6a(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <sigwait@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
jmp    11a0 <t_func+0x50>

LLVM IR (-O0):
@SIGUSR1 = global i32 0
@SIG_BLOCK = global i32 0
@.str = [16 x i8] c"Recv signal:%d\0A\00"
define i8* @t_func(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 @sigemptyset(i32* %3)
%6 = load i32, i32* @SIGUSR1
%7 = call i32 @sigaddset(i32* %3, i32 %6)
%8 = load i32, i32* @SIG_BLOCK
%9 = call i32 @pthread_sigmask(i32 %8, i32* %3, i32* null)
br label %10
10: ; preds = %1, %10
%11 = call i32 @sigwait(i32* %3, i32* %4)
%12 = load i32, i32* %4
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %10
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@SIG_BLOCK = global i32 0
@.str = [16 x i8] c"Recv signal:%d\0A\00"
define noalias i8* @t_func(i8* nocapture readnone %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = call i32 @sigemptyset(i32* %2)
%6 = load i32, i32* @SIGUSR1
%7 = call i32 @sigaddset(i32* %2, i32 %6)
%8 = load i32, i32* @SIG_BLOCK
%9 = call i32 @pthread_sigmask(i32 %8, i32* %2, i32* null)
%10 = bitcast i32* %3 to i8*
br label %11
11: ; preds = %11, %1
%12 = call i32 @sigwait(i32* %2, i32* %3)
%13 = load i32, i32* %3
%14 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %11
}