#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 stat {
  int st_mode;
  int st_size;
};
struct sockaddr_un {
  int /*<<< orphan*/ sun_path;
  int /*<<< orphan*/ sun_family;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ F_OK;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ SOCK_STREAM;
int S_IFDIR;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ fail();
scalar_t__ fstat(int, struct stat *);
scalar_t__ log10(double);
scalar_t__ malloc(int);
int open(char *, int, ...);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ senderr(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int strlen(char *);
int /*<<< orphan*/ term(int);
int /*<<< orphan*/ usage(char *);
int write(int, char *, int);
int main(int argc, char **argv) {
  char *action, c, *dst_file, *exe, *form, *incdirs, *lensrcstr, *socket_file,
      *src_file, *src;
  int bytesread, fd, digits, lensrc, modinfo, sock, status;
  struct sockaddr_un server;
  struct stat fileinfo;
  exe = argv[0];
  if ((argc < 6) || (argc > 7))
    usage(exe);
  socket_file = argv[1];
  src_file = argv[2];
  dst_file = argv[3];
  action = argv[4];
  form = argv[5];
  incdirs = argv[6];
  if (access(socket_file, F_OK) < 0) {
    printf("<socket> '%s' not found\n", src_file);
    usage(exe);
  }
  if (access(src_file, F_OK) < 0) {
    printf("<infile> '%s' not found\n", src_file);
    usage(exe);
  }
  modinfo = strcmp(action, "modinfo") == 0 ? 1 : 0;
  if (strcmp(action, "passthrough") != 0 && strcmp(action, "translate") != 0 &&
      !modinfo)
    usage(exe);
  if (strcmp(form, "fixed") != 0 && strcmp(form, "free") != 0)
    usage(exe);
  if (modinfo) {
    if ((fd = open(dst_file, O_RDONLY)) < 0) {
      printf("<moddir> output directory '%s' not found\n", dst_file);
      usage(exe);
    }
    if (fstat(fd, &fileinfo) < 0) {
      printf("Could not get <moddir> '%s' info\n", dst_file);
      fail();
    }
    if (!(fileinfo.st_mode & S_IFDIR)) {
      printf("'%s' requires output directory <moddir>, not '%s'\n", action,
             dst_file);
      usage(exe);
    }
    close(fd);
  }
  if ((fd = open(src_file, O_RDONLY)) < 0) {
    printf("Could not open <infile> '%s'\n", src_file);
    fail();
  }
  if (fstat(fd, &fileinfo) < 0) {
    printf("Could not get <infile> '%s' info\n", src_file);
    fail();
  }
  lensrc = fileinfo.st_size;
  if ((src = (char *)malloc(lensrc) + 1) == NULL) {
    printf("Could not allocate input buffer for <infile> '%s'\n", src_file);
    fail();
  }
  if (read(fd, src, lensrc) < 0) {
    printf("Could not read <infile> '%s'\n", src_file);
    fail();
  }
  close(fd);
  sock = socket(AF_UNIX, SOCK_STREAM, 0);
  if (sock < 0) {
    printf("Could not create socket\n");
    fail();
  }
  server.sun_family = AF_UNIX;
  strcpy(server.sun_path, socket_file);
  if (connect(sock, (struct sockaddr *)&server, sizeof(struct sockaddr_un)) <
      0) {
    close(sock);
    printf("Could not connect to server on socket '%s'\n", socket_file);
    fail();
  }
  digits = (int)log10((double)lensrc);
  if ((lensrcstr = (char *)malloc(digits + 2)) == NULL) {
    printf("Could not allocate source-length string\n");
    fail();
  }
  sprintf(lensrcstr, "%d\n", lensrc - 1);
  status = write(sock, src_file, strlen(src_file));
  if (status < 0)
    senderr("input file name");
  term(sock);
  status = write(sock, dst_file, strlen(dst_file));
  if (status < 0)
    senderr("output path");
  term(sock);
  status = write(sock, action, strlen(action));
  if (status < 0)
    senderr("action");
  term(sock);
  status = write(sock, form, strlen(form));
  if (status < 0)
    senderr("form");
  term(sock);
  if (incdirs != NULL)
    status = write(sock, incdirs, strlen(incdirs));
  if (status < 0)
    senderr("includes");
  term(sock);
  status = write(sock, lensrcstr, strlen(lensrcstr));
  if (status < 0)
    senderr("source-length string");
  status = write(sock, src, lensrc);
  if (status < 0)
    senderr("source");
  if (!modinfo)
    if ((fd = open(dst_file, O_CREAT | O_TRUNC | O_WRONLY,
                   S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) {
      printf("Could not open output file '%s' for writing\n", dst_file);
      fail();
    }
  bytesread = 0;
  while (read(sock, &c, 1) > 0) {
    if (c == '\0')
      break;
    ++bytesread;
    if (!modinfo)
      status = write(fd, &c, 1);
  }
  if (!modinfo)
    close(fd);
  close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x6,-0x8(%rbp)
jl     1268 <main+0x38>
cmpl   $0x7,-0x8(%rbp)
jle    1271 <main+0x41>
mov    -0x30(%rbp),%rdi
call   10e0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x50(%rbp),%rdi
mov    0x2cc4(%rip),%rax
mov    (%rax),%esi
call   1100 <access@plt>
cmp    $0x0,%rax
jge    12f0 <main+0xc0>
mov    -0x58(%rbp),%rsi
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   10e0 <usage@plt>
mov    -0x58(%rbp),%rdi
mov    0x2c8d(%rip),%rax
mov    (%rax),%esi
call   1100 <access@plt>
cmp    $0x0,%rax
jge    1327 <main+0xf7>
mov    -0x58(%rbp),%rsi
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   10e0 <usage@plt>
mov    -0x18(%rbp),%rdi
lea    0xd00(%rip),%rsi
call   10b0 <strcmp@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x74(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xce4(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     1392 <main+0x162>
mov    -0x18(%rbp),%rdi
lea    0xcd6(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     1392 <main+0x162>
cmpl   $0x0,-0x74(%rbp)
jne    1392 <main+0x162>
mov    -0x30(%rbp),%rdi
call   10e0 <usage@plt>
mov    -0x38(%rbp),%rdi
lea    0xcb3(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     13cf <main+0x19f>
mov    -0x38(%rbp),%rdi
lea    0xc9f(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     13cf <main+0x19f>
mov    -0x30(%rbp),%rdi
call   10e0 <usage@plt>
cmpl   $0x0,-0x74(%rbp)
je     1485 <main+0x255>
mov    -0x28(%rbp),%rdi
mov    0x2bf4(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10f0 <open@plt>
mov    %eax,-0x68(%rbp)
cmp    $0x0,%eax
jge    1414 <main+0x1e4>
mov    -0x28(%rbp),%rsi
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   10e0 <usage@plt>
mov    -0x68(%rbp),%edi
lea    -0x90(%rbp),%rsi
call   1140 <fstat@plt>
cmp    $0x0,%rax
jge    1446 <main+0x216>
mov    -0x28(%rbp),%rsi
lea    0xc4d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <fail@plt>
mov    -0x90(%rbp),%eax
mov    0x2b2d(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    147d <main+0x24d>
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xc3a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   10e0 <usage@plt>
mov    -0x68(%rbp),%edi
call   1080 <close@plt>
mov    -0x58(%rbp),%rdi
mov    0x2b48(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10f0 <open@plt>
mov    %eax,-0x68(%rbp)
cmp    $0x0,%eax
jge    14be <main+0x28e>
mov    -0x58(%rbp),%rsi
lea    0xc2a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <fail@plt>
mov    -0x68(%rbp),%edi
lea    -0x90(%rbp),%rsi
call   1140 <fstat@plt>
cmp    $0x0,%rax
jge    14f0 <main+0x2c0>
mov    -0x58(%rbp),%rsi
lea    0xc16(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <fail@plt>
mov    -0x8c(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%edi
call   10d0 <malloc@plt>
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
cmp    $0x0,%rax
jne    152c <main+0x2fc>
mov    -0x58(%rbp),%rsi
lea    0xbfc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <fail@plt>
mov    -0x68(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    -0x70(%rbp),%edx
call   10a0 <read@plt>
cmp    $0x0,%rax
jge    155e <main+0x32e>
mov    -0x58(%rbp),%rsi
lea    0xbfd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <fail@plt>
mov    -0x68(%rbp),%edi
call   1080 <close@plt>
mov    0x2a63(%rip),%rax
mov    (%rax),%edi
mov    0x2a42(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0x0,-0x78(%rbp)
jge    15a1 <main+0x371>
lea    0xbd8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <fail@plt>
mov    0x2a28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x88(%rbp),%edi
mov    -0x50(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x78(%rbp),%edi
lea    -0x88(%rbp),%rsi
mov    $0x8,%edx
call   1130 <connect@plt>
cmp    $0x0,%rax
jge    15fe <main+0x3ce>
mov    -0x78(%rbp),%edi
call   1080 <close@plt>
mov    -0x50(%rbp),%rsi
lea    0xb94(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <fail@plt>
cvtsi2sdl -0x70(%rbp),%xmm0
call   1110 <log10@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%edi
add    $0x2,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1639 <main+0x409>
lea    0xb85(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <fail@plt>
mov    -0x48(%rbp),%rdi
mov    -0x70(%rbp),%edx
sub    $0x1,%edx
lea    0xb8f(%rip),%rsi
call   1120 <sprintf@plt>
mov    -0x78(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x9c(%rbp),%edi
mov    -0x98(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jge    1699 <main+0x469>
lea    0xb49(%rip),%rdi
call   10c0 <senderr@plt>
mov    -0x78(%rbp),%edi
call   1090 <term@plt>
mov    -0x78(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jge    16eb <main+0x4bb>
lea    0xb07(%rip),%rdi
call   10c0 <senderr@plt>
mov    -0x78(%rbp),%edi
call   1090 <term@plt>
mov    -0x78(%rbp),%eax
mov    %eax,-0xbc(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xbc(%rbp),%edi
mov    -0xb8(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jge    173d <main+0x50d>
lea    0xac1(%rip),%rdi
call   10c0 <senderr@plt>
mov    -0x78(%rbp),%edi
call   1090 <term@plt>
mov    -0x78(%rbp),%eax
mov    %eax,-0xcc(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xcc(%rbp),%edi
mov    -0xc8(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jge    178f <main+0x55f>
lea    0xa76(%rip),%rdi
call   10c0 <senderr@plt>
mov    -0x78(%rbp),%edi
call   1090 <term@plt>
cmpq   $0x0,-0x40(%rbp)
je     17d6 <main+0x5a6>
mov    -0x78(%rbp),%eax
mov    %eax,-0xdc(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xdc(%rbp),%edi
mov    -0xd8(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jge    17ec <main+0x5bc>
lea    0xa1e(%rip),%rdi
call   10c0 <senderr@plt>
mov    -0x78(%rbp),%edi
call   1090 <term@plt>
mov    -0x78(%rbp),%eax
mov    %eax,-0xec(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x48(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xec(%rbp),%edi
mov    -0xe8(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jge    183e <main+0x60e>
lea    0x9d5(%rip),%rdi
call   10c0 <senderr@plt>
mov    -0x78(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    -0x70(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jge    1866 <main+0x636>
lea    0x9c2(%rip),%rdi
call   10c0 <senderr@plt>
cmpl   $0x0,-0x74(%rbp)
jne    18e4 <main+0x6b4>
mov    -0x28(%rbp),%rdi
mov    0x277d(%rip),%rax
mov    (%rax),%esi
mov    0x276c(%rip),%rax
or     (%rax),%esi
mov    0x2703(%rip),%rax
or     (%rax),%esi
mov    0x270a(%rip),%rax
mov    (%rax),%edx
mov    0x2729(%rip),%rax
or     (%rax),%edx
mov    0x2708(%rip),%rax
or     (%rax),%edx
mov    0x26f7(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   10f0 <open@plt>
mov    %eax,-0x68(%rbp)
cmp    $0x0,%eax
jge    18df <main+0x6af>
mov    -0x28(%rbp),%rsi
lea    0x959(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <fail@plt>
jmp    18e4 <main+0x6b4>
movl   $0x0,-0x64(%rbp)
mov    -0x78(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
cmp    $0x0,%rax
jle    1944 <main+0x714>
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jne    1918 <main+0x6e8>
jmp    1944 <main+0x714>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x74(%rbp)
jne    193f <main+0x70f>
mov    -0x68(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %eax,-0x7c(%rbp)
jmp    18eb <main+0x6bb>
cmpl   $0x0,-0x74(%rbp)
jne    1956 <main+0x726>
mov    -0x68(%rbp),%edi
call   1080 <close@plt>
mov    -0x78(%rbp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbp
mov    (%rsi),%r14
add    $0xfffffff8,%edi
cmp    $0xfffffffd,%edi
ja     1264 <main+0x24>
mov    %r14,%rdi
call   10f0 <usage@plt>
mov    0x8(%rbp),%rdi
mov    0x10(%rbp),%rbx
mov    0x18(%rbp),%r12
mov    0x20(%rbp),%rax
mov    %rax,0x18(%rsp)
mov    0x28(%rbp),%r13
mov    0x30(%rbp),%rax
mov    %rax,0x50(%rsp)
mov    0x2cfb(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rdi,0x40(%rsp)
call   1110 <access@plt>
test   %rax,%rax
jns    12b8 <main+0x78>
lea    0xd5a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
call   10f0 <usage@plt>
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1110 <access@plt>
test   %rax,%rax
jns    12e1 <main+0xa1>
lea    0xd4a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
call   10f0 <usage@plt>
mov    %rbx,0x10(%rsp)
lea    0xd45(%rip),%rsi
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
mov    %rax,%r15
lea    0xd36(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1334 <main+0xf4>
lea    0xd2e(%rip),%rsi
mov    0x18(%rsp),%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1334 <main+0xf4>
test   %r15,%r15
je     1334 <main+0xf4>
mov    %r14,%rdi
call   10f0 <usage@plt>
lea    0xd15(%rip),%rsi
mov    %r13,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1364 <main+0x124>
lea    0xd07(%rip),%rsi
mov    %r13,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1364 <main+0x124>
mov    %r14,%rdi
call   10f0 <usage@plt>
test   %r15,%r15
jne    13fc <main+0x1bc>
mov    0x2c64(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1100 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    139f <main+0x15f>
lea    0xcce(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
call   10f0 <usage@plt>
lea    0x20(%rsp),%rsi
mov    %ebp,%edi
call   1150 <fstat@plt>
test   %rax,%rax
jns    13c8 <main+0x188>
lea    0xcce(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
call   1060 <fail@plt>
mov    0x2bb1(%rip),%rax
mov    (%rax),%eax
test   %eax,0x20(%rsp)
jne    13f5 <main+0x1b5>
lea    0xcc9(%rip),%rdi
mov    0x18(%rsp),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
call   10f0 <usage@plt>
mov    %ebp,%edi
call   1090 <close@plt>
mov    0x2bd5(%rip),%rax
mov    (%rax),%esi
mov    0x10(%rsp),%rdi
xor    %eax,%eax
call   1100 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1431 <main+0x1f1>
lea    0xcbc(%rip),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
call   1060 <fail@plt>
mov    %r12,0x28(%rsp)
lea    0x20(%rsp),%rsi
mov    %ebp,%edi
call   1150 <fstat@plt>
test   %rax,%rax
jns    1461 <main+0x221>
lea    0xcaa(%rip),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
call   1060 <fail@plt>
mov    0x24(%rsp),%r12d
mov    %r12d,%edi
call   10e0 <malloc@plt>
add    $0x1,%rax
mov    %ebp,%edi
mov    %rax,0x38(%rsp)
mov    %rax,%rsi
mov    %r12d,%edx
call   10b0 <read@plt>
test   %rax,%rax
jns    14a3 <main+0x263>
lea    0xc8a(%rip),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
call   1060 <fail@plt>
mov    %ebp,%edi
call   1090 <close@plt>
mov    0x2b1f(%rip),%rbx
mov    (%rbx),%edi
mov    0x2afe(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    14dd <main+0x29d>
lea    0xd24(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <fail@plt>
mov    %r13,0x48(%rsp)
mov    (%rbx),%eax
mov    %eax,0x34(%rsp)
mov    0x30(%rsp),%edi
mov    0x40(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0x30(%rsp),%rsi
mov    %r14d,%edi
mov    $0x8,%edx
call   1140 <connect@plt>
test   %rax,%rax
jns    1530 <main+0x2f0>
mov    %r14d,%edi
call   1090 <close@plt>
lea    0xc19(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
call   1060 <fail@plt>
cvtsi2sd %r12d,%xmm0
call   1120 <log10@plt>
lea    0x2(%rax),%edi
call   10e0 <malloc@plt>
mov    %rax,%r13
test   %rax,%rax
jne    155d <main+0x31d>
lea    0xc7c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <fail@plt>
lea    -0x1(%r12),%edx
lea    0xbfb(%rip),%rsi
mov    %r13,%rdi
call   1130 <sprintf@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   %eax,%eax
jns    159b <main+0x35b>
lea    0xbd2(%rip),%rdi
call   10d0 <senderr@plt>
mov    %r14d,%edi
call   10a0 <term@plt>
mov    0x28(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   %eax,%eax
jns    15cd <main+0x38d>
lea    0xbb0(%rip),%rdi
call   10d0 <senderr@plt>
mov    %r14d,%edi
call   10a0 <term@plt>
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   %eax,%eax
jns    15ff <main+0x3bf>
lea    0xb8a(%rip),%rdi
call   10d0 <senderr@plt>
mov    %r14d,%edi
call   10a0 <term@plt>
mov    0x48(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1633 <main+0x3f3>
lea    0xb5d(%rip),%rdi
call   10d0 <senderr@plt>
mov    %r14d,%edi
call   10a0 <term@plt>
mov    0x50(%rsp),%rax
test   %rax,%rax
je     165f <main+0x41f>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,%ebx
test   %ebx,%ebx
jns    166f <main+0x42f>
lea    0xb26(%rip),%rdi
call   10d0 <senderr@plt>
mov    %r14d,%edi
call   10a0 <term@plt>
mov    %r13,%rdi
call   1070 <strlen@plt>
mov    %r14d,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   %eax,%eax
jns    169c <main+0x45c>
lea    0xb49(%rip),%rdi
call   10d0 <senderr@plt>
mov    %r14d,%edi
mov    0x38(%rsp),%rsi
mov    %r12d,%edx
call   1050 <write@plt>
test   %eax,%eax
jns    16bc <main+0x47c>
lea    0xae2(%rip),%rdi
call   10d0 <senderr@plt>
test   %r15,%r15
mov    0x28(%rsp),%rbx
je     172d <main+0x4ed>
mov    0x292b(%rip),%rax
mov    0x291c(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x28b1(%rip),%rax
or     (%rax),%esi
mov    0x28b8(%rip),%rax
mov    0x28d9(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x28b6(%rip),%rax
or     (%rax),%edx
mov    0x28a5(%rip),%rax
or     (%rax),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1100 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    172d <main+0x4ed>
lea    0xa84(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
call   1060 <fail@plt>
lea    0xf(%rsp),%rsi
mov    %r14d,%edi
mov    $0x1,%edx
call   10b0 <read@plt>
test   %rax,%rax
jle    1780 <main+0x540>
cmpb   $0x0,0xf(%rsp)
je     1780 <main+0x540>
lea    0xf(%rsp),%rbx
test   %r15,%r15
je     1764 <main+0x524>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
test   %rax,%rax
jle    1780 <main+0x540>
cmpb   $0x0,0xf(%rsp)
jne    1750 <main+0x510>
test   %r15,%r15
je     178c <main+0x54c>
mov    %ebp,%edi
call   1090 <close@plt>
mov    %r14d,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.stat = type { i32, i32 }
%struct.sockaddr = type { i32 }
@F_OK = global i32 0
@.str = [25 x i8] c"<socket> '%s' not found\0A\00"
@.str.1 = [25 x i8] c"<infile> '%s' not found\0A\00"
@.str.2 = [8 x i8] c"modinfo\00"
@.str.3 = [12 x i8] c"passthrough\00"
@.str.4 = [10 x i8] c"translate\00"
@.str.5 = [6 x i8] c"fixed\00"
@.str.6 = [5 x i8] c"free\00"
@O_RDONLY = global i32 0
@.str.7 = [42 x i8] c"<moddir> output directory '%s' not found\0A\00"
@.str.8 = [34 x i8] c"Could not get <moddir> '%s' info\0A\00"
@S_IFDIR = global i32 0
@.str.9 = [51 x i8] c"'%s' requires output directory <moddir>, not '%s'\0A\00"
@.str.10 = [30 x i8] c"Could not open <infile> '%s'\0A\00"
@.str.11 = [34 x i8] c"Could not get <infile> '%s' info\0A\00"
@.str.12 = [51 x i8] c"Could not allocate input buffer for <infile> '%s'\0A\00"
@.str.13 = [30 x i8] c"Could not read <infile> '%s'\0A\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.14 = [25 x i8] c"Could not create socket\0A\00"
@.str.15 = [44 x i8] c"Could not connect to server on socket '%s'\0A\00"
@.str.16 = [41 x i8] c"Could not allocate source-length string\0A\00"
@.str.17 = [4 x i8] c"%d\0A\00"
@.str.18 = [16 x i8] c"input file name\00"
@.str.19 = [12 x i8] c"output path\00"
@.str.20 = [7 x i8] c"action\00"
@.str.21 = [5 x i8] c"form\00"
@.str.22 = [9 x i8] c"includes\00"
@.str.23 = [21 x i8] c"source-length string\00"
@.str.24 = [7 x i8] c"source\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_WRONLY = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str.25 = [45 x i8] c"Could not open output file '%s' for writing\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca %struct.sockaddr_un
%24 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
store i8* %27, i8** %9
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 6
br i1 %29, label %33, label %30
30: ; preds = %2
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 7
br i1 %32, label %33, label %36
33: ; preds = %30, %2
%34 = load i8*, i8** %9
%35 = call i32 @usage(i8* %34)
br label %36
36: ; preds = %33, %30
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
store i8* %39, i8** %13
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
store i8* %42, i8** %14
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 3
%45 = load i8*, i8** %44
store i8* %45, i8** %8
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 4
%48 = load i8*, i8** %47
store i8* %48, i8** %6
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 5
%51 = load i8*, i8** %50
store i8* %51, i8** %10
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 6
%54 = load i8*, i8** %53
store i8* %54, i8** %11
%55 = load i8*, i8** %13
%56 = load i32, i32* @F_OK
%57 = call i64 @access(i8* %55, i32 %56)
%58 = icmp slt i64 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %36
%60 = load i8*, i8** %14
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %60)
%62 = load i8*, i8** %9
%63 = call i32 @usage(i8* %62)
br label %64
64: ; preds = %59, %36
%65 = load i8*, i8** %14
%66 = load i32, i32* @F_OK
%67 = call i64 @access(i8* %65, i32 %66)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %74
69: ; preds = %64
%70 = load i8*, i8** %14
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %70)
%72 = load i8*, i8** %9
%73 = call i32 @usage(i8* %72)
br label %74
74: ; preds = %69, %64
%75 = load i8*, i8** %6
%76 = call i64 @strcmp(i8* %75, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%77 = icmp eq i64 %76, 0
%78 = zext i1 %77 to i64
%79 = select i1 %77, i32 1, i32 0
store i32 %79, i32* %20
%80 = load i8*, i8** %6
%81 = call i64 @strcmp(i8* %80, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %93
83: ; preds = %74
%84 = load i8*, i8** %6
%85 = call i64 @strcmp(i8* %84, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%86 = icmp ne i64 %85, 0
br i1 %86, label %87, label %93
87: ; preds = %83
%88 = load i32, i32* %20
%89 = icmp ne i32 %88, 0
br i1 %89, label %93, label %90
90: ; preds = %87
%91 = load i8*, i8** %9
%92 = call i32 @usage(i8* %91)
br label %93
93: ; preds = %90, %87, %83, %74
%94 = load i8*, i8** %10
%95 = call i64 @strcmp(i8* %94, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %104
97: ; preds = %93
%98 = load i8*, i8** %10
%99 = call i64 @strcmp(i8* %98, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%100 = icmp ne i64 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %97
%102 = load i8*, i8** %9
%103 = call i32 @usage(i8* %102)
br label %104
104: ; preds = %101, %97, %93
%105 = load i32, i32* %20
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %140
107: ; preds = %104
%108 = load i8*, i8** %8
%109 = load i32, i32* @O_RDONLY
%110 = call i32 (i8*, i32, ...) @open(i8* %108, i32 %109)
store i32 %110, i32* %17
%111 = icmp slt i32 %110, 0
br i1 %111, label %112, label %117
112: ; preds = %107
%113 = load i8*, i8** %8
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i8* %113)
%115 = load i8*, i8** %9
%116 = call i32 @usage(i8* %115)
br label %117
117: ; preds = %112, %107
%118 = load i32, i32* %17
%119 = call i64 @fstat(i32 %118, %struct.stat* %24)
%120 = icmp slt i64 %119, 0
br i1 %120, label %121, label %125
121: ; preds = %117
%122 = load i8*, i8** %8
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i8* %122)
%124 = call i32 (...) @fail()
br label %125
125: ; preds = %121, %117
%126 = getelementptr inbounds %struct.stat, %struct.stat* %24, i32 0, i32 0
%127 = load i32, i32* %126
%128 = load i32, i32* @S_IFDIR
%129 = and i32 %127, %128
%130 = icmp ne i32 %129, 0
br i1 %130, label %137, label %131
131: ; preds = %125
%132 = load i8*, i8** %6
%133 = load i8*, i8** %8
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0), i8* %132, i8* %133)
%135 = load i8*, i8** %9
%136 = call i32 @usage(i8* %135)
br label %137
137: ; preds = %131, %125
%138 = load i32, i32* %17
%139 = call i32 @close(i32 %138)
br label %140
140: ; preds = %137, %104
%141 = load i8*, i8** %14
%142 = load i32, i32* @O_RDONLY
%143 = call i32 (i8*, i32, ...) @open(i8* %141, i32 %142)
store i32 %143, i32* %17
%144 = icmp slt i32 %143, 0
br i1 %144, label %145, label %149
145: ; preds = %140
%146 = load i8*, i8** %14
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), i8* %146)
%148 = call i32 (...) @fail()
br label %149
149: ; preds = %145, %140
%150 = load i32, i32* %17
%151 = call i64 @fstat(i32 %150, %struct.stat* %24)
%152 = icmp slt i64 %151, 0
br i1 %152, label %153, label %157
153: ; preds = %149
%154 = load i8*, i8** %14
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i8* %154)
%156 = call i32 (...) @fail()
br label %157
157: ; preds = %153, %149
%158 = getelementptr inbounds %struct.stat, %struct.stat* %24, i32 0, i32 1
%159 = load i32, i32* %158
store i32 %159, i32* %19
%160 = load i32, i32* %19
%161 = call i64 @malloc(i32 %160)
%162 = inttoptr i64 %161 to i8*
%163 = getelementptr inbounds i8, i8* %162, i64 1
store i8* %163, i8** %15
%164 = icmp eq i8* %163, null
br i1 %164, label %165, label %169
165: ; preds = %157
%166 = load i8*, i8** %14
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.12, i64 0, i64 0), i8* %166)
%168 = call i32 (...) @fail()
br label %169
169: ; preds = %165, %157
%170 = load i32, i32* %17
%171 = load i8*, i8** %15
%172 = load i32, i32* %19
%173 = call i64 @read(i32 %170, i8* %171, i32 %172)
%174 = icmp slt i64 %173, 0
br i1 %174, label %175, label %179
175: ; preds = %169
%176 = load i8*, i8** %14
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), i8* %176)
%178 = call i32 (...) @fail()
br label %179
179: ; preds = %175, %169
%180 = load i32, i32* %17
%181 = call i32 @close(i32 %180)
%182 = load i32, i32* @AF_UNIX
%183 = load i32, i32* @SOCK_STREAM
%184 = call i32 @socket(i32 %182, i32 %183, i32 0)
store i32 %184, i32* %21
%185 = load i32, i32* %21
%186 = icmp slt i32 %185, 0
br i1 %186, label %187, label %190
187: ; preds = %179
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
%189 = call i32 (...) @fail()
br label %190
190: ; preds = %187, %179
%191 = load i32, i32* @AF_UNIX
%192 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %23, i32 0, i32 1
store i32 %191, i32* %192
%193 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %23, i32 0, i32 0
%194 = load i32, i32* %193
%195 = load i8*, i8** %13
%196 = call i32 @strcpy(i32 %194, i8* %195)
%197 = load i32, i32* %21
%198 = bitcast %struct.sockaddr_un* %23 to %struct.sockaddr*
%199 = call i64 @connect(i32 %197, %struct.sockaddr* %198, i32 8)
%200 = icmp slt i64 %199, 0
br i1 %200, label %201, label %207
201: ; preds = %190
%202 = load i32, i32* %21
%203 = call i32 @close(i32 %202)
%204 = load i8*, i8** %13
%205 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.15, i64 0, i64 0), i8* %204)
%206 = call i32 (...) @fail()
br label %207
207: ; preds = %201, %190
%208 = load i32, i32* %19
%209 = sitofp i32 %208 to double
%210 = call i64 @log10(double %209)
%211 = trunc i64 %210 to i32
store i32 %211, i32* %18
%212 = load i32, i32* %18
%213 = add nsw i32 %212, 2
%214 = call i64 @malloc(i32 %213)
%215 = inttoptr i64 %214 to i8*
store i8* %215, i8** %12
%216 = icmp eq i8* %215, null
br i1 %216, label %217, label %220
217: ; preds = %207
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.16, i64 0, i64 0))
%219 = call i32 (...) @fail()
br label %220
220: ; preds = %217, %207
%221 = load i8*, i8** %12
%222 = load i32, i32* %19
%223 = sub nsw i32 %222, 1
%224 = call i32 @sprintf(i8* %221, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0), i32 %223)
%225 = load i32, i32* %21
%226 = load i8*, i8** %14
%227 = load i8*, i8** %14
%228 = call i32 @strlen(i8* %227)
%229 = call i32 @write(i32 %225, i8* %226, i32 %228)
store i32 %229, i32* %22
%230 = load i32, i32* %22
%231 = icmp slt i32 %230, 0
br i1 %231, label %232, label %234
232: ; preds = %220
%233 = call i32 @senderr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.18, i64 0, i64 0))
br label %234
234: ; preds = %232, %220
%235 = load i32, i32* %21
%236 = call i32 @term(i32 %235)
%237 = load i32, i32* %21
%238 = load i8*, i8** %8
%239 = load i8*, i8** %8
%240 = call i32 @strlen(i8* %239)
%241 = call i32 @write(i32 %237, i8* %238, i32 %240)
store i32 %241, i32* %22
%242 = load i32, i32* %22
%243 = icmp slt i32 %242, 0
br i1 %243, label %244, label %246
244: ; preds = %234
%245 = call i32 @senderr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
br label %246
246: ; preds = %244, %234
%247 = load i32, i32* %21
%248 = call i32 @term(i32 %247)
%249 = load i32, i32* %21
%250 = load i8*, i8** %6
%251 = load i8*, i8** %6
%252 = call i32 @strlen(i8* %251)
%253 = call i32 @write(i32 %249, i8* %250, i32 %252)
store i32 %253, i32* %22
%254 = load i32, i32* %22
%255 = icmp slt i32 %254, 0
br i1 %255, label %256, label %258
256: ; preds = %246
%257 = call i32 @senderr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0))
br label %258
258: ; preds = %256, %246
%259 = load i32, i32* %21
%260 = call i32 @term(i32 %259)
%261 = load i32, i32* %21
%262 = load i8*, i8** %10
%263 = load i8*, i8** %10
%264 = call i32 @strlen(i8* %263)
%265 = call i32 @write(i32 %261, i8* %262, i32 %264)
store i32 %265, i32* %22
%266 = load i32, i32* %22
%267 = icmp slt i32 %266, 0
br i1 %267, label %268, label %270
268: ; preds = %258
%269 = call i32 @senderr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0))
br label %270
270: ; preds = %268, %258
%271 = load i32, i32* %21
%272 = call i32 @term(i32 %271)
%273 = load i8*, i8** %11
%274 = icmp ne i8* %273, null
br i1 %274, label %275, label %281
275: ; preds = %270
%276 = load i32, i32* %21
%277 = load i8*, i8** %11
%278 = load i8*, i8** %11
%279 = call i32 @strlen(i8* %278)
%280 = call i32 @write(i32 %276, i8* %277, i32 %279)
store i32 %280, i32* %22
br label %281
281: ; preds = %275, %270
%282 = load i32, i32* %22
%283 = icmp slt i32 %282, 0
br i1 %283, label %284, label %286
284: ; preds = %281
%285 = call i32 @senderr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i64 0, i64 0))
br label %286
286: ; preds = %284, %281
%287 = load i32, i32* %21
%288 = call i32 @term(i32 %287)
%289 = load i32, i32* %21
%290 = load i8*, i8** %12
%291 = load i8*, i8** %12
%292 = call i32 @strlen(i8* %291)
%293 = call i32 @write(i32 %289, i8* %290, i32 %292)
store i32 %293, i32* %22
%294 = load i32, i32* %22
%295 = icmp slt i32 %294, 0
br i1 %295, label %296, label %298
296: ; preds = %286
%297 = call i32 @senderr(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.23, i64 0, i64 0))
br label %298
298: ; preds = %296, %286
%299 = load i32, i32* %21
%300 = load i8*, i8** %15
%301 = load i32, i32* %19
%302 = call i32 @write(i32 %299, i8* %300, i32 %301)
store i32 %302, i32* %22
%303 = load i32, i32* %22
%304 = icmp slt i32 %303, 0
br i1 %304, label %305, label %307
305: ; preds = %298
%306 = call i32 @senderr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.24, i64 0, i64 0))
br label %307
307: ; preds = %305, %298
%308 = load i32, i32* %20
%309 = icmp ne i32 %308, 0
br i1 %309, label %331, label %310
310: ; preds = %307
%311 = load i8*, i8** %8
%312 = load i32, i32* @O_CREAT
%313 = load i32, i32* @O_TRUNC
%314 = or i32 %312, %313
%315 = load i32, i32* @O_WRONLY
%316 = or i32 %314, %315
%317 = load i32, i32* @S_IRUSR
%318 = load i32, i32* @S_IWUSR
%319 = or i32 %317, %318
%320 = load i32, i32* @S_IRGRP
%321 = or i32 %319, %320
%322 = load i32, i32* @S_IROTH
%323 = or i32 %321, %322
%324 = call i32 (i8*, i32, ...) @open(i8* %311, i32 %316, i32 %323)
store i32 %324, i32* %17
%325 = icmp slt i32 %324, 0
br i1 %325, label %326, label %330
326: ; preds = %310
%327 = load i8*, i8** %8
%328 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.25, i64 0, i64 0), i8* %327)
%329 = call i32 (...) @fail()
br label %330
330: ; preds = %326, %310
br label %331
331: ; preds = %330, %307
store i32 0, i32* %16
br label %332
332: ; preds = %349, %331
%333 = load i32, i32* %21
%334 = call i64 @read(i32 %333, i8* %7, i32 1)
%335 = icmp sgt i64 %334, 0
br i1 %335, label %336, label %350
336: ; preds = %332
%337 = load i8, i8* %7
%338 = sext i8 %337 to i32
%339 = icmp eq i32 %338, 0
br i1 %339, label %340, label %341
340: ; preds = %336
br label %350
341: ; preds = %336
%342 = load i32, i32* %16
%343 = add nsw i32 %342, 1
store i32 %343, i32* %16
%344 = load i32, i32* %20
%345 = icmp ne i32 %344, 0
br i1 %345, label %349, label %346
346: ; preds = %341
%347 = load i32, i32* %17
%348 = call i32 @write(i32 %347, i8* %7, i32 1)
store i32 %348, i32* %22
br label %349
349: ; preds = %346, %341
br label %332
350: ; preds = %340, %332
%351 = load i32, i32* %20
%352 = icmp ne i32 %351, 0
br i1 %352, label %356, label %353
353: ; preds = %350
%354 = load i32, i32* %17
%355 = call i32 @close(i32 %354)
br label %356
356: ; preds = %353, %350
%357 = load i32, i32* %21
%358 = call i32 @close(i32 %357)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.stat = type { i32, i32 }
%struct.sockaddr = type { i32 }
@F_OK = global i32 0
@.str = [25 x i8] c"<socket> '%s' not found\0A\00"
@.str.1 = [25 x i8] c"<infile> '%s' not found\0A\00"
@.str.2 = [8 x i8] c"modinfo\00"
@.str.3 = [12 x i8] c"passthrough\00"
@.str.4 = [10 x i8] c"translate\00"
@.str.5 = [6 x i8] c"fixed\00"
@.str.6 = [5 x i8] c"free\00"
@O_RDONLY = global i32 0
@.str.7 = [42 x i8] c"<moddir> output directory '%s' not found\0A\00"
@.str.8 = [34 x i8] c"Could not get <moddir> '%s' info\0A\00"
@S_IFDIR = global i32 0
@.str.9 = [51 x i8] c"'%s' requires output directory <moddir>, not '%s'\0A\00"
@.str.10 = [30 x i8] c"Could not open <infile> '%s'\0A\00"
@.str.11 = [34 x i8] c"Could not get <infile> '%s' info\0A\00"
@.str.13 = [30 x i8] c"Could not read <infile> '%s'\0A\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.15 = [44 x i8] c"Could not connect to server on socket '%s'\0A\00"
@.str.17 = [4 x i8] c"%d\0A\00"
@.str.18 = [16 x i8] c"input file name\00"
@.str.19 = [12 x i8] c"output path\00"
@.str.20 = [7 x i8] c"action\00"
@.str.21 = [5 x i8] c"form\00"
@.str.22 = [9 x i8] c"includes\00"
@.str.23 = [21 x i8] c"source-length string\00"
@.str.24 = [7 x i8] c"source\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_WRONLY = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str.25 = [45 x i8] c"Could not open output file '%s' for writing\0A\00"
@str = [40 x i8] c"Could not allocate source-length string\00"
@str.26 = [24 x i8] c"Could not create socket\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca %struct.sockaddr_un
%5 = alloca %struct.stat
%6 = bitcast %struct.sockaddr_un* %4 to i8*
%7 = bitcast %struct.stat* %5 to i8*
%8 = load i8*, i8** %1
%9 = add i32 %0, -8
%10 = icmp ult i32 %9, -2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @usage(i8* %8)
br label %13
13: ; preds = %2, %11
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8*, i8** %1, i64 4
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8*, i8** %1, i64 5
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8*, i8** %1, i64 6
%25 = load i8*, i8** %24
%26 = load i32, i32* @F_OK
%27 = tail call i64 @access(i8* %15, i32 %26)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %13
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %17)
%31 = tail call i32 @usage(i8* %8)
br label %32
32: ; preds = %29, %13
%33 = load i32, i32* @F_OK
%34 = tail call i64 @access(i8* %17, i32 %33)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%38 = tail call i32 @usage(i8* %8)
br label %39
39: ; preds = %36, %32
%40 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
%42 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %50, label %44
44: ; preds = %39
%45 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
%47 = select i1 %46, i1 true, i1 %41
br i1 %47, label %50, label %48
48: ; preds = %44
%49 = tail call i32 @usage(i8* %8)
br label %50
50: ; preds = %48, %44, %39
%51 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %58, label %53
53: ; preds = %50
%54 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %53
%57 = tail call i32 @usage(i8* %8)
br label %58
58: ; preds = %56, %53, %50
br i1 %41, label %59, label %83
59: ; preds = %58
%60 = load i32, i32* @O_RDONLY
%61 = tail call i32 (i8*, i32, ...) @open(i8* %19, i32 %60)
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i8* %19)
%65 = tail call i32 @usage(i8* %8)
br label %66
66: ; preds = %63, %59
%67 = call i64 @fstat(i32 %61, %struct.stat* %5)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i8* %19)
%71 = tail call i32 (...) @fail()
br label %72
72: ; preds = %69, %66
%73 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%74 = load i32, i32* %73
%75 = load i32, i32* @S_IFDIR
%76 = and i32 %75, %74
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %72
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0), i8* %21, i8* %19)
%80 = tail call i32 @usage(i8* %8)
br label %81
81: ; preds = %78, %72
%82 = tail call i32 @close(i32 %61)
br label %83
83: ; preds = %81, %58
%84 = load i32, i32* @O_RDONLY
%85 = tail call i32 (i8*, i32, ...) @open(i8* %17, i32 %84)
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %83
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), i8* %17)
%89 = tail call i32 (...) @fail()
br label %90
90: ; preds = %87, %83
%91 = call i64 @fstat(i32 %85, %struct.stat* %5)
%92 = icmp slt i64 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i8* %17)
%95 = tail call i32 (...) @fail()
br label %96
96: ; preds = %93, %90
%97 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 1
%98 = load i32, i32* %97
%99 = tail call i64 @malloc(i32 %98)
%100 = inttoptr i64 %99 to i8*
%101 = getelementptr inbounds i8, i8* %100, i64 1
%102 = tail call i64 @read(i32 %85, i8* %101, i32 %98)
%103 = icmp slt i64 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %96
%105 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), i8* %17)
%106 = tail call i32 (...) @fail()
br label %107
107: ; preds = %104, %96
%108 = tail call i32 @close(i32 %85)
%109 = load i32, i32* @AF_UNIX
%110 = load i32, i32* @SOCK_STREAM
%111 = tail call i32 @socket(i32 %109, i32 %110, i32 0)
%112 = icmp slt i32 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %107
%114 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.26, i64 0, i64 0))
%115 = tail call i32 (...) @fail()
br label %116
116: ; preds = %113, %107
%117 = load i32, i32* @AF_UNIX
%118 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %4, i64 0, i32 1
store i32 %117, i32* %118
%119 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %4, i64 0, i32 0
%120 = load i32, i32* %119
%121 = tail call i32 @strcpy(i32 %120, i8* %15)
%122 = bitcast %struct.sockaddr_un* %4 to %struct.sockaddr*
%123 = call i64 @connect(i32 %111, %struct.sockaddr* %122, i32 8)
%124 = icmp slt i64 %123, 0
br i1 %124, label %125, label %129
125: ; preds = %116
%126 = call i32 @close(i32 %111)
%127 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.15, i64 0, i64 0), i8* %15)
%128 = call i32 (...) @fail()
br label %129
129: ; preds = %125, %116
%130 = sitofp i32 %98 to double
%131 = call i64 @log10(double %130)
%132 = trunc i64 %131 to i32
%133 = add nsw i32 %132, 2
%134 = call i64 @malloc(i32 %133)
%135 = inttoptr i64 %134 to i8*
%136 = icmp eq i64 %134, 0
br i1 %136, label %137, label %140
137: ; preds = %129
%138 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%139 = call i32 (...) @fail()
br label %140
140: ; preds = %137, %129
%141 = add nsw i32 %98, -1
%142 = call i32 @sprintf(i8* dereferenceable(1) %135, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0), i32 %141)
%143 = call i32 @strlen(i8* %17)
%144 = call i32 @write(i32 %111, i8* %17, i32 %143)
%145 = icmp slt i32 %144, 0
br i1 %145, label %146, label %148
146: ; preds = %140
%147 = call i32 @senderr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.18, i64 0, i64 0))
br label %148
148: ; preds = %146, %140
%149 = call i32 @term(i32 %111)
%150 = call i32 @strlen(i8* %19)
%151 = call i32 @write(i32 %111, i8* %19, i32 %150)
%152 = icmp slt i32 %151, 0
br i1 %152, label %153, label %155
153: ; preds = %148
%154 = call i32 @senderr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
br label %155
155: ; preds = %153, %148
%156 = call i32 @term(i32 %111)
%157 = call i32 @strlen(i8* %21)
%158 = call i32 @write(i32 %111, i8* %21, i32 %157)
%159 = icmp slt i32 %158, 0
br i1 %159, label %160, label %162
160: ; preds = %155
%161 = call i32 @senderr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0))
br label %162
162: ; preds = %160, %155
%163 = call i32 @term(i32 %111)
%164 = call i32 @strlen(i8* %23)
%165 = call i32 @write(i32 %111, i8* %23, i32 %164)
%166 = icmp slt i32 %165, 0
br i1 %166, label %167, label %169
167: ; preds = %162
%168 = call i32 @senderr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0))
br label %169
169: ; preds = %167, %162
%170 = call i32 @term(i32 %111)
%171 = icmp eq i8* %25, null
br i1 %171, label %175, label %172
172: ; preds = %169
%173 = call i32 @strlen(i8* %25)
%174 = call i32 @write(i32 %111, i8* %25, i32 %173)
br label %175
175: ; preds = %172, %169
%176 = phi i32 [ %174, %172 ], [ %165, %169 ]
%177 = icmp slt i32 %176, 0
br i1 %177, label %178, label %180
178: ; preds = %175
%179 = call i32 @senderr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i64 0, i64 0))
br label %180
180: ; preds = %178, %175
%181 = call i32 @term(i32 %111)
%182 = call i32 @strlen(i8* %135)
%183 = call i32 @write(i32 %111, i8* %135, i32 %182)
%184 = icmp slt i32 %183, 0
br i1 %184, label %185, label %187
185: ; preds = %180
%186 = call i32 @senderr(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.23, i64 0, i64 0))
br label %187
187: ; preds = %185, %180
%188 = call i32 @write(i32 %111, i8* %101, i32 %98)
%189 = icmp slt i32 %188, 0
br i1 %189, label %190, label %192
190: ; preds = %187
%191 = call i32 @senderr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.24, i64 0, i64 0))
br label %192
192: ; preds = %190, %187
br i1 %41, label %211, label %193
193: ; preds = %192
%194 = load i32, i32* @O_CREAT
%195 = load i32, i32* @O_TRUNC
%196 = or i32 %195, %194
%197 = load i32, i32* @O_WRONLY
%198 = or i32 %196, %197
%199 = load i32, i32* @S_IRUSR
%200 = load i32, i32* @S_IWUSR
%201 = or i32 %200, %199
%202 = load i32, i32* @S_IRGRP
%203 = or i32 %201, %202
%204 = load i32, i32* @S_IROTH
%205 = or i32 %203, %204
%206 = call i32 (i8*, i32, ...) @open(i8* %19, i32 %198, i32 %205)
%207 = icmp slt i32 %206, 0
br i1 %207, label %208, label %211
208: ; preds = %193
%209 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.25, i64 0, i64 0), i8* %19)
%210 = call i32 (...) @fail()
br label %211
211: ; preds = %193, %208, %192
%212 = phi i32 [ %85, %192 ], [ %206, %208 ], [ %206, %193 ]
%213 = call i64 @read(i32 %111, i8* %3, i32 1)
%214 = icmp slt i64 %213, 1
%215 = load i8, i8* %3
%216 = icmp eq i8 %215, 0
%217 = select i1 %214, i1 true, i1 %216
br i1 %217, label %227, label %218
218: ; preds = %211, %221
br i1 %41, label %221, label %219
219: ; preds = %218
%220 = call i32 @write(i32 %212, i8* %3, i32 1)
br label %221
221: ; preds = %219, %218
%222 = call i64 @read(i32 %111, i8* %3, i32 1)
%223 = icmp slt i64 %222, 1
%224 = load i8, i8* %3
%225 = icmp eq i8 %224, 0
%226 = select i1 %223, i1 true, i1 %225
br i1 %226, label %227, label %218
227: ; preds = %221, %211
br i1 %41, label %230, label %228
228: ; preds = %227
%229 = call i32 @close(i32 %212)
br label %230
230: ; preds = %228, %227
%231 = call i32 @close(i32 %111)
ret i32 0
}