#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*/ PR_SET_PDEATHSIG;
int /*<<< orphan*/ SIGBUS;
int /*<<< orphan*/ SIGFPE;
int /*<<< orphan*/ SIGILL;
int /*<<< orphan*/ SIGKILL;
int /*<<< orphan*/ SIGSEGV;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ _exit(int);
scalar_t__ prctl(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sigdelset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigsuspend(int /*<<< orphan*/ *);
int /*<<< orphan*/ xclose(int);
void sentinel(void) {
  if (prctl(PR_SET_PDEATHSIG, SIGKILL) != 0)
    _exit(11);
  xclose(3);
  xclose(4);
  xclose(6);
  sigset_t mask;
  sigfillset(&mask);
  sigdelset(&mask, SIGBUS);
  sigdelset(&mask, SIGFPE);
  sigdelset(&mask, SIGILL);
  sigdelset(&mask, SIGSEGV);
  sigdelset(&mask, SIGTERM);
  sigsuspend(&mask);
  _exit(13);
}


x86 assembly (clang, -O0):
<sentinel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
call   1060 <prctl@plt>
cmp    $0x0,%rax
je     1193 <sentinel+0x33>
mov    $0xb,%edi
call   1030 <_exit@plt>
mov    $0x3,%edi
call   1040 <xclose@plt>
mov    $0x4,%edi
call   1040 <xclose@plt>
mov    $0x6,%edi
call   1040 <xclose@plt>
lea    -0x4(%rbp),%rdi
call   1050 <sigfillset@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1080 <sigdelset@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1080 <sigdelset@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1080 <sigdelset@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1080 <sigdelset@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1080 <sigdelset@plt>
lea    -0x4(%rbp),%rdi
call   1070 <sigsuspend@plt>
mov    $0xd,%edi
call   1030 <_exit@plt>

x86 assembly (clang, -O2):
<sentinel>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
call   1060 <prctl@plt>
test   %rax,%rax
jne    1217 <sentinel+0xb7>
mov    $0x3,%edi
call   1040 <xclose@plt>
mov    $0x4,%edi
call   1040 <xclose@plt>
mov    $0x6,%edi
call   1040 <xclose@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <sigfillset@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <sigdelset@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <sigdelset@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <sigdelset@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <sigdelset@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <sigdelset@plt>
mov    %rbx,%rdi
call   1070 <sigsuspend@plt>
mov    $0xd,%edi
call   1030 <_exit@plt>
mov    $0xb,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@PR_SET_PDEATHSIG = global i32 0
@SIGKILL = global i32 0
@SIGBUS = global i32 0
@SIGFPE = global i32 0
@SIGILL = global i32 0
@SIGSEGV = global i32 0
@SIGTERM = global i32 0
define void @sentinel() {
%1 = alloca i32
%2 = load i32, i32* @PR_SET_PDEATHSIG
%3 = load i32, i32* @SIGKILL
%4 = call i64 @prctl(i32 %2, i32 %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @_exit(i32 11)
unreachable
8: ; preds = %0
%9 = call i32 @xclose(i32 3)
%10 = call i32 @xclose(i32 4)
%11 = call i32 @xclose(i32 6)
%12 = call i32 @sigfillset(i32* %1)
%13 = load i32, i32* @SIGBUS
%14 = call i32 @sigdelset(i32* %1, i32 %13)
%15 = load i32, i32* @SIGFPE
%16 = call i32 @sigdelset(i32* %1, i32 %15)
%17 = load i32, i32* @SIGILL
%18 = call i32 @sigdelset(i32* %1, i32 %17)
%19 = load i32, i32* @SIGSEGV
%20 = call i32 @sigdelset(i32* %1, i32 %19)
%21 = load i32, i32* @SIGTERM
%22 = call i32 @sigdelset(i32* %1, i32 %21)
%23 = call i32 @sigsuspend(i32* %1)
%24 = call i32 @_exit(i32 13)
unreachable
}

LLVM IR (-O2):
@PR_SET_PDEATHSIG = global i32 0
@SIGKILL = global i32 0
@SIGBUS = global i32 0
@SIGFPE = global i32 0
@SIGILL = global i32 0
@SIGSEGV = global i32 0
@SIGTERM = global i32 0
define void @sentinel() {
%1 = alloca i32
%2 = load i32, i32* @PR_SET_PDEATHSIG
%3 = load i32, i32* @SIGKILL
%4 = tail call i64 @prctl(i32 %2, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = tail call i32 @_exit(i32 11)
unreachable
8: ; preds = %0
%9 = tail call i32 @xclose(i32 3)
%10 = tail call i32 @xclose(i32 4)
%11 = tail call i32 @xclose(i32 6)
%12 = bitcast i32* %1 to i8*
%13 = call i32 @sigfillset(i32* %1)
%14 = load i32, i32* @SIGBUS
%15 = call i32 @sigdelset(i32* %1, i32 %14)
%16 = load i32, i32* @SIGFPE
%17 = call i32 @sigdelset(i32* %1, i32 %16)
%18 = load i32, i32* @SIGILL
%19 = call i32 @sigdelset(i32* %1, i32 %18)
%20 = load i32, i32* @SIGSEGV
%21 = call i32 @sigdelset(i32* %1, i32 %20)
%22 = load i32, i32* @SIGTERM
%23 = call i32 @sigdelset(i32* %1, i32 %22)
%24 = call i32 @sigsuspend(i32* %1)
%25 = call i32 @_exit(i32 13)
unreachable
}