#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*/ SIGTSTP;
void SIG_DFL(int);
int /*<<< orphan*/ SIG_UNBLOCK;
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ kill(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, void (*)(int));
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
void sig_tstp(int signo) {
  sigset_t mask;
  sigemptyset(&mask);
  sigaddset(&mask, SIGTSTP);
  sigprocmask(SIG_UNBLOCK, &mask, NULL);
  signal(SIGTSTP, SIG_DFL);
  kill(getpid(), SIGTSTP);
  signal(SIGTSTP, sig_tstp);
}


x86 assembly (clang, -O0):
<sig_tstp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <sigemptyset@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1080 <sigaddset@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
mov    0x2e1c(%rip),%rsi
call   1050 <signal@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%edi
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
call   1070 <kill@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    0x2e08(%rip),%rsi
call   1050 <signal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_tstp>:
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sigemptyset@plt>
mov    0x2e60(%rip),%r14
mov    (%r14),%esi
mov    %rbx,%rdi
call   1080 <sigaddset@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    (%r14),%edi
mov    0x2e28(%rip),%rsi
call   1050 <signal@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    (%r14),%esi
mov    %eax,%edi
call   1070 <kill@plt>
mov    (%r14),%edi
mov    0x2e20(%rip),%rsi
call   1050 <signal@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@SIGTSTP = global i32 0
@SIG_UNBLOCK = global i32 0
define void @sig_tstp(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @sigemptyset(i32* %3)
%5 = load i32, i32* @SIGTSTP
%6 = call i32 @sigaddset(i32* %3, i32 %5)
%7 = load i32, i32* @SIG_UNBLOCK
%8 = call i32 @sigprocmask(i32 %7, i32* %3, i32* null)
%9 = load i32, i32* @SIGTSTP
%10 = call i32 @signal(i32 %9, void (i32)* @SIG_DFL)
%11 = call i32 (...) @getpid()
%12 = load i32, i32* @SIGTSTP
%13 = call i32 @kill(i32 %11, i32 %12)
%14 = load i32, i32* @SIGTSTP
%15 = call i32 @signal(i32 %14, void (i32)* @sig_tstp)
ret void
}

LLVM IR (-O2):
@SIGTSTP = global i32 0
@SIG_UNBLOCK = global i32 0
define void @sig_tstp(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @sigemptyset(i32* %2)
%5 = load i32, i32* @SIGTSTP
%6 = call i32 @sigaddset(i32* %2, i32 %5)
%7 = load i32, i32* @SIG_UNBLOCK
%8 = call i32 @sigprocmask(i32 %7, i32* %2, i32* null)
%9 = load i32, i32* @SIGTSTP
%10 = call i32 @signal(i32 %9, void (i32)* @SIG_DFL)
%11 = call i32 (...) @getpid()
%12 = load i32, i32* @SIGTSTP
%13 = call i32 @kill(i32 %11, i32 %12)
%14 = load i32, i32* @SIGTSTP
%15 = call i32 @signal(i32 %14, void (i32)* @sig_tstp)
ret void
}