#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 flock {
  scalar_t__ l_type;
  int l_pid;
  scalar_t__ l_len;
  scalar_t__ l_start;
  int /*<<< orphan*/ l_whence;
};
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ F_GETLK;
int /*<<< orphan*/ F_SETLK;
scalar_t__ F_UNLCK;
void *F_WRLCK;
int O_APPEND;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int PATH_MAX;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int S_IRGRP;
int S_IROTH;
int S_IRWXU;
int /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ dup2(int, int /*<<< orphan*/);
scalar_t__ execve(char *, char **, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fcntl(int, int /*<<< orphan*/, struct flock *);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ ftruncate(int, int /*<<< orphan*/);
int getpid();
scalar_t__ kill(int, int /*<<< orphan*/);
scalar_t__ malloc(int);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *realpath(char *, char *);
int setsid();
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main(int argc, const char *argv[]) {
  int fd, stdin, pid_fd;
  pid_t pid;
  char buffer[PATH_MAX];
  char *env[] = {NULL};
  char **argv_for_execve = (char **)malloc(3 * sizeof(char *));
  struct flock flockstr;
  if (realpath("/usr/local/linuxkit3/"
               "php7-zts/bin/php",
               buffer) == NULL) {
    fprintf(stderr, "File %s not found.\n",
            "/usr/local/linuxkit3/"
            "php7-zts/bin/php");
    exit(EXIT_FAILURE);
  }
  if (realpath("/usr/local/linuxkit3/"
               "bin/main.php",
               buffer) == NULL) {
    fprintf(stderr, "File %s not found.\n",
            "/usr/local/linuxkit3/"
            "bin/main.php");
    exit(EXIT_FAILURE);
  }
  pid_fd = open("/usr/local/linuxkit3/"
                "run/linuxkit3.pid",
                O_CREAT | O_RDWR, S_IRWXU | S_IRGRP | S_IROTH);
  flockstr.l_type = F_WRLCK;
  if (fcntl(pid_fd, F_GETLK, &flockstr) < 0) {
    perror("fcntl()");
    exit(EXIT_FAILURE);
  }
  if (flockstr.l_type != F_UNLCK) {
    if (argc == 1) {
      fprintf(stderr,
              "Linux KIT 3 daemon is running, pid is %d.\nStop it, please "
              "execute: %s stop\n",
              flockstr.l_pid, argv[0]);
      exit(EXIT_FAILURE);
    } else if (!strcmp(argv[1], "stop")) {
      if (kill(flockstr.l_pid, SIGTERM) < 0) {
        perror("kill()");
        exit(EXIT_FAILURE);
      }
      unlink("/usr/local/linuxkit3/"
             "run/linuxkit3.pid");
      printf("Stop pid %d\n", flockstr.l_pid);
      exit(EXIT_SUCCESS);
    } else if (!strcmp(argv[1], "restart")) {
      if (kill(flockstr.l_pid, SIGTERM) < 0) {
        perror("kill()");
        exit(EXIT_FAILURE);
      }
      printf("Stop pid %d\n", flockstr.l_pid);
    } else {
      fprintf(stderr, "Unsupport operation\n");
      exit(EXIT_FAILURE);
    }
  } else if (argc != 1 && !strcmp(argv[1], "stop")) {
    fprintf(stderr, "Linux KIT 3 daemon is not running.\n");
    exit(EXIT_FAILURE);
  }
  flockstr.l_type = F_WRLCK;
  flockstr.l_whence = SEEK_SET;
  flockstr.l_start = 0;
  flockstr.l_len = 0;
  argv_for_execve[0] = "Hi, i am Linux KIT 3 daemon, running for: ";
  argv_for_execve[1] = "/usr/local/linuxkit3/"
                       "bin/main.php";
  argv_for_execve[2] = NULL;
  printf("Staring Linux KIT 3 daemon...\n");
  switch (fork()) {
  case 0:
    break;
  case -1:
    perror("fork()");
    exit(EXIT_FAILURE);
  default:
    exit(EXIT_SUCCESS);
  }
  if (setsid() == -1) {
    perror("setsid()");
    exit(EXIT_FAILURE);
  }
  switch (fork()) {
  case 0:
    break;
  case -1:
    perror("fork()");
    exit(EXIT_FAILURE);
  default:
    exit(EXIT_SUCCESS);
  }
  if (fcntl(pid_fd, F_SETLK, &flockstr) < 0) {
    perror("fcntl()");
    exit(EXIT_FAILURE);
  }
  pid = getpid();
  sprintf(buffer, "%d", pid);
  if (ftruncate(pid_fd, 0) < 0) {
    perror("ftruncate()");
    exit(EXIT_FAILURE);
  }
  write(pid_fd, buffer, strlen(buffer));
  fd = open("/dev/null", O_RDONLY);
  close(STDIN_FILENO);
  dup2(fd, STDIN_FILENO);
  fd = open("/usr/local/linuxkit3/"
            "logs/linuxkit3.log",
            O_RDWR | O_APPEND | O_CREAT, S_IRWXU | S_IRGRP);
  close(STDOUT_FILENO);
  close(STDERR_FILENO);
  dup2(fd, STDOUT_FILENO);
  dup2(fd, STDERR_FILENO);
  if (execve("/usr/local/linuxkit3/"
             "php7-zts/bin/php",
             argv_for_execve, env)) {
    perror("execve()");
    fprintf(stderr, "Linux KIT 3 daemon start unsuccessfully\n");
    exit(EXIT_FAILURE);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d68(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10b0 <memset@plt>
mov    $0x18,%edi
call   1130 <malloc@plt>
mov    -0x70(%rbp),%rsi
mov    %rax,-0x40(%rbp)
lea    0xd32(%rip),%rdi
call   1110 <realpath@plt>
cmp    $0x0,%rax
jne    1309 <main+0xa9>
mov    0x2cac(%rip),%rax
mov    (%rax),%edi
lea    0xd39(%rip),%rsi
lea    0xd0c(%rip),%rdx
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    0x2c66(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    -0x70(%rbp),%rsi
lea    0xd26(%rip),%rdi
call   1110 <realpath@plt>
cmp    $0x0,%rax
jne    134f <main+0xef>
mov    0x2c66(%rip),%rax
mov    (%rax),%edi
lea    0xcf3(%rip),%rsi
lea    0xd00(%rip),%rdx
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    0x2c20(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    0x2ca2(%rip),%rax
mov    (%rax),%esi
mov    0x2c69(%rip),%rax
or     (%rax),%esi
mov    0x2c68(%rip),%rax
mov    (%rax),%edx
mov    0x2c07(%rip),%rax
or     (%rax),%edx
mov    0x2bf6(%rip),%rax
or     (%rax),%edx
lea    0xcd9(%rip),%rdi
mov    $0x0,%al
call   1140 <open@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2bcc(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2c03(%rip),%rax
mov    (%rax),%esi
lea    -0x68(%rbp),%rdx
call   1040 <fcntl@plt>
cmp    $0x0,%rax
jge    13d4 <main+0x174>
lea    0xcc2(%rip),%rdi
call   1150 <perror@plt>
mov    0x2b9b(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    -0x68(%rbp),%rax
mov    0x2bc1(%rip),%rcx
cmp    (%rcx),%rax
je     153a <main+0x2da>
cmpl   $0x1,-0x8(%rbp)
jne    1421 <main+0x1c1>
mov    0x2b97(%rip),%rax
mov    (%rax),%edi
mov    -0x60(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xc7f(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    0x2b4e(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xca7(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%eax
jne    149e <main+0x23e>
mov    -0x60(%rbp),%edi
mov    0x2b70(%rip),%rax
mov    (%rax),%esi
call   1120 <kill@plt>
cmp    $0x0,%rax
jge    1473 <main+0x213>
lea    0xc7c(%rip),%rdi
call   1150 <perror@plt>
mov    0x2afc(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
lea    0xbe2(%rip),%rdi
call   1030 <unlink@plt>
mov    -0x60(%rbp),%esi
lea    0xc5a(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    0x2ac1(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc43(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%eax
jne    1506 <main+0x2a6>
mov    -0x60(%rbp),%edi
mov    0x2af3(%rip),%rax
mov    (%rax),%esi
call   1120 <kill@plt>
cmp    $0x0,%rax
jge    14f0 <main+0x290>
lea    0xbff(%rip),%rdi
call   1150 <perror@plt>
mov    0x2a7f(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    -0x60(%rbp),%esi
lea    0xbe9(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    152b <main+0x2cb>
mov    0x2a83(%rip),%rax
mov    (%rax),%edi
lea    0xbe2(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    0x2a44(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
jmp    1530 <main+0x2d0>
jmp    1535 <main+0x2d5>
jmp    158b <main+0x32b>
cmpl   $0x1,-0x8(%rbp)
je     1586 <main+0x326>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xb84(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%eax
jne    1586 <main+0x326>
mov    0x2a28(%rip),%rax
mov    (%rax),%edi
lea    0xb9c(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    0x29e9(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
jmp    158b <main+0x32b>
mov    0x29ce(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    0x29e8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x40(%rbp),%rax
lea    0xb71(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rax
lea    0xa6c(%rip),%rcx
mov    %rcx,0x8(%rax)
mov    -0x40(%rbp),%rax
movq   $0x0,0x10(%rax)
lea    0xb77(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x75(%rbp)
call   1090 <printf@plt>
mov    -0x75(%rbp),%al
call   1180 <fork@plt>
mov    %eax,%ecx
mov    %ecx,-0x74(%rbp)
sub    $0xffffffff,%eax
je     161f <main+0x3bf>
jmp    160a <main+0x3aa>
mov    -0x74(%rbp),%eax
test   %eax,%eax
jne    1639 <main+0x3d9>
jmp    161a <main+0x3ba>
jmp    1647 <main+0x3e7>
lea    0xb55(%rip),%rdi
call   1150 <perror@plt>
mov    0x2936(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    0x2918(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    $0x0,%al
call   10d0 <setsid@plt>
cmp    $0xffffffff,%eax
jne    1671 <main+0x411>
lea    0xb24(%rip),%rdi
call   1150 <perror@plt>
mov    0x28fe(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
xor    %eax,%eax
call   1180 <fork@plt>
mov    %eax,%ecx
mov    %ecx,-0x7c(%rbp)
sub    $0xffffffff,%eax
je     16a0 <main+0x440>
jmp    168b <main+0x42b>
mov    -0x7c(%rbp),%eax
test   %eax,%eax
jne    16ba <main+0x45a>
jmp    169b <main+0x43b>
jmp    16c8 <main+0x468>
lea    0xad4(%rip),%rdi
call   1150 <perror@plt>
mov    0x28b5(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    0x2897(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    0x28de(%rip),%rax
mov    (%rax),%esi
lea    -0x68(%rbp),%rdx
call   1040 <fcntl@plt>
cmp    $0x0,%rax
jge    1701 <main+0x4a1>
lea    0x995(%rip),%rdi
call   1150 <perror@plt>
mov    0x286e(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edx
lea    0xa72(%rip),%rsi
call   1160 <sprintf@plt>
mov    -0x1c(%rbp),%edi
xor    %esi,%esi
call   10a0 <ftruncate@plt>
cmp    $0x0,%rax
jge    174c <main+0x4ec>
lea    0xa55(%rip),%rdi
call   1150 <perror@plt>
mov    0x2823(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
mov    -0x70(%rbp),%rdi
mov    -0x1c(%rbp),%eax
mov    %eax,-0x80(%rbp)
call   1070 <strlen@plt>
mov    -0x80(%rbp),%edi
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    0x2850(%rip),%rax
mov    (%rax),%esi
lea    0xa21(%rip),%rdi
mov    $0x0,%al
call   1140 <open@plt>
mov    %eax,-0x14(%rbp)
mov    0x27c6(%rip),%rax
mov    (%rax),%edi
call   10c0 <close@plt>
mov    -0x14(%rbp),%edi
mov    0x27b5(%rip),%rax
mov    (%rax),%esi
call   1080 <dup2@plt>
mov    0x281f(%rip),%rax
mov    (%rax),%esi
mov    0x278e(%rip),%rax
or     (%rax),%esi
mov    0x283d(%rip),%rax
or     (%rax),%esi
mov    0x280c(%rip),%rax
mov    (%rax),%edx
mov    0x27ab(%rip),%rax
or     (%rax),%edx
lea    0x9ce(%rip),%rdi
mov    $0x0,%al
call   1140 <open@plt>
mov    %eax,-0x14(%rbp)
mov    0x27f9(%rip),%rax
mov    (%rax),%edi
call   10c0 <close@plt>
mov    0x278b(%rip),%rax
mov    (%rax),%edi
call   10c0 <close@plt>
mov    -0x14(%rbp),%edi
mov    0x27da(%rip),%rax
mov    (%rax),%esi
call   1080 <dup2@plt>
mov    -0x14(%rbp),%edi
mov    0x2769(%rip),%rax
mov    (%rax),%esi
call   1080 <dup2@plt>
mov    -0x40(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    0x7d3(%rip),%rdi
call   10e0 <execve@plt>
cmp    $0x0,%rax
je     186d <main+0x60d>
lea    0x989(%rip),%rdi
call   1150 <perror@plt>
mov    0x2741(%rip),%rax
mov    (%rax),%edi
lea    0x97d(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    0x2702(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    %edi,%r12d
mov    0x2d6a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
movq   $0x0,-0x58(%rbp)
mov    $0x18,%edi
call   1130 <malloc@plt>
mov    %rax,%r14
lea    0xd53(%rip),%rdi
mov    %r13,%rsi
call   1110 <realpath@plt>
test   %rax,%rax
je     15b1 <main+0x351>
lea    0xd75(%rip),%rdi
mov    %r13,%rsi
call   1110 <realpath@plt>
test   %rax,%rax
je     15ca <main+0x36a>
mov    0x2d1b(%rip),%rax
mov    0x2ce4(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2ce1(%rip),%rax
mov    0x2c82(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2c6f(%rip),%rax
or     (%rax),%edx
lea    0xd52(%rip),%rdi
xor    %eax,%eax
call   1140 <open@plt>
mov    %eax,%r15d
mov    0x2c45(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    0x2c7f(%rip),%rax
mov    (%rax),%esi
lea    -0x50(%rbp),%rdx
mov    %r15d,%edi
call   1050 <fcntl@plt>
test   %rax,%rax
js     15a5 <main+0x345>
mov    -0x50(%rbp),%rax
mov    0x2c55(%rip),%rcx
cmp    (%rcx),%rax
jne    1383 <main+0x123>
cmp    $0x1,%r12d
je     13ea <main+0x18a>
mov    0x8(%rbx),%rdi
lea    0xd72(%rip),%rsi
call   10f0 <strcmp@plt>
test   %eax,%eax
jne    13ea <main+0x18a>
mov    0x2c1b(%rip),%rax
mov    (%rax),%edi
lea    0xd8f(%rip),%rsi
jmp    1670 <main+0x410>
cmp    $0x1,%r12d
je     161d <main+0x3bd>
mov    0x8(%rbx),%rbx
lea    0xd3f(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <strcmp@plt>
test   %eax,%eax
je     163c <main+0x3dc>
lea    0xd41(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <strcmp@plt>
test   %eax,%eax
jne    1660 <main+0x400>
mov    -0x48(%rbp),%edi
mov    0x2bef(%rip),%rax
mov    (%rax),%esi
call   1120 <kill@plt>
test   %rax,%rax
js     1652 <main+0x3f2>
mov    -0x48(%rbp),%esi
lea    0xd00(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x2b6f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    0x2b89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
xorps  %xmm0,%xmm0
movups %xmm0,-0x40(%rbp)
lea    0xd1f(%rip),%rax
mov    %rax,(%r14)
lea    0xc1e(%rip),%rax
mov    %rax,0x8(%r14)
movq   $0x0,0x10(%r14)
lea    0xdb0(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1180 <fork@plt>
test   %eax,%eax
jne    1590 <main+0x330>
xor    %eax,%eax
call   10d0 <setsid@plt>
cmp    $0xffffffff,%eax
je     15ed <main+0x38d>
xor    %eax,%eax
call   1180 <fork@plt>
test   %eax,%eax
jne    1590 <main+0x330>
mov    0x2b47(%rip),%rax
mov    (%rax),%esi
lea    -0x50(%rbp),%rdx
mov    %r15d,%edi
call   1050 <fcntl@plt>
test   %rax,%rax
js     15a5 <main+0x345>
xor    %eax,%eax
call   1070 <getpid@plt>
lea    0xcde(%rip),%rsi
mov    %r13,%rdi
mov    %eax,%edx
call   1160 <sprintf@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   10b0 <ftruncate@plt>
test   %rax,%rax
js     15f6 <main+0x396>
mov    %r13,%rdi
call   1080 <strlen@plt>
mov    %r15d,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    0x2af9(%rip),%rax
mov    (%rax),%esi
lea    0xcab(%rip),%rdi
xor    %eax,%eax
call   1140 <open@plt>
mov    %eax,%ebx
mov    0x2a70(%rip),%r15
mov    (%r15),%edi
call   10c0 <close@plt>
mov    (%r15),%esi
mov    %ebx,%edi
call   1090 <dup2@plt>
mov    0x2a47(%rip),%rax
mov    (%rax),%esi
mov    0x2ac6(%rip),%rax
or     (%rax),%esi
mov    0x2aed(%rip),%rax
or     (%rax),%esi
mov    0x2a64(%rip),%rax
mov    (%rax),%edx
mov    0x2ab3(%rip),%rax
or     (%rax),%edx
lea    0xc5f(%rip),%rdi
xor    %eax,%eax
call   1140 <open@plt>
mov    %eax,%ebx
mov    0x2aaa(%rip),%r15
mov    (%r15),%edi
call   10c0 <close@plt>
mov    0x2a3b(%rip),%r12
mov    (%r12),%edi
call   10c0 <close@plt>
mov    (%r15),%esi
mov    %ebx,%edi
call   1090 <dup2@plt>
mov    (%r12),%esi
mov    %ebx,%edi
call   1090 <dup2@plt>
lea    0xa96(%rip),%rdi
lea    -0x58(%rbp),%rdx
mov    %r14,%rsi
call   10e0 <execve@plt>
test   %rax,%rax
jne    15ff <main+0x39f>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0xffffffff,%eax
jne    16a2 <main+0x442>
lea    0xbbc(%rip),%rdi
jmp    1659 <main+0x3f9>
lea    0xad7(%rip),%rdi
jmp    1659 <main+0x3f9>
mov    0x29d8(%rip),%rax
mov    (%rax),%edi
lea    0xa65(%rip),%rsi
lea    0xa38(%rip),%rdx
jmp    15e1 <main+0x381>
mov    0x29bf(%rip),%rax
mov    (%rax),%edi
lea    0xa4c(%rip),%rsi
lea    0xa59(%rip),%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
jmp    1677 <main+0x417>
lea    0xb6f(%rip),%rdi
jmp    1659 <main+0x3f9>
lea    0xb72(%rip),%rdi
jmp    1659 <main+0x3f9>
lea    0xba7(%rip),%rdi
call   1150 <perror@plt>
mov    0x297e(%rip),%rax
mov    (%rax),%edi
lea    0xb9b(%rip),%rsi
jmp    1670 <main+0x410>
mov    0x296c(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%edx
mov    (%rbx),%rcx
lea    0xa58(%rip),%rsi
xor    %eax,%eax
call   1100 <fprintf@plt>
jmp    1677 <main+0x417>
mov    -0x48(%rbp),%edi
mov    0x2972(%rip),%rax
mov    (%rax),%esi
call   1120 <kill@plt>
test   %rax,%rax
jns    1685 <main+0x425>
lea    0xa83(%rip),%rdi
call   1150 <perror@plt>
jmp    1677 <main+0x417>
mov    0x2929(%rip),%rax
mov    (%rax),%edi
lea    0xa88(%rip),%rsi
xor    %eax,%eax
call   1100 <fprintf@plt>
mov    0x28ea(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>
lea    0x9d0(%rip),%rdi
call   1030 <unlink@plt>
mov    -0x48(%rbp),%esi
lea    0xa48(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x28af(%rip),%rax
mov    (%rax),%edi
call   1170 <exit@plt>

LLVM IR (-O0):
%struct.flock = type { i64, i32, i64, i64, i32 }
@PATH_MAX = global i32 0
@.str = [38 x i8] c"/usr/local/linuxkit3/php7-zts/bin/php\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"File %s not found.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [34 x i8] c"/usr/local/linuxkit3/bin/main.php\00"
@.str.3 = [39 x i8] c"/usr/local/linuxkit3/run/linuxkit3.pid\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@S_IRWXU = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@F_WRLCK = global i8* null
@F_GETLK = global i32 0
@.str.4 = [8 x i8] c"fcntl()\00"
@F_UNLCK = global i64 0
@.str.5 = [76 x i8] c"Linux KIT 3 daemon is running, pid is %d.\0AStop it, please execute: %s stop\0A\00"
@.str.6 = [5 x i8] c"stop\00"
@SIGTERM = global i32 0
@.str.7 = [7 x i8] c"kill()\00"
@.str.8 = [13 x i8] c"Stop pid %d\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.9 = [8 x i8] c"restart\00"
@.str.10 = [21 x i8] c"Unsupport operation\0A\00"
@.str.11 = [36 x i8] c"Linux KIT 3 daemon is not running.\0A\00"
@SEEK_SET = global i32 0
@.str.12 = [43 x i8] c"Hi, i am Linux KIT 3 daemon, running for: \00"
@.str.13 = [31 x i8] c"Staring Linux KIT 3 daemon...\0A\00"
@.str.14 = [7 x i8] c"fork()\00"
@.str.15 = [9 x i8] c"setsid()\00"
@F_SETLK = global i32 0
@.str.16 = [3 x i8] c"%d\00"
@.str.17 = [12 x i8] c"ftruncate()\00"
@.str.18 = [10 x i8] c"/dev/null\00"
@O_RDONLY = global i32 0
@STDIN_FILENO = global i32 0
@.str.19 = [40 x i8] c"/usr/local/linuxkit3/logs/linuxkit3.log\00"
@O_APPEND = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str.20 = [9 x i8] c"execve()\00"
@.str.21 = [41 x i8] c"Linux KIT 3 daemon start unsuccessfully\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca [1 x i8*]
%13 = alloca i8**
%14 = alloca %struct.flock
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* @PATH_MAX
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %10
%18 = alloca i8, i64 %16
store i64 %16, i64* %11
%19 = bitcast [1 x i8*]* %12 to i8*
%20 = call i64 @malloc(i32 24)
%21 = inttoptr i64 %20 to i8**
store i8** %21, i8*** %13
%22 = call i32* @realpath(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %18)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %29
24: ; preds = %2
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %2
%30 = call i32* @realpath(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %29
%38 = load i32, i32* @O_CREAT
%39 = load i32, i32* @O_RDWR
%40 = or i32 %38, %39
%41 = load i32, i32* @S_IRWXU
%42 = load i32, i32* @S_IRGRP
%43 = or i32 %41, %42
%44 = load i32, i32* @S_IROTH
%45 = or i32 %43, %44
%46 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %40, i32 %45)
store i32 %46, i32* %8
%47 = load i8*, i8** @F_WRLCK
%48 = ptrtoint i8* %47 to i64
%49 = getelementptr inbounds %struct.flock, %struct.flock* %14, i32 0, i32 0
store i64 %48, i64* %49
%50 = load i32, i32* %8
%51 = load i32, i32* @F_GETLK
%52 = call i64 @fcntl(i32 %50, i32 %51, %struct.flock* %14)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %37
%55 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%56 = load i32, i32* @EXIT_FAILURE
%57 = call i32 @exit(i32 %56)
unreachable
58: ; preds = %37
%59 = getelementptr inbounds %struct.flock, %struct.flock* %14, i32 0, i32 0
%60 = load i64, i64* %59
%61 = load i64, i64* @F_UNLCK
%62 = icmp ne i64 %60, %61
br i1 %62, label %63, label %127
63: ; preds = %58
%64 = load i32, i32* %4
%65 = icmp eq i32 %64, 1
br i1 %65, label %66, label %76
66: ; preds = %63
%67 = load i32, i32* @stderr
%68 = getelementptr inbounds %struct.flock, %struct.flock* %14, i32 0, i32 1
%69 = load i32, i32* %68
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 0
%72 = load i8*, i8** %71
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.5, i64 0, i64 0), i32 %69, i8* %72)
%74 = load i32, i32* @EXIT_FAILURE
%75 = call i32 @exit(i32 %74)
unreachable
76: ; preds = %63
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 1
%79 = load i8*, i8** %78
%80 = call i32 @strcmp(i8* %79, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%81 = icmp ne i32 %80, 0
br i1 %81, label %99, label %82
82: ; preds = %76
%83 = getelementptr inbounds %struct.flock, %struct.flock* %14, i32 0, i32 1
%84 = load i32, i32* %83
%85 = load i32, i32* @SIGTERM
%86 = call i64 @kill(i32 %84, i32 %85)
%87 = icmp slt i64 %86, 0
br i1 %87, label %88, label %92
88: ; preds = %82
%89 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %82
%93 = call i32 @unlink(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%94 = getelementptr inbounds %struct.flock, %struct.flock* %14, i32 0, i32 1
%95 = load i32, i32* %94
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %95)
%97 = load i32, i32* @EXIT_SUCCESS
%98 = call i32 @exit(i32 %97)
unreachable
99: ; preds = %76
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 1
%102 = load i8*, i8** %101
%103 = call i32 @strcmp(i8* %102, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%104 = icmp ne i32 %103, 0
br i1 %104, label %119, label %105
105: ; preds = %99
%106 = getelementptr inbounds %struct.flock, %struct.flock* %14, i32 0, i32 1
%107 = load i32, i32* %106
%108 = load i32, i32* @SIGTERM
%109 = call i64 @kill(i32 %107, i32 %108)
%110 = icmp slt i64 %109, 0
br i1 %110, label %111, label %115
111: ; preds = %105
%112 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%113 = load i32, i32* @EXIT_FAILURE
%114 = call i32 @exit(i32 %113)
unreachable
115: ; preds = %105
%116 = getelementptr inbounds %struct.flock, %struct.flock* %14, i32 0, i32 1
%117 = load i32, i32* %116
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %117)
br label %124
119: ; preds = %99
%120 = load i32, i32* @stderr
%121 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%122 = load i32, i32* @EXIT_FAILURE
%123 = call i32 @exit(i32 %122)
unreachable
124: ; preds = %115
br label %125
125: ; preds = %124
br label %126
126: ; preds = %125
br label %142
127: ; preds = %58
%128 = load i32, i32* %4
%129 = icmp ne i32 %128, 1
br i1 %129, label %130, label %141
130: ; preds = %127
%131 = load i8**, i8*** %5
%132 = getelementptr inbounds i8*, i8** %131, i64 1
%133 = load i8*, i8** %132
%134 = call i32 @strcmp(i8* %133, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%135 = icmp ne i32 %134, 0
br i1 %135, label %141, label %136
136: ; preds = %130
%137 = load i32, i32* @stderr
%138 = call i32 (i32, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.11, i64 0, i64 0))
%139 = load i32, i32* @EXIT_FAILURE
%140 = call i32 @exit(i32 %139)
unreachable
141: ; preds = %130, %127
br label %142
142: ; preds = %141, %126
%143 = load i8*, i8** @F_WRLCK
%144 = ptrtoint i8* %143 to i64
%145 = getelementptr inbounds %struct.flock, %struct.flock* %14, i32 0, i32 0
store i64 %144, i64* %145
%146 = load i32, i32* @SEEK_SET
%147 = getelementptr inbounds %struct.flock, %struct.flock* %14, i32 0, i32 4
store i32 %146, i32* %147
%148 = getelementptr inbounds %struct.flock, %struct.flock* %14, i32 0, i32 3
store i64 0, i64* %148
%149 = getelementptr inbounds %struct.flock, %struct.flock* %14, i32 0, i32 2
store i64 0, i64* %149
%150 = load i8**, i8*** %13
%151 = getelementptr inbounds i8*, i8** %150, i64 0
store i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i8** %151
%152 = load i8**, i8*** %13
%153 = getelementptr inbounds i8*, i8** %152, i64 1
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8** %153
%154 = load i8**, i8*** %13
%155 = getelementptr inbounds i8*, i8** %154, i64 2
store i8* null, i8** %155
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
%157 = call i32 (...) @fork()
switch i32 %157, label %163 [
i32 0, label %158
i32 -1, label %159
]
158: ; preds = %142
br label %166
159: ; preds = %142
%160 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%161 = load i32, i32* @EXIT_FAILURE
%162 = call i32 @exit(i32 %161)
unreachable
163: ; preds = %142
%164 = load i32, i32* @EXIT_SUCCESS
%165 = call i32 @exit(i32 %164)
unreachable
166: ; preds = %158
%167 = call i32 (...) @setsid()
%168 = icmp eq i32 %167, -1
br i1 %168, label %169, label %173
169: ; preds = %166
%170 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0))
%171 = load i32, i32* @EXIT_FAILURE
%172 = call i32 @exit(i32 %171)
unreachable
173: ; preds = %166
%174 = call i32 (...) @fork()
switch i32 %174, label %180 [
i32 0, label %175
i32 -1, label %176
]
175: ; preds = %173
br label %183
176: ; preds = %173
%177 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%178 = load i32, i32* @EXIT_FAILURE
%179 = call i32 @exit(i32 %178)
unreachable
180: ; preds = %173
%181 = load i32, i32* @EXIT_SUCCESS
%182 = call i32 @exit(i32 %181)
unreachable
183: ; preds = %175
%184 = load i32, i32* %8
%185 = load i32, i32* @F_SETLK
%186 = call i64 @fcntl(i32 %184, i32 %185, %struct.flock* %14)
%187 = icmp slt i64 %186, 0
br i1 %187, label %188, label %192
188: ; preds = %183
%189 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%190 = load i32, i32* @EXIT_FAILURE
%191 = call i32 @exit(i32 %190)
unreachable
192: ; preds = %183
%193 = call i32 (...) @getpid()
store i32 %193, i32* %9
%194 = load i32, i32* %9
%195 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 %194)
%196 = load i32, i32* %8
%197 = call i64 @ftruncate(i32 %196, i32 0)
%198 = icmp slt i64 %197, 0
br i1 %198, label %199, label %203
199: ; preds = %192
%200 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0))
%201 = load i32, i32* @EXIT_FAILURE
%202 = call i32 @exit(i32 %201)
unreachable
203: ; preds = %192
%204 = load i32, i32* %8
%205 = call i32 @strlen(i8* %18)
%206 = call i32 @write(i32 %204, i8* %18, i32 %205)
%207 = load i32, i32* @O_RDONLY
%208 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i32 %207)
store i32 %208, i32* %6
%209 = load i32, i32* @STDIN_FILENO
%210 = call i32 @close(i32 %209)
%211 = load i32, i32* %6
%212 = load i32, i32* @STDIN_FILENO
%213 = call i32 @dup2(i32 %211, i32 %212)
%214 = load i32, i32* @O_RDWR
%215 = load i32, i32* @O_APPEND
%216 = or i32 %214, %215
%217 = load i32, i32* @O_CREAT
%218 = or i32 %216, %217
%219 = load i32, i32* @S_IRWXU
%220 = load i32, i32* @S_IRGRP
%221 = or i32 %219, %220
%222 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.19, i64 0, i64 0), i32 %218, i32 %221)
store i32 %222, i32* %6
%223 = load i32, i32* @STDOUT_FILENO
%224 = call i32 @close(i32 %223)
%225 = load i32, i32* @STDERR_FILENO
%226 = call i32 @close(i32 %225)
%227 = load i32, i32* %6
%228 = load i32, i32* @STDOUT_FILENO
%229 = call i32 @dup2(i32 %227, i32 %228)
%230 = load i32, i32* %6
%231 = load i32, i32* @STDERR_FILENO
%232 = call i32 @dup2(i32 %230, i32 %231)
%233 = load i8**, i8*** %13
%234 = getelementptr inbounds [1 x i8*], [1 x i8*]* %12, i64 0, i64 0
%235 = call i64 @execve(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8** %233, i8** %234)
%236 = icmp ne i64 %235, 0
br i1 %236, label %237, label %243
237: ; preds = %203
%238 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0))
%239 = load i32, i32* @stderr
%240 = call i32 (i32, i8*, ...) @fprintf(i32 %239, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.21, i64 0, i64 0))
%241 = load i32, i32* @EXIT_FAILURE
%242 = call i32 @exit(i32 %241)
unreachable
243: ; preds = %203
store i32 0, i32* %3
%244 = load i8*, i8** %10
%245 = load i32, i32* %3
ret i32 %245
}

LLVM IR (-O2):
%struct.flock = type { i64, i32, i64, i64, i32 }
@PATH_MAX = global i32 0
@.str = [38 x i8] c"/usr/local/linuxkit3/php7-zts/bin/php\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"File %s not found.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [34 x i8] c"/usr/local/linuxkit3/bin/main.php\00"
@.str.3 = [39 x i8] c"/usr/local/linuxkit3/run/linuxkit3.pid\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@S_IRWXU = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@F_WRLCK = global i8* null
@F_GETLK = global i32 0
@.str.4 = [8 x i8] c"fcntl()\00"
@F_UNLCK = global i64 0
@.str.5 = [76 x i8] c"Linux KIT 3 daemon is running, pid is %d.\0AStop it, please execute: %s stop\0A\00"
@.str.6 = [5 x i8] c"stop\00"
@SIGTERM = global i32 0
@.str.7 = [7 x i8] c"kill()\00"
@.str.8 = [13 x i8] c"Stop pid %d\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.9 = [8 x i8] c"restart\00"
@.str.10 = [21 x i8] c"Unsupport operation\0A\00"
@.str.11 = [36 x i8] c"Linux KIT 3 daemon is not running.\0A\00"
@SEEK_SET = global i32 0
@.str.12 = [43 x i8] c"Hi, i am Linux KIT 3 daemon, running for: \00"
@.str.14 = [7 x i8] c"fork()\00"
@.str.15 = [9 x i8] c"setsid()\00"
@F_SETLK = global i32 0
@.str.16 = [3 x i8] c"%d\00"
@.str.17 = [12 x i8] c"ftruncate()\00"
@.str.18 = [10 x i8] c"/dev/null\00"
@O_RDONLY = global i32 0
@STDIN_FILENO = global i32 0
@.str.19 = [40 x i8] c"/usr/local/linuxkit3/logs/linuxkit3.log\00"
@O_APPEND = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str.20 = [9 x i8] c"execve()\00"
@.str.21 = [41 x i8] c"Linux KIT 3 daemon start unsuccessfully\0A\00"
@str = [30 x i8] c"Staring Linux KIT 3 daemon...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1 x i8*]
%4 = alloca %struct.flock
%5 = load i32, i32* @PATH_MAX
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = bitcast [1 x i8*]* %3 to i8*
%9 = bitcast [1 x i8*]* %3 to i64*
store i64 0, i64* %9
%10 = tail call i64 @malloc(i32 24)
%11 = inttoptr i64 %10 to i8**
%12 = bitcast %struct.flock* %4 to i8*
%13 = call i32* @realpath(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %7)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = call i32* @realpath(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %20
%29 = load i32, i32* @O_CREAT
%30 = load i32, i32* @O_RDWR
%31 = or i32 %30, %29
%32 = load i32, i32* @S_IRWXU
%33 = load i32, i32* @S_IRGRP
%34 = or i32 %33, %32
%35 = load i32, i32* @S_IROTH
%36 = or i32 %34, %35
%37 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %31, i32 %36)
%38 = load i8*, i8** @F_WRLCK
%39 = ptrtoint i8* %38 to i64
%40 = getelementptr inbounds %struct.flock, %struct.flock* %4, i64 0, i32 0
store i64 %39, i64* %40
%41 = load i32, i32* @F_GETLK
%42 = call i64 @fcntl(i32 %37, i32 %41, %struct.flock* %4)
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %28
%45 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %28
%49 = load i64, i64* %40
%50 = load i64, i64* @F_UNLCK
%51 = icmp eq i64 %49, %50
%52 = icmp eq i32 %0, 1
br i1 %51, label %104, label %53
53: ; preds = %48
br i1 %52, label %54, label %62
54: ; preds = %53
%55 = load i32, i32* @stderr
%56 = getelementptr inbounds %struct.flock, %struct.flock* %4, i64 0, i32 1
%57 = load i32, i32* %56
%58 = load i8*, i8** %1
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.5, i64 0, i64 0), i32 %57, i8* %58)
%60 = load i32, i32* @EXIT_FAILURE
%61 = call i32 @exit(i32 %60)
unreachable
62: ; preds = %53
%63 = getelementptr inbounds i8*, i8** %1, i64 1
%64 = load i8*, i8** %63
%65 = call i32 @strcmp(i8* dereferenceable(1) %64, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %83
67: ; preds = %62
%68 = getelementptr inbounds %struct.flock, %struct.flock* %4, i64 0, i32 1
%69 = load i32, i32* %68
%70 = load i32, i32* @SIGTERM
%71 = call i64 @kill(i32 %69, i32 %70)
%72 = icmp slt i64 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %67
%74 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%75 = load i32, i32* @EXIT_FAILURE
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %67
%78 = call i32 @unlink(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%79 = load i32, i32* %68
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %79)
%81 = load i32, i32* @EXIT_SUCCESS
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %62
%84 = call i32 @strcmp(i8* dereferenceable(1) %64, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %99
86: ; preds = %83
%87 = getelementptr inbounds %struct.flock, %struct.flock* %4, i64 0, i32 1
%88 = load i32, i32* %87
%89 = load i32, i32* @SIGTERM
%90 = call i64 @kill(i32 %88, i32 %89)
%91 = icmp slt i64 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %86
%93 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%94 = load i32, i32* @EXIT_FAILURE
%95 = call i32 @exit(i32 %94)
unreachable
96: ; preds = %86
%97 = load i32, i32* %87
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %97)
br label %115
99: ; preds = %83
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%102 = load i32, i32* @EXIT_FAILURE
%103 = call i32 @exit(i32 %102)
unreachable
104: ; preds = %48
br i1 %52, label %115, label %105
105: ; preds = %104
%106 = getelementptr inbounds i8*, i8** %1, i64 1
%107 = load i8*, i8** %106
%108 = call i32 @strcmp(i8* dereferenceable(1) %107, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %115
110: ; preds = %105
%111 = load i32, i32* @stderr
%112 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.11, i64 0, i64 0))
%113 = load i32, i32* @EXIT_FAILURE
%114 = call i32 @exit(i32 %113)
unreachable
115: ; preds = %104, %105, %96
%116 = load i8*, i8** @F_WRLCK
%117 = ptrtoint i8* %116 to i64
store i64 %117, i64* %40
%118 = load i32, i32* @SEEK_SET
%119 = getelementptr inbounds %struct.flock, %struct.flock* %4, i64 0, i32 4
store i32 %118, i32* %119
%120 = getelementptr inbounds %struct.flock, %struct.flock* %4, i64 0, i32 2
%121 = bitcast i64* %120 to i8*
store i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i8** %11
%122 = getelementptr inbounds i8*, i8** %11, i64 1
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8** %122
%123 = getelementptr inbounds i8*, i8** %11, i64 2
store i8* null, i8** %123
%124 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%125 = call i32 (...) @fork()
switch i32 %125, label %130 [
i32 0, label %133
i32 -1, label %126
]
126: ; preds = %115
%127 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%128 = load i32, i32* @EXIT_FAILURE
%129 = call i32 @exit(i32 %128)
unreachable
130: ; preds = %115
%131 = load i32, i32* @EXIT_SUCCESS
%132 = call i32 @exit(i32 %131)
unreachable
133: ; preds = %115
%134 = call i32 (...) @setsid()
%135 = icmp eq i32 %134, -1
br i1 %135, label %136, label %140
136: ; preds = %133
%137 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0))
%138 = load i32, i32* @EXIT_FAILURE
%139 = call i32 @exit(i32 %138)
unreachable
140: ; preds = %133
%141 = call i32 (...) @fork()
switch i32 %141, label %146 [
i32 0, label %149
i32 -1, label %142
]
142: ; preds = %140
%143 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%144 = load i32, i32* @EXIT_FAILURE
%145 = call i32 @exit(i32 %144)
unreachable
146: ; preds = %140
%147 = load i32, i32* @EXIT_SUCCESS
%148 = call i32 @exit(i32 %147)
unreachable
149: ; preds = %140
%150 = load i32, i32* @F_SETLK
%151 = call i64 @fcntl(i32 %37, i32 %150, %struct.flock* %4)
%152 = icmp slt i64 %151, 0
br i1 %152, label %153, label %157
153: ; preds = %149
%154 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%155 = load i32, i32* @EXIT_FAILURE
%156 = call i32 @exit(i32 %155)
unreachable
157: ; preds = %149
%158 = call i32 (...) @getpid()
%159 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 %158)
%160 = call i64 @ftruncate(i32 %37, i32 0)
%161 = icmp slt i64 %160, 0
br i1 %161, label %162, label %166
162: ; preds = %157
%163 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0))
%164 = load i32, i32* @EXIT_FAILURE
%165 = call i32 @exit(i32 %164)
unreachable
166: ; preds = %157
%167 = call i32 @strlen(i8* %7)
%168 = call i32 @write(i32 %37, i8* %7, i32 %167)
%169 = load i32, i32* @O_RDONLY
%170 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i32 %169)
%171 = load i32, i32* @STDIN_FILENO
%172 = call i32 @close(i32 %171)
%173 = load i32, i32* @STDIN_FILENO
%174 = call i32 @dup2(i32 %170, i32 %173)
%175 = load i32, i32* @O_RDWR
%176 = load i32, i32* @O_APPEND
%177 = or i32 %176, %175
%178 = load i32, i32* @O_CREAT
%179 = or i32 %177, %178
%180 = load i32, i32* @S_IRWXU
%181 = load i32, i32* @S_IRGRP
%182 = or i32 %181, %180
%183 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.19, i64 0, i64 0), i32 %179, i32 %182)
%184 = load i32, i32* @STDOUT_FILENO
%185 = call i32 @close(i32 %184)
%186 = load i32, i32* @STDERR_FILENO
%187 = call i32 @close(i32 %186)
%188 = load i32, i32* @STDOUT_FILENO
%189 = call i32 @dup2(i32 %183, i32 %188)
%190 = load i32, i32* @STDERR_FILENO
%191 = call i32 @dup2(i32 %183, i32 %190)
%192 = getelementptr inbounds [1 x i8*], [1 x i8*]* %3, i64 0, i64 0
%193 = call i64 @execve(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8** %11, i8** %192)
%194 = icmp eq i64 %193, 0
br i1 %194, label %201, label %195
195: ; preds = %166
%196 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0))
%197 = load i32, i32* @stderr
%198 = call i32 (i32, i8*, ...) @fprintf(i32 %197, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.21, i64 0, i64 0))
%199 = load i32, i32* @EXIT_FAILURE
%200 = call i32 @exit(i32 %199)
unreachable
201: ; preds = %166
ret i32 0
}