#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 */
struct sigaction {
  int /*<<< orphan*/ sa_mask;
  scalar_t__ sa_flags;
  int /*<<< orphan*/ sa_handler;
};
typedef int /*<<< orphan*/ sigset_t;
typedef scalar_t__ pid_t;

/* Variables and functions */
int EINTR;
int EINVAL;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ _exit(int);
int errno;
int /*<<< orphan*/ execvp(char const *, char **);
scalar_t__ fork();
scalar_t__ sigaction(int /*<<< orphan*/, struct sigaction *,
                     struct sigaction *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
scalar_t__ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int mu_spawnvp(const char *prog, char *av[], int *stat) {
  pid_t pid;
  int err = 0;
  int progstat;
  struct sigaction ignore;
  struct sigaction saveintr;
  struct sigaction savequit;
  sigset_t chldmask;
  sigset_t savemask;
  if (!prog || !av)
    return EINVAL;
  ignore.sa_handler = SIG_IGN;
  ignore.sa_flags = 0;
  sigemptyset(&ignore.sa_mask);
  if (sigaction(SIGINT, &ignore, &saveintr) < 0)
    return errno;
  if (sigaction(SIGQUIT, &ignore, &savequit) < 0) {
    sigaction(SIGINT, &saveintr, NULL);
    return errno;
  }
  sigemptyset(&chldmask);
  sigaddset(&chldmask, SIGCHLD);
  if (sigprocmask(SIG_BLOCK, &chldmask, &savemask) < 0) {
    sigaction(SIGINT, &saveintr, NULL);
    sigaction(SIGQUIT, &savequit, NULL);
    return errno;
  }
  pid = fork();
  if (pid < 0) {
    err = errno;
  } else if (pid == 0) {
    sigaction(SIGINT, &saveintr, NULL);
    sigaction(SIGQUIT, &savequit, NULL);
    sigprocmask(SIG_SETMASK, &savemask, NULL);
    execvp(prog, av);
    _exit(127);
  } else {
    while (waitpid(pid, &progstat, 0) < 0)
      if (errno != EINTR) {
        err = errno;
        break;
      }
    if (err == 0 && stat)
      *stat = progstat;
  }
  if (sigaction(SIGINT, &saveintr, NULL) < 0)
    err = err ? err : errno;
  if (sigaction(SIGQUIT, &savequit, NULL) < 0)
    err = err ? err : errno;
  if (sigprocmask(SIG_SETMASK, &savemask, NULL) < 0)
    err = err ? err : errno;
  return err;
}


x86 assembly (clang, -O0):
<mu_spawnvp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b4 <mu_spawnvp+0x34>
cmpq   $0x0,-0x18(%rbp)
jne    11c5 <mu_spawnvp+0x45>
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14c7 <mu_spawnvp+0x347>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
lea    -0x48(%rbp),%rdi
call   1060 <sigemptyset@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    -0x48(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1050 <sigaction@plt>
cmp    $0x0,%rax
jge    1213 <mu_spawnvp+0x93>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14c7 <mu_spawnvp+0x347>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
lea    -0x48(%rbp),%rsi
lea    -0x78(%rbp),%rdx
call   1050 <sigaction@plt>
cmp    $0x0,%rax
jge    125a <mu_spawnvp+0xda>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14c7 <mu_spawnvp+0x347>
lea    -0x7c(%rbp),%rdi
call   1060 <sigemptyset@plt>
mov    0x2d66(%rip),%rax
mov    (%rax),%esi
lea    -0x7c(%rbp),%rdi
call   1090 <sigaddset@plt>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
lea    -0x7c(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jge    12d2 <mu_spawnvp+0x152>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
lea    -0x78(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    0x2cf0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14c7 <mu_spawnvp+0x347>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    12f9 <mu_spawnvp+0x179>
mov    0x2cc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    13d1 <mu_spawnvp+0x251>
cmpq   $0x0,-0x28(%rbp)
jne    135d <mu_spawnvp+0x1dd>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
lea    -0x78(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    0x2ca1(%rip),%rax
mov    (%rax),%edi
lea    -0x80(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <execvp@plt>
mov    $0x7f,%edi
call   1040 <_exit@plt>
jmp    1362 <mu_spawnvp+0x1e2>
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1070 <waitpid@plt>
cmp    $0x0,%rax
jge    13a9 <mu_spawnvp+0x229>
mov    0x2c36(%rip),%rax
mov    (%rax),%eax
mov    0x2c1d(%rip),%rcx
cmp    (%rcx),%eax
je     13a4 <mu_spawnvp+0x224>
mov    0x2c1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    13a9 <mu_spawnvp+0x229>
jmp    1362 <mu_spawnvp+0x1e2>
cmpl   $0x0,-0x2c(%rbp)
jne    13c7 <mu_spawnvp+0x247>
cmpq   $0x0,-0x20(%rbp)
je     13c7 <mu_spawnvp+0x247>
mov    -0x30(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    13cc <mu_spawnvp+0x24c>
jmp    13d1 <mu_spawnvp+0x251>
mov    0x2c10(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
cmp    $0x0,%rax
jge    1421 <mu_spawnvp+0x2a1>
cmpl   $0x0,-0x2c(%rbp)
je     1409 <mu_spawnvp+0x289>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    1418 <mu_spawnvp+0x298>
mov    0x2ba8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2bb8(%rip),%rax
mov    (%rax),%edi
lea    -0x78(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
cmp    $0x0,%rax
jge    1471 <mu_spawnvp+0x2f1>
cmpl   $0x0,-0x2c(%rbp)
je     1459 <mu_spawnvp+0x2d9>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x88(%rbp)
jmp    1468 <mu_spawnvp+0x2e8>
mov    0x2b58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2b60(%rip),%rax
mov    (%rax),%edi
lea    -0x80(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jge    14c1 <mu_spawnvp+0x341>
cmpl   $0x0,-0x2c(%rbp)
je     14a9 <mu_spawnvp+0x329>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x8c(%rbp)
jmp    14b8 <mu_spawnvp+0x338>
mov    0x2b08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mu_spawnvp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
test   %rdi,%rdi
je     12bf <mu_spawnvp+0x13f>
mov    %rsi,%r15
test   %rsi,%rsi
je     12bf <mu_spawnvp+0x13f>
mov    %rdx,%r14
mov    %rdi,%r13
mov    0x2e18(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x50(%rsp)
movq   $0x0,0x48(%rsp)
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sigemptyset@plt>
mov    0x2e15(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0x10(%rsp),%rdx
mov    %rbx,%rsi
call   1050 <sigaction@plt>
test   %rax,%rax
js     12f6 <mu_spawnvp+0x176>
mov    0x2ded(%rip),%r12
mov    (%r12),%edi
lea    0x40(%rsp),%rsi
lea    0x28(%rsp),%rdx
call   1050 <sigaction@plt>
test   %rax,%rax
js     12cd <mu_spawnvp+0x14d>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sigemptyset@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1090 <sigaddset@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
lea    0x4(%rsp),%rdx
mov    %rbx,%rsi
call   1030 <sigprocmask@plt>
test   %rax,%rax
js     12d7 <mu_spawnvp+0x157>
xor    %eax,%eax
call   10a0 <fork@plt>
test   %rax,%rax
js     1301 <mu_spawnvp+0x181>
je     138f <mu_spawnvp+0x20f>
mov    %rax,%r12
lea    0x8(%rsp),%r15
mov    0x2d47(%rip),%r13
mov    0x2d30(%rip),%rbp
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1070 <waitpid@plt>
test   %rax,%rax
jns    129d <mu_spawnvp+0x11d>
mov    0x0(%r13),%ebx
cmp    0x0(%rbp),%ebx
je     1280 <mu_spawnvp+0x100>
test   %r14,%r14
je     130a <mu_spawnvp+0x18a>
test   %ebx,%ebx
mov    0x2d35(%rip),%rbp
mov    0x2d36(%rip),%rcx
jne    1318 <mu_spawnvp+0x198>
mov    0x8(%rsp),%eax
mov    %eax,(%r14)
xor    %ebx,%ebx
jmp    1318 <mu_spawnvp+0x198>
mov    0x2cda(%rip),%rax
mov    (%rax),%ebx
jmp    137e <mu_spawnvp+0x1fe>
mov    0x0(%rbp),%edi
lea    0x10(%rsp),%rsi
jmp    12ef <mu_spawnvp+0x16f>
mov    0x0(%rbp),%edi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    (%r12),%edi
lea    0x28(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    0x2cbb(%rip),%rax
mov    (%rax),%ebx
jmp    137e <mu_spawnvp+0x1fe>
mov    0x2cb0(%rip),%rax
mov    (%rax),%ebx
mov    0x2ccf(%rip),%rbp
mov    0x2cd0(%rip),%rcx
mov    (%rcx),%edi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    0x2c8b(%rip),%r14
mov    %ebx,%ecx
test   %ebx,%ebx
jne    1336 <mu_spawnvp+0x1b6>
mov    (%r14),%ecx
test   %rax,%rax
cmovs  %ecx,%ebx
mov    0x0(%rbp),%edi
lea    0x28(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    %ebx,%ecx
test   %ebx,%ebx
jne    1354 <mu_spawnvp+0x1d4>
mov    (%r14),%ecx
test   %rax,%rax
cmovs  %ecx,%ebx
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
lea    0x4(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    %ebx,%ecx
test   %ebx,%ebx
jne    1378 <mu_spawnvp+0x1f8>
mov    (%r14),%ecx
test   %rax,%rax
cmovs  %ecx,%ebx
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    0x2c35(%rip),%rax
mov    (%rax),%edi
lea    0x28(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    0x2c18(%rip),%rax
mov    (%rax),%edi
lea    0x4(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1080 <execvp@plt>
mov    $0x7f,%edi
call   1040 <_exit@plt>

LLVM IR (-O0):
%struct.sigaction = type { i32, i64, i32 }
@EINVAL = global i32 0
@SIG_IGN = global i32 0
@SIGINT = global i32 0
@errno = global i32 0
@SIGQUIT = global i32 0
@SIGCHLD = global i32 0
@SIG_BLOCK = global i32 0
@SIG_SETMASK = global i32 0
@EINTR = global i32 0
define i32 @mu_spawnvp(i8* %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.sigaction
%12 = alloca %struct.sigaction
%13 = alloca %struct.sigaction
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
store i32 0, i32* %9
%16 = load i8*, i8** %5
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = load i8**, i8*** %6
%20 = icmp ne i8** %19, null
br i1 %20, label %23, label %21
21: ; preds = %18, %3
%22 = load i32, i32* @EINVAL
store i32 %22, i32* %4
br label %139
23: ; preds = %18
%24 = load i32, i32* @SIG_IGN
%25 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %11, i32 0, i32 2
store i32 %24, i32* %25
%26 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %11, i32 0, i32 1
store i64 0, i64* %26
%27 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %11, i32 0, i32 0
%28 = call i32 @sigemptyset(i32* %27)
%29 = load i32, i32* @SIGINT
%30 = call i64 @sigaction(i32 %29, %struct.sigaction* %11, %struct.sigaction* %12)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %23
%33 = load i32, i32* @errno
store i32 %33, i32* %4
br label %139
34: ; preds = %23
%35 = load i32, i32* @SIGQUIT
%36 = call i64 @sigaction(i32 %35, %struct.sigaction* %11, %struct.sigaction* %13)
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i32, i32* @SIGINT
%40 = call i64 @sigaction(i32 %39, %struct.sigaction* %12, %struct.sigaction* null)
%41 = load i32, i32* @errno
store i32 %41, i32* %4
br label %139
42: ; preds = %34
%43 = call i32 @sigemptyset(i32* %14)
%44 = load i32, i32* @SIGCHLD
%45 = call i32 @sigaddset(i32* %14, i32 %44)
%46 = load i32, i32* @SIG_BLOCK
%47 = call i64 @sigprocmask(i32 %46, i32* %14, i32* %15)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %55
49: ; preds = %42
%50 = load i32, i32* @SIGINT
%51 = call i64 @sigaction(i32 %50, %struct.sigaction* %12, %struct.sigaction* null)
%52 = load i32, i32* @SIGQUIT
%53 = call i64 @sigaction(i32 %52, %struct.sigaction* %13, %struct.sigaction* null)
%54 = load i32, i32* @errno
store i32 %54, i32* %4
br label %139
55: ; preds = %42
%56 = call i64 (...) @fork()
store i64 %56, i64* %8
%57 = load i64, i64* %8
%58 = icmp slt i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = load i32, i32* @errno
store i32 %60, i32* %9
br label %98
61: ; preds = %55
%62 = load i64, i64* %8
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %75
64: ; preds = %61
%65 = load i32, i32* @SIGINT
%66 = call i64 @sigaction(i32 %65, %struct.sigaction* %12, %struct.sigaction* null)
%67 = load i32, i32* @SIGQUIT
%68 = call i64 @sigaction(i32 %67, %struct.sigaction* %13, %struct.sigaction* null)
%69 = load i32, i32* @SIG_SETMASK
%70 = call i64 @sigprocmask(i32 %69, i32* %15, i32* null)
%71 = load i8*, i8** %5
%72 = load i8**, i8*** %6
%73 = call i32 @execvp(i8* %71, i8** %72)
%74 = call i32 @_exit(i32 127)
unreachable
75: ; preds = %61
br label %76
76: ; preds = %86, %75
%77 = load i64, i64* %8
%78 = call i64 @waitpid(i64 %77, i32* %10, i32 0)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %87
80: ; preds = %76
%81 = load i32, i32* @errno
%82 = load i32, i32* @EINTR
%83 = icmp ne i32 %81, %82
br i1 %83, label %84, label %86
84: ; preds = %80
%85 = load i32, i32* @errno
store i32 %85, i32* %9
br label %87
86: ; preds = %80
br label %76
87: ; preds = %84, %76
%88 = load i32, i32* %9
%89 = icmp eq i32 %88, 0
br i1 %89, label %90, label %96
90: ; preds = %87
%91 = load i32*, i32** %7
%92 = icmp ne i32* %91, null
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = load i32, i32* %10
%95 = load i32*, i32** %7
store i32 %94, i32* %95
br label %96
96: ; preds = %93, %90, %87
br label %97
97: ; preds = %96
br label %98
98: ; preds = %97, %59
%99 = load i32, i32* @SIGINT
%100 = call i64 @sigaction(i32 %99, %struct.sigaction* %12, %struct.sigaction* null)
%101 = icmp slt i64 %100, 0
br i1 %101, label %102, label %111
102: ; preds = %98
%103 = load i32, i32* %9
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %107
105: ; preds = %102
%106 = load i32, i32* %9
br label %109
107: ; preds = %102
%108 = load i32, i32* @errno
br label %109
109: ; preds = %107, %105
%110 = phi i32 [ %106, %105 ], [ %108, %107 ]
store i32 %110, i32* %9
br label %111
111: ; preds = %109, %98
%112 = load i32, i32* @SIGQUIT
%113 = call i64 @sigaction(i32 %112, %struct.sigaction* %13, %struct.sigaction* null)
%114 = icmp slt i64 %113, 0
br i1 %114, label %115, label %124
115: ; preds = %111
%116 = load i32, i32* %9
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %120
118: ; preds = %115
%119 = load i32, i32* %9
br label %122
120: ; preds = %115
%121 = load i32, i32* @errno
br label %122
122: ; preds = %120, %118
%123 = phi i32 [ %119, %118 ], [ %121, %120 ]
store i32 %123, i32* %9
br label %124
124: ; preds = %122, %111
%125 = load i32, i32* @SIG_SETMASK
%126 = call i64 @sigprocmask(i32 %125, i32* %15, i32* null)
%127 = icmp slt i64 %126, 0
br i1 %127, label %128, label %137
128: ; preds = %124
%129 = load i32, i32* %9
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %133
131: ; preds = %128
%132 = load i32, i32* %9
br label %135
133: ; preds = %128
%134 = load i32, i32* @errno
br label %135
135: ; preds = %133, %131
%136 = phi i32 [ %132, %131 ], [ %134, %133 ]
store i32 %136, i32* %9
br label %137
137: ; preds = %135, %124
%138 = load i32, i32* %9
store i32 %138, i32* %4
br label %139
139: ; preds = %137, %49, %38, %32, %21
%140 = load i32, i32* %4
ret i32 %140
}

LLVM IR (-O2):
%struct.sigaction = type { i32, i64, i32 }
@EINVAL = global i32 0
@SIG_IGN = global i32 0
@SIGINT = global i32 0
@errno = global i32 0
@SIGQUIT = global i32 0
@SIGCHLD = global i32 0
@SIG_BLOCK = global i32 0
@SIG_SETMASK = global i32 0
@EINTR = global i32 0
define i32 @mu_spawnvp(i8* %0, i8** %1, i32* writeonly %2) {
%4 = alloca i32
%5 = alloca %struct.sigaction
%6 = alloca %struct.sigaction
%7 = alloca %struct.sigaction
%8 = alloca i32
%9 = alloca i32
%10 = bitcast i32* %4 to i8*
%11 = bitcast %struct.sigaction* %5 to i8*
%12 = bitcast %struct.sigaction* %6 to i8*
%13 = bitcast %struct.sigaction* %7 to i8*
%14 = bitcast i32* %8 to i8*
%15 = bitcast i32* %9 to i8*
%16 = icmp ne i8* %0, null
%17 = icmp ne i8** %1, null
%18 = and i1 %16, %17
br i1 %18, label %21, label %19
19: ; preds = %3
%20 = load i32, i32* @EINVAL
br label %106
21: ; preds = %3
%22 = load i32, i32* @SIG_IGN
%23 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i64 0, i32 2
store i32 %22, i32* %23
%24 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i64 0, i32 1
store i64 0, i64* %24
%25 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i64 0, i32 0
%26 = call i32 @sigemptyset(i32* %25)
%27 = load i32, i32* @SIGINT
%28 = call i64 @sigaction(i32 %27, %struct.sigaction* %5, %struct.sigaction* %6)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %21
%31 = load i32, i32* @errno
br label %106
32: ; preds = %21
%33 = load i32, i32* @SIGQUIT
%34 = call i64 @sigaction(i32 %33, %struct.sigaction* %5, %struct.sigaction* %7)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i32, i32* @SIGINT
%38 = call i64 @sigaction(i32 %37, %struct.sigaction* %6, %struct.sigaction* null)
%39 = load i32, i32* @errno
br label %106
40: ; preds = %32
%41 = call i32 @sigemptyset(i32* %8)
%42 = load i32, i32* @SIGCHLD
%43 = call i32 @sigaddset(i32* %8, i32 %42)
%44 = load i32, i32* @SIG_BLOCK
%45 = call i64 @sigprocmask(i32 %44, i32* %8, i32* %9)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %40
%48 = load i32, i32* @SIGINT
%49 = call i64 @sigaction(i32 %48, %struct.sigaction* %6, %struct.sigaction* null)
%50 = load i32, i32* @SIGQUIT
%51 = call i64 @sigaction(i32 %50, %struct.sigaction* %7, %struct.sigaction* null)
%52 = load i32, i32* @errno
br label %106
53: ; preds = %40
%54 = call i64 (...) @fork()
%55 = icmp slt i64 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = load i32, i32* @errno
br label %83
58: ; preds = %53
%59 = icmp eq i64 %54, 0
br i1 %59, label %60, label %69
60: ; preds = %58
%61 = load i32, i32* @SIGINT
%62 = call i64 @sigaction(i32 %61, %struct.sigaction* %6, %struct.sigaction* null)
%63 = load i32, i32* @SIGQUIT
%64 = call i64 @sigaction(i32 %63, %struct.sigaction* %7, %struct.sigaction* null)
%65 = load i32, i32* @SIG_SETMASK
%66 = call i64 @sigprocmask(i32 %65, i32* %9, i32* null)
%67 = call i32 @execvp(i8* %0, i8** %1)
%68 = call i32 @_exit(i32 127)
unreachable
69: ; preds = %58, %72
%70 = call i64 @waitpid(i64 %54, i32* %4, i32 0)
%71 = icmp slt i64 %70, 0
br i1 %71, label %72, label %76
72: ; preds = %69
%73 = load i32, i32* @errno
%74 = load i32, i32* @EINTR
%75 = icmp eq i32 %73, %74
br i1 %75, label %69, label %76
76: ; preds = %72, %69
%77 = phi i32 [ 0, %69 ], [ %73, %72 ]
%78 = icmp eq i32 %77, 0
%79 = icmp ne i32* %2, null
%80 = and i1 %79, %78
br i1 %80, label %81, label %83
81: ; preds = %76
%82 = load i32, i32* %4
store i32 %82, i32* %2
br label %83
83: ; preds = %81, %76, %56
%84 = phi i32 [ %57, %56 ], [ 0, %81 ], [ %77, %76 ]
%85 = load i32, i32* @SIGINT
%86 = call i64 @sigaction(i32 %85, %struct.sigaction* %6, %struct.sigaction* null)
%87 = icmp slt i64 %86, 0
%88 = icmp eq i32 %84, 0
%89 = load i32, i32* @errno
%90 = select i1 %87, i1 %88, i1 false
%91 = select i1 %90, i32 %89, i32 %84
%92 = load i32, i32* @SIGQUIT
%93 = call i64 @sigaction(i32 %92, %struct.sigaction* %7, %struct.sigaction* null)
%94 = icmp slt i64 %93, 0
%95 = icmp eq i32 %91, 0
%96 = load i32, i32* @errno
%97 = select i1 %94, i1 %95, i1 false
%98 = select i1 %97, i32 %96, i32 %91
%99 = load i32, i32* @SIG_SETMASK
%100 = call i64 @sigprocmask(i32 %99, i32* %9, i32* null)
%101 = icmp slt i64 %100, 0
%102 = icmp eq i32 %98, 0
%103 = load i32, i32* @errno
%104 = select i1 %101, i1 %102, i1 false
%105 = select i1 %104, i32 %103, i32 %98
br label %106
106: ; preds = %83, %47, %36, %30, %19
%107 = phi i32 [ %31, %30 ], [ %39, %36 ], [ %52, %47 ], [ %105, %83 ], [ %20, %19 ]
ret i32 %107
}