#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 */
scalar_t__ READ();
int /*<<< orphan*/ SIGTRAP;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ WRITE(int /*<<< orphan*/);
int /*<<< orphan*/ e(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
void test_step_child() {
  sigset_t set;
  signal(SIGUSR1, SIG_IGN);
  WRITE(0);
  if (READ() != 0)
    e(100);
  signal(SIGTRAP, SIG_IGN);
  sigfillset(&set);
  sigprocmask(SIG_SETMASK, &set, NULL);
  exit(42);
}


x86 assembly (clang, -O0):
<test_step_child>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    0x2e50(%rip),%rax
mov    (%rax),%esi
call   1050 <signal@plt>
xor    %edi,%edi
call   1090 <WRITE@plt>
mov    $0x0,%al
call   1040 <READ@plt>
cmp    $0x0,%rax
je     11b1 <test_step_child+0x41>
mov    $0x64,%edi
call   1070 <e@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
call   1050 <signal@plt>
lea    -0x4(%rbp),%rdi
call   1060 <sigfillset@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    $0x2a,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<test_step_child>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    0x2e53(%rip),%rbx
mov    (%rbx),%esi
call   1050 <signal@plt>
xor    %edi,%edi
call   1090 <WRITE@plt>
xor    %eax,%eax
call   1040 <READ@plt>
test   %rax,%rax
je     11a9 <test_step_child+0x39>
mov    $0x64,%edi
call   1070 <e@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1050 <signal@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sigfillset@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    $0x2a,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@SIGUSR1 = global i32 0
@SIG_IGN = global i32 0
@SIGTRAP = global i32 0
@SIG_SETMASK = global i32 0
define void @test_step_child() {
%1 = alloca i32
%2 = load i32, i32* @SIGUSR1
%3 = load i32, i32* @SIG_IGN
%4 = call i32 @signal(i32 %2, i32 %3)
%5 = call i32 @WRITE(i32 0)
%6 = call i64 (...) @READ()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @e(i32 100)
br label %10
10: ; preds = %8, %0
%11 = load i32, i32* @SIGTRAP
%12 = load i32, i32* @SIG_IGN
%13 = call i32 @signal(i32 %11, i32 %12)
%14 = call i32 @sigfillset(i32* %1)
%15 = load i32, i32* @SIG_SETMASK
%16 = call i32 @sigprocmask(i32 %15, i32* %1, i32* null)
%17 = call i32 @exit(i32 42)
unreachable
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@SIG_IGN = global i32 0
@SIGTRAP = global i32 0
@SIG_SETMASK = global i32 0
define void @test_step_child() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @SIGUSR1
%4 = load i32, i32* @SIG_IGN
%5 = tail call i32 @signal(i32 %3, i32 %4)
%6 = tail call i32 @WRITE(i32 0)
%7 = tail call i64 (...) @READ()
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = tail call i32 @e(i32 100)
br label %11
11: ; preds = %9, %0
%12 = load i32, i32* @SIGTRAP
%13 = load i32, i32* @SIG_IGN
%14 = tail call i32 @signal(i32 %12, i32 %13)
%15 = call i32 @sigfillset(i32* %1)
%16 = load i32, i32* @SIG_SETMASK
%17 = call i32 @sigprocmask(i32 %16, i32* %1, i32* null)
%18 = call i32 @exit(i32 42)
unreachable
}