#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*/ uid_t;
struct stat {
  int dummy;
};
struct passwd {
  char *pw_name;
};
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
scalar_t__ ESRCH;
scalar_t__ atoi(char *);
scalar_t__ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
scalar_t__ getpgrp();
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
scalar_t__ kill(scalar_t__, int /*<<< orphan*/);
char *optarg;
int optind;
int /*<<< orphan*/ setuid(int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, scalar_t__ *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strstr(char *, char *);
scalar_t__ unlink(char *);
int main(int argc, char *argv[]) {
  pid_t pid, oldpid;
  uid_t uid;
  struct passwd *pw;
  struct stat statbuf;
  FILE *fout;
  FILE *fin;
  char fName[1024], buf[1024], procName[1024];
  int removeLock = 0;
  int c;
  char *pChar;
  pid = getpgrp();
  uid = getuid();
  pw = getpwuid(uid);
  setuid(0);
  strcpy(fName, "/var/lock/");
  while ((c = getopt(argc, argv, "rhd:p:")) != EOF) {
    switch (c) {
    case 'd':
      strcpy(fName, optarg);
      break;
    case 'p':
      pid = atoi(optarg);
      break;
    case 'r':
      removeLock = 1;
      break;
    case 'h':
      fprintf(stdout, "%s\n\n", "lockport 1.0");
      fprintf(stdout, "usage : lockport [-r] [-d directory_name] [-p PID] port "
                      "[process_name]\n");
      fprintf(stdout, "-r  : remove a lock\n");
      fprintf(stdout, "-d  : directory for lock file\n");
      fprintf(stdout, "-p  : set PID to be written to file\n");
      fprintf(stdout, "-h  : print help\n");
      fprintf(stdout, "Note: process name required for creating a lock only\n");
      return 0;
      break;
    }
  }
  if (removeLock) {
    if (optind == argc - 1) {
      if (fName[strlen(fName) - 1] != '/')
        strcat(fName, "/");
      strcat(fName, "LCK..");
      if ((pChar = (char *)strstr(argv[argc - 1], "/dev/")) != NULL)
        pChar += 5;
      else
        pChar = argv[argc - 1];
      strcat(fName, pChar);
      if (unlink(fName) == 0) {
        fprintf(stdout, "1\n");
        return 0;
      } else {
        fprintf(stdout, "0\n");
        return 0;
      }
    } else {
      fprintf(stderr, "lockport(): wrong number of arguments\n");
      fprintf(stdout, "0\n");
      return 0;
    }
  } else {
    if (optind == argc - 2) {
      if (fName[strlen(fName) - 1] != '/')
        strcat(fName, "/");
      strcat(fName, "LCK..");
      if ((pChar = (char *)strstr(argv[argc - 2], "/dev/")) != NULL)
        pChar += 5;
      else
        pChar = argv[argc - 2];
      strcat(fName, pChar);
      strcpy(procName, argv[argc - 1]);
    } else {
      fprintf(stderr, "lockport(): wrong number of arguments\n");
      fprintf(stdout, "0\n");
      return 0;
    }
  }
  if (stat(fName, &statbuf) == 0) {
    fin = fopen(fName, "r");
    if (fin != NULL) {
      fgets(buf, 1024, fin);
      sscanf(buf, "%i %*s %*s", &oldpid);
      if ((oldpid > 0) && (kill(oldpid, 0) < 0) && (errno == ESRCH)) {
        unlink(fName);
      } else {
        fprintf(stdout, "0\n");
        return 0;
      }
    } else {
      fprintf(stdout, "0\n");
      return 0;
    }
  }
  fout = fopen(fName, "w");
  if (fout != NULL) {
    fprintf(fout, "%i %s %s", pid, procName, pw->pw_name);
    fclose(fout);
    fprintf(stdout, "1\n");
  } else
    fprintf(stdout, "0\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xc54(%rbp)
mov    $0x0,%al
call   10e0 <getpgrp@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1080 <getuid@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <getpwuid@plt>
mov    %rax,-0x30(%rbp)
xor    %edi,%edi
call   1130 <setuid@plt>
lea    -0x450(%rbp),%rdi
lea    0xdc3(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdbb(%rip),%rdx
call   1100 <getopt@plt>
mov    %eax,-0xc58(%rbp)
mov    0x2d42(%rip),%rcx
cmp    (%rcx),%eax
je     13d3 <main+0x1b3>
mov    -0xc58(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0xc68(%rbp)
sub    $0xe,%eax
ja     13ce <main+0x1ae>
mov    -0xc68(%rbp),%rax
lea    0xd31(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x450(%rbp),%rdi
mov    0x2d12(%rip),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
jmp    13ce <main+0x1ae>
mov    0x2cfe(%rip),%rax
mov    (%rax),%rdi
call   1110 <atoi@plt>
mov    %rax,-0x18(%rbp)
jmp    13ce <main+0x1ae>
movl   $0x1,-0xc54(%rbp)
jmp    13ce <main+0x1ae>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
lea    0xd24(%rip),%rsi
lea    0xd22(%rip),%rdx
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c79(%rip),%rax
mov    (%rax),%edi
lea    0xd18(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
lea    0xd49(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
lea    0xd47(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c34(%rip),%rax
mov    (%rax),%edi
lea    0xd4f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
lea    0xd5d(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c06(%rip),%rax
mov    (%rax),%edi
lea    0xd58(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1803 <main+0x5e3>
jmp    127e <main+0x5e>
cmpl   $0x0,-0xc54(%rbp)
je     1545 <main+0x325>
mov    0x2bf1(%rip),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    150b <main+0x2eb>
lea    -0x450(%rbp),%rdi
call   1070 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x450(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
je     142c <main+0x20c>
lea    -0x450(%rbp),%rdi
lea    0xc1e(%rip),%rsi
call   1120 <strcat@plt>
lea    -0x450(%rbp),%rdi
lea    0xd0f(%rip),%rsi
call   1120 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xcf8(%rip),%rsi
call   1140 <strstr@plt>
mov    %rax,-0xc60(%rbp)
cmp    $0x0,%rax
je     1484 <main+0x264>
mov    -0xc60(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0xc60(%rbp)
jmp    149c <main+0x27c>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0xc60(%rbp)
lea    -0x450(%rbp),%rdi
mov    -0xc60(%rbp),%rsi
call   1120 <strcat@plt>
lea    -0x450(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jne    14e8 <main+0x2c8>
mov    0x2aec(%rip),%rax
mov    (%rax),%edi
lea    0xc80(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1803 <main+0x5e3>
mov    0x2ac9(%rip),%rax
mov    (%rax),%edi
lea    0xc60(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1803 <main+0x5e3>
mov    0x2ab6(%rip),%rax
mov    (%rax),%edi
lea    0xc40(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2a8f(%rip),%rax
mov    (%rax),%edi
lea    0xc26(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1803 <main+0x5e3>
mov    0x2a8c(%rip),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jne    1636 <main+0x416>
lea    -0x450(%rbp),%rdi
call   1070 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x450(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
je     1591 <main+0x371>
lea    -0x450(%rbp),%rdi
lea    0xab9(%rip),%rsi
call   1120 <strcat@plt>
lea    -0x450(%rbp),%rdi
lea    0xbaa(%rip),%rsi
call   1120 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xb93(%rip),%rsi
call   1140 <strstr@plt>
mov    %rax,-0xc60(%rbp)
cmp    $0x0,%rax
je     15e9 <main+0x3c9>
mov    -0xc60(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0xc60(%rbp)
jmp    1601 <main+0x3e1>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0xc60(%rbp)
lea    -0x450(%rbp),%rdi
mov    -0xc60(%rbp),%rsi
call   1120 <strcat@plt>
lea    -0xc50(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcpy@plt>
jmp    1670 <main+0x450>
mov    0x298b(%rip),%rax
mov    (%rax),%edi
lea    0xb15(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2964(%rip),%rax
mov    (%rax),%edi
lea    0xafb(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1803 <main+0x5e3>
jmp    1675 <main+0x455>
lea    -0x450(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0x0,%rax
jne    1778 <main+0x558>
lea    -0x450(%rbp),%rdi
lea    0xae5(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1750 <main+0x530>
lea    -0x850(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    $0x400,%esi
call   1090 <fgets@plt>
lea    -0x850(%rbp),%rdi
lea    0xab0(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   10d0 <sscanf@plt>
cmpq   $0x0,-0x20(%rbp)
jle    1728 <main+0x508>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   10c0 <kill@plt>
cmp    $0x0,%rax
jge    1728 <main+0x508>
mov    0x28bc(%rip),%rax
mov    (%rax),%rax
mov    0x289a(%rip),%rcx
cmp    (%rcx),%rax
jne    1728 <main+0x508>
lea    -0x450(%rbp),%rdi
call   1030 <unlink@plt>
jmp    174b <main+0x52b>
mov    0x2889(%rip),%rax
mov    (%rax),%edi
lea    0xa20(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1803 <main+0x5e3>
jmp    1773 <main+0x553>
mov    0x2861(%rip),%rax
mov    (%rax),%edi
lea    0x9f8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1803 <main+0x5e3>
jmp    1778 <main+0x558>
lea    -0x450(%rbp),%rdi
lea    0xa09(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     17e5 <main+0x5c5>
mov    -0x40(%rbp),%rax
mov    %eax,%edi
mov    -0x18(%rbp),%rdx
lea    -0xc50(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    (%rax),%r8
lea    0x9d8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x27e8(%rip),%rax
mov    (%rax),%edi
lea    0x97c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    17fc <main+0x5dc>
mov    0x27cc(%rip),%rax
mov    (%rax),%edi
lea    0x963(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc28,%rsp
mov    %rsi,%r12
mov    %edi,%ebx
xor    %eax,%eax
call   10e0 <getpgrp@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1080 <getuid@plt>
mov    %eax,%edi
call   1060 <getpwuid@plt>
mov    %rax,%r13
xor    %edi,%edi
call   1130 <setuid@plt>
lea    0xdc1(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1040 <strcpy@plt>
lea    0xdbb(%rip),%rdx
mov    %ebx,%edi
mov    %r12,%rsi
call   1100 <getopt@plt>
mov    0x2d5f(%rip),%r15
cmp    (%r15),%eax
je     1388 <main+0x168>
movl   $0x0,0x4(%rsp)
mov    %r13,0x8(%rsp)
mov    %r14,%r13
lea    0xd8a(%rip),%r14
lea    0xd58(%rip),%rbp
jmp    12d6 <main+0xb6>
nopw   0x0(%rax,%rax,1)
mov    0x2d41(%rip),%rax
mov    (%rax),%rsi
lea    0x20(%rsp),%rdi
call   1040 <strcpy@plt>
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r14,%rdx
call   1100 <getopt@plt>
cmp    (%r15),%eax
je     130a <main+0xea>
add    $0xffffff9c,%eax
ror    %eax
cmp    $0x7,%eax
ja     12c4 <main+0xa4>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    0x2d07(%rip),%rax
mov    (%rax),%rdi
call   1110 <atoi@plt>
mov    %rax,%r13
jmp    12c4 <main+0xa4>
xchg   %ax,%ax
movl   $0x1,0x4(%rsp)
jmp    12c4 <main+0xa4>
cmpl   $0x0,0x4(%rsp)
mov    %r13,%r14
mov    0x8(%rsp),%r13
je     1388 <main+0x168>
mov    0x2cb8(%rip),%rax
movslq (%rax),%rbp
add    $0xffffffff,%ebx
cmp    %ebx,%ebp
jne    13ed <main+0x1cd>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
je     1355 <main+0x135>
lea    0xcde(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1120 <strcat@plt>
lea    0xdd1(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1120 <strcat@plt>
mov    (%r12,%rbp,8),%rdi
lea    0xdc2(%rip),%rsi
call   1140 <strstr@plt>
test   %rax,%rax
je     15c8 <main+0x3a8>
add    $0x5,%rax
jmp    15cc <main+0x3ac>
mov    0x2c49(%rip),%rax
movslq (%rax),%r15
lea    -0x2(%rbx),%eax
cmp    %eax,%r15d
jne    13ed <main+0x1cd>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbp,1)
je     13c1 <main+0x1a1>
lea    0xc72(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1120 <strcat@plt>
lea    0xd65(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1120 <strcat@plt>
mov    (%r12,%r15,8),%rdi
lea    0xd56(%rip),%rsi
call   1140 <strstr@plt>
test   %rax,%rax
je     142f <main+0x20f>
add    $0x5,%rax
jmp    1433 <main+0x213>
mov    0x2bd4(%rip),%rax
mov    (%rax),%edi
lea    0xd42(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2bad(%rip),%rax
mov    (%rax),%edi
lea    0xd28(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
add    $0xc28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r12,%r15,8),%rax
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %rax,%rsi
call   1120 <strcat@plt>
movslq %ebx,%rax
mov    -0x8(%r12,%rax,8),%rsi
lea    0x420(%rsp),%rdi
call   1040 <strcpy@plt>
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
call   10b0 <stat@plt>
test   %rax,%rax
je     14bf <main+0x29f>
lea    0xd02(%rip),%rsi
lea    0x20(%rsp),%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1404 <main+0x1e4>
mov    %rax,%rbx
mov    0x0(%r13),%r8
lea    0xce7(%rip),%rsi
lea    0x420(%rsp),%rcx
mov    %ebx,%edi
mov    %r14,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x2b07(%rip),%rax
mov    (%rax),%edi
lea    0xc7f(%rip),%rsi
jmp    1414 <main+0x1f4>
lea    0xca0(%rip),%rsi
lea    0x20(%rsp),%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1404 <main+0x1e4>
lea    0x820(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
lea    0xc70(%rip),%rsi
lea    0x18(%rsp),%rdx
mov    %rbx,%rdi
call   10d0 <sscanf@plt>
mov    0x18(%rsp),%rdi
test   %rdi,%rdi
jle    1404 <main+0x1e4>
xor    %esi,%esi
call   10c0 <kill@plt>
test   %rax,%rax
jns    1404 <main+0x1e4>
mov    0x2a96(%rip),%rax
mov    (%rax),%rax
mov    0x2a74(%rip),%rcx
cmp    (%rcx),%rax
jne    1404 <main+0x1e4>
lea    0x20(%rsp),%rdi
call   1030 <unlink@plt>
jmp    146a <main+0x24a>
mov    0x2a65(%rip),%rbx
mov    (%rbx),%edi
lea    0xad6(%rip),%rsi
lea    0xad4(%rip),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xad1(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xb09(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xb0e(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xb1d(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xb32(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xb34(%rip),%rsi
jmp    1414 <main+0x1f4>
mov    (%r12,%rbp,8),%rax
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1120 <strcat@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0x29cd(%rip),%rcx
mov    (%rcx),%edi
test   %rax,%rax
jne    140d <main+0x1ed>
lea    0xb3c(%rip),%rsi
jmp    1414 <main+0x1f4>

LLVM IR (-O0):
%struct.passwd = type { i8* }
%struct.stat = type { i32 }
@.str = [11 x i8] c"/var/lock/\00"
@.str.1 = [7 x i8] c"rhd:p:\00"
@EOF = global i32 0
@optarg = global i8* null
@stdout = global i32 0
@.str.2 = [5 x i8] c"%s\0A\0A\00"
@.str.3 = [13 x i8] c"lockport 1.0\00"
@.str.4 = [72 x i8] c"usage : lockport [-r] [-d directory_name] [-p PID] port [process_name]\0A\00"
@.str.5 = [21 x i8] c"-r : remove a lock\0A\00"
@.str.6 = [31 x i8] c"-d : directory for lock file\0A\00"
@.str.7 = [37 x i8] c"-p : set PID to be written to file\0A\00"
@.str.8 = [18 x i8] c"-h : print help\0A\00"
@.str.9 = [54 x i8] c"Note: process name required for creating a lock only\0A\00"
@optind = global i32 0
@.str.10 = [2 x i8] c"/\00"
@.str.11 = [6 x i8] c"LCK..\00"
@.str.12 = [6 x i8] c"/dev/\00"
@.str.13 = [3 x i8] c"1\0A\00"
@.str.14 = [3 x i8] c"0\0A\00"
@stderr = global i32 0
@.str.15 = [39 x i8] c"lockport(): wrong number of arguments\0A\00"
@.str.16 = [2 x i8] c"r\00"
@.str.17 = [11 x i8] c"%i %*s %*s\00"
@errno = global i64 0
@ESRCH = global i64 0
@.str.18 = [2 x i8] c"w\00"
@.str.19 = [9 x i8] c"%i %s %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca %struct.passwd*
%10 = alloca %struct.stat
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca [1024 x i8]
%14 = alloca [1024 x i8]
%15 = alloca [1024 x i8]
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %16
%19 = call i64 (...) @getpgrp()
store i64 %19, i64* %6
%20 = call i32 (...) @getuid()
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = call %struct.passwd* @getpwuid(i32 %21)
store %struct.passwd* %22, %struct.passwd** %9
%23 = call i32 @setuid(i32 0)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%25 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %57, %2
%27 = load i32, i32* %4
%28 = load i8**, i8*** %5
%29 = call i32 @getopt(i32 %27, i8** %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 %29, i32* %17
%30 = load i32, i32* @EOF
%31 = icmp ne i32 %29, %30
br i1 %31, label %32, label %58
32: ; preds = %26
%33 = load i32, i32* %17
switch i32 %33, label %57 [
i32 100, label %34
i32 112, label %38
i32 114, label %41
i32 104, label %42
]
34: ; preds = %32
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%36 = load i8*, i8** @optarg
%37 = call i32 @strcpy(i8* %35, i8* %36)
br label %57
38: ; preds = %32
%39 = load i8*, i8** @optarg
%40 = call i64 @atoi(i8* %39)
store i64 %40, i64* %6
br label %57
41: ; preds = %32
store i32 1, i32* %16
br label %57
42: ; preds = %32
%43 = load i32, i32* @stdout
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%45 = load i32, i32* @stdout
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.4, i64 0, i64 0))
%47 = load i32, i32* @stdout
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%49 = load i32, i32* @stdout
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%51 = load i32, i32* @stdout
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
%53 = load i32, i32* @stdout
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%55 = load i32, i32* @stdout
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %233
57: ; preds = %32, %41, %38, %34
br label %26
58: ; preds = %26
%59 = load i32, i32* %16
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %118
61: ; preds = %58
%62 = load i32, i32* @optind
%63 = load i32, i32* %4
%64 = sub nsw i32 %63, 1
%65 = icmp eq i32 %62, %64
br i1 %65, label %66, label %113
66: ; preds = %61
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%68 = call i32 @strlen(i8* %67)
%69 = sub nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp ne i32 %73, 47
br i1 %74, label %75, label %78
75: ; preds = %66
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%77 = call i32 @strcat(i8* %76, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %78
78: ; preds = %75, %66
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%80 = call i32 @strcat(i8* %79, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%81 = load i8**, i8*** %5
%82 = load i32, i32* %4
%83 = sub nsw i32 %82, 1
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8*, i8** %81, i64 %84
%86 = load i8*, i8** %85
%87 = call i64 @strstr(i8* %86, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%88 = inttoptr i64 %87 to i8*
store i8* %88, i8** %18
%89 = icmp ne i8* %88, null
br i1 %89, label %90, label %93
90: ; preds = %78
%91 = load i8*, i8** %18
%92 = getelementptr inbounds i8, i8* %91, i64 5
store i8* %92, i8** %18
br label %100
93: ; preds = %78
%94 = load i8**, i8*** %5
%95 = load i32, i32* %4
%96 = sub nsw i32 %95, 1
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8*, i8** %94, i64 %97
%99 = load i8*, i8** %98
store i8* %99, i8** %18
br label %100
100: ; preds = %93, %90
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%102 = load i8*, i8** %18
%103 = call i32 @strcat(i8* %101, i8* %102)
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%105 = call i64 @unlink(i8* %104)
%106 = icmp eq i64 %105, 0
br i1 %106, label %107, label %110
107: ; preds = %100
%108 = load i32, i32* @stdout
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %3
br label %233
110: ; preds = %100
%111 = load i32, i32* @stdout
%112 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %3
br label %233
113: ; preds = %61
%114 = load i32, i32* @stderr
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.15, i64 0, i64 0))
%116 = load i32, i32* @stdout
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %3
br label %233
118: ; preds = %58
%119 = load i32, i32* @optind
%120 = load i32, i32* %4
%121 = sub nsw i32 %120, 2
%122 = icmp eq i32 %119, %121
br i1 %122, label %123, label %169
123: ; preds = %118
%124 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%125 = call i32 @strlen(i8* %124)
%126 = sub nsw i32 %125, 1
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %127
%129 = load i8, i8* %128
%130 = sext i8 %129 to i32
%131 = icmp ne i32 %130, 47
br i1 %131, label %132, label %135
132: ; preds = %123
%133 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%134 = call i32 @strcat(i8* %133, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %135
135: ; preds = %132, %123
%136 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%137 = call i32 @strcat(i8* %136, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%138 = load i8**, i8*** %5
%139 = load i32, i32* %4
%140 = sub nsw i32 %139, 2
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i8*, i8** %138, i64 %141
%143 = load i8*, i8** %142
%144 = call i64 @strstr(i8* %143, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%145 = inttoptr i64 %144 to i8*
store i8* %145, i8** %18
%146 = icmp ne i8* %145, null
br i1 %146, label %147, label %150
147: ; preds = %135
%148 = load i8*, i8** %18
%149 = getelementptr inbounds i8, i8* %148, i64 5
store i8* %149, i8** %18
br label %157
150: ; preds = %135
%151 = load i8**, i8*** %5
%152 = load i32, i32* %4
%153 = sub nsw i32 %152, 2
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds i8*, i8** %151, i64 %154
%156 = load i8*, i8** %155
store i8* %156, i8** %18
br label %157
157: ; preds = %150, %147
%158 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%159 = load i8*, i8** %18
%160 = call i32 @strcat(i8* %158, i8* %159)
%161 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%162 = load i8**, i8*** %5
%163 = load i32, i32* %4
%164 = sub nsw i32 %163, 1
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds i8*, i8** %162, i64 %165
%167 = load i8*, i8** %166
%168 = call i32 @strcpy(i8* %161, i8* %167)
br label %174
169: ; preds = %118
%170 = load i32, i32* @stderr
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %170, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.15, i64 0, i64 0))
%172 = load i32, i32* @stdout
%173 = call i32 (i32, i8*, ...) @fprintf(i32 %172, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %3
br label %233
174: ; preds = %157
br label %175
175: ; preds = %174
%176 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%177 = call i64 @stat(i8* %176, %struct.stat* %10)
%178 = icmp eq i64 %177, 0
br i1 %178, label %179, label %211
179: ; preds = %175
%180 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%181 = call i32* @fopen(i8* %180, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
store i32* %181, i32** %12
%182 = load i32*, i32** %12
%183 = icmp ne i32* %182, null
br i1 %183, label %184, label %207
184: ; preds = %179
%185 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%186 = load i32*, i32** %12
%187 = call i32 @fgets(i8* %185, i32 1024, i32* %186)
%188 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%189 = call i32 @sscanf(i8* %188, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.17, i64 0, i64 0), i64* %7)
%190 = load i64, i64* %7
%191 = icmp sgt i64 %190, 0
br i1 %191, label %192, label %203
192: ; preds = %184
%193 = load i64, i64* %7
%194 = call i64 @kill(i64 %193, i32 0)
%195 = icmp slt i64 %194, 0
br i1 %195, label %196, label %203
196: ; preds = %192
%197 = load i64, i64* @errno
%198 = load i64, i64* @ESRCH
%199 = icmp eq i64 %197, %198
br i1 %199, label %200, label %203
200: ; preds = %196
%201 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%202 = call i64 @unlink(i8* %201)
br label %206
203: ; preds = %196, %192, %184
%204 = load i32, i32* @stdout
%205 = call i32 (i32, i8*, ...) @fprintf(i32 %204, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %3
br label %233
206: ; preds = %200
br label %210
207: ; preds = %179
%208 = load i32, i32* @stdout
%209 = call i32 (i32, i8*, ...) @fprintf(i32 %208, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %3
br label %233
210: ; preds = %206
br label %211
211: ; preds = %210, %175
%212 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%213 = call i32* @fopen(i8* %212, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
store i32* %213, i32** %11
%214 = load i32*, i32** %11
%215 = icmp ne i32* %214, null
br i1 %215, label %216, label %229
216: ; preds = %211
%217 = load i32*, i32** %11
%218 = ptrtoint i32* %217 to i32
%219 = load i64, i64* %6
%220 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%221 = load %struct.passwd*, %struct.passwd** %9
%222 = getelementptr inbounds %struct.passwd, %struct.passwd* %221, i32 0, i32 0
%223 = load i8*, i8** %222
%224 = call i32 (i32, i8*, ...) @fprintf(i32 %218, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0), i64 %219, i8* %220, i8* %223)
%225 = load i32*, i32** %11
%226 = call i32 @fclose(i32* %225)
%227 = load i32, i32* @stdout
%228 = call i32 (i32, i8*, ...) @fprintf(i32 %227, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
br label %232
229: ; preds = %211
%230 = load i32, i32* @stdout
%231 = call i32 (i32, i8*, ...) @fprintf(i32 %230, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
br label %232
232: ; preds = %229, %216
store i32 0, i32* %3
br label %233
233: ; preds = %232, %207, %203, %169, %113, %110, %107, %42
%234 = load i32, i32* %3
ret i32 %234
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.passwd = type { i8* }
@.str = [11 x i8] c"/var/lock/\00"
@.str.1 = [7 x i8] c"rhd:p:\00"
@EOF = global i32 0
@optarg = global i8* null
@stdout = global i32 0
@.str.2 = [5 x i8] c"%s\0A\0A\00"
@.str.3 = [13 x i8] c"lockport 1.0\00"
@.str.4 = [72 x i8] c"usage : lockport [-r] [-d directory_name] [-p PID] port [process_name]\0A\00"
@.str.5 = [21 x i8] c"-r : remove a lock\0A\00"
@.str.6 = [31 x i8] c"-d : directory for lock file\0A\00"
@.str.7 = [37 x i8] c"-p : set PID to be written to file\0A\00"
@.str.8 = [18 x i8] c"-h : print help\0A\00"
@.str.9 = [54 x i8] c"Note: process name required for creating a lock only\0A\00"
@optind = global i32 0
@.str.10 = [2 x i8] c"/\00"
@.str.11 = [6 x i8] c"LCK..\00"
@.str.12 = [6 x i8] c"/dev/\00"
@.str.13 = [3 x i8] c"1\0A\00"
@.str.14 = [3 x i8] c"0\0A\00"
@stderr = global i32 0
@.str.15 = [39 x i8] c"lockport(): wrong number of arguments\0A\00"
@.str.16 = [2 x i8] c"r\00"
@.str.17 = [11 x i8] c"%i %*s %*s\00"
@errno = global i64 0
@ESRCH = global i64 0
@.str.18 = [2 x i8] c"w\00"
@.str.19 = [9 x i8] c"%i %s %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i64
%4 = alloca %struct.stat
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = bitcast i64* %3 to i8*
%9 = bitcast %struct.stat* %4 to i8*
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%13 = tail call i64 (...) @getpgrp()
%14 = tail call i32 (...) @getuid()
%15 = tail call %struct.passwd* @getpwuid(i32 %14)
%16 = tail call i32 @setuid(i32 0)
%17 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %97, label %21
21: ; preds = %2, %49
%22 = phi i32 [ %52, %49 ], [ %18, %2 ]
%23 = phi i32 [ %51, %49 ], [ 0, %2 ]
%24 = phi i64 [ %50, %49 ], [ %13, %2 ]
%25 = add i32 %22, -100
%26 = call i32 @llvm.fshl.i32(i32 %25, i32 %25, i32 31)
switch i32 %26, label %49 [
i32 0, label %27
i32 6, label %30
i32 7, label %33
i32 2, label %34
]
27: ; preds = %21
%28 = load i8*, i8** @optarg
%29 = call i32 @strcpy(i8* %10, i8* %28)
br label %49
30: ; preds = %21
%31 = load i8*, i8** @optarg
%32 = call i64 @atoi(i8* %31)
br label %49
33: ; preds = %21
br label %49
34: ; preds = %21
%35 = load i32, i32* @stdout
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* @stdout
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.4, i64 0, i64 0))
%39 = load i32, i32* @stdout
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%41 = load i32, i32* @stdout
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%43 = load i32, i32* @stdout
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
%45 = load i32, i32* @stdout
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%47 = load i32, i32* @stdout
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.9, i64 0, i64 0))
br label %176
49: ; preds = %21, %33, %30, %27
%50 = phi i64 [ %24, %21 ], [ %24, %33 ], [ %32, %30 ], [ %24, %27 ]
%51 = phi i32 [ %23, %21 ], [ 1, %33 ], [ %23, %30 ], [ %23, %27 ]
%52 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%53 = load i32, i32* @EOF
%54 = icmp eq i32 %52, %53
br i1 %54, label %55, label %21
55: ; preds = %49
%56 = icmp eq i32 %51, 0
br i1 %56, label %97, label %57
57: ; preds = %55
%58 = load i32, i32* @optind
%59 = add nsw i32 %0, -1
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %92
61: ; preds = %57
%62 = call i32 @strlen(i8* %10)
%63 = add nsw i32 %62, -1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = icmp eq i8 %66, 47
br i1 %67, label %70, label %68
68: ; preds = %61
%69 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %70
70: ; preds = %68, %61
%71 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%72 = sext i32 %58 to i64
%73 = getelementptr inbounds i8*, i8** %1, i64 %72
%74 = load i8*, i8** %73
%75 = call i64 @strstr(i8* %74, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %80, label %77
77: ; preds = %70
%78 = inttoptr i64 %75 to i8*
%79 = getelementptr inbounds i8, i8* %78, i64 5
br label %82
80: ; preds = %70
%81 = load i8*, i8** %73
br label %82
82: ; preds = %80, %77
%83 = phi i8* [ %79, %77 ], [ %81, %80 ]
%84 = call i32 @strcat(i8* %10, i8* %83)
%85 = call i64 @unlink(i8* %10)
%86 = icmp eq i64 %85, 0
%87 = load i32, i32* @stdout
br i1 %86, label %88, label %90
88: ; preds = %82
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
br label %176
90: ; preds = %82
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
br label %176
92: ; preds = %57
%93 = load i32, i32* @stderr
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.15, i64 0, i64 0))
%95 = load i32, i32* @stdout
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
br label %176
97: ; preds = %2, %55
%98 = phi i64 [ %50, %55 ], [ %13, %2 ]
%99 = load i32, i32* @optind
%100 = add nsw i32 %0, -2
%101 = icmp eq i32 %99, %100
br i1 %101, label %102, label %133
102: ; preds = %97
%103 = call i32 @strlen(i8* %10)
%104 = add nsw i32 %103, -1
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %105
%107 = load i8, i8* %106
%108 = icmp eq i8 %107, 47
br i1 %108, label %111, label %109
109: ; preds = %102
%110 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %111
111: ; preds = %109, %102
%112 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%113 = sext i32 %99 to i64
%114 = getelementptr inbounds i8*, i8** %1, i64 %113
%115 = load i8*, i8** %114
%116 = call i64 @strstr(i8* %115, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%117 = icmp eq i64 %116, 0
br i1 %117, label %121, label %118
118: ; preds = %111
%119 = inttoptr i64 %116 to i8*
%120 = getelementptr inbounds i8, i8* %119, i64 5
br label %123
121: ; preds = %111
%122 = load i8*, i8** %114
br label %123
123: ; preds = %121, %118
%124 = phi i8* [ %120, %118 ], [ %122, %121 ]
%125 = call i32 @strcat(i8* %10, i8* %124)
%126 = add nsw i32 %0, -1
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i8*, i8** %1, i64 %127
%129 = load i8*, i8** %128
%130 = call i32 @strcpy(i8* %12, i8* %129)
%131 = call i64 @stat(i8* %10, %struct.stat* %4)
%132 = icmp eq i64 %131, 0
br i1 %132, label %138, label %161
133: ; preds = %97
%134 = load i32, i32* @stderr
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.15, i64 0, i64 0))
%136 = load i32, i32* @stdout
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %136, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
br label %176
138: ; preds = %123
%139 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%140 = icmp eq i32* %139, null
br i1 %140, label %158, label %141
141: ; preds = %138
%142 = call i32 @fgets(i8* %11, i32 1024, i32* %139)
%143 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.17, i64 0, i64 0), i64* %3)
%144 = load i64, i64* %3
%145 = icmp sgt i64 %144, 0
br i1 %145, label %146, label %155
146: ; preds = %141
%147 = call i64 @kill(i64 %144, i32 0)
%148 = icmp slt i64 %147, 0
br i1 %148, label %149, label %155
149: ; preds = %146
%150 = load i64, i64* @errno
%151 = load i64, i64* @ESRCH
%152 = icmp eq i64 %150, %151
br i1 %152, label %153, label %155
153: ; preds = %149
%154 = call i64 @unlink(i8* %10)
br label %161
155: ; preds = %149, %146, %141
%156 = load i32, i32* @stdout
%157 = call i32 (i32, i8*, ...) @fprintf(i32 %156, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
br label %176
158: ; preds = %138
%159 = load i32, i32* @stdout
%160 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
br label %176
161: ; preds = %153, %123
%162 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%163 = icmp eq i32* %162, null
br i1 %163, label %173, label %164
164: ; preds = %161
%165 = ptrtoint i32* %162 to i64
%166 = trunc i64 %165 to i32
%167 = getelementptr inbounds %struct.passwd, %struct.passwd* %15, i64 0, i32 0
%168 = load i8*, i8** %167
%169 = call i32 (i32, i8*, ...) @fprintf(i32 %166, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0), i64 %98, i8* %12, i8* %168)
%170 = call i32 @fclose(i32* %162)
%171 = load i32, i32* @stdout
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %171, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
br label %176
173: ; preds = %161
%174 = load i32, i32* @stdout
%175 = call i32 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
br label %176
176: ; preds = %164, %173, %158, %155, %133, %92, %90, %88, %34
ret i32 0
}