#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*/ priority;
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ ebuf;

/* Variables and functions */
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIG_IGN;
scalar_t__ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ log_err(int /*<<< orphan*/, char *);
int /*<<< orphan*/ log_msg(char, char *, char *);
int /*<<< orphan*/ log_set_err_pipe(int);
int /*<<< orphan*/ log_set_file(int /*<<< orphan*/, char, int /*<<< orphan*/);
scalar_t__ pipe(int *);
int /*<<< orphan*/ posix_signal(int /*<<< orphan*/, int /*<<< orphan*/);
int read(int, char *, int);
scalar_t__ setsid();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ umask(int /*<<< orphan*/);
void begin_daemonize(int *fd_ptr, pid_t *pgid_ptr) {
  int fds[2];
  pid_t pid;
  int n;
  signed char priority;
  char ebuf[1024];
  pid_t pgid;
  umask(0);
  if (pipe(fds) < 0) {
    log_err(errno, "Unable to create daemon pipe");
  }
  log_set_err_pipe(fds[1]);
  if ((pid = fork()) < 0) {
    log_err(errno, "Unable to create child process");
  } else if (pid > 0) {
    log_set_err_pipe(-1);
    if (close(fds[1]) < 0) {
      log_err(errno, "Unable to close write-pipe in parent process");
    }
    if ((n = read(fds[0], &priority, sizeof(priority))) < 0) {
      log_err(errno, "Unable to read status from grandchild process");
    }
    if ((n > 0) && (priority >= 0)) {
      if ((n = read(fds[0], ebuf, sizeof(ebuf))) < 0) {
        log_err(errno, "Unable to read error message from grandchild process");
      }
      if ((n > 0) && (ebuf[0] != '\0')) {
        log_set_file(stderr, priority, 0);
        log_msg(priority, "%s", ebuf);
      }
      exit(1);
    }
    exit(0);
  }
  if (close(fds[0]) < 0) {
    log_err(errno, "Unable to close read-pipe in child process");
  }
  if ((pgid = setsid()) < 0) {
    log_err(errno, "Unable to disassociate controlling tty");
  }
  posix_signal(SIGHUP, SIG_IGN);
  if ((pid = fork()) < 0) {
    log_err(errno, "Unable to create grandchild process");
  } else if (pid > 0) {
    exit(0);
  }
  if (fd_ptr) {
    *fd_ptr = fds[1];
  }
  if (pgid_ptr) {
    *pgid_ptr = pgid;
  }
  return;
}


