#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 sockaddr_un {
  char *sun_path;
  int /*<<< orphan*/ sun_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ cli_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ getsockname(int, struct sockaddr *, int *);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, size_t);
char *strstr(char *, char *);
scalar_t__ write(int, char *, int);
int main(int argc, char *argv[]) {
  int sockfd, newsockfd, servlen, n, i, how_many;
  socklen_t clilen;
  struct sockaddr_un cli_addr, serv_addr, name_addr;
  socklen_t namelen;
  char buffer[10240];
  char *begin_container, *end_container;
  size_t containerlen;
  if (argc != 4 && argc != 5) {
    fprintf(stderr,
            "Usage: %s how_many docker_socket container_id ip_address\n",
            argv[0]);
    exit(2);
  }
  how_many = atoi(argv[1]);
  if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
    perror("socket");
    exit(1);
  }
  memset((char *)&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sun_family = AF_UNIX;
  strcpy(serv_addr.sun_path, argv[2]);
  servlen = (sizeof(*(&serv_addr)) - sizeof((&serv_addr)->sun_path) +
             strlen((&serv_addr)->sun_path));
  if (bind(sockfd, (struct sockaddr *)&serv_addr, servlen) < 0) {
    perror("bind");
    exit(1);
  }
  namelen = (sizeof(*(&name_addr)) - sizeof((&name_addr)->sun_path) +
             strlen((&name_addr)->sun_path));
  if (getsockname(sockfd, (struct sockaddr *)&name_addr, &namelen) < 0) {
    perror("getsockname");
    exit(1);
  }
  listen(sockfd, 1);
  clilen = sizeof(cli_addr);
  for (i = 0; how_many == 0 || i < how_many; i++) {
    newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
    if (newsockfd < 0) {
      perror("accept");
      exit(1);
    }
    n = read(newsockfd, buffer, 10240);
    if (write(1, buffer, n) < 0) {
      perror("write(1)");
      exit(1);
    }
    if ((begin_container = strstr(buffer, "/containers/")) == NULL) {
      exit(1);
    }
    begin_container += sizeof("/containers/") - 1;
    if ((end_container = strchr(begin_container, '/')) == NULL) {
      exit(1);
    }
    *end_container = '\0';
    if ((containerlen = end_container - begin_container) == 0) {
      sprintf(buffer,
              "HTTP/1.0 404 Not Found\r\nContent-Type: text/plain; "
              "charset=utf-8\r\nDate: Sun, 20 Sep 2015 19:58:43 GMT\r\n\r\nno "
              "such id: %s\n",
              "CONTAINER");
    } else if (strncmp(begin_container, argv[3], containerlen) != 0) {
      sprintf(buffer,
              "HTTP/1.0 404 Not Found\r\nContent-Type: text/plain; "
              "charset=utf-8\r\nDate: Sun, 20 Sep 2015 19:58:43 GMT\r\n\r\nno "
              "such id: %s\n",
              begin_container);
    } else {
      sprintf(
          buffer,
          "HTTP/1.0 200 OK\r\nContent-Type: application/json\r\nDate: Sun, 20 "
          "Sep 2015 19:53:31 "
          "GMT\r\n\r\n{\"Id\":"
          "\"12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a\""
          ",\"Created\":\"2015-09-20T11:24:42.329765535Z\",\"Path\":\"/sbin/"
          "init\",\"Args\":[],\"State\":{\"Running\":true,\"Paused\":false,"
          "\"Restarting\":false,\"OOMKilled\":false,\"Dead\":false,\"Pid\":"
          "28145,\"ExitCode\":0,\"Error\":\"\",\"StartedAt\":\"2015-09-20T11:"
          "24:42.850759517Z\",\"FinishedAt\":\"0001-01-01T00:00:00Z\"},"
          "\"Image\":"
          "\"55c1102409b9642a20b5f1d1d894a8419aaaf539e867005d36ac4ffd59abed012a"
          "2\",\"NetworkSettings\":{\"Bridge\":\"\",\"EndpointID\":"
          "\"4fb52aafa1874afea14712e1a71ab85ffec7d508f5f5b2b302bbf54a1e398853\""
          ",\"Gateway\":\"172.17.42.1\",\"GlobalIPv6Address\":\"\","
          "\"GlobalIPv6PrefixLen\":0,\"HairpinMode\":false,\"IPAddress\":\"%"
          "s\",\"IPPrefixLen\":16,\"IPv6Gateway\":\"\","
          "\"LinkLocalIPv6Address\":\"\",\"LinkLocalIPv6PrefixLen\":0,"
          "\"MacAddress\":\"02:42:ac:11:00:02\",\"NetworkID\":"
          "\"ea191dc39711f748a4b26d03abdb98817135b65a53d3c2beba6586d9ffceaf31\""
          ",\"PortMapping\":null,\"Ports\":{},\"SandboxKey\":\"/var/run/docker/"
          "netns/"
          "12b2dd585ecb\",\"SecondaryIPAddresses\":null,"
          "\"SecondaryIPv6Addresses\":null},\"ResolvConfPath\":\"/var/lib/"
          "docker/containers/"
          "12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/"
          "resolv.conf\",\"HostnamePath\":\"/var/lib/docker/containers/"
          "12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/"
          "hostname\",\"HostsPath\":\"/var/lib/docker/containers/"
          "12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/"
          "hosts\",\"LogPath\":\"/var/lib/docker/containers/"
          "12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/"
          "12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a-"
          "json.log\",\"Name\":\"/"
          "%s\",\"RestartCount\":0,\"Driver\":\"aufs\",\"ExecDriver\":\"native-"
          "0.2\",\"MountLabel\":\"\",\"ProcessLabel\":\"\",\"Volumes\":{},"
          "\"VolumesRW\":{},\"AppArmorProfile\":\"\",\"ExecIDs\":null,"
          "\"HostConfig\":{\"Binds\":null,\"ContainerIDFile\":\"\",\"LxcConf\":"
          "[],\"Memory\":0,\"MemorySwap\":0,\"CpuShares\":0,\"CpuPeriod\":0,"
          "\"CpusetCpus\":\"\",\"CpusetMems\":\"\",\"CpuQuota\":0,"
          "\"BlkioWeight\":0,\"OomKillDisable\":false,\"Privileged\":false,"
          "\"PortBindings\":{},\"Links\":null,\"PublishAllPorts\":false,"
          "\"Dns\":null,\"DnsSearch\":null,\"ExtraHosts\":null,\"VolumesFrom\":"
          "null,\"Devices\":[],\"NetworkMode\":\"bridge\",\"IpcMode\":\"\","
          "\"PidMode\":\"\",\"UTSMode\":\"\",\"CapAdd\":null,\"CapDrop\":null,"
          "\"RestartPolicy\":{\"Name\":\"no\",\"MaximumRetryCount\":0},"
          "\"SecurityOpt\":null,\"ReadonlyRootfs\":false,\"Ulimits\":null,"
          "\"LogConfig\":{\"Type\":\"json-file\",\"Config\":{}},"
          "\"CgroupParent\":\"\"},\"Config\":{\"Hostname\":\"12b2dd585ecb\","
          "\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,"
          "\"AttachStdout\":true,\"AttachStderr\":true,\"PortSpecs\":null,"
          "\"ExposedPorts\":null,\"Tty\":false,\"OpenStdin\":false,"
          "\"StdinOnce\":false,\"Env\":[\"PATH=/usr/local/sbin:/usr/local/bin:/"
          "usr/sbin:/usr/bin:/sbin:/"
          "bin\"],\"Cmd\":null,\"Image\":\"hello-world\",\"Volumes\":null,"
          "\"VolumeDriver\":\"\",\"WorkingDir\":\"\",\"Entrypoint\":[\"/"
          "hello\"],\"NetworkDisabled\":false,\"MacAddress\":\"\",\"OnBuild\":"
          "null,\"Labels\":{},\"Memory\":0,\"MemorySwap\":0,\"CpuShares\":0,"
          "\"Cpuset\":\"\"}}\n",
          argv[4], argv[3]);
    }
    if (write(newsockfd, buffer, strlen(buffer)) < 0) {
      perror("write(newsockfd)");
      exit(1);
    }
    close(newsockfd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x28a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1283 <main+0x53>
cmpl   $0x5,-0x8(%rbp)
je     1283 <main+0x53>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd8c(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x2,%edi
call   1130 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
mov    0x2d2d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    12ce <main+0x9e>
lea    0xd7b(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <memset@plt>
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
cltq
add    $0x8,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
jge    133c <main+0x10c>
lea    0xd14(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x60(%rbp),%rdi
call   1060 <strlen@plt>
cltq
add    $0x8,%rax
mov    %eax,-0x64(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x60(%rbp),%rsi
lea    -0x64(%rbp),%rdx
call   1100 <getsockname@plt>
cmp    $0x0,%rax
jge    137e <main+0x14e>
lea    0xcd7(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   10c0 <listen@plt>
movl   $0x10,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x28(%rbp)
mov    %al,-0x2889(%rbp)
je     13ba <main+0x18a>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
setl   %al
mov    %al,-0x2889(%rbp)
mov    -0x2889(%rbp),%al
test   $0x1,%al
jne    13cd <main+0x19d>
jmp    15e1 <main+0x3b1>
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1400 <main+0x1d0>
lea    0xc61(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x18(%rbp),%edi
lea    -0x2870(%rbp),%rsi
mov    $0x2800,%edx
call   10a0 <read@plt>
mov    %eax,-0x20(%rbp)
lea    -0x2870(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    $0x1,%edi
call   1050 <write@plt>
cmp    $0x0,%rax
jge    144b <main+0x21b>
lea    0xc1d(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    -0x2870(%rbp),%rdi
lea    0xc09(%rip),%rsi
call   1140 <strstr@plt>
mov    %rax,-0x2878(%rbp)
cmp    $0x0,%rax
jne    1479 <main+0x249>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x2878(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x2878(%rbp)
mov    -0x2878(%rbp),%rdi
mov    $0x2f,%esi
call   1070 <strchr@plt>
mov    %rax,-0x2880(%rbp)
cmp    $0x0,%rax
jne    14b7 <main+0x287>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x2880(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x2880(%rbp),%rax
mov    -0x2878(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x2888(%rbp)
cmp    $0x0,%rax
jne    1504 <main+0x2d4>
lea    -0x2870(%rbp),%rdi
lea    0xb7e(%rip),%rsi
lea    0xbef(%rip),%rdx
mov    $0x0,%al
call   1120 <sprintf@plt>
jmp    1574 <main+0x344>
mov    -0x2878(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    -0x2888(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     154a <main+0x31a>
lea    -0x2870(%rbp),%rdi
mov    -0x2878(%rbp),%rdx
lea    0xb31(%rip),%rsi
mov    $0x0,%al
call   1120 <sprintf@plt>
jmp    156f <main+0x33f>
lea    -0x2870(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
lea    0xb89(%rip),%rsi
mov    $0x0,%al
call   1120 <sprintf@plt>
jmp    1574 <main+0x344>
mov    -0x18(%rbp),%eax
mov    %eax,-0x289c(%rbp)
lea    -0x2870(%rbp),%rax
mov    %rax,-0x2898(%rbp)
lea    -0x2870(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x289c(%rbp),%edi
mov    -0x2898(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    $0x0,%rax
jge    15cb <main+0x39b>
lea    0x168c(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1399 <main+0x169>
xor    %eax,%eax
add    $0x28a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2858,%rsp
mov    %rsi,%rbp
and    $0xfffffffe,%edi
cmp    $0x4,%edi
jne    148b <main+0x25b>
mov    0x8(%rbp),%rdi
call   1110 <atoi@plt>
mov    %eax,0xc(%rsp)
mov    0x2d84(%rip),%r15
mov    (%r15),%edi
mov    0x2d62(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
test   %eax,%eax
js     14ae <main+0x27e>
mov    %eax,%ebx
lea    0x20(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x28(%rsp)
mov    0x20(%rsp),%rdi
mov    0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    0x20(%rsp),%rdi
call   1060 <strlen@plt>
lea    0x8(%rax),%edx
mov    %ebx,%edi
mov    %r14,%rsi
call   10d0 <bind@plt>
test   %rax,%rax
js     14b7 <main+0x287>
mov    %rbp,0x18(%rsp)
call   1060 <strlen@plt>
add    $0x8,%eax
mov    %eax,0x10(%rsp)
lea    0x30(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1100 <getsockname@plt>
test   %rax,%rax
js     14c0 <main+0x290>
mov    $0x1,%ebp
mov    %ebx,%edi
mov    $0x1,%esi
call   10c0 <listen@plt>
movl   $0x10,0x14(%rsp)
cmpl   $0x0,0xc(%rsp)
js     1445 <main+0x215>
lea    0x50(%rsp),%r13
xchg   %ax,%ax
mov    %ebp,%r14d
mov    %ebx,%edi
lea    0x40(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   10f0 <accept@plt>
test   %eax,%eax
js     1463 <main+0x233>
mov    %eax,%r12d
mov    %eax,%edi
mov    %r13,%rsi
mov    $0x2800,%edx
call   10a0 <read@plt>
mov    $0x1,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   %rax,%rax
js     146c <main+0x23c>
mov    %r13,%rdi
lea    0xcf2(%rip),%rsi
call   1140 <strstr@plt>
test   %rax,%rax
je     1459 <main+0x229>
mov    %rax,%r15
add    $0xc,%r15
mov    %r15,%rdi
mov    $0x2f,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1459 <main+0x229>
movb   $0x0,(%rax)
sub    %r15,%rax
je     13d0 <main+0x1a0>
mov    0x18(%rsp),%rbp
mov    0x18(%rbp),%rsi
mov    %r15,%rdi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
je     13f0 <main+0x1c0>
mov    %r13,%rdi
lea    0xca9(%rip),%rsi
mov    %r15,%rdx
jmp    13e1 <main+0x1b1>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
lea    0xc95(%rip),%rsi
lea    0xd06(%rip),%rdx
xor    %eax,%eax
call   1120 <sprintf@plt>
jmp    1409 <main+0x1d9>
nopw   0x0(%rax,%rax,1)
mov    0x18(%rbp),%rcx
mov    0x20(%rbp),%rdx
mov    %r13,%rdi
lea    0xcef(%rip),%rsi
xor    %eax,%eax
call   1120 <sprintf@plt>
mov    %r13,%rdi
call   1060 <strlen@plt>
mov    %r12d,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   %rax,%rax
js     1475 <main+0x245>
mov    %r12d,%edi
call   1090 <close@plt>
lea    0x1(%r14),%ebp
cmpl   $0x0,0xc(%rsp)
je     1320 <main+0xf0>
cmp    0xc(%rsp),%r14d
jl     1320 <main+0xf0>
xor    %eax,%eax
add    $0x2858,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xbe8(%rip),%rdi
jmp    147c <main+0x24c>
lea    0xbe6(%rip),%rdi
jmp    147c <main+0x24c>
lea    0x17cc(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x2b46(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xb61(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x2,%edi
call   1130 <exit@plt>
lea    0xb85(%rip),%rdi
jmp    147c <main+0x24c>
lea    0xb83(%rip),%rdi
jmp    147c <main+0x24c>
lea    0xb7f(%rip),%rdi
jmp    147c <main+0x24c>

LLVM IR (-O0):
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [58 x i8] c"Usage: %s how_many docker_socket container_id ip_address\0A\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [5 x i8] c"bind\00"
@.str.3 = [12 x i8] c"getsockname\00"
@.str.4 = [7 x i8] c"accept\00"
@.str.5 = [9 x i8] c"write(1)\00"
@.str.6 = [13 x i8] c"/containers/\00"
@.str.7 = [120 x i8] c"HTTP/1.0 404 Not Found\0D\0AContent-Type: text/plain; charset=utf-8\0D\0ADate: Sun, 20 Sep 2015 19:58:43 GMT\0D\0A\0D\0Ano such id: %s\0A\00"
@.str.8 = [10 x i8] c"CONTAINER\00"
@.str.9 = [2903 x i8] c"HTTP/1.0 200 OK\0D\0AContent-Type: application/json\0D\0ADate: Sun, 20 Sep 2015 19:53:31 GMT\0D\0A\0D\0A{\22Id\22:\2212b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a\22,\22Created\22:\222015-09-20T11:24:42.329765535Z\22,\22Path\22:\22/sbin/init\22,\22Args\22:[],\22State\22:{\22Running\22:true,\22Paused\22:false,\22Restarting\22:false,\22OOMKilled\22:false,\22Dead\22:false,\22Pid\22:28145,\22ExitCode\22:0,\22Error\22:\22\22,\22StartedAt\22:\222015-09-20T11:24:42.850759517Z\22,\22FinishedAt\22:\220001-01-01T00:00:00Z\22},\22Image\22:\2255c1102409b9642a20b5f1d1d894a8419aaaf539e867005d36ac4ffd59abed012a2\22,\22NetworkSettings\22:{\22Bridge\22:\22\22,\22EndpointID\22:\224fb52aafa1874afea14712e1a71ab85ffec7d508f5f5b2b302bbf54a1e398853\22,\22Gateway\22:\22172.17.42.1\22,\22GlobalIPv6Address\22:\22\22,\22GlobalIPv6PrefixLen\22:0,\22HairpinMode\22:false,\22IPAddress\22:\22%s\22,\22IPPrefixLen\22:16,\22IPv6Gateway\22:\22\22,\22LinkLocalIPv6Address\22:\22\22,\22LinkLocalIPv6PrefixLen\22:0,\22MacAddress\22:\2202:42:ac:11:00:02\22,\22NetworkID\22:\22ea191dc39711f748a4b26d03abdb98817135b65a53d3c2beba6586d9ffceaf31\22,\22PortMapping\22:null,\22Ports\22:{},\22SandboxKey\22:\22/var/run/docker/netns/12b2dd585ecb\22,\22SecondaryIPAddresses\22:null,\22SecondaryIPv6Addresses\22:null},\22ResolvConfPath\22:\22/var/lib/docker/containers/12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/resolv.conf\22,\22HostnamePath\22:\22/var/lib/docker/containers/12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/hostname\22,\22HostsPath\22:\22/var/lib/docker/containers/12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/hosts\22,\22LogPath\22:\22/var/lib/docker/containers/12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a-json.log\22,\22Name\22:\22/%s\22,\22RestartCount\22:0,\22Driver\22:\22aufs\22,\22ExecDriver\22:\22native-0.2\22,\22MountLabel\22:\22\22,\22ProcessLabel\22:\22\22,\22Volumes\22:{},\22VolumesRW\22:{},\22AppArmorProfile\22:\22\22,\22ExecIDs\22:null,\22HostConfig\22:{\22Binds\22:null,\22ContainerIDFile\22:\22\22,\22LxcConf\22:[],\22Memory\22:0,\22MemorySwap\22:0,\22CpuShares\22:0,\22CpuPeriod\22:0,\22CpusetCpus\22:\22\22,\22CpusetMems\22:\22\22,\22CpuQuota\22:0,\22BlkioWeight\22:0,\22OomKillDisable\22:false,\22Privileged\22:false,\22PortBindings\22:{},\22Links\22:null,\22PublishAllPorts\22:false,\22Dns\22:null,\22DnsSearch\22:null,\22ExtraHosts\22:null,\22VolumesFrom\22:null,\22Devices\22:[],\22NetworkMode\22:\22bridge\22,\22IpcMode\22:\22\22,\22PidMode\22:\22\22,\22UTSMode\22:\22\22,\22CapAdd\22:null,\22CapDrop\22:null,\22RestartPolicy\22:{\22Name\22:\22no\22,\22MaximumRetryCount\22:0},\22SecurityOpt\22:null,\22ReadonlyRootfs\22:false,\22Ulimits\22:null,\22LogConfig\22:{\22Type\22:\22json-file\22,\22Config\22:{}},\22CgroupParent\22:\22\22},\22Config\22:{\22Hostname\22:\2212b2dd585ecb\22,\22Domainname\22:\22\22,\22User\22:\22\22,\22AttachStdin\22:false,\22AttachStdout\22:true,\22AttachStderr\22:true,\22PortSpecs\22:null,\22ExposedPorts\22:null,\22Tty\22:false,\22OpenStdin\22:false,\22StdinOnce\22:false,\22Env\22:[\22PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\22],\22Cmd\22:null,\22Image\22:\22hello-world\22,\22Volumes\22:null,\22VolumeDriver\22:\22\22,\22WorkingDir\22:\22\22,\22Entrypoint\22:[\22/hello\22],\22NetworkDisabled\22:false,\22MacAddress\22:\22\22,\22OnBuild\22:null,\22Labels\22:{},\22Memory\22:0,\22MemorySwap\22:0,\22CpuShares\22:0,\22Cpuset\22:\22\22}}\0A\00"
@.str.10 = [17 x i8] c"write(newsockfd)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.sockaddr_un
%14 = alloca %struct.sockaddr_un
%15 = alloca %struct.sockaddr_un
%16 = alloca i32
%17 = alloca [10240 x i8]
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 4
br i1 %22, label %23, label %33
23: ; preds = %2
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 5
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = call i32 @exit(i32 2)
unreachable
33: ; preds = %23, %2
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %11
%38 = load i32, i32* @AF_UNIX
%39 = load i32, i32* @SOCK_STREAM
%40 = call i32 @socket(i32 %38, i32 %39, i32 0)
store i32 %40, i32* %6
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %33
%43 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %33
%46 = bitcast %struct.sockaddr_un* %14 to i8*
%47 = call i32 @memset(i8* %46, i32 0, i32 16)
%48 = load i32, i32* @AF_UNIX
%49 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %14, i32 0, i32 1
store i32 %48, i32* %49
%50 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %14, i32 0, i32 0
%51 = load i8*, i8** %50
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 2
%54 = load i8*, i8** %53
%55 = call i32 @strcpy(i8* %51, i8* %54)
%56 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %14, i32 0, i32 0
%57 = load i8*, i8** %56
%58 = call i32 @strlen(i8* %57)
%59 = sext i32 %58 to i64
%60 = add i64 8, %59
%61 = trunc i64 %60 to i32
store i32 %61, i32* %8
%62 = load i32, i32* %6
%63 = bitcast %struct.sockaddr_un* %14 to %struct.sockaddr*
%64 = load i32, i32* %8
%65 = call i64 @bind(i32 %62, %struct.sockaddr* %63, i32 %64)
%66 = icmp slt i64 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %45
%68 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %45
%71 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %15, i32 0, i32 0
%72 = load i8*, i8** %71
%73 = call i32 @strlen(i8* %72)
%74 = sext i32 %73 to i64
%75 = add i64 8, %74
%76 = trunc i64 %75 to i32
store i32 %76, i32* %16
%77 = load i32, i32* %6
%78 = bitcast %struct.sockaddr_un* %15 to %struct.sockaddr*
%79 = call i64 @getsockname(i32 %77, %struct.sockaddr* %78, i32* %16)
%80 = icmp slt i64 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %70
%82 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %70
%85 = load i32, i32* %6
%86 = call i32 @listen(i32 %85, i32 1)
store i32 16, i32* %12
store i32 0, i32* %10
br label %87
87: ; preds = %176, %84
%88 = load i32, i32* %11
%89 = icmp eq i32 %88, 0
br i1 %89, label %94, label %90
90: ; preds = %87
%91 = load i32, i32* %10
%92 = load i32, i32* %11
%93 = icmp slt i32 %91, %92
br label %94
94: ; preds = %90, %87
%95 = phi i1 [ true, %87 ], [ %93, %90 ]
br i1 %95, label %96, label %179
96: ; preds = %94
%97 = load i32, i32* %6
%98 = bitcast %struct.sockaddr_un* %13 to %struct.sockaddr*
%99 = call i32 @accept(i32 %97, %struct.sockaddr* %98, i32* %12)
store i32 %99, i32* %7
%100 = load i32, i32* %7
%101 = icmp slt i32 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %96
%103 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %96
%106 = load i32, i32* %7
%107 = getelementptr inbounds [10240 x i8], [10240 x i8]* %17, i64 0, i64 0
%108 = call i32 @read(i32 %106, i8* %107, i32 10240)
store i32 %108, i32* %9
%109 = getelementptr inbounds [10240 x i8], [10240 x i8]* %17, i64 0, i64 0
%110 = load i32, i32* %9
%111 = call i64 @write(i32 1, i8* %109, i32 %110)
%112 = icmp slt i64 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %105
%114 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%115 = call i32 @exit(i32 1)
unreachable
116: ; preds = %105
%117 = getelementptr inbounds [10240 x i8], [10240 x i8]* %17, i64 0, i64 0
%118 = call i8* @strstr(i8* %117, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
store i8* %118, i8** %18
%119 = icmp eq i8* %118, null
br i1 %119, label %120, label %122
120: ; preds = %116
%121 = call i32 @exit(i32 1)
unreachable
122: ; preds = %116
%123 = load i8*, i8** %18
%124 = getelementptr inbounds i8, i8* %123, i64 12
store i8* %124, i8** %18
%125 = load i8*, i8** %18
%126 = call i8* @strchr(i8* %125, i8 signext 47)
store i8* %126, i8** %19
%127 = icmp eq i8* %126, null
br i1 %127, label %128, label %130
128: ; preds = %122
%129 = call i32 @exit(i32 1)
unreachable
130: ; preds = %122
%131 = load i8*, i8** %19
store i8 0, i8* %131
%132 = load i8*, i8** %19
%133 = load i8*, i8** %18
%134 = ptrtoint i8* %132 to i64
%135 = ptrtoint i8* %133 to i64
%136 = sub i64 %134, %135
store i64 %136, i64* %20
%137 = icmp eq i64 %136, 0
br i1 %137, label %138, label %141
138: ; preds = %130
%139 = getelementptr inbounds [10240 x i8], [10240 x i8]* %17, i64 0, i64 0
%140 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %139, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %163
141: ; preds = %130
%142 = load i8*, i8** %18
%143 = load i8**, i8*** %5
%144 = getelementptr inbounds i8*, i8** %143, i64 3
%145 = load i8*, i8** %144
%146 = load i64, i64* %20
%147 = call i64 @strncmp(i8* %142, i8* %145, i64 %146)
%148 = icmp ne i64 %147, 0
br i1 %148, label %149, label %153
149: ; preds = %141
%150 = getelementptr inbounds [10240 x i8], [10240 x i8]* %17, i64 0, i64 0
%151 = load i8*, i8** %18
%152 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %150, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.7, i64 0, i64 0), i8* %151)
br label %162
153: ; preds = %141
%154 = getelementptr inbounds [10240 x i8], [10240 x i8]* %17, i64 0, i64 0
%155 = load i8**, i8*** %5
%156 = getelementptr inbounds i8*, i8** %155, i64 4
%157 = load i8*, i8** %156
%158 = load i8**, i8*** %5
%159 = getelementptr inbounds i8*, i8** %158, i64 3
%160 = load i8*, i8** %159
%161 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %154, i8* getelementptr inbounds ([2903 x i8], [2903 x i8]* @.str.9, i64 0, i64 0), i8* %157, i8* %160)
br label %162
162: ; preds = %153, %149
br label %163
163: ; preds = %162, %138
%164 = load i32, i32* %7
%165 = getelementptr inbounds [10240 x i8], [10240 x i8]* %17, i64 0, i64 0
%166 = getelementptr inbounds [10240 x i8], [10240 x i8]* %17, i64 0, i64 0
%167 = call i32 @strlen(i8* %166)
%168 = call i64 @write(i32 %164, i8* %165, i32 %167)
%169 = icmp slt i64 %168, 0
br i1 %169, label %170, label %173
170: ; preds = %163
%171 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%172 = call i32 @exit(i32 1)
unreachable
173: ; preds = %163
%174 = load i32, i32* %7
%175 = call i32 @close(i32 %174)
br label %176
176: ; preds = %173
%177 = load i32, i32* %10
%178 = add nsw i32 %177, 1
store i32 %178, i32* %10
br label %87
179: ; preds = %94
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [58 x i8] c"Usage: %s how_many docker_socket container_id ip_address\0A\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [5 x i8] c"bind\00"
@.str.3 = [12 x i8] c"getsockname\00"
@.str.4 = [7 x i8] c"accept\00"
@.str.5 = [9 x i8] c"write(1)\00"
@.str.6 = [13 x i8] c"/containers/\00"
@.str.7 = [120 x i8] c"HTTP/1.0 404 Not Found\0D\0AContent-Type: text/plain; charset=utf-8\0D\0ADate: Sun, 20 Sep 2015 19:58:43 GMT\0D\0A\0D\0Ano such id: %s\0A\00"
@.str.8 = [10 x i8] c"CONTAINER\00"
@.str.9 = [2903 x i8] c"HTTP/1.0 200 OK\0D\0AContent-Type: application/json\0D\0ADate: Sun, 20 Sep 2015 19:53:31 GMT\0D\0A\0D\0A{\22Id\22:\2212b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a\22,\22Created\22:\222015-09-20T11:24:42.329765535Z\22,\22Path\22:\22/sbin/init\22,\22Args\22:[],\22State\22:{\22Running\22:true,\22Paused\22:false,\22Restarting\22:false,\22OOMKilled\22:false,\22Dead\22:false,\22Pid\22:28145,\22ExitCode\22:0,\22Error\22:\22\22,\22StartedAt\22:\222015-09-20T11:24:42.850759517Z\22,\22FinishedAt\22:\220001-01-01T00:00:00Z\22},\22Image\22:\2255c1102409b9642a20b5f1d1d894a8419aaaf539e867005d36ac4ffd59abed012a2\22,\22NetworkSettings\22:{\22Bridge\22:\22\22,\22EndpointID\22:\224fb52aafa1874afea14712e1a71ab85ffec7d508f5f5b2b302bbf54a1e398853\22,\22Gateway\22:\22172.17.42.1\22,\22GlobalIPv6Address\22:\22\22,\22GlobalIPv6PrefixLen\22:0,\22HairpinMode\22:false,\22IPAddress\22:\22%s\22,\22IPPrefixLen\22:16,\22IPv6Gateway\22:\22\22,\22LinkLocalIPv6Address\22:\22\22,\22LinkLocalIPv6PrefixLen\22:0,\22MacAddress\22:\2202:42:ac:11:00:02\22,\22NetworkID\22:\22ea191dc39711f748a4b26d03abdb98817135b65a53d3c2beba6586d9ffceaf31\22,\22PortMapping\22:null,\22Ports\22:{},\22SandboxKey\22:\22/var/run/docker/netns/12b2dd585ecb\22,\22SecondaryIPAddresses\22:null,\22SecondaryIPv6Addresses\22:null},\22ResolvConfPath\22:\22/var/lib/docker/containers/12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/resolv.conf\22,\22HostnamePath\22:\22/var/lib/docker/containers/12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/hostname\22,\22HostsPath\22:\22/var/lib/docker/containers/12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/hosts\22,\22LogPath\22:\22/var/lib/docker/containers/12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a/12b2dd585ecbdf168ad8a3645744445afe58794af7fdf2ab2b1bb97b6af3fc4a-json.log\22,\22Name\22:\22/%s\22,\22RestartCount\22:0,\22Driver\22:\22aufs\22,\22ExecDriver\22:\22native-0.2\22,\22MountLabel\22:\22\22,\22ProcessLabel\22:\22\22,\22Volumes\22:{},\22VolumesRW\22:{},\22AppArmorProfile\22:\22\22,\22ExecIDs\22:null,\22HostConfig\22:{\22Binds\22:null,\22ContainerIDFile\22:\22\22,\22LxcConf\22:[],\22Memory\22:0,\22MemorySwap\22:0,\22CpuShares\22:0,\22CpuPeriod\22:0,\22CpusetCpus\22:\22\22,\22CpusetMems\22:\22\22,\22CpuQuota\22:0,\22BlkioWeight\22:0,\22OomKillDisable\22:false,\22Privileged\22:false,\22PortBindings\22:{},\22Links\22:null,\22PublishAllPorts\22:false,\22Dns\22:null,\22DnsSearch\22:null,\22ExtraHosts\22:null,\22VolumesFrom\22:null,\22Devices\22:[],\22NetworkMode\22:\22bridge\22,\22IpcMode\22:\22\22,\22PidMode\22:\22\22,\22UTSMode\22:\22\22,\22CapAdd\22:null,\22CapDrop\22:null,\22RestartPolicy\22:{\22Name\22:\22no\22,\22MaximumRetryCount\22:0},\22SecurityOpt\22:null,\22ReadonlyRootfs\22:false,\22Ulimits\22:null,\22LogConfig\22:{\22Type\22:\22json-file\22,\22Config\22:{}},\22CgroupParent\22:\22\22},\22Config\22:{\22Hostname\22:\2212b2dd585ecb\22,\22Domainname\22:\22\22,\22User\22:\22\22,\22AttachStdin\22:false,\22AttachStdout\22:true,\22AttachStderr\22:true,\22PortSpecs\22:null,\22ExposedPorts\22:null,\22Tty\22:false,\22OpenStdin\22:false,\22StdinOnce\22:false,\22Env\22:[\22PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\22],\22Cmd\22:null,\22Image\22:\22hello-world\22,\22Volumes\22:null,\22VolumeDriver\22:\22\22,\22WorkingDir\22:\22\22,\22Entrypoint\22:[\22/hello\22],\22NetworkDisabled\22:false,\22MacAddress\22:\22\22,\22OnBuild\22:null,\22Labels\22:{},\22Memory\22:0,\22MemorySwap\22:0,\22CpuShares\22:0,\22Cpuset\22:\22\22}}\0A\00"
@.str.10 = [17 x i8] c"write(newsockfd)\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_un
%5 = alloca %struct.sockaddr_un
%6 = alloca %struct.sockaddr_un
%7 = alloca i32
%8 = alloca [10240 x i8]
%9 = bitcast i32* %3 to i8*
%10 = bitcast %struct.sockaddr_un* %4 to i8*
%11 = bitcast %struct.sockaddr_un* %5 to i8*
%12 = bitcast %struct.sockaddr_un* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = getelementptr inbounds [10240 x i8], [10240 x i8]* %8, i64 0, i64 0
%15 = and i32 %0, -2
%16 = icmp eq i32 %15, 4
br i1 %16, label %22, label %17
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %1
%20 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = tail call i32 @exit(i32 2)
unreachable
22: ; preds = %2
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call i32 @atoi(i8* %24)
%26 = load i32, i32* @AF_UNIX
%27 = load i32, i32* @SOCK_STREAM
%28 = tail call i32 @socket(i32 %26, i32 %27, i32 0)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %22
%31 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %22
%34 = call i32 @memset(i8* %11, i32 0, i32 16)
%35 = load i32, i32* @AF_UNIX
%36 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %5, i64 0, i32 1
store i32 %35, i32* %36
%37 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %5, i64 0, i32 0
%38 = load i8*, i8** %37
%39 = getelementptr inbounds i8*, i8** %1, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @strcpy(i8* %38, i8* %40)
%42 = load i8*, i8** %37
%43 = call i32 @strlen(i8* %42)
%44 = add i32 %43, 8
%45 = bitcast %struct.sockaddr_un* %5 to %struct.sockaddr*
%46 = call i64 @bind(i32 %28, %struct.sockaddr* %45, i32 %44)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %33
%49 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %33
%52 = call i32 @strlen(i8* undef)
%53 = add i32 %52, 8
store i32 %53, i32* %7
%54 = bitcast %struct.sockaddr_un* %6 to %struct.sockaddr*
%55 = call i64 @getsockname(i32 %28, %struct.sockaddr* %54, i32* %7)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %51
%58 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %51
%61 = call i32 @listen(i32 %28, i32 1)
store i32 16, i32* %3
%62 = icmp eq i32 %25, 0
%63 = icmp sgt i32 %25, -1
br i1 %63, label %64, label %122
64: ; preds = %60
%65 = bitcast %struct.sockaddr_un* %4 to %struct.sockaddr*
%66 = getelementptr inbounds i8*, i8** %1, i64 3
%67 = getelementptr inbounds i8*, i8** %1, i64 4
br label %68
68: ; preds = %64, %117
%69 = phi i32 [ 0, %64 ], [ %119, %117 ]
%70 = call i32 @accept(i32 %28, %struct.sockaddr* %65, i32* %3)
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %68
%73 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%74 = call i32 @exit(i32 1)
unreachable
75: ; preds = %68
%76 = call i32 @read(i32 %70, i8* %14, i32 10240)
%77 = call i64 @write(i32 1, i8* %14, i32 %76)
%78 = icmp slt i64 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %75
%80 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %75
%83 = call i8* @strstr(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%84 = icmp eq i8* %83, null
br i1 %84, label %85, label %87
85: ; preds = %82
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %82
%88 = getelementptr inbounds i8, i8* %83, i64 12
%89 = call i8* @strchr(i8* %88, i8 signext 47)
%90 = icmp eq i8* %89, null
br i1 %90, label %91, label %93
91: ; preds = %87
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %87
store i8 0, i8* %89
%94 = ptrtoint i8* %89 to i64
%95 = ptrtoint i8* %88 to i64
%96 = sub i64 %94, %95
%97 = icmp eq i64 %96, 0
br i1 %97, label %98, label %100
98: ; preds = %93
%99 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([120 x i8], [120 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %110
100: ; preds = %93
%101 = load i8*, i8** %66
%102 = call i64 @strncmp(i8* %88, i8* %101, i64 %96)
%103 = icmp eq i64 %102, 0
br i1 %103, label %106, label %104
104: ; preds = %100
%105 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([120 x i8], [120 x i8]* @.str.7, i64 0, i64 0), i8* %88)
br label %110
106: ; preds = %100
%107 = load i8*, i8** %67
%108 = load i8*, i8** %66
%109 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([2903 x i8], [2903 x i8]* @.str.9, i64 0, i64 0), i8* %107, i8* %108)
br label %110
110: ; preds = %104, %106, %98
%111 = call i32 @strlen(i8* %14)
%112 = call i64 @write(i32 %70, i8* %14, i32 %111)
%113 = icmp slt i64 %112, 0
br i1 %113, label %114, label %117
114: ; preds = %110
%115 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%116 = call i32 @exit(i32 1)
unreachable
117: ; preds = %110
%118 = call i32 @close(i32 %70)
%119 = add nuw nsw i32 %69, 1
%120 = icmp slt i32 %119, %25
%121 = select i1 %62, i1 true, i1 %120
br i1 %121, label %68, label %122
122: ; preds = %117, %60
ret i32 0
}