#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*/ SIGABRT;
int /*<<< orphan*/ SIG_SETMASK;
scalar_t__ is_changed(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ pthread_exit(void *);
int /*<<< orphan*/ pthread_sigmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
void *a_thread_func() {
  sigset_t actl, oactl;
  sigemptyset(&actl);
  sigemptyset(&oactl);
  sigaddset(&actl, SIGABRT);
  pthread_sigmask(SIG_SETMASK, &actl, NULL);
  pthread_sigmask(SIG_SETMASK, NULL, &oactl);
  if (is_changed(oactl, SIGABRT)) {
    pthread_exit((void *)-1);
  }
  printf("PASS: signal mask was not changed.\n");
  pthread_exit((void *)0);
  return NULL;
}


x86 assembly (clang, -O0):
<a_thread_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1040 <sigemptyset@plt>
lea    -0x8(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1080 <sigaddset@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <pthread_sigmask@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x8(%rbp),%rdx
call   1070 <pthread_sigmask@plt>
mov    -0x8(%rbp),%edi
mov    0x2e16(%rip),%rax
mov    (%rax),%esi
call   1050 <is_changed@plt>
cmp    $0x0,%rax
je     11df <a_thread_func+0x7f>
mov    $0xffffffffffffffff,%rdi
call   1060 <pthread_exit@plt>
lea    0xe1a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <pthread_exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a_thread_func>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sigemptyset@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e51(%rip),%r15
mov    (%r15),%esi
mov    %rbx,%rdi
call   1080 <sigaddset@plt>
mov    0x2e4f(%rip),%r12
mov    (%r12),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1070 <pthread_sigmask@plt>
mov    (%r12),%edi
xor    %esi,%esi
mov    %r14,%rdx
call   1070 <pthread_sigmask@plt>
mov    (%rsp),%edi
mov    (%r15),%esi
call   1050 <is_changed@plt>
test   %rax,%rax
je     11d1 <a_thread_func+0x71>
mov    $0xffffffffffffffff,%rdi
call   1060 <pthread_exit@plt>
lea    0xe28(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <pthread_exit@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SIGABRT = global i32 0
@SIG_SETMASK = global i32 0
@.str = [36 x i8] c"PASS: signal mask was not changed.\0A\00"
define i8* @a_thread_func() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @sigemptyset(i32* %1)
%4 = call i32 @sigemptyset(i32* %2)
%5 = load i32, i32* @SIGABRT
%6 = call i32 @sigaddset(i32* %1, i32 %5)
%7 = load i32, i32* @SIG_SETMASK
%8 = call i32 @pthread_sigmask(i32 %7, i32* %1, i32* null)
%9 = load i32, i32* @SIG_SETMASK
%10 = call i32 @pthread_sigmask(i32 %9, i32* null, i32* %2)
%11 = load i32, i32* %2
%12 = load i32, i32* @SIGABRT
%13 = call i64 @is_changed(i32 %11, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @pthread_exit(i8* inttoptr (i64 -1 to i8*))
br label %17
17: ; preds = %15, %0
%18 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @pthread_exit(i8* null)
ret i8* null
}

LLVM IR (-O2):
@SIGABRT = global i32 0
@SIG_SETMASK = global i32 0
@str = [35 x i8] c"PASS: signal mask was not changed.\00"
define noalias i8* @a_thread_func() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @sigemptyset(i32* %1)
%6 = call i32 @sigemptyset(i32* %2)
%7 = load i32, i32* @SIGABRT
%8 = call i32 @sigaddset(i32* %1, i32 %7)
%9 = load i32, i32* @SIG_SETMASK
%10 = call i32 @pthread_sigmask(i32 %9, i32* %1, i32* null)
%11 = load i32, i32* @SIG_SETMASK
%12 = call i32 @pthread_sigmask(i32 %11, i32* null, i32* %2)
%13 = load i32, i32* %2
%14 = load i32, i32* @SIGABRT
%15 = call i64 @is_changed(i32 %13, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %0
%18 = call i32 @pthread_exit(i8* inttoptr (i64 -1 to i8*))
br label %19
19: ; preds = %17, %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%21 = call i32 @pthread_exit(i8* null)
ret i8* null
}