#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 ENOSYS;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ __environ;
int errno;
int /*<<< orphan*/ execve(char *, char *const *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int sigaction(int /*<<< orphan*/, struct sigaction *, struct sigaction *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ vfork();
int waitpid(scalar_t__, int *, int /*<<< orphan*/);
int gtm_system(const char *line) {
  int status, save;
  pid_t pid;
  struct sigaction sa, intr, quit;
  sigset_t block, omask;
  if (line == NULL)
    return gtm_system("exit 0") == 0;
  sa.sa_handler = SIG_IGN;
  sa.sa_flags = 0;
  sigemptyset(&sa.sa_mask);
  if (sigaction(SIGINT, &sa, &intr) < 0)
    return -1;
  if (sigaction(SIGQUIT, &sa, &quit) < 0) {
    save = errno;
    (void)sigaction(SIGINT, &intr, (struct sigaction *)NULL);
    errno = save;
    return -1;
  }
  sigemptyset(&block);
  sigaddset(&block, SIGCHLD);
  save = errno;
  if (sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
    if (errno == ENOSYS)
      errno = save;
    else {
      save = errno;
      (void)sigaction(SIGINT, &intr, (struct sigaction *)NULL);
      (void)sigaction(SIGQUIT, &quit, (struct sigaction *)NULL);
      errno = save;
      return -1;
    }
  }
  pid = vfork();
  if (pid == (pid_t)0) {
    const char *new_argv[4];
    new_argv[0] = "sh";
    new_argv[1] = "-c";
    new_argv[2] = line;
    new_argv[3] = NULL;
    (void)sigaction(SIGINT, &intr, (struct sigaction *)NULL);
    (void)sigaction(SIGQUIT, &quit, (struct sigaction *)NULL);
    (void)sigprocmask(SIG_SETMASK, &omask, (sigset_t *)NULL);
    (void)execve("/bin/sh", (char *const *)new_argv, __environ);
    exit(127);
  } else if (pid < (pid_t)0)
    status = -1;
  else {
    int n;
    do
      n = waitpid(pid, &status, 0);
    while (n == -1 && errno == EINTR);
    if (n != pid)
      status = -1;
  }
  save = errno;
  if ((sigaction(SIGINT, &intr, (struct sigaction *)NULL) |
       sigaction(SIGQUIT, &quit, (struct sigaction *)NULL) |
       sigprocmask(SIG_SETMASK, &omask, (sigset_t *)NULL)) != 0) {
    if (errno == ENOSYS)
      errno = save;
    else
      return -1;
  }
  return status;
}


x86 assembly (clang, -O0):
<gtm_system>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c9 <gtm_system+0x39>
lea    0xe4f(%rip),%rdi
call   1040 <gtm_system@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1520 <gtm_system+0x390>
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
lea    -0x38(%rbp),%rdi
call   1070 <sigemptyset@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1050 <sigaction@plt>
cmp    $0x0,%eax
jge    1211 <gtm_system+0x81>
movl   $0xffffffff,-0x4(%rbp)
jmp    1520 <gtm_system+0x390>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rsi
lea    -0x68(%rbp),%rdx
call   1050 <sigaction@plt>
cmp    $0x0,%eax
jge    126a <gtm_system+0xda>
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    -0x18(%rbp),%ecx
mov    0x2d4c(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1520 <gtm_system+0x390>
lea    -0x6c(%rbp),%rdi
call   1070 <sigemptyset@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%esi
lea    -0x6c(%rbp),%rdi
call   10b0 <sigaddset@plt>
mov    0x2d1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
lea    -0x6c(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0x0,%eax
jge    132e <gtm_system+0x19e>
mov    0x2cf1(%rip),%rax
mov    (%rax),%eax
mov    0x2d18(%rip),%rcx
cmp    (%rcx),%eax
jne    12d9 <gtm_system+0x149>
mov    -0x18(%rbp),%ecx
mov    0x2cd6(%rip),%rax
mov    %ecx,(%rax)
jmp    1329 <gtm_system+0x199>
mov    0x2cc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
lea    -0x68(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    -0x18(%rbp),%ecx
mov    0x2c8d(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1520 <gtm_system+0x390>
jmp    132e <gtm_system+0x19e>
mov    $0x0,%al
call   1090 <vfork@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    13d8 <gtm_system+0x248>
lea    0xcc4(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    0xcae(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
movq   $0x0,-0x78(%rbp)
mov    0x2c69(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    0x2c43(%rip),%rax
mov    (%rax),%edi
lea    -0x68(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
lea    -0x90(%rbp),%rsi
mov    0x2c38(%rip),%rax
mov    (%rax),%edx
lea    0xc41(%rip),%rdi
call   1060 <execve@plt>
mov    $0x7f,%edi
call   10a0 <exit@plt>
cmpq   $0x0,-0x20(%rbp)
jge    13ef <gtm_system+0x25f>
movl   $0xffffffff,-0x14(%rbp)
jmp    1464 <gtm_system+0x2d4>
jmp    13f4 <gtm_system+0x264>
mov    -0x20(%rbp),%rdi
lea    -0x14(%rbp),%rsi
xor    %edx,%edx
call   1080 <waitpid@plt>
mov    %eax,-0x94(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x94(%rbp)
mov    %al,-0x95(%rbp)
jne    1439 <gtm_system+0x2a9>
mov    0x2b83(%rip),%rax
mov    (%rax),%eax
mov    0x2b6a(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
mov    %al,-0x95(%rbp)
mov    -0x95(%rbp),%al
test   $0x1,%al
jne    13f4 <gtm_system+0x264>
movslq -0x94(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     145f <gtm_system+0x2cf>
movl   $0xffffffff,-0x14(%rbp)
jmp    1464 <gtm_system+0x2d4>
jmp    1469 <gtm_system+0x2d9>
mov    0x2b38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2b64(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    %eax,-0xa0(%rbp)
mov    0x2b38(%rip),%rax
mov    (%rax),%edi
lea    -0x68(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    %eax,%ecx
mov    -0xa0(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x9c(%rbp)
mov    0x2b0a(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    %eax,%ecx
mov    -0x9c(%rbp),%eax
or     %ecx,%eax
cmp    $0x0,%eax
je     151a <gtm_system+0x38a>
mov    0x2ac1(%rip),%rax
mov    (%rax),%eax
mov    0x2ae8(%rip),%rcx
cmp    (%rcx),%eax
jne    1509 <gtm_system+0x379>
mov    -0x18(%rbp),%ecx
mov    0x2aa6(%rip),%rax
mov    %ecx,(%rax)
jmp    1515 <gtm_system+0x385>
movl   $0xffffffff,-0x4(%rbp)
jmp    1520 <gtm_system+0x390>
jmp    151a <gtm_system+0x38a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gtm_system>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
test   %rdi,%rdi
je     12d4 <gtm_system+0x144>
mov    %rdi,%rbx
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x80(%rsp)
movq   $0x0,0x78(%rsp)
lea    0x70(%rsp),%rbp
mov    %rbp,%rdi
call   1070 <sigemptyset@plt>
mov    0x2e06(%rip),%r15
mov    (%r15),%edi
lea    0x40(%rsp),%rdx
mov    %rbp,%rsi
call   1050 <sigaction@plt>
mov    $0xffffffff,%r14d
test   %eax,%eax
js     13a0 <gtm_system+0x210>
mov    0x2dd1(%rip),%r13
mov    0x0(%r13),%edi
lea    0x70(%rsp),%rsi
lea    0x58(%rsp),%rdx
call   1050 <sigaction@plt>
test   %eax,%eax
js     12ee <gtm_system+0x15e>
lea    0x3c(%rsp),%rbp
mov    %rbp,%rdi
call   1070 <sigemptyset@plt>
mov    0x2d92(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10b0 <sigaddset@plt>
mov    0x2d69(%rip),%r12
mov    (%r12),%r15d
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rdx
mov    %rbp,%rsi
call   1030 <sigprocmask@plt>
test   %eax,%eax
jns    1274 <gtm_system+0xe4>
mov    (%r12),%ebp
mov    0x2d70(%rip),%rax
cmp    (%rax),%ebp
jne    1377 <gtm_system+0x1e7>
mov    %r15d,(%r12)
xor    %eax,%eax
call   1090 <vfork@plt>
test   %rax,%rax
je     13b5 <gtm_system+0x225>
js     130d <gtm_system+0x17d>
mov    %rax,%rbp
lea    0x10(%rsp),%rbx
mov    0x2cff(%rip),%r13
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1080 <waitpid@plt>
mov    (%r12),%r15d
cmp    $0xffffffff,%eax
jne    12bc <gtm_system+0x12c>
cmp    0x0(%r13),%r15d
je     12a0 <gtm_system+0x110>
cltq
cmp    %rax,%rbp
mov    0x2d08(%rip),%r13
je     1319 <gtm_system+0x189>
movl   $0xffffffff,0x10(%rsp)
ff
jmp    1319 <gtm_system+0x189>
lea    0xd25(%rip),%rdi
call   1040 <gtm_system@plt>
xor    %r14d,%r14d
test   %eax,%eax
sete   %r14b
jmp    13a0 <gtm_system+0x210>
mov    0x2cb3(%rip),%rbx
mov    (%rbx),%ebp
mov    (%r15),%edi
lea    0x40(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    %ebp,(%rbx)
jmp    13a0 <gtm_system+0x210>
movl   $0xffffffff,0x10(%rsp)
ff
mov    (%r12),%r15d
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
lea    0x40(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    %eax,%ebx
mov    0x0(%r13),%edi
lea    0x58(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    %eax,%ebp
or     %ebx,%ebp
mov    0x2c7d(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
or     %ebp,%eax
je     1370 <gtm_system+0x1e0>
mov    (%r12),%eax
mov    0x2c70(%rip),%rcx
cmp    (%rcx),%eax
jne    13a0 <gtm_system+0x210>
mov    %r15d,(%r12)
mov    0x10(%rsp),%r14d
jmp    13a0 <gtm_system+0x210>
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
lea    0x40(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    0x0(%r13),%edi
lea    0x58(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    %ebp,(%r12)
mov    %r14d,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc53(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xc3f(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %rbx,0x20(%rsp)
movq   $0x0,0x28(%rsp)
mov    0x2bfe(%rip),%rax
mov    (%rax),%edi
lea    0x40(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    0x0(%r13),%edi
lea    0x58(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    0x2bc1(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    0x2bdc(%rip),%rax
mov    (%rax),%edx
lea    0xbe5(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1060 <execve@plt>
mov    $0x7f,%edi
call   10a0 <exit@plt>

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

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