#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ uint32_t;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ server_addr;
typedef int /*<<< orphan*/ on;
typedef int /*<<< orphan*/ cli_addr;
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int O_NONBLOCK;
int O_RDONLY;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ fcntl(int, int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(short);
int listen(int, int);
int /*<<< orphan*/ logging(int /*<<< orphan*/ *, char *, unsigned char *, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int, int);
int ntohl(int /*<<< orphan*/);
int open(char const *, int /*<<< orphan*/);
int read(int, unsigned char *, int);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
size_t sprintf(char *, char *, ...);
int /*<<< orphan*/ *stdout;
char *strerror(int);
int write(int, unsigned char *, int);
int startup(short port, FILE *logfile, int verbose, const char *tpm_device) {
  int rc = 0;
  int irc = 0;
  char messageBuffer[4096];
  size_t messageLength;
  int server_sockfd = -1;
  struct sockaddr_in server_addr;
  unsigned char buffer[4096];
  int len = 0;
  int paramSize;
  int tpm_fd = 0;
  if (rc == 0) {
    server_sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (server_sockfd == -1) {
      messageLength =
          sprintf(messageBuffer, "Error creating server socket() %d %s\n",
                  errno, strerror(errno));
      if (NULL != logfile) {
        logging(logfile, messageBuffer, NULL, 0);
      }
      logging(stdout, messageBuffer, NULL, 0);
      rc = 1;
    }
  }
  if (rc == 0) {
    memset(&server_addr, 0x0, sizeof(server_addr));
    server_addr.sin_family = AF_INET;
    server_addr.sin_port = htons(port);
    server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
    int on = 1;
    irc = setsockopt(server_sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
    if (irc != 0) {
      messageLength =
          sprintf(messageBuffer, "Error, server setsockopt() %d %s\n", errno,
                  strerror(errno));
      if (NULL != logfile) {
        logging(logfile, messageBuffer, NULL, 0);
      }
      logging(stdout, messageBuffer, NULL, 0);
      rc = 1;
    }
  }
  if (rc == 0) {
    irc = bind(server_sockfd, (struct sockaddr *)&server_addr,
               sizeof(server_addr));
    if (irc != 0) {
      messageLength = sprintf(messageBuffer, "Error, server bind() %d %s\n",
                              errno, strerror(errno));
      if (NULL != logfile) {
        logging(logfile, messageBuffer, NULL, 0);
      }
      logging(stdout, messageBuffer, NULL, 0);
      rc = 1;
    }
  }
  if (rc == 0) {
    irc = listen(server_sockfd, 1);
    if (irc != 0) {
      messageLength = sprintf(messageBuffer, "Error, server listen() %d %s\n",
                              errno, strerror(errno));
      if (NULL != logfile) {
        logging(logfile, messageBuffer, NULL, 0);
      }
      logging(stdout, messageBuffer, NULL, 0);
      rc = 1;
    }
  }
  while (rc == 0) {
    struct sockaddr_in cli_addr;
    socklen_t cli_len = sizeof(cli_addr);
    int client_sockfd;
    if (rc == 0) {
      client_sockfd =
          accept(server_sockfd, (struct sockaddr *)&cli_addr, &cli_len);
      if (client_sockfd < 0) {
        messageLength = sprintf(messageBuffer, "Error, accept() %d %s\n", errno,
                                strerror(errno));
        if (NULL != logfile) {
          logging(logfile, messageBuffer, NULL, 0);
        }
        logging(stdout, messageBuffer, NULL, 0);
        rc = 1;
      }
    }
    if (rc == 0) {
      len = read(client_sockfd, buffer, sizeof(buffer));
      if (len <= 0) {
        messageLength = sprintf(messageBuffer, "Error, socket read() %d %s\n",
                                errno, strerror(errno));
        if (NULL != logfile) {
          logging(logfile, messageBuffer, NULL, 0);
        }
        logging(stdout, messageBuffer, NULL, 0);
        rc = 1;
      }
    }
    if (rc == 0) {
      tpm_fd = open(tpm_device, O_RDWR);
      if (tpm_fd <= 0) {
        messageLength =
            sprintf(messageBuffer, "Error opening %s\n", tpm_device);
        if (NULL != logfile) {
          logging(logfile, messageBuffer, NULL, 0);
        }
        logging(stdout, messageBuffer, NULL, 0);
        rc = 1;
      }
    }
    if (rc == 0) {
      fcntl(tpm_fd, O_RDONLY | O_NONBLOCK);
      if (NULL != logfile) {
        logging(logfile, " REQUEST:", buffer, len);
      }
      if (verbose) {
        logging(stdout, " REQUEST:", buffer, len);
      }
      len = write(tpm_fd, buffer, len);
      if (len < 0) {
        messageLength = sprintf(messageBuffer, "Error, TPM write() %d %s\n",
                                errno, strerror(errno));
        if (NULL != logfile) {
          logging(logfile, messageBuffer, NULL, 0);
        }
        logging(stdout, messageBuffer, NULL, 0);
        rc = 1;
      }
    }
    if (rc == 0) {
      len = read(tpm_fd, buffer, sizeof(buffer));
      if (len <= 0) {
        messageLength = sprintf(messageBuffer, "Error, TPM read() %d %s\n",
                                errno, strerror(errno));
        if (NULL != logfile) {
          logging(logfile, messageBuffer, NULL, 0);
        }
        logging(stdout, messageBuffer, NULL, 0);
        rc = 1;
      }
    }
    if (rc == 0) {
      if (NULL != logfile) {
        logging(logfile, "RESPONSE:", buffer, len);
      }
      if (verbose) {
        logging(stdout, "RESPONSE:", buffer, len);
      }
      paramSize = (ntohl(*(uint32_t *)&buffer[2]));
      if (len != paramSize) {
        messageLength =
            sprintf(messageBuffer,
                    "Error, Malformed TPM response, read %u paramSize %u\n",
                    len, paramSize);
        if (NULL != logfile) {
          logging(logfile, messageBuffer, NULL, 0);
        }
        logging(stdout, messageBuffer, NULL, 0);
        rc = 1;
      }
    }
    if (rc == 0) {
      buffer[0] = 0;
      close(tpm_fd);
      len = write(client_sockfd, buffer, len);
      if (len <= 0) {
        messageLength = sprintf(messageBuffer, "Error, socket write() %d %s\n",
                                errno, strerror(errno));
        if (NULL != logfile) {
          logging(logfile, messageBuffer, NULL, 0);
        }
        logging(stdout, messageBuffer, NULL, 0);
        rc = 1;
      }
    }
    close(client_sockfd);
  }
  close(server_sockfd);
  return rc;
}


x86 assembly (clang, -O0):
<startup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2110,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0xffffffff,-0x103c(%rbp)
ff ff ff
movl   $0x0,-0x2054(%rbp)
movl   $0x0,-0x205c(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1329 <startup+0x119>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x103c(%rbp)
cmpl   $0xffffffff,-0x103c(%rbp)
jne    1324 <startup+0x114>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x2088(%rbp)
mov    0x2d04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x207c(%rbp)
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x2088(%rbp),%rdi
mov    -0x207c(%rbp),%edx
mov    %rax,%rcx
lea    0xd2f(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    %rax,-0x1038(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1301 <startup+0xf1>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x2c98(%rip),%rax
mov    (%rax),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
movl   $0x1,-0x24(%rbp)
jmp    1329 <startup+0x119>
cmpl   $0x0,-0x24(%rbp)
jne    1453 <startup+0x243>
lea    -0x1048(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2c8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1040(%rbp)
movswl -0x2(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x1044(%rbp)
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x1048(%rbp)
movl   $0x1,-0x2060(%rbp)
mov    -0x103c(%rbp),%edi
mov    0x2c51(%rip),%rax
mov    (%rax),%esi
mov    0x2c00(%rip),%rax
mov    (%rax),%edx
lea    -0x2060(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     144e <startup+0x23e>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x2098(%rbp)
mov    0x2bda(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x208c(%rbp)
mov    0x2bcb(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x2098(%rbp),%rdi
mov    -0x208c(%rbp),%edx
mov    %rax,%rcx
lea    0xc2b(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    %rax,-0x1038(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     142b <startup+0x21b>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x2b6e(%rip),%rax
mov    (%rax),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
movl   $0x1,-0x24(%rbp)
jmp    1453 <startup+0x243>
cmpl   $0x0,-0x24(%rbp)
jne    151b <startup+0x30b>
mov    -0x103c(%rbp),%edi
lea    -0x1048(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     1516 <startup+0x306>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x20a8(%rbp)
mov    0x2b12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x209c(%rbp)
mov    0x2b03(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x20a8(%rbp),%rdi
mov    -0x209c(%rbp),%edx
mov    %rax,%rcx
lea    0xb85(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    %rax,-0x1038(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     14f3 <startup+0x2e3>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x2aa6(%rip),%rax
mov    (%rax),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
movl   $0x1,-0x24(%rbp)
jmp    151b <startup+0x30b>
cmpl   $0x0,-0x24(%rbp)
jne    15dc <startup+0x3cc>
mov    -0x103c(%rbp),%edi
mov    $0x1,%esi
call   10c0 <listen@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     15d7 <startup+0x3c7>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x20b8(%rbp)
mov    0x2a51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20ac(%rbp)
mov    0x2a42(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x20b8(%rbp),%rdi
mov    -0x20ac(%rbp),%edx
mov    %rax,%rcx
lea    0xae0(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    %rax,-0x1038(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     15b4 <startup+0x3a4>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x29e5(%rip),%rax
mov    (%rax),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
movl   $0x1,-0x24(%rbp)
jmp    15dc <startup+0x3cc>
jmp    15e1 <startup+0x3d1>
cmpl   $0x0,-0x24(%rbp)
jne    1c22 <startup+0xa12>
movl   $0xc,-0x2074(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    16c5 <startup+0x4b5>
mov    -0x103c(%rbp),%edi
lea    -0x2070(%rbp),%rsi
lea    -0x2074(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x2078(%rbp)
cmpl   $0x0,-0x2078(%rbp)
jge    16c0 <startup+0x4b0>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x20c8(%rbp)
mov    0x2968(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20bc(%rbp)
mov    0x2959(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x20c8(%rbp),%rdi
mov    -0x20bc(%rbp),%edx
mov    %rax,%rcx
lea    0xa15(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    %rax,-0x1038(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     169d <startup+0x48d>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x28fc(%rip),%rax
mov    (%rax),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
movl   $0x1,-0x24(%rbp)
jmp    16c5 <startup+0x4b5>
cmpl   $0x0,-0x24(%rbp)
jne    1793 <startup+0x583>
mov    -0x2078(%rbp),%edi
lea    -0x2050(%rbp),%rsi
mov    $0x1000,%edx
call   10a0 <read@plt>
mov    %eax,-0x2054(%rbp)
cmpl   $0x0,-0x2054(%rbp)
jg     178e <startup+0x57e>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x20d8(%rbp)
mov    0x289a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20cc(%rbp)
mov    0x288b(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x20d8(%rbp),%rdi
mov    -0x20cc(%rbp),%edx
mov    %rax,%rcx
lea    0x95e(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    %rax,-0x1038(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     176b <startup+0x55b>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x282e(%rip),%rax
mov    (%rax),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
movl   $0x1,-0x24(%rbp)
jmp    1793 <startup+0x583>
cmpl   $0x0,-0x24(%rbp)
jne    182c <startup+0x61c>
mov    -0x20(%rbp),%rdi
mov    0x2840(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x205c(%rbp)
cmpl   $0x0,-0x205c(%rbp)
jg     1827 <startup+0x617>
lea    -0x1030(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0x8e1(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    %rax,-0x1038(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1804 <startup+0x5f4>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x2795(%rip),%rax
mov    (%rax),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
movl   $0x1,-0x24(%rbp)
jmp    182c <startup+0x61c>
cmpl   $0x0,-0x24(%rbp)
jne    196e <startup+0x75e>
mov    -0x205c(%rbp),%edi
mov    0x2785(%rip),%rax
mov    (%rax),%esi
mov    0x2784(%rip),%rax
or     (%rax),%esi
call   1040 <fcntl@plt>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     187c <startup+0x66c>
mov    -0x10(%rbp),%rdi
lea    -0x2050(%rbp),%rdx
mov    -0x2054(%rbp),%ecx
lea    0x850(%rip),%rsi
call   10b0 <logging@plt>
cmpl   $0x0,-0x14(%rbp)
je     18a9 <startup+0x699>
mov    0x2713(%rip),%rax
mov    (%rax),%rdi
lea    -0x2050(%rbp),%rdx
mov    -0x2054(%rbp),%ecx
lea    0x823(%rip),%rsi
call   10b0 <logging@plt>
mov    -0x205c(%rbp),%edi
lea    -0x2050(%rbp),%rsi
mov    -0x2054(%rbp),%edx
call   1050 <write@plt>
mov    %eax,-0x2054(%rbp)
cmpl   $0x0,-0x2054(%rbp)
jge    1969 <startup+0x759>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x20e8(%rbp)
mov    0x26bf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20dc(%rbp)
mov    0x26b0(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x20e8(%rbp),%rdi
mov    -0x20dc(%rbp),%edx
mov    %rax,%rcx
lea    0x7bb(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    %rax,-0x1038(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1946 <startup+0x736>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x2653(%rip),%rax
mov    (%rax),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
movl   $0x1,-0x24(%rbp)
jmp    196e <startup+0x75e>
cmpl   $0x0,-0x24(%rbp)
jne    1a3c <startup+0x82c>
mov    -0x205c(%rbp),%edi
lea    -0x2050(%rbp),%rsi
mov    $0x1000,%edx
call   10a0 <read@plt>
mov    %eax,-0x2054(%rbp)
cmpl   $0x0,-0x2054(%rbp)
jg     1a37 <startup+0x827>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x20f8(%rbp)
mov    0x25f1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20ec(%rbp)
mov    0x25e2(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x20f8(%rbp),%rdi
mov    -0x20ec(%rbp),%edx
mov    %rax,%rcx
lea    0x707(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    %rax,-0x1038(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1a14 <startup+0x804>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x2585(%rip),%rax
mov    (%rax),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
movl   $0x1,-0x24(%rbp)
jmp    1a3c <startup+0x82c>
cmpl   $0x0,-0x24(%rbp)
jne    1b31 <startup+0x921>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1a6f <startup+0x85f>
mov    -0x10(%rbp),%rdi
lea    -0x2050(%rbp),%rdx
mov    -0x2054(%rbp),%ecx
lea    0x69a(%rip),%rsi
call   10b0 <logging@plt>
cmpl   $0x0,-0x14(%rbp)
je     1a9c <startup+0x88c>
mov    0x2520(%rip),%rax
mov    (%rax),%rdi
lea    -0x2050(%rbp),%rdx
mov    -0x2054(%rbp),%ecx
lea    0x66d(%rip),%rsi
call   10b0 <logging@plt>
mov    -0x204e(%rbp),%edi
call   1110 <ntohl@plt>
mov    %eax,-0x2058(%rbp)
mov    -0x2054(%rbp),%eax
cmp    -0x2058(%rbp),%eax
je     1b2c <startup+0x91c>
lea    -0x1030(%rbp),%rdi
mov    -0x2054(%rbp),%edx
mov    -0x2058(%rbp),%ecx
lea    0x635(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    %rax,-0x1038(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1b09 <startup+0x8f9>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x2490(%rip),%rax
mov    (%rax),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
movl   $0x1,-0x24(%rbp)
jmp    1b31 <startup+0x921>
cmpl   $0x0,-0x24(%rbp)
jne    1c12 <startup+0xa02>
movb   $0x0,-0x2050(%rbp)
mov    -0x205c(%rbp),%edi
call   1090 <close@plt>
mov    -0x2078(%rbp),%edi
lea    -0x2050(%rbp),%rsi
mov    -0x2054(%rbp),%edx
call   1050 <write@plt>
mov    %eax,-0x2054(%rbp)
cmpl   $0x0,-0x2054(%rbp)
jg     1c0d <startup+0x9fd>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x2108(%rbp)
mov    0x241b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20fc(%rbp)
mov    0x240c(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x2108(%rbp),%rdi
mov    -0x20fc(%rbp),%edx
mov    %rax,%rcx
lea    0x589(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    %rax,-0x1038(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1bea <startup+0x9da>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x23af(%rip),%rax
mov    (%rax),%rdi
lea    -0x1030(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
movl   $0x1,-0x24(%rbp)
jmp    1c12 <startup+0xa02>
mov    -0x2078(%rbp),%edi
call   1090 <close@plt>
jmp    15e1 <startup+0x3d1>
mov    -0x103c(%rbp),%edi
call   1090 <close@plt>
mov    -0x24(%rbp),%eax
add    $0x2110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<startup>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2048,%rsp
mov    %rcx,%r15
mov    %edx,%r13d
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2da5(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d74(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
cmp    $0xffffffff,%eax
je     12d9 <startup+0xc9>
mov    %eax,%r12d
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    (%rbx),%eax
mov    %eax,0x20(%rsp)
movswl %bp,%edi
call   1060 <htons@plt>
mov    %eax,0x1c(%rsp)
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,0x18(%rsp)
movl   $0x1,0x1040(%rsp)
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
mov    0x2cf7(%rip),%rax
mov    (%rax),%edx
lea    0x1040(%rsp),%rcx
mov    %r12d,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %eax,%eax
je     133a <startup+0x12a>
mov    0x2ce4(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xd52(%rip),%rsi
jmp    1391 <startup+0x181>
mov    0x2cc8(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1120 <strerror@plt>
lea    0xd10(%rip),%rsi
lea    0x40(%rsp),%rdi
mov    %ebx,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1100 <sprintf@plt>
test   %r14,%r14
je     1317 <startup+0x107>
lea    0x40(%rsp),%rsi
mov    %r14,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x2c82(%rip),%rax
mov    (%rax),%rdi
lea    0x40(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    $0xffffffff,%r12d
jmp    13d0 <startup+0x1c0>
lea    0x18(%rsp),%rsi
mov    %r12d,%edi
mov    $0xc,%edx
call   10d0 <bind@plt>
test   %eax,%eax
je     1369 <startup+0x159>
mov    0x2c51(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xce1(%rip),%rsi
jmp    1391 <startup+0x181>
mov    %r12d,%edi
mov    $0x1,%esi
call   10c0 <listen@plt>
test   %eax,%eax
je     13ef <startup+0x1df>
mov    0x2c27(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xcd3(%rip),%rsi
lea    0x40(%rsp),%rdi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1100 <sprintf@plt>
test   %r14,%r14
je     13b8 <startup+0x1a8>
lea    0x40(%rsp),%rsi
mov    %r14,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x2be1(%rip),%rax
mov    (%rax),%rdi
lea    0x40(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    %r12d,%edi
call   1090 <close@plt>
mov    $0x1,%eax
add    $0x2048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movl   $0xc,0x10(%rsp)
lea    0x30(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r12d,%edi
call   10f0 <accept@plt>
test   %eax,%eax
js     159c <startup+0x38c>
lea    0x1040(%rsp),%rsi
mov    %r15,0x28(%rsp)
mov    %r13d,0x14(%rsp)
mov    %eax,0xc(%rsp)
mov    %eax,%edi
mov    $0x1000,%edx
call   10a0 <read@plt>
test   %eax,%eax
jle    1604 <startup+0x3f4>
mov    %eax,%ebp
mov    0x2ba4(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   10e0 <open@plt>
test   %eax,%eax
jle    161d <startup+0x40d>
mov    %eax,%r13d
mov    0x2b70(%rip),%rax
mov    (%rax),%esi
mov    0x2b5f(%rip),%rax
or     (%rax),%esi
mov    %r13d,%edi
call   1040 <fcntl@plt>
test   %r14,%r14
je     1491 <startup+0x281>
mov    %r14,%rdi
lea    0xc45(%rip),%rsi
lea    0x1040(%rsp),%rdx
mov    %ebp,%ecx
call   10b0 <logging@plt>
cmpl   $0x0,0x14(%rsp)
lea    0x1040(%rsp),%rbx
je     14bb <startup+0x2ab>
mov    0x2af9(%rip),%rax
mov    (%rax),%rdi
lea    0xc16(%rip),%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   10b0 <logging@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1050 <write@plt>
test   %eax,%eax
js     1635 <startup+0x425>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   10a0 <read@plt>
test   %eax,%eax
jle    1651 <startup+0x441>
mov    %eax,%r15d
test   %r14,%r14
je     1505 <startup+0x2f5>
mov    %r14,%rdi
lea    0xc0a(%rip),%rsi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   10b0 <logging@plt>
cmpl   $0x0,0x14(%rsp)
je     1528 <startup+0x318>
mov    0x2a8d(%rip),%rax
mov    (%rax),%rdi
lea    0xbe7(%rip),%rsi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   10b0 <logging@plt>
mov    0x1042(%rsp),%edi
call   1110 <ntohl@plt>
cmp    %eax,%r15d
jne    166d <startup+0x45d>
movb   $0x0,0x1040(%rsp)
mov    %r13d,%edi
call   1090 <close@plt>
mov    0xc(%rsp),%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <write@plt>
test   %eax,%eax
jle    168a <startup+0x47a>
mov    %ebp,%edi
call   1090 <close@plt>
movl   $0xc,0x10(%rsp)
mov    %r12d,%edi
lea    0x30(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   10f0 <accept@plt>
test   %eax,%eax
mov    0x28(%rsp),%r15
lea    0x1040(%rsp),%rsi
jns    1423 <startup+0x213>
mov    %eax,0xc(%rsp)
mov    0x2a01(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xacb(%rip),%rsi
lea    0x40(%rsp),%rdi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1100 <sprintf@plt>
test   %r14,%r14
je     15de <startup+0x3ce>
lea    0x40(%rsp),%rsi
mov    %r14,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0x29bb(%rip),%rax
mov    (%rax),%rdi
lea    0x40(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   10b0 <logging@plt>
mov    0xc(%rsp),%edi
call   1090 <close@plt>
jmp    13d0 <startup+0x1c0>
mov    0x299d(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xa7e(%rip),%rsi
jmp    15b7 <startup+0x3a7>
lea    0xa91(%rip),%rsi
lea    0x40(%rsp),%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1100 <sprintf@plt>
jmp    15c8 <startup+0x3b8>
mov    0x296c(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xa85(%rip),%rsi
jmp    15b7 <startup+0x3a7>
mov    0x2950(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xa83(%rip),%rsi
jmp    15b7 <startup+0x3a7>
lea    0xa9a(%rip),%rsi
lea    0x40(%rsp),%rdi
mov    %r15d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1100 <sprintf@plt>
jmp    15c8 <startup+0x3b8>
mov    0x2917(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xaa2(%rip),%rsi
jmp    15b7 <startup+0x3a7>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [38 x i8] c"Error creating server socket() %d %s\0A\00"
@errno = global i32 0
@stdout = global i32* null
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [34 x i8] c"Error, server setsockopt() %d %s\0A\00"
@.str.2 = [28 x i8] c"Error, server bind() %d %s\0A\00"
@.str.3 = [30 x i8] c"Error, server listen() %d %s\0A\00"
@.str.4 = [23 x i8] c"Error, accept() %d %s\0A\00"
@.str.5 = [28 x i8] c"Error, socket read() %d %s\0A\00"
@O_RDWR = global i32 0
@.str.6 = [18 x i8] c"Error opening %s\0A\00"
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.7 = [10 x i8] c" REQUEST:\00"
@.str.8 = [26 x i8] c"Error, TPM write() %d %s\0A\00"
@.str.9 = [25 x i8] c"Error, TPM read() %d %s\0A\00"
@.str.10 = [10 x i8] c"RESPONSE:\00"
@.str.11 = [53 x i8] c"Error, Malformed TPM response, read %u paramSize %u\0A\00"
@.str.12 = [29 x i8] c"Error, socket write() %d %s\0A\00"
define i32 @startup(i16 signext %0, i32* %1, i32 %2, i8* %3) {
%5 = alloca i16
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [4096 x i8]
%12 = alloca i64
%13 = alloca i32
%14 = alloca %struct.sockaddr_in
%15 = alloca [4096 x i8]
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca %struct.sockaddr_in
%21 = alloca i32
%22 = alloca i32
store i16 %0, i16* %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 -1, i32* %13
store i32 0, i32* %16
store i32 0, i32* %18
%23 = load i32, i32* %9
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %48
25: ; preds = %4
%26 = load i32, i32* @AF_INET
%27 = load i32, i32* @SOCK_STREAM
%28 = call i32 @socket(i32 %26, i32 %27, i32 0)
store i32 %28, i32* %13
%29 = load i32, i32* %13
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %47
31: ; preds = %25
%32 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%33 = load i32, i32* @errno
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i64 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %33, i8* %35)
store i64 %36, i64* %12
%37 = load i32*, i32** %6
%38 = icmp ne i32* null, %37
br i1 %38, label %39, label %43
39: ; preds = %31
%40 = load i32*, i32** %6
%41 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%42 = call i32 @logging(i32* %40, i8* %41, i8* null, i32 0)
br label %43
43: ; preds = %39, %31
%44 = load i32*, i32** @stdout
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%46 = call i32 @logging(i32* %44, i8* %45, i8* null, i32 0)
store i32 1, i32* %9
br label %47
47: ; preds = %43, %25
br label %48
48: ; preds = %47, %4
%49 = load i32, i32* %9
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %85
51: ; preds = %48
%52 = call i32 @memset(%struct.sockaddr_in* %14, i32 0, i32 12)
%53 = load i32, i32* @AF_INET
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 2
store i32 %53, i32* %54
%55 = load i16, i16* %5
%56 = call i32 @htons(i16 signext %55)
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 1
store i32 %56, i32* %57
%58 = load i32, i32* @INADDR_ANY
%59 = call i32 @htonl(i32 %58)
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 0
%61 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %60, i32 0, i32 0
store i32 %59, i32* %61
store i32 1, i32* %19
%62 = load i32, i32* %13
%63 = load i32, i32* @SOL_SOCKET
%64 = load i32, i32* @SO_REUSEADDR
%65 = call i32 @setsockopt(i32 %62, i32 %63, i32 %64, i32* %19, i32 4)
store i32 %65, i32* %10
%66 = load i32, i32* %10
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %84
68: ; preds = %51
%69 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%70 = load i32, i32* @errno
%71 = load i32, i32* @errno
%72 = call i8* @strerror(i32 %71)
%73 = call i64 (i8*, i8*, ...) @sprintf(i8* %69, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %70, i8* %72)
store i64 %73, i64* %12
%74 = load i32*, i32** %6
%75 = icmp ne i32* null, %74
br i1 %75, label %76, label %80
76: ; preds = %68
%77 = load i32*, i32** %6
%78 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%79 = call i32 @logging(i32* %77, i8* %78, i8* null, i32 0)
br label %80
80: ; preds = %76, %68
%81 = load i32*, i32** @stdout
%82 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%83 = call i32 @logging(i32* %81, i8* %82, i8* null, i32 0)
store i32 1, i32* %9
br label %84
84: ; preds = %80, %51
br label %85
85: ; preds = %84, %48
%86 = load i32, i32* %9
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %111
88: ; preds = %85
%89 = load i32, i32* %13
%90 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
%91 = call i32 @bind(i32 %89, %struct.sockaddr* %90, i32 12)
store i32 %91, i32* %10
%92 = load i32, i32* %10
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %110
94: ; preds = %88
%95 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%96 = load i32, i32* @errno
%97 = load i32, i32* @errno
%98 = call i8* @strerror(i32 %97)
%99 = call i64 (i8*, i8*, ...) @sprintf(i8* %95, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %96, i8* %98)
store i64 %99, i64* %12
%100 = load i32*, i32** %6
%101 = icmp ne i32* null, %100
br i1 %101, label %102, label %106
102: ; preds = %94
%103 = load i32*, i32** %6
%104 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%105 = call i32 @logging(i32* %103, i8* %104, i8* null, i32 0)
br label %106
106: ; preds = %102, %94
%107 = load i32*, i32** @stdout
%108 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%109 = call i32 @logging(i32* %107, i8* %108, i8* null, i32 0)
store i32 1, i32* %9
br label %110
110: ; preds = %106, %88
br label %111
111: ; preds = %110, %85
%112 = load i32, i32* %9
%113 = icmp eq i32 %112, 0
br i1 %113, label %114, label %136
114: ; preds = %111
%115 = load i32, i32* %13
%116 = call i32 @listen(i32 %115, i32 1)
store i32 %116, i32* %10
%117 = load i32, i32* %10
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %135
119: ; preds = %114
%120 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%121 = load i32, i32* @errno
%122 = load i32, i32* @errno
%123 = call i8* @strerror(i32 %122)
%124 = call i64 (i8*, i8*, ...) @sprintf(i8* %120, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %121, i8* %123)
store i64 %124, i64* %12
%125 = load i32*, i32** %6
%126 = icmp ne i32* null, %125
br i1 %126, label %127, label %131
127: ; preds = %119
%128 = load i32*, i32** %6
%129 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%130 = call i32 @logging(i32* %128, i8* %129, i8* null, i32 0)
br label %131
131: ; preds = %127, %119
%132 = load i32*, i32** @stdout
%133 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%134 = call i32 @logging(i32* %132, i8* %133, i8* null, i32 0)
store i32 1, i32* %9
br label %135
135: ; preds = %131, %114
br label %136
136: ; preds = %135, %111
br label %137
137: ; preds = %363, %136
%138 = load i32, i32* %9
%139 = icmp eq i32 %138, 0
br i1 %139, label %140, label %366
140: ; preds = %137
store i32 12, i32* %21
%141 = load i32, i32* %9
%142 = icmp eq i32 %141, 0
br i1 %142, label %143, label %166
143: ; preds = %140
%144 = load i32, i32* %13
%145 = bitcast %struct.sockaddr_in* %20 to %struct.sockaddr*
%146 = call i32 @accept(i32 %144, %struct.sockaddr* %145, i32* %21)
store i32 %146, i32* %22
%147 = load i32, i32* %22
%148 = icmp slt i32 %147, 0
br i1 %148, label %149, label %165
149: ; preds = %143
%150 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%151 = load i32, i32* @errno
%152 = load i32, i32* @errno
%153 = call i8* @strerror(i32 %152)
%154 = call i64 (i8*, i8*, ...) @sprintf(i8* %150, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %151, i8* %153)
store i64 %154, i64* %12
%155 = load i32*, i32** %6
%156 = icmp ne i32* null, %155
br i1 %156, label %157, label %161
157: ; preds = %149
%158 = load i32*, i32** %6
%159 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%160 = call i32 @logging(i32* %158, i8* %159, i8* null, i32 0)
br label %161
161: ; preds = %157, %149
%162 = load i32*, i32** @stdout
%163 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%164 = call i32 @logging(i32* %162, i8* %163, i8* null, i32 0)
store i32 1, i32* %9
br label %165
165: ; preds = %161, %143
br label %166
166: ; preds = %165, %140
%167 = load i32, i32* %9
%168 = icmp eq i32 %167, 0
br i1 %168, label %169, label %192
169: ; preds = %166
%170 = load i32, i32* %22
%171 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%172 = call i32 @read(i32 %170, i8* %171, i32 4096)
store i32 %172, i32* %16
%173 = load i32, i32* %16
%174 = icmp sle i32 %173, 0
br i1 %174, label %175, label %191
175: ; preds = %169
%176 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%177 = load i32, i32* @errno
%178 = load i32, i32* @errno
%179 = call i8* @strerror(i32 %178)
%180 = call i64 (i8*, i8*, ...) @sprintf(i8* %176, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %177, i8* %179)
store i64 %180, i64* %12
%181 = load i32*, i32** %6
%182 = icmp ne i32* null, %181
br i1 %182, label %183, label %187
183: ; preds = %175
%184 = load i32*, i32** %6
%185 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%186 = call i32 @logging(i32* %184, i8* %185, i8* null, i32 0)
br label %187
187: ; preds = %183, %175
%188 = load i32*, i32** @stdout
%189 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%190 = call i32 @logging(i32* %188, i8* %189, i8* null, i32 0)
store i32 1, i32* %9
br label %191
191: ; preds = %187, %169
br label %192
192: ; preds = %191, %166
%193 = load i32, i32* %9
%194 = icmp eq i32 %193, 0
br i1 %194, label %195, label %216
195: ; preds = %192
%196 = load i8*, i8** %8
%197 = load i32, i32* @O_RDWR
%198 = call i32 @open(i8* %196, i32 %197)
store i32 %198, i32* %18
%199 = load i32, i32* %18
%200 = icmp sle i32 %199, 0
br i1 %200, label %201, label %215
201: ; preds = %195
%202 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%203 = load i8*, i8** %8
%204 = call i64 (i8*, i8*, ...) @sprintf(i8* %202, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %203)
store i64 %204, i64* %12
%205 = load i32*, i32** %6
%206 = icmp ne i32* null, %205
br i1 %206, label %207, label %211
207: ; preds = %201
%208 = load i32*, i32** %6
%209 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%210 = call i32 @logging(i32* %208, i8* %209, i8* null, i32 0)
br label %211
211: ; preds = %207, %201
%212 = load i32*, i32** @stdout
%213 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%214 = call i32 @logging(i32* %212, i8* %213, i8* null, i32 0)
store i32 1, i32* %9
br label %215
215: ; preds = %211, %195
br label %216
216: ; preds = %215, %192
%217 = load i32, i32* %9
%218 = icmp eq i32 %217, 0
br i1 %218, label %219, label %264
219: ; preds = %216
%220 = load i32, i32* %18
%221 = load i32, i32* @O_RDONLY
%222 = load i32, i32* @O_NONBLOCK
%223 = or i32 %221, %222
%224 = call i32 @fcntl(i32 %220, i32 %223)
%225 = load i32*, i32** %6
%226 = icmp ne i32* null, %225
br i1 %226, label %227, label %232
227: ; preds = %219
%228 = load i32*, i32** %6
%229 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%230 = load i32, i32* %16
%231 = call i32 @logging(i32* %228, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %229, i32 %230)
br label %232
232: ; preds = %227, %219
%233 = load i32, i32* %7
%234 = icmp ne i32 %233, 0
br i1 %234, label %235, label %240
235: ; preds = %232
%236 = load i32*, i32** @stdout
%237 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%238 = load i32, i32* %16
%239 = call i32 @logging(i32* %236, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %237, i32 %238)
br label %240
240: ; preds = %235, %232
%241 = load i32, i32* %18
%242 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%243 = load i32, i32* %16
%244 = call i32 @write(i32 %241, i8* %242, i32 %243)
store i32 %244, i32* %16
%245 = load i32, i32* %16
%246 = icmp slt i32 %245, 0
br i1 %246, label %247, label %263
247: ; preds = %240
%248 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%249 = load i32, i32* @errno
%250 = load i32, i32* @errno
%251 = call i8* @strerror(i32 %250)
%252 = call i64 (i8*, i8*, ...) @sprintf(i8* %248, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %249, i8* %251)
store i64 %252, i64* %12
%253 = load i32*, i32** %6
%254 = icmp ne i32* null, %253
br i1 %254, label %255, label %259
255: ; preds = %247
%256 = load i32*, i32** %6
%257 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%258 = call i32 @logging(i32* %256, i8* %257, i8* null, i32 0)
br label %259
259: ; preds = %255, %247
%260 = load i32*, i32** @stdout
%261 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%262 = call i32 @logging(i32* %260, i8* %261, i8* null, i32 0)
store i32 1, i32* %9
br label %263
263: ; preds = %259, %240
br label %264
264: ; preds = %263, %216
%265 = load i32, i32* %9
%266 = icmp eq i32 %265, 0
br i1 %266, label %267, label %290
267: ; preds = %264
%268 = load i32, i32* %18
%269 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%270 = call i32 @read(i32 %268, i8* %269, i32 4096)
store i32 %270, i32* %16
%271 = load i32, i32* %16
%272 = icmp sle i32 %271, 0
br i1 %272, label %273, label %289
273: ; preds = %267
%274 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%275 = load i32, i32* @errno
%276 = load i32, i32* @errno
%277 = call i8* @strerror(i32 %276)
%278 = call i64 (i8*, i8*, ...) @sprintf(i8* %274, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i32 %275, i8* %277)
store i64 %278, i64* %12
%279 = load i32*, i32** %6
%280 = icmp ne i32* null, %279
br i1 %280, label %281, label %285
281: ; preds = %273
%282 = load i32*, i32** %6
%283 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%284 = call i32 @logging(i32* %282, i8* %283, i8* null, i32 0)
br label %285
285: ; preds = %281, %273
%286 = load i32*, i32** @stdout
%287 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%288 = call i32 @logging(i32* %286, i8* %287, i8* null, i32 0)
store i32 1, i32* %9
br label %289
289: ; preds = %285, %267
br label %290
290: ; preds = %289, %264
%291 = load i32, i32* %9
%292 = icmp eq i32 %291, 0
br i1 %292, label %293, label %333
293: ; preds = %290
%294 = load i32*, i32** %6
%295 = icmp ne i32* null, %294
br i1 %295, label %296, label %301
296: ; preds = %293
%297 = load i32*, i32** %6
%298 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%299 = load i32, i32* %16
%300 = call i32 @logging(i32* %297, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %298, i32 %299)
br label %301
301: ; preds = %296, %293
%302 = load i32, i32* %7
%303 = icmp ne i32 %302, 0
br i1 %303, label %304, label %309
304: ; preds = %301
%305 = load i32*, i32** @stdout
%306 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%307 = load i32, i32* %16
%308 = call i32 @logging(i32* %305, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %306, i32 %307)
br label %309
309: ; preds = %304, %301
%310 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 2
%311 = bitcast i8* %310 to i32*
%312 = load i32, i32* %311
%313 = call i32 @ntohl(i32 %312)
store i32 %313, i32* %17
%314 = load i32, i32* %16
%315 = load i32, i32* %17
%316 = icmp ne i32 %314, %315
br i1 %316, label %317, label %332
317: ; preds = %309
%318 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%319 = load i32, i32* %16
%320 = load i32, i32* %17
%321 = call i64 (i8*, i8*, ...) @sprintf(i8* %318, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0), i32 %319, i32 %320)
store i64 %321, i64* %12
%322 = load i32*, i32** %6
%323 = icmp ne i32* null, %322
br i1 %323, label %324, label %328
324: ; preds = %317
%325 = load i32*, i32** %6
%326 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%327 = call i32 @logging(i32* %325, i8* %326, i8* null, i32 0)
br label %328
328: ; preds = %324, %317
%329 = load i32*, i32** @stdout
%330 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%331 = call i32 @logging(i32* %329, i8* %330, i8* null, i32 0)
store i32 1, i32* %9
br label %332
332: ; preds = %328, %309
br label %333
333: ; preds = %332, %290
%334 = load i32, i32* %9
%335 = icmp eq i32 %334, 0
br i1 %335, label %336, label %363
336: ; preds = %333
%337 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
store i8 0, i8* %337
%338 = load i32, i32* %18
%339 = call i32 @close(i32 %338)
%340 = load i32, i32* %22
%341 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%342 = load i32, i32* %16
%343 = call i32 @write(i32 %340, i8* %341, i32 %342)
store i32 %343, i32* %16
%344 = load i32, i32* %16
%345 = icmp sle i32 %344, 0
br i1 %345, label %346, label %362
346: ; preds = %336
%347 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%348 = load i32, i32* @errno
%349 = load i32, i32* @errno
%350 = call i8* @strerror(i32 %349)
%351 = call i64 (i8*, i8*, ...) @sprintf(i8* %347, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), i32 %348, i8* %350)
store i64 %351, i64* %12
%352 = load i32*, i32** %6
%353 = icmp ne i32* null, %352
br i1 %353, label %354, label %358
354: ; preds = %346
%355 = load i32*, i32** %6
%356 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%357 = call i32 @logging(i32* %355, i8* %356, i8* null, i32 0)
br label %358
358: ; preds = %354, %346
%359 = load i32*, i32** @stdout
%360 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%361 = call i32 @logging(i32* %359, i8* %360, i8* null, i32 0)
store i32 1, i32* %9
br label %362
362: ; preds = %358, %336
br label %363
363: ; preds = %362, %333
%364 = load i32, i32* %22
%365 = call i32 @close(i32 %364)
br label %137
366: ; preds = %137
%367 = load i32, i32* %13
%368 = call i32 @close(i32 %367)
%369 = load i32, i32* %9
ret i32 %369
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [38 x i8] c"Error creating server socket() %d %s\0A\00"
@errno = global i32 0
@stdout = global i32* null
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [34 x i8] c"Error, server setsockopt() %d %s\0A\00"
@.str.2 = [28 x i8] c"Error, server bind() %d %s\0A\00"
@.str.3 = [30 x i8] c"Error, server listen() %d %s\0A\00"
@.str.4 = [23 x i8] c"Error, accept() %d %s\0A\00"
@.str.5 = [28 x i8] c"Error, socket read() %d %s\0A\00"
@O_RDWR = global i32 0
@.str.6 = [18 x i8] c"Error opening %s\0A\00"
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.7 = [10 x i8] c" REQUEST:\00"
@.str.8 = [26 x i8] c"Error, TPM write() %d %s\0A\00"
@.str.9 = [25 x i8] c"Error, TPM read() %d %s\0A\00"
@.str.10 = [10 x i8] c"RESPONSE:\00"
@.str.11 = [53 x i8] c"Error, Malformed TPM response, read %u paramSize %u\0A\00"
@.str.12 = [29 x i8] c"Error, socket write() %d %s\0A\00"
define i32 @startup(i16 signext %0, i32* %1, i32 %2, i8* %3) {
%5 = alloca [4096 x i8]
%6 = alloca %struct.sockaddr_in
%7 = alloca [4096 x i8]
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca i32
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%12 = bitcast %struct.sockaddr_in* %6 to i8*
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%14 = load i32, i32* @AF_INET
%15 = load i32, i32* @SOCK_STREAM
%16 = tail call i32 @socket(i32 %14, i32 %15, i32 0)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %28
18: ; preds = %4
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %19, i8* %20)
%22 = icmp eq i32* %1, null
br i1 %22, label %25, label %23
23: ; preds = %18
%24 = call i32 @logging(i32* %1, i8* %11, i8* null, i32 0)
br label %25
25: ; preds = %23, %18
%26 = load i32*, i32** @stdout
%27 = call i32 @logging(i32* %26, i8* %11, i8* null, i32 0)
br label %166
28: ; preds = %4
%29 = call i32 @memset(%struct.sockaddr_in* %6, i32 0, i32 12)
%30 = load i32, i32* @AF_INET
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i32 %30, i32* %31
%32 = call i32 @htons(i16 signext %0)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1
store i32 %32, i32* %33
%34 = load i32, i32* @INADDR_ANY
%35 = call i32 @htonl(i32 %34)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0, i32 0
store i32 %35, i32* %36
%37 = bitcast i32* %8 to i8*
store i32 1, i32* %8
%38 = load i32, i32* @SOL_SOCKET
%39 = load i32, i32* @SO_REUSEADDR
%40 = call i32 @setsockopt(i32 %16, i32 %38, i32 %39, i32* %8, i32 4)
%41 = icmp eq i32 %40, 0
br i1 %41, label %52, label %42
42: ; preds = %28
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %43, i8* %44)
%46 = icmp eq i32* %1, null
br i1 %46, label %49, label %47
47: ; preds = %42
%48 = call i32 @logging(i32* %1, i8* %11, i8* null, i32 0)
br label %49
49: ; preds = %42, %47
%50 = load i32*, i32** @stdout
%51 = call i32 @logging(i32* %50, i8* %11, i8* null, i32 0)
br label %166
52: ; preds = %28
%53 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%54 = call i32 @bind(i32 %16, %struct.sockaddr* %53, i32 12)
%55 = icmp eq i32 %54, 0
br i1 %55, label %66, label %56
56: ; preds = %52
%57 = load i32, i32* @errno
%58 = call i8* @strerror(i32 %57)
%59 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %57, i8* %58)
%60 = icmp eq i32* %1, null
br i1 %60, label %63, label %61
61: ; preds = %56
%62 = call i32 @logging(i32* %1, i8* %11, i8* null, i32 0)
br label %63
63: ; preds = %61, %56
%64 = load i32*, i32** @stdout
%65 = call i32 @logging(i32* %64, i8* %11, i8* null, i32 0)
br label %166
66: ; preds = %52
%67 = call i32 @listen(i32 %16, i32 1)
%68 = icmp eq i32 %67, 0
br i1 %68, label %79, label %69
69: ; preds = %66
%70 = load i32, i32* @errno
%71 = call i8* @strerror(i32 %70)
%72 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %70, i8* %71)
%73 = icmp eq i32* %1, null
br i1 %73, label %76, label %74
74: ; preds = %69
%75 = call i32 @logging(i32* %1, i8* %11, i8* null, i32 0)
br label %76
76: ; preds = %74, %69
%77 = load i32*, i32** @stdout
%78 = call i32 @logging(i32* %77, i8* %11, i8* null, i32 0)
br label %166
79: ; preds = %66
%80 = bitcast %struct.sockaddr_in* %9 to i8*
%81 = bitcast i32* %10 to i8*
%82 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%83 = icmp eq i32* %1, null
%84 = icmp eq i32 %2, 0
%85 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 2
%86 = bitcast i8* %85 to i32*
store i32 12, i32* %10
%87 = call i32 @accept(i32 %16, %struct.sockaddr* %82, i32* %10)
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %94
89: ; preds = %154, %79
%90 = phi i32 [ %87, %79 ], [ %156, %154 ]
%91 = load i32, i32* @errno
%92 = call i8* @strerror(i32 %91)
%93 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %91, i8* %92)
br i1 %83, label %161, label %158
94: ; preds = %79, %154
%95 = phi i32 [ %156, %154 ], [ %87, %79 ]
%96 = call i32 @read(i32 %95, i8* %13, i32 4096)
%97 = icmp slt i32 %96, 1
br i1 %97, label %98, label %102
98: ; preds = %94
%99 = load i32, i32* @errno
%100 = call i8* @strerror(i32 %99)
%101 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %99, i8* %100)
br i1 %83, label %161, label %158
102: ; preds = %94
%103 = load i32, i32* @O_RDWR
%104 = call i32 @open(i8* %3, i32 %103)
%105 = icmp slt i32 %104, 1
br i1 %105, label %106, label %108
106: ; preds = %102
%107 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %3)
br i1 %83, label %161, label %158
108: ; preds = %102
%109 = load i32, i32* @O_RDONLY
%110 = load i32, i32* @O_NONBLOCK
%111 = or i32 %110, %109
%112 = call i32 @fcntl(i32 %104, i32 %111)
br i1 %83, label %115, label %113
113: ; preds = %108
%114 = call i32 @logging(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %13, i32 %96)
br label %115
115: ; preds = %113, %108
br i1 %84, label %119, label %116
116: ; preds = %115
%117 = load i32*, i32** @stdout
%118 = call i32 @logging(i32* %117, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %13, i32 %96)
br label %119
119: ; preds = %116, %115
%120 = call i32 @write(i32 %104, i8* %13, i32 %96)
%121 = icmp slt i32 %120, 0
br i1 %121, label %122, label %126
122: ; preds = %119
%123 = load i32, i32* @errno
%124 = call i8* @strerror(i32 %123)
%125 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %123, i8* %124)
br i1 %83, label %161, label %158
126: ; preds = %119
%127 = call i32 @read(i32 %104, i8* %13, i32 4096)
%128 = icmp slt i32 %127, 1
br i1 %128, label %129, label %133
129: ; preds = %126
%130 = load i32, i32* @errno
%131 = call i8* @strerror(i32 %130)
%132 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i32 %130, i8* %131)
br i1 %83, label %161, label %158
133: ; preds = %126
br i1 %83, label %136, label %134
134: ; preds = %133
%135 = call i32 @logging(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %13, i32 %127)
br label %136
136: ; preds = %134, %133
br i1 %84, label %140, label %137
137: ; preds = %136
%138 = load i32*, i32** @stdout
%139 = call i32 @logging(i32* %138, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %13, i32 %127)
br label %140
140: ; preds = %137, %136
%141 = load i32, i32* %86
%142 = call i32 @ntohl(i32 %141)
%143 = icmp eq i32 %127, %142
br i1 %143, label %146, label %144
144: ; preds = %140
%145 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0), i32 %127, i32 %142)
br i1 %83, label %161, label %158
146: ; preds = %140
store i8 0, i8* %13
%147 = call i32 @close(i32 %104)
%148 = call i32 @write(i32 %95, i8* %13, i32 %127)
%149 = icmp slt i32 %148, 1
br i1 %149, label %150, label %154
150: ; preds = %146
%151 = load i32, i32* @errno
%152 = call i8* @strerror(i32 %151)
%153 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), i32 %151, i8* %152)
br i1 %83, label %161, label %158
154: ; preds = %146
%155 = call i32 @close(i32 %95)
store i32 12, i32* %10
%156 = call i32 @accept(i32 %16, %struct.sockaddr* %82, i32* %10)
%157 = icmp slt i32 %156, 0
br i1 %157, label %89, label %94
158: ; preds = %150, %144, %129, %122, %106, %98, %89
%159 = phi i32 [ %95, %150 ], [ %95, %144 ], [ %95, %129 ], [ %95, %122 ], [ %95, %106 ], [ %95, %98 ], [ %90, %89 ]
%160 = call i32 @logging(i32* %1, i8* %11, i8* null, i32 0)
br label %161
161: ; preds = %158, %150, %144, %129, %122, %106, %98, %89
%162 = phi i32 [ %159, %158 ], [ %95, %150 ], [ %95, %144 ], [ %95, %129 ], [ %95, %122 ], [ %95, %106 ], [ %95, %98 ], [ %90, %89 ]
%163 = load i32*, i32** @stdout
%164 = call i32 @logging(i32* %163, i8* %11, i8* null, i32 0)
%165 = call i32 @close(i32 %162)
br label %166
166: ; preds = %25, %49, %63, %76, %161
%167 = phi i32 [ %16, %161 ], [ -1, %25 ], [ %16, %49 ], [ %16, %63 ], [ %16, %76 ]
%168 = call i32 @close(i32 %167)
ret i32 1
}