#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;
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ execlp(char *, int /*<<< orphan*/ *);
scalar_t__ fork();
int /*<<< orphan*/ kill(scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  pid_t pid;
  sigset_t set;
  sigemptyset(&set);
  sigaddset(&set, SIGUSR1);
  sigprocmask(SIG_BLOCK, &set, NULL);
  pid = fork();
  if (pid == 0) {
    execlp(argv[1], NULL);
  }
  while (1) {
    kill(pid, SIGUSR1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1c(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
lea    -0x1c(%rbp),%rdi
call   1070 <sigaddset@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    -0x1c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ce <main+0x6e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <execlp@plt>
jmp    11d3 <main+0x73>
mov    -0x18(%rbp),%rdi
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
call   1050 <kill@plt>
jmp    11d3 <main+0x73>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e68(%rip),%r15
mov    (%r15),%esi
mov    %rbx,%rdi
call   1070 <sigaddset@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
xor    %eax,%eax
call   1080 <fork@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11c0 <main+0x60>
mov    0x8(%r14),%rdi
xor    %esi,%esi
call   1060 <execlp@plt>
nopl   0x0(%rax,%rax,1)
mov    (%r15),%esi
mov    %rbx,%rdi
call   1050 <kill@plt>
jmp    11c0 <main+0x60>

LLVM IR (-O0):
@SIGUSR1 = global i32 0
@SIG_BLOCK = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @sigemptyset(i32* %7)
%9 = load i32, i32* @SIGUSR1
%10 = call i32 @sigaddset(i32* %7, i32 %9)
%11 = load i32, i32* @SIG_BLOCK
%12 = call i32 @sigprocmask(i32 %11, i32* %7, i32* null)
%13 = call i64 (...) @fork()
store i64 %13, i64* %6
%14 = load i64, i64* %6
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @execlp(i8* %19, i32* null)
br label %21
21: ; preds = %16, %2
br label %22
22: ; preds = %21, %22
%23 = load i64, i64* %6
%24 = load i32, i32* @SIGUSR1
%25 = call i32 @kill(i64 %23, i32 %24)
br label %22
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@SIG_BLOCK = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @sigemptyset(i32* %3)
%6 = load i32, i32* @SIGUSR1
%7 = call i32 @sigaddset(i32* %3, i32 %6)
%8 = load i32, i32* @SIG_BLOCK
%9 = call i32 @sigprocmask(i32 %8, i32* %3, i32* null)
%10 = call i64 (...) @fork()
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @execlp(i8* %14, i32* null)
br label %16
16: ; preds = %12, %2
br label %17
17: ; preds = %16, %17
%18 = load i32, i32* @SIGUSR1
%19 = call i32 @kill(i64 %10, i32 %18)
br label %17
}