#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 */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ reuse;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ INADDR_ANY;
int O_NONBLOCK;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int read(int, unsigned char *, int);
scalar_t__ recv(int, unsigned char *, int, int /*<<< orphan*/);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int, unsigned char *, int);
int main(int argc, char *argv[]) {
  int input_file;
  int output_file1;
  int output_file2;
  int byte_read;
  unsigned char choice;
  int port;
  unsigned char packet[188];
  if (argc >= 5) {
    input_file = open(argv[1], O_RDONLY);
    if (input_file < 0) {
      fprintf(stderr, "Can't open file %s\n", argv[1]);
      return 0;
    }
    output_file1 = open(argv[2], O_WRONLY);
    if (output_file1 < 0) {
      fprintf(stderr, "Can't open file %s\n", argv[2]);
      return 0;
    }
    output_file2 = open(argv[3], O_WRONLY);
    if (output_file2 < 0) {
      fprintf(stderr, "Can't open file %s\n", argv[3]);
      return 0;
    }
    port = atoi(argv[4]);
    if (port < 0) {
      fprintf(stderr, "Can't open port %s\n", argv[4]);
      return 0;
    }
  } else {
    fprintf(stderr, "Usage: 'tsoutputswitch inputfile.ts outputfile1.ts "
                    "outputfile2.ts port'\n");
    fprintf(stderr, "0 output on outputfile1 \n");
    fprintf(stderr, "1 output on outputfile2 \n");
    fprintf(stderr, "2 output on both \n");
    fprintf(stderr, "N.B. if they are not fifo the file size will increase\n");
    fprintf(stderr, "Default is 0\n");
    return 0;
  }
  int listen_sd;
  listen_sd = socket(AF_INET, SOCK_DGRAM, 0);
  if (listen_sd < 0) {
    fprintf(stderr, "secsocket - socket() error\n");
    exit(-1);
  } else {
    fprintf(stderr, "secsocket - socket() is OK\n");
  }
  int flags;
  flags = fcntl(listen_sd, F_GETFL, 0);
  fcntl(listen_sd, F_SETFL, flags | O_NONBLOCK);
  int reuse = 1;
  if (setsockopt(listen_sd, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse,
                 sizeof(reuse)) < 0) {
    fprintf(stderr, "setting SO_REUSEADDR failed\n");
    close(listen_sd);
    exit(-1);
  }
  struct sockaddr_in addr;
  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_addr.s_addr = INADDR_ANY;
  addr.sin_port = htons(port);
  int result = bind(listen_sd, (struct sockaddr *)&addr, sizeof(addr));
  if (result < 0) {
    fprintf(stderr, "secsocket - bind() error\n");
    close(listen_sd);
    exit(-1);
  } else {
  }
  byte_read = 1;
  choice = 0;
  int new_choice = 0;
  unsigned char received = 0;
  while (byte_read) {
    if (recv(listen_sd, &received, 1, 0) > 0) {
      fprintf(stderr, "received %d\n", received - 48);
      new_choice = received - 48;
    }
    byte_read = read(input_file, packet, 188);
    if (byte_read > 0) {
      if (new_choice != choice) {
        close(output_file1);
        output_file1 = open(argv[2], O_WRONLY);
        if (output_file1 < 0) {
          fprintf(stderr, "Can't open file %s\n", argv[2]);
          return 0;
        }
        close(output_file2);
        output_file2 = open(argv[3], O_WRONLY);
        if (output_file2 < 0) {
          fprintf(stderr, "Can't open file %s\n", argv[3]);
          return 0;
        }
        choice = new_choice;
      }
      if (choice == 0 || choice == 2) {
        write(output_file1, packet, 188);
      }
      if (choice == 1 || choice == 2) {
        write(output_file2, packet, 188);
      }
    }
  }
  close(input_file);
  close(output_file1);
  close(output_file2);
  close(listen_sd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jl     1337 <main+0x157>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dbe(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1251 <main+0x71>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1766 <main+0x586>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2d28(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    129f <main+0xbf>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xd74(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1766 <main+0x586>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x2cda(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    12ed <main+0x10d>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xd26(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1766 <main+0x586>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1332 <main+0x152>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xcf5(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1766 <main+0x586>
jmp    13cd <main+0x1ed>
mov    0x2c72(%rip),%rax
mov    (%rax),%edi
lea    0xce1(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2c5b(%rip),%rax
mov    (%rax),%edi
lea    0xd13(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
lea    0xd16(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
lea    0xd19(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2c16(%rip),%rax
mov    (%rax),%edi
lea    0xd15(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2bff(%rip),%rax
mov    (%rax),%edi
lea    0xd35(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1766 <main+0x586>
mov    0x2c0c(%rip),%rax
mov    (%rax),%edi
mov    0x2be3(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0xf4(%rbp)
cmpl   $0x0,-0xf4(%rbp)
jge    141a <main+0x23a>
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
lea    0xcf4(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
mov    0x2b8f(%rip),%rax
mov    (%rax),%edi
lea    0xcef(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0xf4(%rbp),%edi
mov    0x2b62(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %eax,-0xf8(%rbp)
mov    -0xf4(%rbp),%edi
mov    0x2b4e(%rip),%rax
mov    (%rax),%esi
mov    -0xf8(%rbp),%edx
mov    0x2b6f(%rip),%rax
or     (%rax),%edx
call   1050 <fcntl@plt>
movl   $0x1,-0xfc(%rbp)
mov    -0xf4(%rbp),%edi
mov    0x2b61(%rip),%rax
mov    (%rax),%esi
mov    0x2b08(%rip),%rax
mov    (%rax),%edx
lea    -0xfc(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    14da <main+0x2fa>
mov    0x2afb(%rip),%rax
mov    (%rax),%edi
lea    0xc77(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0xf4(%rbp),%edi
call   1090 <close@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
lea    -0x108(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2aec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x100(%rbp)
mov    0x2ac5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x104(%rbp)
mov    -0x28(%rbp),%edi
call   1070 <htons@plt>
mov    %eax,-0x108(%rbp)
mov    -0xf4(%rbp),%edi
lea    -0x108(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
mov    %eax,-0x10c(%rbp)
cmpl   $0x0,-0x10c(%rbp)
jge    156f <main+0x38f>
mov    0x2a66(%rip),%rax
mov    (%rax),%edi
lea    0xbff(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0xf4(%rbp),%edi
call   1090 <close@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
jmp    1574 <main+0x394>
movl   $0x1,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
movl   $0x0,-0x110(%rbp)
movb   $0x0,-0x111(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     173c <main+0x55c>
mov    -0xf4(%rbp),%edi
lea    -0x111(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
jle    15ee <main+0x40e>
mov    0x29ec(%rip),%rax
mov    (%rax),%edi
movzbl -0x111(%rbp),%edx
sub    $0x30,%edx
lea    0xb95(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movzbl -0x111(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x110(%rbp)
mov    -0x14(%rbp),%edi
lea    -0xf0(%rbp),%rsi
mov    $0xbc,%edx
call   10a0 <read@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    1737 <main+0x557>
mov    -0x110(%rbp),%eax
movzbl -0x21(%rbp),%ecx
cmp    %ecx,%eax
je     16d6 <main+0x4f6>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2950(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1677 <main+0x497>
mov    0x295d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0x99c(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1766 <main+0x586>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x28fa(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    16cd <main+0x4ed>
mov    0x2907(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0x946(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1766 <main+0x586>
mov    -0x110(%rbp),%eax
mov    %al,-0x21(%rbp)
movzbl -0x21(%rbp),%eax
cmp    $0x0,%eax
je     16f0 <main+0x510>
movzbl -0x21(%rbp),%eax
cmp    $0x2,%eax
jne    1704 <main+0x524>
mov    -0x18(%rbp),%edi
lea    -0xf0(%rbp),%rsi
mov    $0xbc,%edx
call   1060 <write@plt>
movzbl -0x21(%rbp),%eax
cmp    $0x1,%eax
je     171e <main+0x53e>
movzbl -0x21(%rbp),%eax
cmp    $0x2,%eax
jne    1732 <main+0x552>
mov    -0x1c(%rbp),%edi
lea    -0xf0(%rbp),%rsi
mov    $0xbc,%edx
call   1060 <write@plt>
jmp    1737 <main+0x557>
jmp    1590 <main+0x3b0>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0xf4(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf8,%rsp
cmp    $0x5,%edi
jl     1483 <main+0x2a3>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x2dc8(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,0x10(%rsp)
test   %eax,%eax
js     14ec <main+0x30c>
mov    0x10(%rbx),%rdi
mov    0x2d62(%rip),%rbp
mov    0x0(%rbp),%esi
call   10d0 <open@plt>
test   %eax,%eax
js     14fb <main+0x31b>
mov    %eax,%r15d
mov    0x18(%rbx),%rdi
mov    0x0(%rbp),%esi
call   10d0 <open@plt>
mov    %eax,0x8(%rsp)
test   %eax,%eax
js     150a <main+0x32a>
mov    0x20(%rbx),%r13
mov    %r13,%rdi
call   10e0 <atoi@plt>
test   %eax,%eax
js     155d <main+0x37d>
mov    %eax,%r14d
mov    %rbx,0x28(%rsp)
mov    0x2d6c(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d42(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,%r12d
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
test   %r12d,%r12d
js     1590 <main+0x3b0>
lea    0xe76(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x2cef(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    0x2ce4(%rip),%rcx
mov    (%rcx),%esi
mov    0x2d0b(%rip),%rcx
or     (%rcx),%eax
mov    %r12d,%edi
mov    %eax,%edx
call   1050 <fcntl@plt>
movl   $0x1,0x14(%rsp)
mov    0x2d00(%rip),%rax
mov    (%rax),%esi
mov    0x2ca7(%rip),%rax
mov    (%rax),%edx
lea    0x14(%rsp),%rcx
mov    %r12d,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
js     15a8 <main+0x3c8>
lea    0x18(%rsp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x20(%rsp)
mov    0x2c97(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
mov    %r14d,%edi
call   1070 <htons@plt>
mov    %eax,0x18(%rsp)
mov    %r12d,%edi
mov    %r13,%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
test   %eax,%eax
js     15ba <main+0x3da>
movb   $0x0,0x7(%rsp)
lea    0x7(%rsp),%rbx
lea    0xe00(%rip),%r13
movl   $0x0,0xc(%rsp)
xor    %ebp,%ebp
jmp    1389 <main+0x1a9>
nopl   0x0(%rax,%rax,1)
test   %r14d,%r14d
je     1539 <main+0x359>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jle    13c7 <main+0x1e7>
mov    0x2c09(%rip),%rax
mov    (%rax),%edi
movzbl 0x7(%rsp),%edx
add    $0xffffffd0,%edx
mov    %r13,%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
movzbl 0x7(%rsp),%eax
add    $0xffffffd0,%eax
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    $0xbc,%edx
call   10a0 <read@plt>
mov    %eax,%r14d
test   %eax,%eax
jle    1380 <main+0x1a0>
movzbl %bpl,%eax
cmp    %eax,0xc(%rsp)
je     1448 <main+0x268>
mov    %rbx,%r13
mov    %r15d,%edi
call   1090 <close@plt>
mov    0x28(%rsp),%rbp
mov    0x10(%rbp),%rdi
mov    0x2b82(%rip),%rbx
mov    (%rbx),%esi
call   10d0 <open@plt>
test   %eax,%eax
js     1572 <main+0x392>
mov    %eax,%r15d
mov    0x8(%rsp),%edi
call   1090 <close@plt>
mov    0x18(%rbp),%rdi
mov    (%rbx),%esi
call   10d0 <open@plt>
mov    %eax,0x8(%rsp)
test   %eax,%eax
js     1581 <main+0x3a1>
mov    0xc(%rsp),%eax
mov    %eax,%ebp
mov    %r13,%rbx
lea    0xd24(%rip),%r13
test   $0xfd,%bpl
jne    1460 <main+0x280>
mov    %r15d,%edi
lea    0x30(%rsp),%rsi
mov    $0xbc,%edx
call   1060 <write@plt>
lea    -0x1(%rbp),%eax
cmp    $0x1,%al
ja     1380 <main+0x1a0>
mov    0x8(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    $0xbc,%edx
call   1060 <write@plt>
jmp    1380 <main+0x1a0>
mov    0x2b26(%rip),%rbx
mov    (%rbx),%edi
lea    0xb95(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xbce(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xbd8(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xbe2(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xbe5(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc0c(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1525 <main+0x345>
mov    0x2abd(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
jmp    1517 <main+0x337>
mov    0x2aae(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
jmp    1517 <main+0x337>
mov    0x2a9f(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbx),%rdx
lea    0xae2(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
xor    %eax,%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rsp),%edi
call   1090 <close@plt>
mov    %r15d,%edi
call   1090 <close@plt>
mov    0x8(%rsp),%edi
call   1090 <close@plt>
mov    %r12d,%edi
call   1090 <close@plt>
jmp    1525 <main+0x345>
mov    0x2a4c(%rip),%rax
mov    (%rax),%edi
lea    0xaa7(%rip),%rsi
mov    %r13,%rdx
jmp    151e <main+0x33e>
mov    0x2a37(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%rdx
jmp    1517 <main+0x337>
mov    0x2a28(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbp),%rdx
jmp    1517 <main+0x337>
lea    0xb66(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
mov    0x2a01(%rip),%rax
mov    (%rax),%edi
lea    0xb7d(%rip),%rsi
jmp    15ca <main+0x3ea>
mov    0x29ef(%rip),%rax
mov    (%rax),%edi
lea    0xb88(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %r12d,%edi
call   1090 <close@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"Can't open file %s\0A\00"
@O_WRONLY = global i32 0
@.str.1 = [20 x i8] c"Can't open port %s\0A\00"
@.str.2 = [73 x i8] c"Usage: 'tsoutputswitch inputfile.ts outputfile1.ts outputfile2.ts port'\0A\00"
@.str.3 = [26 x i8] c"0 output on outputfile1 \0A\00"
@.str.4 = [26 x i8] c"1 output on outputfile2 \0A\00"
@.str.5 = [19 x i8] c"2 output on both \0A\00"
@.str.6 = [55 x i8] c"N.B. if they are not fifo the file size will increase\0A\00"
@.str.7 = [14 x i8] c"Default is 0\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.8 = [28 x i8] c"secsocket - socket() error\0A\00"
@.str.9 = [28 x i8] c"secsocket - socket() is OK\0A\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.10 = [29 x i8] c"setting SO_REUSEADDR failed\0A\00"
@INADDR_ANY = global i32 0
@.str.11 = [26 x i8] c"secsocket - bind() error\0A\00"
@.str.12 = [13 x i8] c"received %d\0A\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 i8
%11 = alloca i32
%12 = alloca [188 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca %struct.sockaddr_in
%17 = alloca i32
%18 = alloca i32
%19 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* %4
%21 = icmp sge i32 %20, 5
br i1 %21, label %22, label %78
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i32, i32* @O_RDONLY
%27 = call i32 @open(i8* %25, i32 %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %22
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %34)
store i32 0, i32* %3
br label %246
36: ; preds = %22
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = load i32, i32* @O_WRONLY
%41 = call i32 @open(i8* %39, i32 %40)
store i32 %41, i32* %7
%42 = load i32, i32* %7
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %36
%45 = load i32, i32* @stderr
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %48)
store i32 0, i32* %3
br label %246
50: ; preds = %36
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 3
%53 = load i8*, i8** %52
%54 = load i32, i32* @O_WRONLY
%55 = call i32 @open(i8* %53, i32 %54)
store i32 %55, i32* %8
%56 = load i32, i32* %8
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %50
%59 = load i32, i32* @stderr
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 3
%62 = load i8*, i8** %61
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %62)
store i32 0, i32* %3
br label %246
64: ; preds = %50
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 4
%67 = load i8*, i8** %66
%68 = call i32 @atoi(i8* %67)
store i32 %68, i32* %11
%69 = load i32, i32* %11
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %64
%72 = load i32, i32* @stderr
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 4
%75 = load i8*, i8** %74
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %75)
store i32 0, i32* %3
br label %246
77: ; preds = %64
br label %91
78: ; preds = %2
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0))
%81 = load i32, i32* @stderr
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0))
%89 = load i32, i32* @stderr
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
br label %246
91: ; preds = %77
%92 = load i32, i32* @AF_INET
%93 = load i32, i32* @SOCK_DGRAM
%94 = call i32 @socket(i32 %92, i32 %93, i32 0)
store i32 %94, i32* %13
%95 = load i32, i32* %13
%96 = icmp slt i32 %95, 0
br i1 %96, label %97, label %101
97: ; preds = %91
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%100 = call i32 @exit(i32 -1)
unreachable
101: ; preds = %91
%102 = load i32, i32* @stderr
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
br label %104
104: ; preds = %101
%105 = load i32, i32* %13
%106 = load i32, i32* @F_GETFL
%107 = call i32 @fcntl(i32 %105, i32 %106, i32 0)
store i32 %107, i32* %14
%108 = load i32, i32* %13
%109 = load i32, i32* @F_SETFL
%110 = load i32, i32* %14
%111 = load i32, i32* @O_NONBLOCK
%112 = or i32 %110, %111
%113 = call i32 @fcntl(i32 %108, i32 %109, i32 %112)
store i32 1, i32* %15
%114 = load i32, i32* %13
%115 = load i32, i32* @SOL_SOCKET
%116 = load i32, i32* @SO_REUSEADDR
%117 = bitcast i32* %15 to i8*
%118 = call i64 @setsockopt(i32 %114, i32 %115, i32 %116, i8* %117, i32 4)
%119 = icmp slt i64 %118, 0
br i1 %119, label %120, label %126
120: ; preds = %104
%121 = load i32, i32* @stderr
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%123 = load i32, i32* %13
%124 = call i32 @close(i32 %123)
%125 = call i32 @exit(i32 -1)
unreachable
126: ; preds = %104
%127 = call i32 @memset(%struct.sockaddr_in* %16, i32 0, i32 12)
%128 = load i32, i32* @AF_INET
%129 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 2
store i32 %128, i32* %129
%130 = load i32, i32* @INADDR_ANY
%131 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 1
%132 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %131, i32 0, i32 0
store i32 %130, i32* %132
%133 = load i32, i32* %11
%134 = call i32 @htons(i32 %133)
%135 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 0
store i32 %134, i32* %135
%136 = load i32, i32* %13
%137 = bitcast %struct.sockaddr_in* %16 to %struct.sockaddr*
%138 = call i32 @bind(i32 %136, %struct.sockaddr* %137, i32 12)
store i32 %138, i32* %17
%139 = load i32, i32* %17
%140 = icmp slt i32 %139, 0
br i1 %140, label %141, label %147
141: ; preds = %126
%142 = load i32, i32* @stderr
%143 = call i32 (i32, i8*, ...) @fprintf(i32 %142, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
%144 = load i32, i32* %13
%145 = call i32 @close(i32 %144)
%146 = call i32 @exit(i32 -1)
unreachable
147: ; preds = %126
br label %148
148: ; preds = %147
store i32 1, i32* %9
store i8 0, i8* %10
store i32 0, i32* %18
store i8 0, i8* %19
br label %149
149: ; preds = %236, %148
%150 = load i32, i32* %9
%151 = icmp ne i32 %150, 0
br i1 %151, label %152, label %237
152: ; preds = %149
%153 = load i32, i32* %13
%154 = call i64 @recv(i32 %153, i8* %19, i32 1, i32 0)
%155 = icmp sgt i64 %154, 0
br i1 %155, label %156, label %165
156: ; preds = %152
%157 = load i32, i32* @stderr
%158 = load i8, i8* %19
%159 = zext i8 %158 to i32
%160 = sub nsw i32 %159, 48
%161 = call i32 (i32, i8*, ...) @fprintf(i32 %157, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i32 %160)
%162 = load i8, i8* %19
%163 = zext i8 %162 to i32
%164 = sub nsw i32 %163, 48
store i32 %164, i32* %18
br label %165
165: ; preds = %156, %152
%166 = load i32, i32* %6
%167 = getelementptr inbounds [188 x i8], [188 x i8]* %12, i64 0, i64 0
%168 = call i32 @read(i32 %166, i8* %167, i32 188)
store i32 %168, i32* %9
%169 = load i32, i32* %9
%170 = icmp sgt i32 %169, 0
br i1 %170, label %171, label %236
171: ; preds = %165
%172 = load i32, i32* %18
%173 = load i8, i8* %10
%174 = zext i8 %173 to i32
%175 = icmp ne i32 %172, %174
br i1 %175, label %176, label %211
176: ; preds = %171
%177 = load i32, i32* %7
%178 = call i32 @close(i32 %177)
%179 = load i8**, i8*** %5
%180 = getelementptr inbounds i8*, i8** %179, i64 2
%181 = load i8*, i8** %180
%182 = load i32, i32* @O_WRONLY
%183 = call i32 @open(i8* %181, i32 %182)
store i32 %183, i32* %7
%184 = load i32, i32* %7
%185 = icmp slt i32 %184, 0
br i1 %185, label %186, label %192
186: ; preds = %176
%187 = load i32, i32* @stderr
%188 = load i8**, i8*** %5
%189 = getelementptr inbounds i8*, i8** %188, i64 2
%190 = load i8*, i8** %189
%191 = call i32 (i32, i8*, ...) @fprintf(i32 %187, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %190)
store i32 0, i32* %3
br label %246
192: ; preds = %176
%193 = load i32, i32* %8
%194 = call i32 @close(i32 %193)
%195 = load i8**, i8*** %5
%196 = getelementptr inbounds i8*, i8** %195, i64 3
%197 = load i8*, i8** %196
%198 = load i32, i32* @O_WRONLY
%199 = call i32 @open(i8* %197, i32 %198)
store i32 %199, i32* %8
%200 = load i32, i32* %8
%201 = icmp slt i32 %200, 0
br i1 %201, label %202, label %208
202: ; preds = %192
%203 = load i32, i32* @stderr
%204 = load i8**, i8*** %5
%205 = getelementptr inbounds i8*, i8** %204, i64 3
%206 = load i8*, i8** %205
%207 = call i32 (i32, i8*, ...) @fprintf(i32 %203, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %206)
store i32 0, i32* %3
br label %246
208: ; preds = %192
%209 = load i32, i32* %18
%210 = trunc i32 %209 to i8
store i8 %210, i8* %10
br label %211
211: ; preds = %208, %171
%212 = load i8, i8* %10
%213 = zext i8 %212 to i32
%214 = icmp eq i32 %213, 0
br i1 %214, label %219, label %215
215: ; preds = %211
%216 = load i8, i8* %10
%217 = zext i8 %216 to i32
%218 = icmp eq i32 %217, 2
br i1 %218, label %219, label %223
219: ; preds = %215, %211
%220 = load i32, i32* %7
%221 = getelementptr inbounds [188 x i8], [188 x i8]* %12, i64 0, i64 0
%222 = call i32 @write(i32 %220, i8* %221, i32 188)
br label %223
223: ; preds = %219, %215
%224 = load i8, i8* %10
%225 = zext i8 %224 to i32
%226 = icmp eq i32 %225, 1
br i1 %226, label %231, label %227
227: ; preds = %223
%228 = load i8, i8* %10
%229 = zext i8 %228 to i32
%230 = icmp eq i32 %229, 2
br i1 %230, label %231, label %235
231: ; preds = %227, %223
%232 = load i32, i32* %8
%233 = getelementptr inbounds [188 x i8], [188 x i8]* %12, i64 0, i64 0
%234 = call i32 @write(i32 %232, i8* %233, i32 188)
br label %235
235: ; preds = %231, %227
br label %236
236: ; preds = %235, %165
br label %149
237: ; preds = %149
%238 = load i32, i32* %6
%239 = call i32 @close(i32 %238)
%240 = load i32, i32* %7
%241 = call i32 @close(i32 %240)
%242 = load i32, i32* %8
%243 = call i32 @close(i32 %242)
%244 = load i32, i32* %13
%245 = call i32 @close(i32 %244)
store i32 0, i32* %3
br label %246
246: ; preds = %237, %202, %186, %78, %71, %58, %44, %30
%247 = load i32, i32* %3
ret i32 %247
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"Can't open file %s\0A\00"
@O_WRONLY = global i32 0
@.str.1 = [20 x i8] c"Can't open port %s\0A\00"
@.str.2 = [73 x i8] c"Usage: 'tsoutputswitch inputfile.ts outputfile1.ts outputfile2.ts port'\0A\00"
@.str.3 = [26 x i8] c"0 output on outputfile1 \0A\00"
@.str.4 = [26 x i8] c"1 output on outputfile2 \0A\00"
@.str.5 = [19 x i8] c"2 output on both \0A\00"
@.str.6 = [55 x i8] c"N.B. if they are not fifo the file size will increase\0A\00"
@.str.7 = [14 x i8] c"Default is 0\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.8 = [28 x i8] c"secsocket - socket() error\0A\00"
@.str.9 = [28 x i8] c"secsocket - socket() is OK\0A\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.10 = [29 x i8] c"setting SO_REUSEADDR failed\0A\00"
@INADDR_ANY = global i32 0
@.str.11 = [26 x i8] c"secsocket - bind() error\0A\00"
@.str.12 = [13 x i8] c"received %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [188 x i8]
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca i8
%7 = getelementptr inbounds [188 x i8], [188 x i8]* %3, i64 0, i64 0
%8 = icmp sgt i32 %0, 4
br i1 %8, label %9, label %47
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDONLY
%13 = tail call i32 @open(i8* %11, i32 %12)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %10
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %174
19: ; preds = %9
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = load i32, i32* @O_WRONLY
%23 = tail call i32 @open(i8* %21, i32 %22)
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %20
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %27)
br label %174
29: ; preds = %19
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
%32 = load i32, i32* @O_WRONLY
%33 = tail call i32 @open(i8* %31, i32 %32)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %29
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %30
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %37)
br label %174
39: ; preds = %29
%40 = getelementptr inbounds i8*, i8** %1, i64 4
%41 = load i8*, i8** %40
%42 = tail call i32 @atoi(i8* %41)
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %60
44: ; preds = %39
%45 = load i32, i32* @stderr
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %41)
br label %174
47: ; preds = %2
%48 = load i32, i32* @stderr
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0))
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%52 = load i32, i32* @stderr
%53 = tail call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%54 = load i32, i32* @stderr
%55 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%56 = load i32, i32* @stderr
%57 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0))
%58 = load i32, i32* @stderr
%59 = tail call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %174
60: ; preds = %39
%61 = load i32, i32* @AF_INET
%62 = load i32, i32* @SOCK_DGRAM
%63 = tail call i32 @socket(i32 %61, i32 %62, i32 0)
%64 = icmp slt i32 %63, 0
%65 = load i32, i32* @stderr
br i1 %64, label %66, label %69
66: ; preds = %60
%67 = tail call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%68 = tail call i32 @exit(i32 -1)
unreachable
69: ; preds = %60
%70 = tail call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%71 = load i32, i32* @F_GETFL
%72 = tail call i32 @fcntl(i32 %63, i32 %71, i32 0)
%73 = load i32, i32* @F_SETFL
%74 = load i32, i32* @O_NONBLOCK
%75 = or i32 %74, %72
%76 = tail call i32 @fcntl(i32 %63, i32 %73, i32 %75)
%77 = bitcast i32* %4 to i8*
store i32 1, i32* %4
%78 = load i32, i32* @SOL_SOCKET
%79 = load i32, i32* @SO_REUSEADDR
%80 = call i64 @setsockopt(i32 %63, i32 %78, i32 %79, i8* %77, i32 4)
%81 = icmp slt i64 %80, 0
br i1 %81, label %82, label %87
82: ; preds = %69
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%85 = call i32 @close(i32 %63)
%86 = call i32 @exit(i32 -1)
unreachable
87: ; preds = %69
%88 = bitcast %struct.sockaddr_in* %5 to i8*
%89 = call i32 @memset(%struct.sockaddr_in* %5, i32 0, i32 12)
%90 = load i32, i32* @AF_INET
%91 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %90, i32* %91
%92 = load i32, i32* @INADDR_ANY
%93 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
store i32 %92, i32* %93
%94 = call i32 @htons(i32 %42)
%95 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i32 %94, i32* %95
%96 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%97 = call i32 @bind(i32 %63, %struct.sockaddr* %96, i32 12)
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %104
99: ; preds = %87
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
%102 = call i32 @close(i32 %63)
%103 = call i32 @exit(i32 -1)
unreachable
104: ; preds = %87
store i8 0, i8* %6
br label %105
105: ; preds = %104, %163
%106 = phi i32 [ 0, %104 ], [ %122, %163 ]
%107 = phi i32 [ %23, %104 ], [ %166, %163 ]
%108 = phi i32 [ %33, %104 ], [ %165, %163 ]
%109 = phi i8 [ 0, %104 ], [ %164, %163 ]
%110 = call i64 @recv(i32 %63, i8* %6, i32 1, i32 0)
%111 = icmp sgt i64 %110, 0
br i1 %111, label %112, label %121
112: ; preds = %105
%113 = load i32, i32* @stderr
%114 = load i8, i8* %6
%115 = zext i8 %114 to i32
%116 = add nsw i32 %115, -48
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i32 %116)
%118 = load i8, i8* %6
%119 = zext i8 %118 to i32
%120 = add nsw i32 %119, -48
br label %121
121: ; preds = %112, %105
%122 = phi i32 [ %120, %112 ], [ %106, %105 ]
%123 = call i32 @read(i32 %13, i8* %7, i32 188)
%124 = icmp sgt i32 %123, 0
br i1 %124, label %125, label %163
125: ; preds = %121
%126 = zext i8 %109 to i32
%127 = icmp eq i32 %122, %126
br i1 %127, label %150, label %128
128: ; preds = %125
%129 = call i32 @close(i32 %107)
%130 = load i8*, i8** %20
%131 = load i32, i32* @O_WRONLY
%132 = call i32 @open(i8* %130, i32 %131)
%133 = icmp slt i32 %132, 0
br i1 %133, label %134, label %138
134: ; preds = %128
%135 = load i32, i32* @stderr
%136 = load i8*, i8** %20
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %136)
br label %173
138: ; preds = %128
%139 = call i32 @close(i32 %108)
%140 = load i8*, i8** %30
%141 = load i32, i32* @O_WRONLY
%142 = call i32 @open(i8* %140, i32 %141)
%143 = icmp slt i32 %142, 0
br i1 %143, label %144, label %148
144: ; preds = %138
%145 = load i32, i32* @stderr
%146 = load i8*, i8** %30
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %145, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %146)
br label %173
148: ; preds = %138
%149 = trunc i32 %122 to i8
br label %150
150: ; preds = %148, %125
%151 = phi i8 [ %149, %148 ], [ %109, %125 ]
%152 = phi i32 [ %142, %148 ], [ %108, %125 ]
%153 = phi i32 [ %132, %148 ], [ %107, %125 ]
%154 = and i8 %151, -3
%155 = icmp eq i8 %154, 0
br i1 %155, label %156, label %158
156: ; preds = %150
%157 = call i32 @write(i32 %153, i8* %7, i32 188)
br label %158
158: ; preds = %150, %156
%159 = add i8 %151, -1
%160 = icmp ult i8 %159, 2
br i1 %160, label %161, label %163
161: ; preds = %158
%162 = call i32 @write(i32 %152, i8* %7, i32 188)
br label %163
163: ; preds = %161, %158, %121
%164 = phi i8 [ %151, %161 ], [ %151, %158 ], [ %109, %121 ]
%165 = phi i32 [ %152, %161 ], [ %152, %158 ], [ %108, %121 ]
%166 = phi i32 [ %153, %161 ], [ %153, %158 ], [ %107, %121 ]
%167 = icmp eq i32 %123, 0
br i1 %167, label %168, label %105
168: ; preds = %163
%169 = call i32 @close(i32 %13)
%170 = call i32 @close(i32 %166)
%171 = call i32 @close(i32 %165)
%172 = call i32 @close(i32 %63)
br label %173
173: ; preds = %168, %144, %134
br label %174
174: ; preds = %173, %47, %44, %35, %25, %15
ret i32 0
}