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

/* Variables and functions */
int /*<<< orphan*/ LOG_CONS;
int /*<<< orphan*/ LOG_DAEMON;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ RLIMIT_NOFILE;
int RLIM_INFINITY;
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIG_IGN;
scalar_t__ chdir(char *);
int /*<<< orphan*/ close(size_t);
int dup(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
scalar_t__ getrlimit(int /*<<< orphan*/, struct rlimit *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ openlog(char const *, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ setsid();
scalar_t__ sigaction(int /*<<< orphan*/, struct sigaction *,
                     int /*<<< orphan*/ *);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
void daemonize(const char *cmd) {
  int fd0, fd1, fd2;
  pid_t pid;
  struct rlimit rl;
  struct sigaction sa;
  umask(0);
  if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
    syslog(LOG_ERR, "Can't get max file descriptor");
    exit(1);
  }
  if ((pid = fork()) < 0) {
    syslog(LOG_ERR, "Error calling function 'fork'");
    exit(1);
  } else if (pid != 0)
    exit(0);
  setsid();
  sa.sa_handler = SIG_IGN;
  sigemptyset(&sa.sa_mask);
  sa.sa_flags = 0;
  if (sigaction(SIGHUP, &sa, NULL) < 0) {
    syslog(LOG_ERR, "Can't ignore SIGHUP signal");
    exit(1);
  }
  if ((pid = fork()) < 0) {
    syslog(LOG_ERR, "Error calling function 'fork'");
    exit(1);
  } else if (pid != 0)
    exit(0);
  if (chdir("/") < 0) {
    syslog(LOG_ERR, "Can't change working dir to /");
    exit(1);
  }
  if (rl.rlim_max == RLIM_INFINITY)
    rl.rlim_max = 1024;
  for (size_t i = 0; i < rl.rlim_max; i++)
    close(i);
  fd0 = open("/dev/null", O_RDWR);
  fd1 = dup(0);
  fd2 = dup(0);
  openlog(cmd, LOG_CONS, LOG_DAEMON);
  if (fd0 != 0 || fd1 != 1 || fd2 != 2) {
    syslog(LOG_ERR, "Wrong file descriptors %d %d %d", fd0, fd1, fd2);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<daemonize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
call   1090 <umask@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   10e0 <getrlimit@plt>
cmp    $0x0,%rax
jge    1220 <daemonize+0x50>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    1256 <daemonize+0x86>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpq   $0x0,-0x20(%rbp)
je     1268 <daemonize+0x98>
xor    %edi,%edi
call   10d0 <exit@plt>
jmp    126d <daemonize+0x9d>
mov    $0x0,%al
call   1070 <setsid@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x38(%rbp),%rdi
add    $0x8,%rdi
call   1080 <sigemptyset@plt>
movq   $0x0,-0x38(%rbp)
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jge    12d6 <daemonize+0x106>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
lea    0xd77(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    130c <daemonize+0x13c>
mov    0x2cae(%rip),%rax
mov    (%rax),%edi
lea    0xd23(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpq   $0x0,-0x20(%rbp)
je     131e <daemonize+0x14e>
xor    %edi,%edi
call   10d0 <exit@plt>
jmp    1323 <daemonize+0x153>
lea    0xd49(%rip),%rdi
call   1040 <chdir@plt>
cmp    $0x0,%rax
jge    135a <daemonize+0x18a>
mov    0x2c60(%rip),%rax
mov    (%rax),%edi
lea    0xd0e(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x28(%rbp),%eax
mov    0x2c4c(%rip),%rcx
cmp    (%rcx),%eax
jne    1373 <daemonize+0x1a3>
movl   $0x400,-0x28(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x28(%rbp),%rcx
cmp    %rcx,%rax
jae    13a6 <daemonize+0x1d6>
mov    -0x40(%rbp),%rdi
call   1060 <close@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    137b <daemonize+0x1ab>
mov    0x2c33(%rip),%rax
mov    (%rax),%esi
lea    0xcbf(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0xc(%rbp)
xor    %edi,%edi
call   1050 <dup@plt>
mov    %eax,-0x10(%rbp)
xor    %edi,%edi
call   1050 <dup@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2bdb(%rip),%rax
mov    (%rax),%esi
mov    0x2bf2(%rip),%rax
mov    (%rax),%edx
call   10c0 <openlog@plt>
cmpl   $0x0,-0xc(%rbp)
jne    140b <daemonize+0x23b>
cmpl   $0x1,-0x10(%rbp)
jne    140b <daemonize+0x23b>
cmpl   $0x2,-0x14(%rbp)
je     1436 <daemonize+0x266>
mov    0x2b8e(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xc5a(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<daemonize>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
xor    %edi,%edi
call   1090 <umask@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   10e0 <getrlimit@plt>
test   %rax,%rax
js     133c <daemonize+0x16c>
xor    %eax,%eax
call   10f0 <fork@plt>
test   %rax,%rax
js     1323 <daemonize+0x153>
jne    1335 <daemonize+0x165>
xor    %eax,%eax
call   1070 <setsid@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
lea    0x10(%rsp),%rdi
call   1080 <sigemptyset@plt>
movq   $0x0,0x8(%rsp)
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
js     134e <daemonize+0x17e>
xor    %eax,%eax
call   10f0 <fork@plt>
test   %rax,%rax
js     1323 <daemonize+0x153>
jne    1335 <daemonize+0x165>
lea    0xdfd(%rip),%rdi
call   1040 <chdir@plt>
test   %rax,%rax
js     1360 <daemonize+0x190>
mov    (%rsp),%eax
mov    0x2d22(%rip),%rcx
cmp    (%rcx),%eax
jne    129b <daemonize+0xcb>
movl   $0x400,(%rsp)
jmp    129f <daemonize+0xcf>
test   %eax,%eax
je     12c5 <daemonize+0xf5>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <close@plt>
add    $0x1,%rbx
movslq (%rsp),%rax
cmp    %rax,%rbx
jb     12b0 <daemonize+0xe0>
mov    0x2d14(%rip),%rax
mov    (%rax),%esi
lea    0xda0(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,%r15d
xor    %edi,%edi
call   1050 <dup@plt>
mov    %eax,%ebx
xor    %edi,%edi
call   1050 <dup@plt>
mov    %eax,%ebp
mov    0x2cc2(%rip),%rax
mov    (%rax),%esi
mov    0x2cd9(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
call   10c0 <openlog@plt>
test   %r15d,%r15d
jne    1381 <daemonize+0x1b1>
cmp    $0x1,%ebx
jne    1381 <daemonize+0x1b1>
cmp    $0x2,%ebp
jne    1381 <daemonize+0x1b1>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c76(%rip),%rax
mov    (%rax),%edi
lea    0xceb(%rip),%rsi
jmp    1370 <daemonize+0x1a0>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
lea    0xcb4(%rip),%rsi
jmp    1370 <daemonize+0x1a0>
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
lea    0xcde(%rip),%rsi
jmp    1370 <daemonize+0x1a0>
mov    0x2c39(%rip),%rax
mov    (%rax),%edi
lea    0xce7(%rip),%rsi
xor    %eax,%eax
call   10a0 <syslog@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2c18(%rip),%rax
mov    (%rax),%edi
lea    0xcee(%rip),%rsi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %ebp,%r8d
xor    %eax,%eax
call   10a0 <syslog@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.rlimit = type { i32 }
%struct.sigaction = type { i64, i32, i32 }
@RLIMIT_NOFILE = global i32 0
@LOG_ERR = global i32 0
@.str = [30 x i8] c"Can't get max file descriptor\00"
@.str.1 = [30 x i8] c"Error calling function 'fork'\00"
@SIG_IGN = global i32 0
@SIGHUP = global i32 0
@.str.2 = [27 x i8] c"Can't ignore SIGHUP signal\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [30 x i8] c"Can't change working dir to /\00"
@RLIM_INFINITY = global i32 0
@.str.5 = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@LOG_CONS = global i32 0
@LOG_DAEMON = global i32 0
@.str.6 = [32 x i8] c"Wrong file descriptors %d %d %d\00"
define void @daemonize(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca %struct.rlimit
%8 = alloca %struct.sigaction
%9 = alloca i64
store i8* %0, i8** %2
%10 = call i32 @umask(i32 0)
%11 = load i32, i32* @RLIMIT_NOFILE
%12 = call i64 @getrlimit(i32 %11, %struct.rlimit* %7)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = load i32, i32* @LOG_ERR
%16 = call i32 (i32, i8*, ...) @syslog(i32 %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %1
%19 = call i64 (...) @fork()
store i64 %19, i64* %6
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* @LOG_ERR
%23 = call i32 (i32, i8*, ...) @syslog(i32 %22, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %18
%26 = load i64, i64* %6
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %25
br label %31
31: ; preds = %30
%32 = call i32 (...) @setsid()
%33 = load i32, i32* @SIG_IGN
%34 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %8, i32 0, i32 2
store i32 %33, i32* %34
%35 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %8, i32 0, i32 1
%36 = call i32 @sigemptyset(i32* %35)
%37 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %8, i32 0, i32 0
store i64 0, i64* %37
%38 = load i32, i32* @SIGHUP
%39 = call i64 @sigaction(i32 %38, %struct.sigaction* %8, i32* null)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %31
%42 = load i32, i32* @LOG_ERR
%43 = call i32 (i32, i8*, ...) @syslog(i32 %42, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %31
%46 = call i64 (...) @fork()
store i64 %46, i64* %6
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = load i32, i32* @LOG_ERR
%50 = call i32 (i32, i8*, ...) @syslog(i32 %49, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %45
%53 = load i64, i64* %6
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = call i32 @exit(i32 0)
unreachable
57: ; preds = %52
br label %58
58: ; preds = %57
%59 = call i64 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %58
%62 = load i32, i32* @LOG_ERR
%63 = call i32 (i32, i8*, ...) @syslog(i32 %62, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %58
%66 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %7, i32 0, i32 0
%67 = load i32, i32* %66
%68 = load i32, i32* @RLIM_INFINITY
%69 = icmp eq i32 %67, %68
br i1 %69, label %70, label %72
70: ; preds = %65
%71 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %7, i32 0, i32 0
store i32 1024, i32* %71
br label %72
72: ; preds = %70, %65
store i64 0, i64* %9
br label %73
73: ; preds = %82, %72
%74 = load i64, i64* %9
%75 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %7, i32 0, i32 0
%76 = load i32, i32* %75
%77 = sext i32 %76 to i64
%78 = icmp ult i64 %74, %77
br i1 %78, label %79, label %85
79: ; preds = %73
%80 = load i64, i64* %9
%81 = call i32 @close(i64 %80)
br label %82
82: ; preds = %79
%83 = load i64, i64* %9
%84 = add i64 %83, 1
store i64 %84, i64* %9
br label %73
85: ; preds = %73
%86 = load i32, i32* @O_RDWR
%87 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %86)
store i32 %87, i32* %3
%88 = call i32 @dup(i32 0)
store i32 %88, i32* %4
%89 = call i32 @dup(i32 0)
store i32 %89, i32* %5
%90 = load i8*, i8** %2
%91 = load i32, i32* @LOG_CONS
%92 = load i32, i32* @LOG_DAEMON
%93 = call i32 @openlog(i8* %90, i32 %91, i32 %92)
%94 = load i32, i32* %3
%95 = icmp ne i32 %94, 0
br i1 %95, label %102, label %96
96: ; preds = %85
%97 = load i32, i32* %4
%98 = icmp ne i32 %97, 1
br i1 %98, label %102, label %99
99: ; preds = %96
%100 = load i32, i32* %5
%101 = icmp ne i32 %100, 2
br i1 %101, label %102, label %109
102: ; preds = %99, %96, %85
%103 = load i32, i32* @LOG_ERR
%104 = load i32, i32* %3
%105 = load i32, i32* %4
%106 = load i32, i32* %5
%107 = call i32 (i32, i8*, ...) @syslog(i32 %103, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %104, i32 %105, i32 %106)
%108 = call i32 @exit(i32 1)
unreachable
109: ; preds = %99
ret void
}

LLVM IR (-O2):
%struct.rlimit = type { i32 }
%struct.sigaction = type { i64, i32, i32 }
@RLIMIT_NOFILE = global i32 0
@LOG_ERR = global i32 0
@.str = [30 x i8] c"Can't get max file descriptor\00"
@.str.1 = [30 x i8] c"Error calling function 'fork'\00"
@SIG_IGN = global i32 0
@SIGHUP = global i32 0
@.str.2 = [27 x i8] c"Can't ignore SIGHUP signal\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [30 x i8] c"Can't change working dir to /\00"
@RLIM_INFINITY = global i32 0
@.str.5 = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@LOG_CONS = global i32 0
@LOG_DAEMON = global i32 0
@.str.6 = [32 x i8] c"Wrong file descriptors %d %d %d\00"
define void @daemonize(i8* %0) {
%2 = alloca %struct.rlimit
%3 = alloca %struct.sigaction
%4 = bitcast %struct.rlimit* %2 to i8*
%5 = bitcast %struct.sigaction* %3 to i8*
%6 = tail call i32 @umask(i32 0)
%7 = load i32, i32* @RLIMIT_NOFILE
%8 = call i64 @getrlimit(i32 %7, %struct.rlimit* %2)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* @LOG_ERR
%12 = call i32 (i32, i8*, ...) @syslog(i32 %11, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %1
%15 = call i64 (...) @fork()
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* @LOG_ERR
%19 = call i32 (i32, i8*, ...) @syslog(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %14
%22 = icmp eq i64 %15, 0
br i1 %22, label %25, label %23
23: ; preds = %21
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %21
%26 = call i32 (...) @setsid()
%27 = load i32, i32* @SIG_IGN
%28 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 2
store i32 %27, i32* %28
%29 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 1
%30 = call i32 @sigemptyset(i32* %29)
%31 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 0
store i64 0, i64* %31
%32 = load i32, i32* @SIGHUP
%33 = call i64 @sigaction(i32 %32, %struct.sigaction* %3, i32* null)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %25
%36 = load i32, i32* @LOG_ERR
%37 = call i32 (i32, i8*, ...) @syslog(i32 %36, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %25
%40 = call i64 (...) @fork()
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i32, i32* @LOG_ERR
%44 = call i32 (i32, i8*, ...) @syslog(i32 %43, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %39
%47 = icmp eq i64 %40, 0
br i1 %47, label %50, label %48
48: ; preds = %46
%49 = call i32 @exit(i32 0)
unreachable
50: ; preds = %46
%51 = call i64 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %50
%54 = load i32, i32* @LOG_ERR
%55 = call i32 (i32, i8*, ...) @syslog(i32 %54, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %50
%58 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %2, i64 0, i32 0
%59 = load i32, i32* %58
%60 = load i32, i32* @RLIM_INFINITY
%61 = icmp eq i32 %59, %60
br i1 %61, label %62, label %63
62: ; preds = %57
store i32 1024, i32* %58
br label %65
63: ; preds = %57
%64 = icmp eq i32 %59, 0
br i1 %64, label %66, label %65
65: ; preds = %62, %63
br label %79
66: ; preds = %79, %63
%67 = load i32, i32* @O_RDWR
%68 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %67)
%69 = call i32 @dup(i32 0)
%70 = call i32 @dup(i32 0)
%71 = load i32, i32* @LOG_CONS
%72 = load i32, i32* @LOG_DAEMON
%73 = call i32 @openlog(i8* %0, i32 %71, i32 %72)
%74 = icmp ne i32 %68, 0
%75 = icmp ne i32 %69, 1
%76 = select i1 %74, i1 true, i1 %75
%77 = icmp ne i32 %70, 2
%78 = select i1 %76, i1 true, i1 %77
br i1 %78, label %86, label %90
79: ; preds = %65, %79
%80 = phi i64 [ %82, %79 ], [ 0, %65 ]
%81 = call i32 @close(i64 %80)
%82 = add nuw i64 %80, 1
%83 = load i32, i32* %58
%84 = sext i32 %83 to i64
%85 = icmp ult i64 %82, %84
br i1 %85, label %79, label %66
86: ; preds = %66
%87 = load i32, i32* @LOG_ERR
%88 = call i32 (i32, i8*, ...) @syslog(i32 %87, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %68, i32 %69, i32 %70)
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %66
ret void
}