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

/* Variables and functions */
scalar_t__ EINTR;
int O_CREAT;
int O_EXCL;
int O_NOCTTY;
int O_RDWR;
int chdir(char *);
int close(int);
int /*<<< orphan*/ cwrite(int, char *, int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fsync(int);
char *getenv(char *);
scalar_t__ getpid();
char *hostname();
char *malloc(int);
int open(char *, int, int);
int read(int /*<<< orphan*/, char *, int);
int rename(char *, char *);
char *rp_srs_fix(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int strlen(char *);
scalar_t__ time(int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char *);
int main(int argc, char *argv[]) {
  char buffer[32770];
  char *p, *x, *y, *rp, *dt;
  int fd, r;
  if (argc == 1) {
    fprintf(stderr, "Usage: %s dir/. < message\n", argv[0]);
    exit(1);
  }
  if (chdir(argv[1]) == -1) {
    fprintf(stderr, "Can't chdir(%s): %s\n", argv[1], strerror(errno));
    exit(111);
  }
  rp = rp_srs_fix(getenv("RPLINE"));
  dt = getenv("DTLINE");
  x = hostname();
  if (!x) {
    fprintf(stderr, "Can't determine hostname: %s\n", strerror(errno));
    exit(111);
  }
  for (p = x; *p; p++) {
    if (*p <= 32 || *p >= 127) {
      *p = 0;
      break;
    }
  }
  y = malloc(strlen(x) + 128);
  if (!y) {
    fprintf(stderr, "malloc(%d): %s\n", (int)(strlen(x) + 128),
            strerror(errno));
    exit(111);
  }
  sprintf(y, "tmp/%lu.%ld.%s", (unsigned long)time(0), (long int)getpid(), x);
  x = malloc(strlen(y));
  if (!x) {
    fprintf(stderr, "malloc(%d): %s\n", (int)strlen(y), strerror(errno));
    exit(111);
  }
  sprintf(x, "new%s", y + 3);
  fd = open(y, O_CREAT | O_RDWR | O_NOCTTY | O_EXCL, 0666);
  if (fd == -1) {
    fprintf(stderr, "creat(%s): %s\n", y, strerror(errno));
    exit(111);
  }
  if (rp && !cwrite(fd, rp, strlen(rp))) {
    fprintf(stderr, "rpwrite(): %s\n", strerror(errno));
    close(fd);
    unlink(y);
    exit(111);
  }
  if (dt && !cwrite(fd, dt, strlen(dt))) {
    fprintf(stderr, "rpwrite(): %s\n", strerror(errno));
    close(fd);
    unlink(y);
    exit(111);
  }
  for (;;) {
    do {
      r = read(0, buffer, sizeof(buffer) - 2);
    } while (r == -1 && (errno == EINTR));
    if (r == -1) {
      fprintf(stderr, "read(): %s\n", strerror(errno));
      close(fd);
      unlink(y);
      exit(111);
    }
    if (r == 0)
      break;
    if (!cwrite(fd, buffer, r)) {
      fprintf(stderr, "write(): %s\n", strerror(errno));
      close(fd);
      unlink(y);
      exit(111);
    }
  }
  if (fsync(fd) == -1) {
    fprintf(stderr, "fsync(): %s\n", strerror(errno));
    close(fd);
    unlink(y);
    exit(111);
  }
  if (close(fd) == -1) {
    fprintf(stderr, "close(): %s\n", strerror(errno));
    unlink(y);
    exit(111);
  }
  for (p = x; *p; p++) {
    if (*p <= 32 || *p >= 127) {
      *p = 0;
      break;
    }
  }
  for (p = y; *p; p++) {
    if (*p <= 32 || *p >= 127) {
      *p = 0;
      break;
    }
  }
  if (rename(y, x) == -1) {
    fprintf(stderr, "rename(): %s\n", strerror(errno));
    unlink(y);
    exit(111);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    127b <main+0x4b>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd96(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <chdir@plt>
cmp    $0xffffffff,%eax
jne    12e6 <main+0xb6>
mov    0x2d30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x805c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8058(%rbp)
mov    0x2d02(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x805c(%rbp),%edi
mov    -0x8058(%rbp),%rdx
mov    %rax,%rcx
lea    0xd46(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
lea    0xd43(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10d0 <rp_srs_fix@plt>
mov    %rax,-0x8040(%rbp)
lea    0xd2f(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8048(%rbp)
mov    $0x0,%al
call   10f0 <hostname@plt>
mov    %rax,-0x8030(%rbp)
cmpq   $0x0,-0x8030(%rbp)
jne    136f <main+0x13f>
mov    0x2c91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8060(%rbp)
mov    0x2c72(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x8060(%rbp),%edi
mov    %rax,%rdx
lea    0xce0(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
mov    -0x8030(%rbp),%rax
mov    %rax,-0x8028(%rbp)
mov    -0x8028(%rbp),%rax
cmpb   $0x0,(%rax)
je     13de <main+0x1ae>
mov    -0x8028(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jle    13b3 <main+0x183>
mov    -0x8028(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7f,%eax
jl     13c2 <main+0x192>
mov    -0x8028(%rbp),%rax
movb   $0x0,(%rax)
jmp    13de <main+0x1ae>
jmp    13c7 <main+0x197>
mov    -0x8028(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8028(%rbp)
jmp    137d <main+0x14d>
mov    -0x8030(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
add    $0x80,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x8038(%rbp)
cmpq   $0x0,-0x8038(%rbp)
jne    1468 <main+0x238>
mov    0x2bb5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8068(%rbp)
mov    -0x8030(%rbp),%rdi
call   1070 <strlen@plt>
add    $0x80,%eax
mov    %eax,-0x8064(%rbp)
mov    0x2b7f(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x8068(%rbp),%edi
mov    -0x8064(%rbp),%edx
mov    %rax,%rcx
lea    0xc05(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
mov    -0x8038(%rbp),%rax
mov    %rax,-0x8078(%rbp)
xor    %edi,%edi
call   10c0 <time@plt>
mov    %rax,-0x8070(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0x8078(%rbp),%rdi
mov    -0x8070(%rbp),%rdx
mov    %rax,%rcx
mov    -0x8030(%rbp),%r8
lea    0xbc2(%rip),%rsi
mov    $0x0,%al
call   1130 <sprintf@plt>
mov    -0x8038(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x8030(%rbp)
cmpq   $0x0,-0x8030(%rbp)
jne    1530 <main+0x300>
mov    0x2ae8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8080(%rbp)
mov    -0x8038(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0x807c(%rbp)
mov    0x2ab7(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x8080(%rbp),%edi
mov    -0x807c(%rbp),%edx
mov    %rax,%rcx
lea    0xb3d(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
mov    -0x8030(%rbp),%rdi
mov    -0x8038(%rbp),%rdx
add    $0x3,%rdx
lea    0xb32(%rip),%rsi
mov    $0x0,%al
call   1130 <sprintf@plt>
mov    -0x8038(%rbp),%rdi
mov    0x2a9a(%rip),%rax
mov    (%rax),%esi
mov    0x2a79(%rip),%rax
or     (%rax),%esi
mov    0x2a60(%rip),%rax
or     (%rax),%esi
mov    0x2a47(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   1110 <open@plt>
mov    %eax,-0x804c(%rbp)
cmpl   $0xffffffff,-0x804c(%rbp)
jne    15ec <main+0x3bc>
mov    0x2a29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x808c(%rbp)
mov    -0x8038(%rbp),%rax
mov    %rax,-0x8088(%rbp)
mov    0x29fc(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x808c(%rbp),%edi
mov    -0x8088(%rbp),%rdx
mov    %rax,%rcx
lea    0xaa6(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
cmpq   $0x0,-0x8040(%rbp)
je     1693 <main+0x463>
mov    -0x804c(%rbp),%eax
mov    %eax,-0x809c(%rbp)
mov    -0x8040(%rbp),%rax
mov    %rax,-0x8098(%rbp)
mov    -0x8040(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x809c(%rbp),%edi
mov    -0x8098(%rbp),%rsi
mov    %eax,%edx
call   1050 <cwrite@plt>
cmp    $0x0,%eax
jne    1693 <main+0x463>
mov    0x2984(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80a0(%rbp)
mov    0x2965(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x80a0(%rbp),%edi
mov    %rax,%rdx
lea    0xa25(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x804c(%rbp),%edi
call   1090 <close@plt>
mov    -0x8038(%rbp),%rdi
call   1040 <unlink@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
cmpq   $0x0,-0x8048(%rbp)
je     173a <main+0x50a>
mov    -0x804c(%rbp),%eax
mov    %eax,-0x80ac(%rbp)
mov    -0x8048(%rbp),%rax
mov    %rax,-0x80a8(%rbp)
mov    -0x8048(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x80ac(%rbp),%edi
mov    -0x80a8(%rbp),%rsi
mov    %eax,%edx
call   1050 <cwrite@plt>
cmp    $0x0,%eax
jne    173a <main+0x50a>
mov    0x28dd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80b0(%rbp)
mov    0x28be(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x80b0(%rbp),%edi
mov    %rax,%rdx
lea    0x97e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x804c(%rbp),%edi
call   1090 <close@plt>
mov    -0x8038(%rbp),%rdi
call   1040 <unlink@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
jmp    173f <main+0x50f>
jmp    1744 <main+0x514>
lea    -0x8020(%rbp),%rsi
xor    %edi,%edi
mov    $0x8000,%edx
call   10a0 <read@plt>
mov    %eax,-0x8050(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x8050(%rbp)
mov    %al,-0x80b1(%rbp)
jne    178f <main+0x55f>
mov    0x283f(%rip),%rax
mov    (%rax),%rax
mov    0x282d(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x80b1(%rbp)
mov    -0x80b1(%rbp),%al
test   $0x1,%al
jne    1744 <main+0x514>
cmpl   $0xffffffff,-0x8050(%rbp)
jne    1800 <main+0x5d0>
mov    0x2817(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80b8(%rbp)
mov    0x27f8(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x80b8(%rbp),%edi
mov    %rax,%rdx
lea    0x8c7(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x804c(%rbp),%edi
call   1090 <close@plt>
mov    -0x8038(%rbp),%rdi
call   1040 <unlink@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
cmpl   $0x0,-0x8050(%rbp)
jne    1812 <main+0x5e2>
jmp    188e <main+0x65e>
mov    -0x804c(%rbp),%edi
lea    -0x8020(%rbp),%rsi
mov    -0x8050(%rbp),%edx
call   1050 <cwrite@plt>
cmp    $0x0,%eax
jne    1889 <main+0x659>
mov    0x278e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80bc(%rbp)
mov    0x276f(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x80bc(%rbp),%edi
mov    %rax,%rdx
lea    0x831(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x804c(%rbp),%edi
call   1090 <close@plt>
mov    -0x8038(%rbp),%rdi
call   1040 <unlink@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
jmp    173f <main+0x50f>
mov    -0x804c(%rbp),%edi
call   1100 <fsync@plt>
cmp    $0xffffffff,%eax
jne    18f8 <main+0x6c8>
mov    0x271f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80c0(%rbp)
mov    0x2700(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x80c0(%rbp),%edi
mov    %rax,%rdx
lea    0x7db(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x804c(%rbp),%edi
call   1090 <close@plt>
mov    -0x8038(%rbp),%rdi
call   1040 <unlink@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
mov    -0x804c(%rbp),%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
jne    1957 <main+0x727>
mov    0x26b5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80c4(%rbp)
mov    0x2696(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x80c4(%rbp),%edi
mov    %rax,%rdx
lea    0x77e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x8038(%rbp),%rdi
call   1040 <unlink@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
mov    -0x8030(%rbp),%rax
mov    %rax,-0x8028(%rbp)
mov    -0x8028(%rbp),%rax
cmpb   $0x0,(%rax)
je     19c6 <main+0x796>
mov    -0x8028(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jle    199b <main+0x76b>
mov    -0x8028(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7f,%eax
jl     19aa <main+0x77a>
mov    -0x8028(%rbp),%rax
movb   $0x0,(%rax)
jmp    19c6 <main+0x796>
jmp    19af <main+0x77f>
mov    -0x8028(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8028(%rbp)
jmp    1965 <main+0x735>
mov    -0x8038(%rbp),%rax
mov    %rax,-0x8028(%rbp)
mov    -0x8028(%rbp),%rax
cmpb   $0x0,(%rax)
je     1a35 <main+0x805>
mov    -0x8028(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jle    1a0a <main+0x7da>
mov    -0x8028(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7f,%eax
jl     1a19 <main+0x7e9>
mov    -0x8028(%rbp),%rax
movb   $0x0,(%rax)
jmp    1a35 <main+0x805>
jmp    1a1e <main+0x7ee>
mov    -0x8028(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8028(%rbp)
jmp    19d4 <main+0x7a4>
mov    -0x8038(%rbp),%rdi
mov    -0x8030(%rbp),%rsi
call   1120 <rename@plt>
cmp    $0xffffffff,%eax
jne    1a9c <main+0x86c>
mov    0x2570(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80c8(%rbp)
mov    0x2551(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x80c8(%rbp),%edi
mov    %rax,%rdx
lea    0x646(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x8038(%rbp),%rdi
call   1040 <unlink@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
xor    %edi,%edi
call   1140 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8008,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jne    126d <main+0x3d>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xda4(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
mov    0x8(%rbx),%rdi
call   1080 <chdir@plt>
cmp    $0xffffffff,%eax
jne    12b7 <main+0x87>
mov    0x2d46(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rbx),%rbx
mov    0x2d29(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
lea    0xd7d(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
lea    0xd72(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10d0 <rp_srs_fix@plt>
mov    %rax,%r13
lea    0xd62(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r12
xor    %eax,%eax
call   10f0 <hostname@plt>
test   %rax,%rax
jne    131e <main+0xee>
mov    0x2cd8(%rip),%rax
mov    (%rax),%ebx
mov    0x2cbf(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
lea    0xd36(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
mov    %rax,%rbp
mov    (%rax),%cl
test   %cl,%cl
je     1349 <main+0x119>
mov    %rbp,%rax
add    $0x1,%rax
xchg   %ax,%ax
add    $0x81,%cl
cmp    $0xa1,%cl
jbe    1345 <main+0x115>
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1330 <main+0x100>
jmp    1349 <main+0x119>
movb   $0x0,-0x1(%rax)
mov    %rbp,%rdi
call   1070 <strlen@plt>
lea    0x80(%rax),%edi
call   10e0 <malloc@plt>
test   %rax,%rax
jne    137a <main+0x14a>
mov    0x2c60(%rip),%rax
mov    (%rax),%ebx
mov    %rbp,%rdi
call   1070 <strlen@plt>
lea    0x80(%rax),%ebp
jmp    13cf <main+0x19f>
mov    %rax,%r15
xor    %edi,%edi
call   10c0 <time@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xcd7(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %rax,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1130 <sprintf@plt>
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10e0 <malloc@plt>
test   %rax,%rax
jne    13fd <main+0x1cd>
mov    0x2c05(%rip),%rax
mov    (%rax),%ebx
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
mov    0x2be2(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
lea    0xc77(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
mov    %rax,%r14
lea    0x3(%r15),%rdx
lea    0xc70(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
call   1130 <sprintf@plt>
mov    0x2bdc(%rip),%rax
mov    0x2bbd(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2ba2(%rip),%rax
or     (%rax),%esi
mov    0x2b89(%rip),%rax
or     (%rax),%esi
mov    %r15,%rdi
mov    $0x1b6,%edx
call   1110 <open@plt>
cmp    $0xffffffff,%eax
jne    1474 <main+0x244>
mov    0x2b76(%rip),%rax
mov    (%rax),%ebx
mov    0x2b5d(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
lea    0xc17(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
jmp    12a3 <main+0x73>
mov    %eax,%ebp
test   %r13,%r13
je     1493 <main+0x263>
mov    %r13,%rdi
call   1070 <strlen@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1050 <cwrite@plt>
test   %eax,%eax
je     14b0 <main+0x280>
test   %r12,%r12
je     14e0 <main+0x2b0>
mov    %r12,%rdi
call   1070 <strlen@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1050 <cwrite@plt>
test   %eax,%eax
jne    14e0 <main+0x2b0>
mov    0x2b11(%rip),%rax
mov    (%rax),%ebx
mov    0x2af8(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
lea    0xbc1(%rip),%rsi
jmp    1556 <main+0x326>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x8000,%edx
call   10a0 <read@plt>
mov    0x2ac2(%rip),%rbx
mov    (%rbx),%rdi
cmp    $0xffffffff,%eax
jne    150a <main+0x2da>
mov    0x2aab(%rip),%rcx
cmp    (%rcx),%rdi
je     14e0 <main+0x2b0>
cmp    $0xffffffff,%eax
je     1541 <main+0x311>
test   %eax,%eax
je     157b <main+0x34b>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    %eax,%edx
call   1050 <cwrite@plt>
test   %eax,%eax
jne    14e0 <main+0x2b0>
mov    0x2a9e(%rip),%rax
mov    (%rax),%r14d
mov    (%rbx),%rdi
call   1150 <strerror@plt>
lea    0xb56(%rip),%rsi
mov    %r14d,%edi
jmp    1558 <main+0x328>
mov    0x2a80(%rip),%rax
mov    (%rax),%ebx
call   1150 <strerror@plt>
lea    0xb49(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %ebp,%edi
call   1090 <close@plt>
mov    %r15,%rdi
call   1040 <unlink@plt>
mov    $0x6f,%edi
call   1140 <exit@plt>
mov    %ebp,%edi
call   1100 <fsync@plt>
cmp    $0xffffffff,%eax
jne    15a5 <main+0x375>
mov    0x2a3a(%rip),%rax
mov    (%rax),%r14d
mov    (%rbx),%rdi
call   1150 <strerror@plt>
lea    0xb0b(%rip),%rsi
mov    %r14d,%edi
jmp    1558 <main+0x328>
mov    %ebp,%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
jne    15ce <main+0x39e>
mov    0x2a10(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx),%rdi
call   1150 <strerror@plt>
lea    0xaef(%rip),%rsi
jmp    1651 <main+0x421>
mov    (%r14),%cl
test   %cl,%cl
je     15f9 <main+0x3c9>
mov    %r14,%rax
add    $0x1,%rax
nopl   0x0(%rax)
add    $0x81,%cl
cmp    $0xa1,%cl
jbe    15f5 <main+0x3c5>
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    15e0 <main+0x3b0>
jmp    15f9 <main+0x3c9>
movb   $0x0,-0x1(%rax)
mov    (%r15),%cl
test   %cl,%cl
je     1629 <main+0x3f9>
mov    %r15,%rax
add    $0x1,%rax
nopw   0x0(%rax,%rax,1)
add    $0x81,%cl
cmp    $0xa1,%cl
jbe    1625 <main+0x3f5>
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1610 <main+0x3e0>
jmp    1629 <main+0x3f9>
movb   $0x0,-0x1(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
call   1120 <rename@plt>
cmp    $0xffffffff,%eax
jne    1662 <main+0x432>
mov    0x2988(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx),%rdi
call   1150 <strerror@plt>
lea    0xa74(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1569 <main+0x339>
xor    %edi,%edi
call   1140 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"Usage: %s dir/. < message\0A\00"
@.str.1 = [21 x i8] c"Can't chdir(%s): %s\0A\00"
@errno = global i64 0
@.str.2 = [7 x i8] c"RPLINE\00"
@.str.3 = [7 x i8] c"DTLINE\00"
@.str.4 = [30 x i8] c"Can't determine hostname: %s\0A\00"
@.str.5 = [16 x i8] c"malloc(%d): %s\0A\00"
@.str.6 = [15 x i8] c"tmp/%lu.%ld.%s\00"
@.str.7 = [6 x i8] c"new%s\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_EXCL = global i32 0
@.str.8 = [15 x i8] c"creat(%s): %s\0A\00"
@.str.9 = [15 x i8] c"rpwrite(): %s\0A\00"
@EINTR = global i64 0
@.str.10 = [12 x i8] c"read(): %s\0A\00"
@.str.11 = [13 x i8] c"write(): %s\0A\00"
@.str.12 = [13 x i8] c"fsync(): %s\0A\00"
@.str.13 = [13 x i8] c"close(): %s\0A\00"
@.str.14 = [14 x i8] c"rename(): %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32770 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @chdir(i8* %26)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %38
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = load i64, i64* @errno
%35 = call i8* @strerror(i64 %34)
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %33, i8* %35)
%37 = call i32 @exit(i32 111)
unreachable
38: ; preds = %23
%39 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%40 = call i8* @rp_srs_fix(i8* %39)
store i8* %40, i8** %10
%41 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i8* %41, i8** %11
%42 = call i8* (...) @hostname()
store i8* %42, i8** %8
%43 = load i8*, i8** %8
%44 = icmp ne i8* %43, null
br i1 %44, label %51, label %45
45: ; preds = %38
%46 = load i32, i32* @stderr
%47 = load i64, i64* @errno
%48 = call i8* @strerror(i64 %47)
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %48)
%50 = call i32 @exit(i32 111)
unreachable
51: ; preds = %38
%52 = load i8*, i8** %8
store i8* %52, i8** %7
br label %53
53: ; preds = %70, %51
%54 = load i8*, i8** %7
%55 = load i8, i8* %54
%56 = icmp ne i8 %55, 0
br i1 %56, label %57, label %73
57: ; preds = %53
%58 = load i8*, i8** %7
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp sle i32 %60, 32
br i1 %61, label %67, label %62
62: ; preds = %57
%63 = load i8*, i8** %7
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp sge i32 %65, 127
br i1 %66, label %67, label %69
67: ; preds = %62, %57
%68 = load i8*, i8** %7
store i8 0, i8* %68
br label %73
69: ; preds = %62
br label %70
70: ; preds = %69
%71 = load i8*, i8** %7
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %7
br label %53
73: ; preds = %67, %53
%74 = load i8*, i8** %8
%75 = call i32 @strlen(i8* %74)
%76 = add nsw i32 %75, 128
%77 = call i8* @malloc(i32 %76)
store i8* %77, i8** %9
%78 = load i8*, i8** %9
%79 = icmp ne i8* %78, null
br i1 %79, label %89, label %80
80: ; preds = %73
%81 = load i32, i32* @stderr
%82 = load i8*, i8** %8
%83 = call i32 @strlen(i8* %82)
%84 = add nsw i32 %83, 128
%85 = load i64, i64* @errno
%86 = call i8* @strerror(i64 %85)
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %84, i8* %86)
%88 = call i32 @exit(i32 111)
unreachable
89: ; preds = %73
%90 = load i8*, i8** %9
%91 = call i64 @time(i32 0)
%92 = call i64 (...) @getpid()
%93 = load i8*, i8** %8
%94 = call i32 (i8*, i8*, ...) @sprintf(i8* %90, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i64 %91, i64 %92, i8* %93)
%95 = load i8*, i8** %9
%96 = call i32 @strlen(i8* %95)
%97 = call i8* @malloc(i32 %96)
store i8* %97, i8** %8
%98 = load i8*, i8** %8
%99 = icmp ne i8* %98, null
br i1 %99, label %108, label %100
100: ; preds = %89
%101 = load i32, i32* @stderr
%102 = load i8*, i8** %9
%103 = call i32 @strlen(i8* %102)
%104 = load i64, i64* @errno
%105 = call i8* @strerror(i64 %104)
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %103, i8* %105)
%107 = call i32 @exit(i32 111)
unreachable
108: ; preds = %89
%109 = load i8*, i8** %8
%110 = load i8*, i8** %9
%111 = getelementptr inbounds i8, i8* %110, i64 3
%112 = call i32 (i8*, i8*, ...) @sprintf(i8* %109, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %111)
%113 = load i8*, i8** %9
%114 = load i32, i32* @O_CREAT
%115 = load i32, i32* @O_RDWR
%116 = or i32 %114, %115
%117 = load i32, i32* @O_NOCTTY
%118 = or i32 %116, %117
%119 = load i32, i32* @O_EXCL
%120 = or i32 %118, %119
%121 = call i32 @open(i8* %113, i32 %120, i32 438)
store i32 %121, i32* %12
%122 = load i32, i32* %12
%123 = icmp eq i32 %122, -1
br i1 %123, label %124, label %131
124: ; preds = %108
%125 = load i32, i32* @stderr
%126 = load i8*, i8** %9
%127 = load i64, i64* @errno
%128 = call i8* @strerror(i64 %127)
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %126, i8* %128)
%130 = call i32 @exit(i32 111)
unreachable
131: ; preds = %108
%132 = load i8*, i8** %10
%133 = icmp ne i8* %132, null
br i1 %133, label %134, label %151
134: ; preds = %131
%135 = load i32, i32* %12
%136 = load i8*, i8** %10
%137 = load i8*, i8** %10
%138 = call i32 @strlen(i8* %137)
%139 = call i32 @cwrite(i32 %135, i8* %136, i32 %138)
%140 = icmp ne i32 %139, 0
br i1 %140, label %151, label %141
141: ; preds = %134
%142 = load i32, i32* @stderr
%143 = load i64, i64* @errno
%144 = call i8* @strerror(i64 %143)
%145 = call i32 (i32, i8*, ...) @fprintf(i32 %142, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %144)
%146 = load i32, i32* %12
%147 = call i32 @close(i32 %146)
%148 = load i8*, i8** %9
%149 = call i32 @unlink(i8* %148)
%150 = call i32 @exit(i32 111)
unreachable
151: ; preds = %134, %131
%152 = load i8*, i8** %11
%153 = icmp ne i8* %152, null
br i1 %153, label %154, label %171
154: ; preds = %151
%155 = load i32, i32* %12
%156 = load i8*, i8** %11
%157 = load i8*, i8** %11
%158 = call i32 @strlen(i8* %157)
%159 = call i32 @cwrite(i32 %155, i8* %156, i32 %158)
%160 = icmp ne i32 %159, 0
br i1 %160, label %171, label %161
161: ; preds = %154
%162 = load i32, i32* @stderr
%163 = load i64, i64* @errno
%164 = call i8* @strerror(i64 %163)
%165 = call i32 (i32, i8*, ...) @fprintf(i32 %162, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %164)
%166 = load i32, i32* %12
%167 = call i32 @close(i32 %166)
%168 = load i8*, i8** %9
%169 = call i32 @unlink(i8* %168)
%170 = call i32 @exit(i32 111)
unreachable
171: ; preds = %154, %151
br label %172
172: ; preds = %218, %171
br label %173
173: ; preds = %183, %172
%174 = getelementptr inbounds [32770 x i8], [32770 x i8]* %6, i64 0, i64 0
%175 = call i32 @read(i32 0, i8* %174, i32 32768)
store i32 %175, i32* %13
br label %176
176: ; preds = %173
%177 = load i32, i32* %13
%178 = icmp eq i32 %177, -1
br i1 %178, label %179, label %183
179: ; preds = %176
%180 = load i64, i64* @errno
%181 = load i64, i64* @EINTR
%182 = icmp eq i64 %180, %181
br label %183
183: ; preds = %179, %176
%184 = phi i1 [ false, %176 ], [ %182, %179 ]
br i1 %184, label %173, label %185
185: ; preds = %183
%186 = load i32, i32* %13
%187 = icmp eq i32 %186, -1
br i1 %187, label %188, label %198
188: ; preds = %185
%189 = load i32, i32* @stderr
%190 = load i64, i64* @errno
%191 = call i8* @strerror(i64 %190)
%192 = call i32 (i32, i8*, ...) @fprintf(i32 %189, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %191)
%193 = load i32, i32* %12
%194 = call i32 @close(i32 %193)
%195 = load i8*, i8** %9
%196 = call i32 @unlink(i8* %195)
%197 = call i32 @exit(i32 111)
unreachable
198: ; preds = %185
%199 = load i32, i32* %13
%200 = icmp eq i32 %199, 0
br i1 %200, label %201, label %202
201: ; preds = %198
br label %219
202: ; preds = %198
%203 = load i32, i32* %12
%204 = getelementptr inbounds [32770 x i8], [32770 x i8]* %6, i64 0, i64 0
%205 = load i32, i32* %13
%206 = call i32 @cwrite(i32 %203, i8* %204, i32 %205)
%207 = icmp ne i32 %206, 0
br i1 %207, label %218, label %208
208: ; preds = %202
%209 = load i32, i32* @stderr
%210 = load i64, i64* @errno
%211 = call i8* @strerror(i64 %210)
%212 = call i32 (i32, i8*, ...) @fprintf(i32 %209, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i8* %211)
%213 = load i32, i32* %12
%214 = call i32 @close(i32 %213)
%215 = load i8*, i8** %9
%216 = call i32 @unlink(i8* %215)
%217 = call i32 @exit(i32 111)
unreachable
218: ; preds = %202
br label %172
219: ; preds = %201
%220 = load i32, i32* %12
%221 = call i32 @fsync(i32 %220)
%222 = icmp eq i32 %221, -1
br i1 %222, label %223, label %233
223: ; preds = %219
%224 = load i32, i32* @stderr
%225 = load i64, i64* @errno
%226 = call i8* @strerror(i64 %225)
%227 = call i32 (i32, i8*, ...) @fprintf(i32 %224, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i8* %226)
%228 = load i32, i32* %12
%229 = call i32 @close(i32 %228)
%230 = load i8*, i8** %9
%231 = call i32 @unlink(i8* %230)
%232 = call i32 @exit(i32 111)
unreachable
233: ; preds = %219
%234 = load i32, i32* %12
%235 = call i32 @close(i32 %234)
%236 = icmp eq i32 %235, -1
br i1 %236, label %237, label %245
237: ; preds = %233
%238 = load i32, i32* @stderr
%239 = load i64, i64* @errno
%240 = call i8* @strerror(i64 %239)
%241 = call i32 (i32, i8*, ...) @fprintf(i32 %238, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* %240)
%242 = load i8*, i8** %9
%243 = call i32 @unlink(i8* %242)
%244 = call i32 @exit(i32 111)
unreachable
245: ; preds = %233
%246 = load i8*, i8** %8
store i8* %246, i8** %7
br label %247
247: ; preds = %264, %245
%248 = load i8*, i8** %7
%249 = load i8, i8* %248
%250 = icmp ne i8 %249, 0
br i1 %250, label %251, label %267
251: ; preds = %247
%252 = load i8*, i8** %7
%253 = load i8, i8* %252
%254 = sext i8 %253 to i32
%255 = icmp sle i32 %254, 32
br i1 %255, label %261, label %256
256: ; preds = %251
%257 = load i8*, i8** %7
%258 = load i8, i8* %257
%259 = sext i8 %258 to i32
%260 = icmp sge i32 %259, 127
br i1 %260, label %261, label %263
261: ; preds = %256, %251
%262 = load i8*, i8** %7
store i8 0, i8* %262
br label %267
263: ; preds = %256
br label %264
264: ; preds = %263
%265 = load i8*, i8** %7
%266 = getelementptr inbounds i8, i8* %265, i32 1
store i8* %266, i8** %7
br label %247
267: ; preds = %261, %247
%268 = load i8*, i8** %9
store i8* %268, i8** %7
br label %269
269: ; preds = %286, %267
%270 = load i8*, i8** %7
%271 = load i8, i8* %270
%272 = icmp ne i8 %271, 0
br i1 %272, label %273, label %289
273: ; preds = %269
%274 = load i8*, i8** %7
%275 = load i8, i8* %274
%276 = sext i8 %275 to i32
%277 = icmp sle i32 %276, 32
br i1 %277, label %283, label %278
278: ; preds = %273
%279 = load i8*, i8** %7
%280 = load i8, i8* %279
%281 = sext i8 %280 to i32
%282 = icmp sge i32 %281, 127
br i1 %282, label %283, label %285
283: ; preds = %278, %273
%284 = load i8*, i8** %7
store i8 0, i8* %284
br label %289
285: ; preds = %278
br label %286
286: ; preds = %285
%287 = load i8*, i8** %7
%288 = getelementptr inbounds i8, i8* %287, i32 1
store i8* %288, i8** %7
br label %269
289: ; preds = %283, %269
%290 = load i8*, i8** %9
%291 = load i8*, i8** %8
%292 = call i32 @rename(i8* %290, i8* %291)
%293 = icmp eq i32 %292, -1
br i1 %293, label %294, label %302
294: ; preds = %289
%295 = load i32, i32* @stderr
%296 = load i64, i64* @errno
%297 = call i8* @strerror(i64 %296)
%298 = call i32 (i32, i8*, ...) @fprintf(i32 %295, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0), i8* %297)
%299 = load i8*, i8** %9
%300 = call i32 @unlink(i8* %299)
%301 = call i32 @exit(i32 111)
unreachable
302: ; preds = %289
%303 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Usage: %s dir/. < message\0A\00"
@.str.1 = [21 x i8] c"Can't chdir(%s): %s\0A\00"
@errno = global i64 0
@.str.2 = [7 x i8] c"RPLINE\00"
@.str.3 = [7 x i8] c"DTLINE\00"
@.str.4 = [30 x i8] c"Can't determine hostname: %s\0A\00"
@.str.5 = [16 x i8] c"malloc(%d): %s\0A\00"
@.str.6 = [15 x i8] c"tmp/%lu.%ld.%s\00"
@.str.7 = [6 x i8] c"new%s\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_EXCL = global i32 0
@.str.8 = [15 x i8] c"creat(%s): %s\0A\00"
@.str.9 = [15 x i8] c"rpwrite(): %s\0A\00"
@EINTR = global i64 0
@.str.10 = [12 x i8] c"read(): %s\0A\00"
@.str.11 = [13 x i8] c"write(): %s\0A\00"
@.str.12 = [13 x i8] c"fsync(): %s\0A\00"
@.str.13 = [13 x i8] c"close(): %s\0A\00"
@.str.14 = [14 x i8] c"rename(): %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32770 x i8]
%4 = getelementptr inbounds [32770 x i8], [32770 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @chdir(i8* %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %12
%19 = load i64, i64* @errno
%20 = tail call i8* @strerror(i64 %19)
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %20)
%22 = tail call i32 @exit(i32 111)
unreachable
23: ; preds = %11
%24 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i8* @rp_srs_fix(i8* %24)
%26 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%27 = tail call i8* (...) @hostname()
%28 = icmp eq i8* %27, null
br i1 %28, label %32, label %29
29: ; preds = %23
%30 = load i8, i8* %27
%31 = icmp eq i8 %30, 0
br i1 %31, label %48, label %38
32: ; preds = %23
%33 = load i32, i32* @stderr
%34 = load i64, i64* @errno
%35 = tail call i8* @strerror(i64 %34)
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %35)
%37 = tail call i32 @exit(i32 111)
unreachable
38: ; preds = %29, %44
%39 = phi i8 [ %46, %44 ], [ %30, %29 ]
%40 = phi i8* [ %45, %44 ], [ %27, %29 ]
%41 = add i8 %39, -127
%42 = icmp ult i8 %41, -94
br i1 %42, label %43, label %44
43: ; preds = %38
store i8 0, i8* %40
br label %48
44: ; preds = %38
%45 = getelementptr inbounds i8, i8* %40, i64 1
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 0
br i1 %47, label %48, label %38
48: ; preds = %44, %29, %43
%49 = tail call i32 @strlen(i8* %27)
%50 = add nsw i32 %49, 128
%51 = tail call i8* @malloc(i32 %50)
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %61
53: ; preds = %48
%54 = load i32, i32* @stderr
%55 = tail call i32 @strlen(i8* %27)
%56 = add nsw i32 %55, 128
%57 = load i64, i64* @errno
%58 = tail call i8* @strerror(i64 %57)
%59 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %56, i8* %58)
%60 = tail call i32 @exit(i32 111)
unreachable
61: ; preds = %48
%62 = tail call i64 @time(i32 0)
%63 = tail call i64 (...) @getpid()
%64 = tail call i32 (i8*, i8*, ...) @sprintf(i8* %51, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i64 %62, i64 %63, i8* %27)
%65 = tail call i32 @strlen(i8* %51)
%66 = tail call i8* @malloc(i32 %65)
%67 = icmp eq i8* %66, null
br i1 %67, label %68, label %75
68: ; preds = %61
%69 = load i32, i32* @stderr
%70 = tail call i32 @strlen(i8* %51)
%71 = load i64, i64* @errno
%72 = tail call i8* @strerror(i64 %71)
%73 = tail call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %70, i8* %72)
%74 = tail call i32 @exit(i32 111)
unreachable
75: ; preds = %61
%76 = getelementptr inbounds i8, i8* %51, i64 3
%77 = tail call i32 (i8*, i8*, ...) @sprintf(i8* %66, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %76)
%78 = load i32, i32* @O_CREAT
%79 = load i32, i32* @O_RDWR
%80 = or i32 %79, %78
%81 = load i32, i32* @O_NOCTTY
%82 = or i32 %80, %81
%83 = load i32, i32* @O_EXCL
%84 = or i32 %82, %83
%85 = tail call i32 @open(i8* %51, i32 %84, i32 438)
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %93
87: ; preds = %75
%88 = load i32, i32* @stderr
%89 = load i64, i64* @errno
%90 = tail call i8* @strerror(i64 %89)
%91 = tail call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %51, i8* %90)
%92 = tail call i32 @exit(i32 111)
unreachable
93: ; preds = %75
%94 = icmp eq i8* %25, null
br i1 %94, label %107, label %95
95: ; preds = %93
%96 = tail call i32 @strlen(i8* %25)
%97 = tail call i32 @cwrite(i32 %85, i8* %25, i32 %96)
%98 = icmp eq i32 %97, 0
br i1 %98, label %99, label %107
99: ; preds = %95
%100 = load i32, i32* @stderr
%101 = load i64, i64* @errno
%102 = tail call i8* @strerror(i64 %101)
%103 = tail call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %102)
%104 = tail call i32 @close(i32 %85)
%105 = tail call i32 @unlink(i8* %51)
%106 = tail call i32 @exit(i32 111)
unreachable
107: ; preds = %95, %93
%108 = icmp eq i8* %26, null
br i1 %108, label %113, label %109
109: ; preds = %107
%110 = tail call i32 @strlen(i8* %26)
%111 = tail call i32 @cwrite(i32 %85, i8* %26, i32 %110)
%112 = icmp eq i32 %111, 0
br i1 %112, label %114, label %113
113: ; preds = %107, %109
br label %122
114: ; preds = %109
%115 = load i32, i32* @stderr
%116 = load i64, i64* @errno
%117 = tail call i8* @strerror(i64 %116)
%118 = tail call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %117)
%119 = tail call i32 @close(i32 %85)
%120 = tail call i32 @unlink(i8* %51)
%121 = tail call i32 @exit(i32 111)
unreachable
122: ; preds = %129, %113
%123 = call i32 @read(i32 0, i8* %4, i32 32768)
%124 = icmp eq i32 %123, -1
%125 = load i64, i64* @errno
%126 = load i64, i64* @EINTR
%127 = icmp eq i64 %125, %126
%128 = select i1 %124, i1 %127, i1 false
br i1 %128, label %129, label %130
129: ; preds = %122, %140
br label %122
130: ; preds = %122
br i1 %124, label %131, label %138
131: ; preds = %130
%132 = load i32, i32* @stderr
%133 = call i8* @strerror(i64 %125)
%134 = call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %133)
%135 = call i32 @close(i32 %85)
%136 = call i32 @unlink(i8* %51)
%137 = call i32 @exit(i32 111)
unreachable
138: ; preds = %130
%139 = icmp eq i32 %123, 0
br i1 %139, label %151, label %140
140: ; preds = %138
%141 = call i32 @cwrite(i32 %85, i8* %4, i32 %123)
%142 = icmp eq i32 %141, 0
br i1 %142, label %143, label %129
143: ; preds = %140
%144 = load i32, i32* @stderr
%145 = load i64, i64* @errno
%146 = call i8* @strerror(i64 %145)
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i8* %146)
%148 = call i32 @close(i32 %85)
%149 = call i32 @unlink(i8* %51)
%150 = call i32 @exit(i32 111)
unreachable
151: ; preds = %138
%152 = call i32 @fsync(i32 %85)
%153 = icmp eq i32 %152, -1
br i1 %153, label %154, label %162
154: ; preds = %151
%155 = load i32, i32* @stderr
%156 = load i64, i64* @errno
%157 = call i8* @strerror(i64 %156)
%158 = call i32 (i32, i8*, ...) @fprintf(i32 %155, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i8* %157)
%159 = call i32 @close(i32 %85)
%160 = call i32 @unlink(i8* %51)
%161 = call i32 @exit(i32 111)
unreachable
162: ; preds = %151
%163 = call i32 @close(i32 %85)
%164 = icmp eq i32 %163, -1
br i1 %164, label %168, label %165
165: ; preds = %162
%166 = load i8, i8* %66
%167 = icmp eq i8 %166, 0
br i1 %167, label %185, label %175
168: ; preds = %162
%169 = load i32, i32* @stderr
%170 = load i64, i64* @errno
%171 = call i8* @strerror(i64 %170)
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %169, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* %171)
%173 = call i32 @unlink(i8* %51)
%174 = call i32 @exit(i32 111)
unreachable
175: ; preds = %165, %181
%176 = phi i8 [ %183, %181 ], [ %166, %165 ]
%177 = phi i8* [ %182, %181 ], [ %66, %165 ]
%178 = add i8 %176, -127
%179 = icmp ult i8 %178, -94
br i1 %179, label %180, label %181
180: ; preds = %175
store i8 0, i8* %177
br label %185
181: ; preds = %175
%182 = getelementptr inbounds i8, i8* %177, i64 1
%183 = load i8, i8* %182
%184 = icmp eq i8 %183, 0
br i1 %184, label %185, label %175
185: ; preds = %181, %165, %180
%186 = load i8, i8* %51
%187 = icmp eq i8 %186, 0
br i1 %187, label %198, label %188
188: ; preds = %185, %194
%189 = phi i8 [ %196, %194 ], [ %186, %185 ]
%190 = phi i8* [ %195, %194 ], [ %51, %185 ]
%191 = add i8 %189, -127
%192 = icmp ult i8 %191, -94
br i1 %192, label %193, label %194
193: ; preds = %188
store i8 0, i8* %190
br label %198
194: ; preds = %188
%195 = getelementptr inbounds i8, i8* %190, i64 1
%196 = load i8, i8* %195
%197 = icmp eq i8 %196, 0
br i1 %197, label %198, label %188
198: ; preds = %194, %185, %193
%199 = call i32 @rename(i8* %51, i8* %66)
%200 = icmp eq i32 %199, -1
br i1 %200, label %201, label %208
201: ; preds = %198
%202 = load i32, i32* @stderr
%203 = load i64, i64* @errno
%204 = call i8* @strerror(i64 %203)
%205 = call i32 (i32, i8*, ...) @fprintf(i32 %202, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0), i8* %204)
%206 = call i32 @unlink(i8* %51)
%207 = call i32 @exit(i32 111)
unreachable
208: ; preds = %198
%209 = call i32 @exit(i32 0)
unreachable
}