x86 assembly (clang, -O0):
<begin_daemonize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %edi,%edi
call   1090 <umask@plt>
lea    -0x18(%rbp),%rdi
call   1060 <pipe@plt>
cmp    $0x0,%rax
jge    1202 <begin_daemonize+0x42>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
call   10d0 <log_err@plt>
mov    -0x14(%rbp),%edi
call   10b0 <log_set_err_pipe@plt>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    1239 <begin_daemonize+0x79>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
call   10d0 <log_err@plt>
jmp    1350 <begin_daemonize+0x190>
cmpq   $0x0,-0x20(%rbp)
jle    134b <begin_daemonize+0x18b>
mov    $0xffffffff,%edi
call   10b0 <log_set_err_pipe@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
cmp    $0x0,%rax
jge    1275 <begin_daemonize+0xb5>
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
lea    0xdcc(%rip),%rsi
call   10d0 <log_err@plt>
mov    -0x18(%rbp),%edi
lea    -0x25(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12a7 <begin_daemonize+0xe7>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
lea    0xdc7(%rip),%rsi
call   10d0 <log_err@plt>
cmpl   $0x0,-0x24(%rbp)
jle    1344 <begin_daemonize+0x184>
movsbl -0x25(%rbp),%eax
cmp    $0x0,%eax
jl     1344 <begin_daemonize+0x184>
mov    -0x18(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12f3 <begin_daemonize+0x133>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
lea    0xda9(%rip),%rsi
call   10d0 <log_err@plt>
cmpl   $0x0,-0x24(%rbp)
jle    133a <begin_daemonize+0x17a>
movsbl -0x430(%rbp),%eax
cmp    $0x0,%eax
je     133a <begin_daemonize+0x17a>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
xor    %edx,%edx
movsbl -0x25(%rbp),%esi
call   1040 <log_set_file@plt>
mov    -0x25(%rbp),%al
lea    -0x430(%rbp),%rdx
lea    0xd9a(%rip),%rsi
movsbl %al,%edi
call   10a0 <log_msg@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
jmp    1350 <begin_daemonize+0x190>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
cmp    $0x0,%rax
jge    1377 <begin_daemonize+0x1b7>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
lea    0xd5d(%rip),%rsi
call   10d0 <log_err@plt>
mov    $0x0,%al
call   1070 <setsid@plt>
mov    %rax,-0x438(%rbp)
cmp    $0x0,%rax
jge    13a4 <begin_daemonize+0x1e4>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
lea    0xd5b(%rip),%rsi
call   10d0 <log_err@plt>
mov    0x2c45(%rip),%rax
mov    (%rax),%edi
mov    0x2c2c(%rip),%rax
mov    (%rax),%esi
call   1030 <posix_signal@plt>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    13ea <begin_daemonize+0x22a>
mov    0x2bf1(%rip),%rax
mov    (%rax),%edi
lea    0xd41(%rip),%rsi
call   10d0 <log_err@plt>
jmp    1401 <begin_daemonize+0x241>
cmpq   $0x0,-0x20(%rbp)
jle    13fc <begin_daemonize+0x23c>
xor    %edi,%edi
call   10c0 <exit@plt>
jmp    1401 <begin_daemonize+0x241>
cmpq   $0x0,-0x8(%rbp)
je     1415 <begin_daemonize+0x255>
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     142e <begin_daemonize+0x26e>
mov    -0x438(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<begin_daemonize>:
push   %r15
push   %r14
push   %rbx
sub    $0x410,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
call   1090 <umask@plt>
lea    0x8(%rsp),%rdi
call   1060 <pipe@plt>
test   %rax,%rax
jns    11fd <begin_daemonize+0x3d>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
call   10d0 <log_err@plt>
mov    0xc(%rsp),%edi
call   10b0 <log_set_err_pipe@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %rax,%rax
js     1276 <begin_daemonize+0xb6>
je     128b <begin_daemonize+0xcb>
mov    $0xffffffff,%edi
call   10b0 <log_set_err_pipe@plt>
mov    0xc(%rsp),%edi
call   1050 <close@plt>
test   %rax,%rax
jns    1241 <begin_daemonize+0x81>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
call   10d0 <log_err@plt>
mov    0x8(%rsp),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
test   %eax,%eax
jns    1334 <begin_daemonize+0x174>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
lea    0xdfd(%rip),%rsi
call   10d0 <log_err@plt>
jmp    1374 <begin_daemonize+0x1b4>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
call   10d0 <log_err@plt>
mov    0x8(%rsp),%edi
call   1050 <close@plt>
test   %rax,%rax
jns    12ae <begin_daemonize+0xee>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
call   10d0 <log_err@plt>
xor    %eax,%eax
call   1070 <setsid@plt>
mov    %rax,%rbx
test   %rax,%rax
jns    12d2 <begin_daemonize+0x112>
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
call   10d0 <log_err@plt>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
mov    0x2cfe(%rip),%rax
mov    (%rax),%esi
call   1030 <posix_signal@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %rax,%rax
js     1318 <begin_daemonize+0x158>
jne    1374 <begin_daemonize+0x1b4>
test   %r15,%r15
je     1303 <begin_daemonize+0x143>
mov    0xc(%rsp),%eax
mov    %eax,(%r15)
test   %r14,%r14
je     130b <begin_daemonize+0x14b>
mov    %rbx,(%r14)
add    $0x410,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2ca9(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
call   10d0 <log_err@plt>
test   %r15,%r15
jne    12fc <begin_daemonize+0x13c>
jmp    1303 <begin_daemonize+0x143>
je     1374 <begin_daemonize+0x1b4>
mov    0x7(%rsp),%bl
test   %bl,%bl
js     1374 <begin_daemonize+0x1b4>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
test   %eax,%eax
jns    137b <begin_daemonize+0x1bb>
mov    0x2c6c(%rip),%rax
mov    (%rax),%edi
lea    0xd32(%rip),%rsi
call   10d0 <log_err@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
je     13ac <begin_daemonize+0x1ec>
cmpb   $0x0,0x10(%rsp)
je     13ac <begin_daemonize+0x1ec>
mov    0x2c45(%rip),%rax
mov    (%rax),%edi
movsbl %bl,%ebx
mov    %ebx,%esi
xor    %edx,%edx
call   1040 <log_set_file@plt>
lea    0xd2c(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   10a0 <log_msg@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@errno = global i32 0
@.str = [29 x i8] c"Unable to create daemon pipe\00"
@.str.1 = [31 x i8] c"Unable to create child process\00"
@.str.2 = [45 x i8] c"Unable to close write-pipe in parent process\00"
@.str.3 = [46 x i8] c"Unable to read status from grandchild process\00"
@.str.4 = [53 x i8] c"Unable to read error message from grandchild process\00"
@stderr = global i32 0
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [43 x i8] c"Unable to close read-pipe in child process\00"
@.str.7 = [39 x i8] c"Unable to disassociate controlling tty\00"
@SIGHUP = global i32 0
@SIG_IGN = global i32 0
@.str.8 = [36 x i8] c"Unable to create grandchild process\00"
define void @begin_daemonize(i32* %0, i64* %1) {
%3 = alloca i32*
%4 = alloca i64*
%5 = alloca [2 x i32]
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8
%9 = alloca [1024 x i8]
%10 = alloca i64
store i32* %0, i32** %3
store i64* %1, i64** %4
%11 = call i32 @umask(i32 0)
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%13 = call i64 @pipe(i32* %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* @errno
%17 = call i32 @log_err(i32 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %15, %2
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%20 = load i32, i32* %19
%21 = call i32 @log_set_err_pipe(i32 %20)
%22 = call i64 (...) @fork()
store i64 %22, i64* %6
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32, i32* @errno
%26 = call i32 @log_err(i32 %25, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %83
27: ; preds = %18
%28 = load i64, i64* %6
%29 = icmp sgt i64 %28, 0
br i1 %29, label %30, label %82
30: ; preds = %27
%31 = call i32 @log_set_err_pipe(i32 -1)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%33 = load i32, i32* %32
%34 = call i64 @close(i32 %33)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = load i32, i32* @errno
%38 = call i32 @log_err(i32 %37, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %36, %30
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%41 = load i32, i32* %40
%42 = call i32 @read(i32 %41, i8* %8, i32 1)
store i32 %42, i32* %7
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = load i32, i32* @errno
%46 = call i32 @log_err(i32 %45, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %44, %39
%48 = load i32, i32* %7
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %80
50: ; preds = %47
%51 = load i8, i8* %8
%52 = sext i8 %51 to i32
%53 = icmp sge i32 %52, 0
br i1 %53, label %54, label %80
54: ; preds = %50
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%56 = load i32, i32* %55
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%58 = call i32 @read(i32 %56, i8* %57, i32 1024)
store i32 %58, i32* %7
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %54
%61 = load i32, i32* @errno
%62 = call i32 @log_err(i32 %61, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
br label %63
63: ; preds = %60, %54
%64 = load i32, i32* %7
%65 = icmp sgt i32 %64, 0
br i1 %65, label %66, label %78
66: ; preds = %63
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %78
71: ; preds = %66
%72 = load i32, i32* @stderr
%73 = load i8, i8* %8
%74 = call i32 @log_set_file(i32 %72, i8 signext %73, i32 0)
%75 = load i8, i8* %8
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%77 = call i32 @log_msg(i8 signext %75, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %76)
br label %78
78: ; preds = %71, %66, %63
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %50, %47
%81 = call i32 @exit(i32 0)
unreachable
82: ; preds = %27
br label %83
83: ; preds = %82, %24
%84 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%85 = load i32, i32* %84
%86 = call i64 @close(i32 %85)
%87 = icmp slt i64 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %83
%89 = load i32, i32* @errno
%90 = call i32 @log_err(i32 %89, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
br label %91
91: ; preds = %88, %83
%92 = call i64 (...) @setsid()
store i64 %92, i64* %10
%93 = icmp slt i64 %92, 0
br i1 %93, label %94, label %97
94: ; preds = %91
%95 = load i32, i32* @errno
%96 = call i32 @log_err(i32 %95, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
br label %97
97: ; preds = %94, %91
%98 = load i32, i32* @SIGHUP
%99 = load i32, i32* @SIG_IGN
%100 = call i32 @posix_signal(i32 %98, i32 %99)
%101 = call i64 (...) @fork()
store i64 %101, i64* %6
%102 = icmp slt i64 %101, 0
br i1 %102, label %103, label %106
103: ; preds = %97
%104 = load i32, i32* @errno
%105 = call i32 @log_err(i32 %104, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %112
106: ; preds = %97
%107 = load i64, i64* %6
%108 = icmp sgt i64 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %106
%110 = call i32 @exit(i32 0)
unreachable
111: ; preds = %106
br label %112
112: ; preds = %111, %103
%113 = load i32*, i32** %3
%114 = icmp ne i32* %113, null
br i1 %114, label %115, label %119
115: ; preds = %112
%116 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%117 = load i32, i32* %116
%118 = load i32*, i32** %3
store i32 %117, i32* %118
br label %119
119: ; preds = %115, %112
%120 = load i64*, i64** %4
%121 = icmp ne i64* %120, null
br i1 %121, label %122, label %125
122: ; preds = %119
%123 = load i64, i64* %10
%124 = load i64*, i64** %4
store i64 %123, i64* %124
br label %125
125: ; preds = %122, %119
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [29 x i8] c"Unable to create daemon pipe\00"
@.str.1 = [31 x i8] c"Unable to create child process\00"
@.str.2 = [45 x i8] c"Unable to close write-pipe in parent process\00"
@.str.3 = [46 x i8] c"Unable to read status from grandchild process\00"
@.str.4 = [53 x i8] c"Unable to read error message from grandchild process\00"
@stderr = global i32 0
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [43 x i8] c"Unable to close read-pipe in child process\00"
@.str.7 = [39 x i8] c"Unable to disassociate controlling tty\00"
@SIGHUP = global i32 0
@SIG_IGN = global i32 0
@.str.8 = [36 x i8] c"Unable to create grandchild process\00"
define void @begin_daemonize(i32* writeonly %0, i64* writeonly %1) {
%3 = alloca [2 x i32]
%4 = alloca i8
%5 = alloca [1024 x i8]
%6 = bitcast [2 x i32]* %3 to i8*
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = tail call i32 @umask(i32 0)
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%10 = call i64 @pipe(i32* %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @errno
%14 = call i32 @log_err(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %12, %2
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%17 = load i32, i32* %16
%18 = call i32 @log_set_err_pipe(i32 %17)
%19 = call i64 (...) @fork()
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i32, i32* @errno
%23 = call i32 @log_err(i32 %22, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %66
24: ; preds = %15
%25 = icmp eq i64 %19, 0
br i1 %25, label %66, label %26
26: ; preds = %24
%27 = call i32 @log_set_err_pipe(i32 -1)
%28 = load i32, i32* %16
%29 = call i64 @close(i32 %28)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i32, i32* @errno
%33 = call i32 @log_err(i32 %32, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %31, %26
%35 = load i32, i32* %9
%36 = call i32 @read(i32 %35, i8* %4, i32 1)
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i32, i32* @errno
%40 = call i32 @log_err(i32 %39, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
br label %64
41: ; preds = %34
%42 = icmp ne i32 %36, 0
%43 = load i8, i8* %4
%44 = icmp sgt i8 %43, -1
%45 = select i1 %42, i1 %44, i1 false
br i1 %45, label %46, label %64
46: ; preds = %41
%47 = load i32, i32* %9
%48 = call i32 @read(i32 %47, i8* %7, i32 1024)
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i32, i32* @errno
%52 = call i32 @log_err(i32 %51, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
br label %62
53: ; preds = %46
%54 = icmp ne i32 %48, 0
%55 = load i8, i8* %7
%56 = icmp ne i8 %55, 0
%57 = select i1 %54, i1 %56, i1 false
br i1 %57, label %58, label %62
58: ; preds = %53
%59 = load i32, i32* @stderr
%60 = call i32 @log_set_file(i32 %59, i8 signext %43, i32 0)
%61 = call i32 @log_msg(i8 signext %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %7)
br label %62
62: ; preds = %50, %58, %53
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %38, %41
%65 = call i32 @exit(i32 0)
unreachable
66: ; preds = %24, %21
%67 = load i32, i32* %9
%68 = call i64 @close(i32 %67)
%69 = icmp slt i64 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %66
%71 = load i32, i32* @errno
%72 = call i32 @log_err(i32 %71, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
br label %73
73: ; preds = %70, %66
%74 = call i64 (...) @setsid()
%75 = icmp slt i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %73
%77 = load i32, i32* @errno
%78 = call i32 @log_err(i32 %77, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
br label %79
79: ; preds = %76, %73
%80 = load i32, i32* @SIGHUP
%81 = load i32, i32* @SIG_IGN
%82 = call i32 @posix_signal(i32 %80, i32 %81)
%83 = call i64 (...) @fork()
%84 = icmp slt i64 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %79
%86 = load i32, i32* @errno
%87 = call i32 @log_err(i32 %86, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %92
88: ; preds = %79
%89 = icmp eq i64 %83, 0
br i1 %89, label %92, label %90
90: ; preds = %88
%91 = call i32 @exit(i32 0)
unreachable
92: ; preds = %88, %85
%93 = icmp eq i32* %0, null
br i1 %93, label %96, label %94
94: ; preds = %92
%95 = load i32, i32* %16
store i32 %95, i32* %0
br label %96
96: ; preds = %94, %92
%97 = icmp eq i64* %1, null
br i1 %97, label %99, label %98
98: ; preds = %96
store i64 %74, i64* %1
br label %99
99: ; preds = %98, %96
ret void
}