#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*/ SIGALRM;
int /*<<< orphan*/ SIGTSTP;
int /*<<< orphan*/ SIGWINCH;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ SIG_UNBLOCK;
int /*<<< orphan*/ __restartwin();
int /*<<< orphan*/ __stopwin();
int /*<<< orphan*/ kill(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
void __stop_signal_handler(int signo) {
  sigset_t oset, set;
  (void)sigemptyset(&set);
  (void)sigaddset(&set, SIGALRM);
  (void)sigaddset(&set, SIGWINCH);
  (void)sigprocmask(SIG_BLOCK, &set, &oset);
  __stopwin();
  (void)sigemptyset(&set);
  (void)sigaddset(&set, SIGTSTP);
  (void)sigprocmask(SIG_UNBLOCK, &set, NULL);
  (void)kill(0, SIGTSTP);
  __restartwin();
  (void)sigprocmask(SIG_SETMASK, &oset, NULL);
}


x86 assembly (clang, -O0):
<__stop_signal_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1080 <sigaddset@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1080 <sigaddset@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    -0xc(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1030 <sigprocmask@plt>
mov    $0x0,%al
call   1070 <__stopwin@plt>
lea    -0xc(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1080 <sigaddset@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    -0xc(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
call   1050 <kill@plt>
mov    $0x0,%al
call   1060 <__restartwin@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__stop_signal_handler>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <sigaddset@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <sigaddset@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <sigprocmask@plt>
xor    %eax,%eax
call   1070 <__stopwin@plt>
mov    %rbx,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e09(%rip),%r15
mov    (%r15),%esi
mov    %rbx,%rdi
call   1080 <sigaddset@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    (%r15),%esi
xor    %edi,%edi
call   1050 <kill@plt>
xor    %eax,%eax
call   1060 <__restartwin@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SIGALRM = global i32 0
@SIGWINCH = global i32 0
@SIG_BLOCK = global i32 0
@SIGTSTP = global i32 0
@SIG_UNBLOCK = global i32 0
@SIG_SETMASK = global i32 0
define void @__stop_signal_handler(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 @sigemptyset(i32* %4)
%6 = load i32, i32* @SIGALRM
%7 = call i32 @sigaddset(i32* %4, i32 %6)
%8 = load i32, i32* @SIGWINCH
%9 = call i32 @sigaddset(i32* %4, i32 %8)
%10 = load i32, i32* @SIG_BLOCK
%11 = call i32 @sigprocmask(i32 %10, i32* %4, i32* %3)
%12 = call i32 (...) @__stopwin()
%13 = call i32 @sigemptyset(i32* %4)
%14 = load i32, i32* @SIGTSTP
%15 = call i32 @sigaddset(i32* %4, i32 %14)
%16 = load i32, i32* @SIG_UNBLOCK
%17 = call i32 @sigprocmask(i32 %16, i32* %4, i32* null)
%18 = load i32, i32* @SIGTSTP
%19 = call i32 @kill(i32 0, i32 %18)
%20 = call i32 (...) @__restartwin()
%21 = load i32, i32* @SIG_SETMASK
%22 = call i32 @sigprocmask(i32 %21, i32* %3, i32* null)
ret void
}

LLVM IR (-O2):
@SIGALRM = global i32 0
@SIGWINCH = global i32 0
@SIG_BLOCK = global i32 0
@SIGTSTP = global i32 0
@SIG_UNBLOCK = global i32 0
@SIG_SETMASK = global i32 0
define void @__stop_signal_handler(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i32 @sigemptyset(i32* %3)
%7 = load i32, i32* @SIGALRM
%8 = call i32 @sigaddset(i32* %3, i32 %7)
%9 = load i32, i32* @SIGWINCH
%10 = call i32 @sigaddset(i32* %3, i32 %9)
%11 = load i32, i32* @SIG_BLOCK
%12 = call i32 @sigprocmask(i32 %11, i32* %3, i32* %2)
%13 = call i32 (...) @__stopwin()
%14 = call i32 @sigemptyset(i32* %3)
%15 = load i32, i32* @SIGTSTP
%16 = call i32 @sigaddset(i32* %3, i32 %15)
%17 = load i32, i32* @SIG_UNBLOCK
%18 = call i32 @sigprocmask(i32 %17, i32* %3, i32* null)
%19 = load i32, i32* @SIGTSTP
%20 = call i32 @kill(i32 0, i32 %19)
%21 = call i32 (...) @__restartwin()
%22 = load i32, i32* @SIG_SETMASK
%23 = call i32 @sigprocmask(i32 %22, i32* %2, i32* null)
ret void
}