#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ F_TLOCK;
int O_CREAT;
int O_RDWR;
int /*<<< orphan*/ SIGTSTP;
int /*<<< orphan*/ SIGTTIN;
int /*<<< orphan*/ SIGTTOU;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ close(int);
int dup(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getdtablesize();
int getpid();
scalar_t__ lockf(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int, ...);
int /*<<< orphan*/ setsid();
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int daemonize(void) {
  int i = 0;
  char str[10];
  switch (fork()) {
  case -1:
    fprintf(stderr,
            "dsme wdd: "
            "daemonize: fork failed: %s\n",
            strerror(errno));
    return -1;
  default:
    exit(EXIT_SUCCESS);
    return -1;
  case 0:
    break;
  }
  setsid();
  i = getdtablesize();
  if (i == -1) {
    i = 256;
  }
  while (--i >= 0) {
    close(i);
  }
  i = open("/dev/null", O_RDWR);
  i = open("/dev/console", O_RDWR);
  if (dup(i) == -1) {
    fprintf(stderr,
            "dsme wdd: "
            "daemonize: dup failed: %s\n",
            strerror(errno));
    return -1;
  }
  i = open("/tmp/dsme.pid", O_RDWR | O_CREAT, 0640);
  if (i < 0) {
    fprintf(stderr, "dsme wdd: "
                    "Can't open lockfile. Exiting.\n");
    exit(EXIT_FAILURE);
  }
  if (lockf(i, F_TLOCK, 0) < 0) {
    fprintf(stderr, "dsme wdd: "
                    "Already running. Exiting.\n");
    exit(EXIT_FAILURE);
  }
  sprintf(str, "%d\n", getpid());
  if (write(i, str, strlen(str)) == -1) {
    fprintf(stderr,
            "dsme wdd: "
            "daemonize: write failed: %s\n",
            strerror(errno));
    return -1;
  }
  close(i);
  signal(SIGTSTP, SIG_IGN);
  signal(SIGTTOU, SIG_IGN);
  signal(SIGTTIN, SIG_IGN);
  return 0;
}


x86 assembly (clang, -O0):
<daemonize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
call   1100 <fork@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
sub    $0xffffffff,%eax
je     1229 <daemonize+0x39>
jmp    1219 <daemonize+0x29>
mov    -0x18(%rbp),%eax
test   %eax,%eax
je     1271 <daemonize+0x81>
jmp    1263 <daemonize+0x73>
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xdb0(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14b1 <daemonize+0x2c1>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    1276 <daemonize+0x86>
mov    $0x0,%al
call   1090 <setsid@plt>
mov    $0x0,%al
call   1110 <getdtablesize@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1298 <daemonize+0xa8>
movl   $0x100,-0x8(%rbp)
jmp    129d <daemonize+0xad>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jl     12bc <daemonize+0xcc>
mov    -0x8(%rbp),%edi
call   1080 <close@plt>
jmp    129d <daemonize+0xad>
mov    0x2d15(%rip),%rax
mov    (%rax),%esi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x8(%rbp)
mov    0x2cfb(%rip),%rax
mov    (%rax),%esi
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <dup@plt>
cmp    $0xffffffff,%eax
jne    133b <daemonize+0x14b>
mov    0x2ca0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xd15(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14b1 <daemonize+0x2c1>
mov    0x2c96(%rip),%rax
mov    (%rax),%esi
mov    0x2cad(%rip),%rax
or     (%rax),%esi
lea    0xd0e(%rip),%rdi
mov    $0x1a0,%edx
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1392 <daemonize+0x1a2>
mov    0x2c34(%rip),%rax
mov    (%rax),%edi
lea    0xcf3(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2c0d(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2c4c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <lockf@plt>
cmp    $0x0,%rax
jge    13d4 <daemonize+0x1e4>
mov    0x2bf2(%rip),%rax
mov    (%rax),%edi
lea    0xcda(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2bcb(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    -0x12(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%edx
lea    0xcce(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x12(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x12(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    145d <daemonize+0x26d>
mov    0x2b7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2b6a(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    %rax,%rdx
lea    0xc78(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14b1 <daemonize+0x2c1>
mov    -0x8(%rbp),%edi
call   1080 <close@plt>
mov    0x2b5c(%rip),%rax
mov    (%rax),%edi
mov    0x2b43(%rip),%rax
mov    (%rax),%esi
call   10a0 <signal@plt>
mov    0x2b4d(%rip),%rax
mov    (%rax),%edi
mov    0x2b2c(%rip),%rax
mov    (%rax),%esi
call   10a0 <signal@plt>
mov    0x2b26(%rip),%rax
mov    (%rax),%edi
mov    0x2b15(%rip),%rax
mov    (%rax),%esi
call   10a0 <signal@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<daemonize>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1100 <fork@plt>
test   %eax,%eax
je     122f <daemonize+0x3f>
cmp    $0xffffffff,%eax
jne    13af <daemonize+0x1bf>
mov    0x2d95(%rip),%rax
mov    (%rax),%ebx
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xdd6(%rip),%rsi
jmp    1393 <daemonize+0x1a3>
xor    %eax,%eax
call   1090 <setsid@plt>
xor    %eax,%eax
call   1110 <getdtablesize@plt>
cmp    $0xffffffff,%eax
mov    $0x100,%ebx
cmovne %eax,%ebx
test   %ebx,%ebx
jle    1260 <daemonize+0x70>
add    $0x1,%ebx
nop
lea    -0x2(%rbx),%edi
call   1080 <close@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1250 <daemonize+0x60>
mov    0x2d71(%rip),%rbx
mov    (%rbx),%esi
lea    0xdb6(%rip),%rdi
xor    %eax,%eax
call   10c0 <open@plt>
mov    (%rbx),%esi
lea    0xdb0(%rip),%rdi
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,%edi
call   1060 <dup@plt>
cmp    $0xffffffff,%eax
je     1355 <daemonize+0x165>
mov    0x2d5a(%rip),%rax
mov    (%rax),%esi
or     (%rbx),%esi
lea    0xdb9(%rip),%rdi
mov    $0x1a0,%edx
xor    %eax,%eax
call   10c0 <open@plt>
test   %eax,%eax
js     13bd <daemonize+0x1cd>
mov    %eax,%ebp
mov    0x2d22(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %edx,%edx
call   1070 <lockf@plt>
test   %rax,%rax
js     13cf <daemonize+0x1df>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xdd4(%rip),%rsi
lea    0x6(%rsp),%r14
mov    %r14,%rdi
mov    %eax,%edx
call   10d0 <sprintf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     1375 <daemonize+0x185>
mov    %ebp,%edi
call   1080 <close@plt>
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
mov    0x2c8f(%rip),%rbp
mov    0x0(%rbp),%esi
call   10a0 <signal@plt>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%esi
call   10a0 <signal@plt>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%esi
call   10a0 <signal@plt>
jmp    13a4 <daemonize+0x1b4>
mov    0x2c4c(%rip),%rax
mov    (%rax),%ebx
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xcca(%rip),%rsi
jmp    1393 <daemonize+0x1a3>
mov    0x2c2c(%rip),%rax
mov    (%rax),%ebx
mov    0x2c1b(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd2f(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2be4(%rip),%rax
mov    (%rax),%edi
lea    0xca3(%rip),%rsi
jmp    13df <daemonize+0x1ef>
mov    0x2bd2(%rip),%rax
mov    (%rax),%edi
lea    0xcba(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x2bab(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"dsme wdd: daemonize: fork failed: %s\0A\00"
@errno = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.1 = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@.str.2 = [13 x i8] c"/dev/console\00"
@.str.3 = [37 x i8] c"dsme wdd: daemonize: dup failed: %s\0A\00"
@.str.4 = [14 x i8] c"/tmp/dsme.pid\00"
@O_CREAT = global i32 0
@.str.5 = [41 x i8] c"dsme wdd: Can't open lockfile. Exiting.\0A\00"
@EXIT_FAILURE = global i32 0
@F_TLOCK = global i32 0
@.str.6 = [37 x i8] c"dsme wdd: Already running. Exiting.\0A\00"
@.str.7 = [4 x i8] c"%d\0A\00"
@.str.8 = [39 x i8] c"dsme wdd: daemonize: write failed: %s\0A\00"
@SIGTSTP = global i32 0
@SIG_IGN = global i32 0
@SIGTTOU = global i32 0
@SIGTTIN = global i32 0
define i32 @daemonize() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i8]
store i32 0, i32* %2
%4 = call i32 (...) @fork()
switch i32 %4, label %10 [
i32 -1, label %5
i32 0, label %13
]
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = call i8* @strerror(i32 %7)
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %8)
store i32 -1, i32* %1
br label %90
10: ; preds = %0
%11 = load i32, i32* @EXIT_SUCCESS
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %0
br label %14
14: ; preds = %13
%15 = call i32 (...) @setsid()
%16 = call i32 (...) @getdtablesize()
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 256, i32* %2
br label %20
20: ; preds = %19, %14
br label %21
21: ; preds = %25, %20
%22 = load i32, i32* %2
%23 = add nsw i32 %22, -1
store i32 %23, i32* %2
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* %2
%27 = call i32 @close(i32 %26)
br label %21
28: ; preds = %21
%29 = load i32, i32* @O_RDWR
%30 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %29)
store i32 %30, i32* %2
%31 = load i32, i32* @O_RDWR
%32 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %31)
store i32 %32, i32* %2
%33 = load i32, i32* %2
%34 = call i32 @dup(i32 %33)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %41
36: ; preds = %28
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %39)
store i32 -1, i32* %1
br label %90
41: ; preds = %28
%42 = load i32, i32* @O_RDWR
%43 = load i32, i32* @O_CREAT
%44 = or i32 %42, %43
%45 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %44, i32 416)
store i32 %45, i32* %2
%46 = load i32, i32* %2
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %41
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %41
%54 = load i32, i32* %2
%55 = load i32, i32* @F_TLOCK
%56 = call i64 @lockf(i32 %54, i32 %55, i32 0)
%57 = icmp slt i64 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %53
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %53
%64 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%65 = call i32 (...) @getpid()
%66 = call i32 @sprintf(i8* %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %2
%68 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%69 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%70 = call i32 @strlen(i8* %69)
%71 = call i32 @write(i32 %67, i8* %68, i32 %70)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %78
73: ; preds = %63
%74 = load i32, i32* @stderr
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i8* %76)
store i32 -1, i32* %1
br label %90
78: ; preds = %63
%79 = load i32, i32* %2
%80 = call i32 @close(i32 %79)
%81 = load i32, i32* @SIGTSTP
%82 = load i32, i32* @SIG_IGN
%83 = call i32 @signal(i32 %81, i32 %82)
%84 = load i32, i32* @SIGTTOU
%85 = load i32, i32* @SIG_IGN
%86 = call i32 @signal(i32 %84, i32 %85)
%87 = load i32, i32* @SIGTTIN
%88 = load i32, i32* @SIG_IGN
%89 = call i32 @signal(i32 %87, i32 %88)
store i32 0, i32* %1
br label %90
90: ; preds = %78, %73, %36, %5
%91 = load i32, i32* %1
ret i32 %91
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"dsme wdd: daemonize: fork failed: %s\0A\00"
@errno = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.1 = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@.str.2 = [13 x i8] c"/dev/console\00"
@.str.3 = [37 x i8] c"dsme wdd: daemonize: dup failed: %s\0A\00"
@.str.4 = [14 x i8] c"/tmp/dsme.pid\00"
@O_CREAT = global i32 0
@.str.5 = [41 x i8] c"dsme wdd: Can't open lockfile. Exiting.\0A\00"
@EXIT_FAILURE = global i32 0
@F_TLOCK = global i32 0
@.str.6 = [37 x i8] c"dsme wdd: Already running. Exiting.\0A\00"
@.str.7 = [4 x i8] c"%d\0A\00"
@.str.8 = [39 x i8] c"dsme wdd: daemonize: write failed: %s\0A\00"
@SIGTSTP = global i32 0
@SIG_IGN = global i32 0
@SIGTTOU = global i32 0
@SIGTTIN = global i32 0
define i32 @daemonize() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @fork()
switch i32 %3, label %9 [
i32 -1, label %4
i32 0, label %12
]
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = load i32, i32* @errno
%7 = tail call i8* @strerror(i32 %6)
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %77
9: ; preds = %0
%10 = load i32, i32* @EXIT_SUCCESS
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = tail call i32 (...) @setsid()
%14 = tail call i32 (...) @getdtablesize()
%15 = icmp eq i32 %14, -1
%16 = select i1 %15, i32 256, i32 %14
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %12, %18
%19 = phi i32 [ %20, %18 ], [ %16, %12 ]
%20 = add nsw i32 %19, -1
%21 = tail call i32 @close(i32 %20)
%22 = icmp ugt i32 %19, 1
br i1 %22, label %18, label %23
23: ; preds = %18, %12
%24 = load i32, i32* @O_RDWR
%25 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @O_RDWR
%27 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = tail call i32 @dup(i32 %27)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %35
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = tail call i8* @strerror(i32 %32)
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %33)
br label %77
35: ; preds = %23
%36 = load i32, i32* @O_RDWR
%37 = load i32, i32* @O_CREAT
%38 = or i32 %37, %36
%39 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %38, i32 416)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %35
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
%45 = tail call i32 @exit(i32 %44)
unreachable
46: ; preds = %35
%47 = load i32, i32* @F_TLOCK
%48 = tail call i64 @lockf(i32 %39, i32 %47, i32 0)
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
%54 = tail call i32 @exit(i32 %53)
unreachable
55: ; preds = %46
%56 = tail call i32 (...) @getpid()
%57 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %56)
%58 = call i32 @strlen(i8* %2)
%59 = call i32 @write(i32 %39, i8* %2, i32 %58)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %66
61: ; preds = %55
%62 = load i32, i32* @stderr
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i8* %64)
br label %77
66: ; preds = %55
%67 = call i32 @close(i32 %39)
%68 = load i32, i32* @SIGTSTP
%69 = load i32, i32* @SIG_IGN
%70 = call i32 @signal(i32 %68, i32 %69)
%71 = load i32, i32* @SIGTTOU
%72 = load i32, i32* @SIG_IGN
%73 = call i32 @signal(i32 %71, i32 %72)
%74 = load i32, i32* @SIGTTIN
%75 = load i32, i32* @SIG_IGN
%76 = call i32 @signal(i32 %74, i32 %75)
br label %77
77: ; preds = %66, %61, %30, %4
%78 = phi i32 [ -1, %30 ], [ -1, %61 ], [ 0, %66 ], [ -1, %4 ]
ret i32 %78
}