#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct sigaction {
  int ai_flags;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  scalar_t__ ai_next;
  int /*<<< orphan*/ sa_handler;
};
struct addrinfo {
  int ai_flags;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  scalar_t__ ai_next;
  int /*<<< orphan*/ sa_handler;
};
typedef int /*<<< orphan*/ siga;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int AI_PASSIVE;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
scalar_t__ bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *gai_strerror(int);
int getaddrinfo(char const *, char const *, struct sigaction *,
                struct sigaction **);
int /*<<< orphan*/ memset(struct sigaction *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int probe(int);
int /*<<< orphan*/ serve1(int);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int /*<<< orphan*/ sigaction(int /*<<< orphan*/, struct sigaction *,
                             int /*<<< orphan*/ *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  if (argc != 4 && argc != 6) {
    fprintf(stderr, "Usage:\n");
    fprintf(stderr, "    udptimeoutchecker serve listen_addr listen_port \n");
    fprintf(stderr, "    udptimeoutchecker probe bind_addr bind_port "
                    "connect_addr connect_port\n");
    fprintf(stderr,
            "Probes time for which UDP connection though a NAT stays open.\n");
    fprintf(stderr, "Example:\n");
    fprintf(stderr, "    udptimeoutchecker serve 0.0.0.0 909\n");
    fprintf(stderr,
            "    udptimeoutchecker probe 0.0.0.0 0 vi-server.org 909\n");
    fprintf(stderr, "\n");
    return 1;
  }
  const char *cmd = argv[1];
  const char *bind_addr_ = argv[2];
  const char *bind_port_ = argv[3];
  const char *send_addr_ = argv[4];
  const char *send_port_ = argv[5];
  if (!!strcmp(cmd, "serve") && !!strcmp(cmd, "probe")) {
    fprintf(stderr, "Command should be 'serve' or 'probe'\n");
    return 1;
  }
  if (!strcmp(cmd, "probe") && argc != 6) {
    fprintf(stderr, "Not enough arguments for probe command\n");
    return 1;
  }
  {
    struct sigaction siga;
    memset(&siga, 0, sizeof(siga));
    siga.sa_handler = SIG_IGN;
    sigaction(SIGCHLD, &siga, NULL);
  }
  struct addrinfo hints;
  struct addrinfo *recv_addr;
  struct addrinfo *send_addr;
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_family = AF_INET;
  hints.ai_flags = AI_PASSIVE;
  int gai_error;
  gai_error = getaddrinfo(bind_addr_, bind_port_, &hints, &recv_addr);
  if (gai_error) {
    fprintf(stderr, "getaddrinfo 1: %s\n", gai_strerror(gai_error));
    return 4;
  }
  if (!recv_addr) {
    fprintf(stderr, "getaddrinfo returned no addresses\n");
    return 6;
  }
  if (recv_addr->ai_next) {
    fprintf(stderr,
            "Warning: using only one of addresses retuned by getaddrinfo\n");
  }
  if (!strcmp(cmd, "probe")) {
    hints.ai_flags &= !AI_PASSIVE;
    gai_error = getaddrinfo(send_addr_, send_port_, &hints, &send_addr);
    if (gai_error) {
      fprintf(stderr, "getaddrinfo 2: %s\n", gai_strerror(gai_error));
      return 13;
    }
    if (!send_addr) {
      fprintf(stderr, "getaddrinfo 2 returned no addresses\n");
      return 15;
    }
    if (send_addr->ai_next) {
      fprintf(
          stderr,
          "Warning: using only one of addresses retuned by getaddrinfo 2\n");
    }
  }
  int s;
  s = socket(recv_addr->ai_family, recv_addr->ai_socktype,
             recv_addr->ai_protocol);
  if (s == -1) {
    perror("socket");
    return 7;
  }
  {
    int one = 1;
    setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one);
  }
  if (bind(s, recv_addr->ai_addr, recv_addr->ai_addrlen)) {
    perror("bind");
    return 5;
  }
  if (!strcmp(cmd, "serve")) {
    for (;;) {
      serve1(s);
      usleep(250 * 1000);
    }
  }
  if (!strcmp(cmd, "probe")) {
    if (-1 == connect(s, send_addr->ai_addr, send_addr->ai_addrlen)) {
      perror("connect");
      return 6;
    }
    return probe(s);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     12d1 <main+0xf1>
cmpl   $0x6,-0x8(%rbp)
je     12d1 <main+0xf1>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
lea    0xd7e(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1744 <main+0x564>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
je     1362 <main+0x182>
mov    -0x18(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
je     1362 <main+0x182>
mov    0x2c6a(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1744 <main+0x564>
mov    -0x18(%rbp),%rdi
lea    0xdcd(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    13a8 <main+0x1c8>
cmpl   $0x6,-0x8(%rbp)
je     13a8 <main+0x1c8>
mov    0x2c24(%rip),%rax
mov    (%rax),%edi
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1744 <main+0x564>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    0x2c01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2c05(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
lea    -0x88(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    0x2bd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
mov    0x2bd8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    0x2bd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x88(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x88(%rbp),%rdx
lea    -0x90(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0x9c(%rbp)
cmpl   $0x0,-0x9c(%rbp)
je     147f <main+0x29f>
mov    0x2b67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x9c(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0xa8(%rbp),%edi
mov    %rax,%rdx
lea    0xd22(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x4,-0x4(%rbp)
jmp    1744 <main+0x564>
cmpq   $0x0,-0x90(%rbp)
jne    14b0 <main+0x2d0>
mov    0x2b1c(%rip),%rax
mov    (%rax),%edi
lea    0xd04(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x6,-0x4(%rbp)
jmp    1744 <main+0x564>
mov    -0x90(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     14d9 <main+0x2f9>
mov    0x2ae7(%rip),%rax
mov    (%rax),%edi
lea    0xcf2(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xc56(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    15dc <main+0x3fc>
mov    0x2ae7(%rip),%rax
cmpl   $0x0,(%rax)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
and    -0x88(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
lea    -0x88(%rbp),%rdx
lea    -0x98(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0x9c(%rbp)
cmpl   $0x0,-0x9c(%rbp)
je     157d <main+0x39d>
mov    0x2a69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
mov    -0x9c(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0xac(%rbp),%edi
mov    %rax,%rdx
lea    0xc97(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xd,-0x4(%rbp)
jmp    1744 <main+0x564>
cmpq   $0x0,-0x98(%rbp)
jne    15ae <main+0x3ce>
mov    0x2a1e(%rip),%rax
mov    (%rax),%edi
lea    0xc79(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xf,-0x4(%rbp)
jmp    1744 <main+0x564>
mov    -0x98(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     15d7 <main+0x3f7>
mov    0x29e9(%rip),%rax
mov    (%rax),%edi
lea    0xc69(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15dc <main+0x3fc>
mov    -0x90(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x90(%rbp),%rax
mov    0x10(%rax),%esi
mov    -0x90(%rbp),%rax
mov    0xc(%rax),%edx
call   1100 <socket@plt>
mov    %eax,-0xa0(%rbp)
cmpl   $0xffffffff,-0xa0(%rbp)
jne    162a <main+0x44a>
lea    0xc5f(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x7,-0x4(%rbp)
jmp    1744 <main+0x564>
movl   $0x1,-0xa4(%rbp)
mov    -0xa0(%rbp),%edi
mov    0x29a7(%rip),%rax
mov    (%rax),%esi
mov    0x295e(%rip),%rax
mov    (%rax),%edx
lea    -0xa4(%rbp),%rcx
mov    $0x4,%r8d
call   1060 <setsockopt@plt>
mov    -0xa0(%rbp),%edi
mov    -0x90(%rbp),%rax
mov    0x8(%rax),%esi
mov    -0x90(%rbp),%rax
mov    0x4(%rax),%edx
call   10b0 <bind@plt>
cmp    $0x0,%rax
je     169f <main+0x4bf>
lea    0xbf1(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x5,-0x4(%rbp)
jmp    1744 <main+0x564>
mov    -0x18(%rbp),%rdi
lea    0xa8a(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    16d7 <main+0x4f7>
jmp    16bd <main+0x4dd>
mov    -0xa0(%rbp),%edi
call   1030 <serve1@plt>
mov    $0x3d090,%edi
call   10f0 <usleep@plt>
jmp    16bd <main+0x4dd>
mov    -0x18(%rbp),%rdi
lea    0xa58(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1744 <main+0x564>
mov    -0xa0(%rbp),%edi
mov    -0x98(%rbp),%rax
mov    0x8(%rax),%esi
mov    -0x98(%rbp),%rax
mov    0x4(%rax),%edx
call   10d0 <connect@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1736 <main+0x556>
lea    0xb5f(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x6,-0x4(%rbp)
jmp    1744 <main+0x564>
mov    -0xa0(%rbp),%edi
call   1040 <probe@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %edi,%eax
and    $0xfffffffd,%eax
cmp    $0x4,%eax
jne    1251 <main+0x71>
mov    %edi,%ebp
mov    0x8(%rsi),%r15
mov    0x10(%rsi),%r13
mov    0x18(%rsi),%r12
mov    0x20(%rsi),%r14
mov    0x28(%rsi),%rbx
lea    0xf1f(%rip),%rsi
mov    %r15,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     12d3 <main+0xf3>
lea    0xf0e(%rip),%rsi
mov    %r15,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     12d3 <main+0xf3>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
lea    0xef4(%rip),%rsi
jmp    12fb <main+0x11b>
mov    0x2d58(%rip),%rbx
mov    (%rbx),%edi
lea    0xd9f(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd97(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xdbd(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xdf8(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe27(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe21(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe3a(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd6b(%rip),%rsi
jmp    12fb <main+0x11b>
lea    0xe60(%rip),%rsi
mov    %r15,%rdi
call   1090 <strcmp@plt>
cmp    $0x6,%ebp
je     1316 <main+0x136>
test   %eax,%eax
jne    1316 <main+0x136>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,0x20(%rsp)
mov    %r14,0x28(%rsp)
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    0x2c85(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x50(%rsp)
mov    0x2c88(%rip),%rax
mov    (%rax),%edi
mov    %rbp,%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    0x2c59(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
mov    0x2c5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x44(%rsp)
mov    0x2c57(%rip),%r14
mov    (%r14),%eax
mov    %eax,0x30(%rsp)
lea    0x8(%rsp),%rcx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
je     13d4 <main+0x1f4>
mov    0x2c02(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xdd0(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x4,%eax
jmp    1307 <main+0x127>
mov    0x8(%rsp),%rax
test   %rax,%rax
je     14f3 <main+0x313>
cmpq   $0x0,0x18(%rax)
je     1400 <main+0x220>
mov    0x2bc0(%rip),%rax
mov    (%rax),%edi
lea    0xdcb(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xd33(%rip),%rsi
mov    %r15,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
mov    0x28(%rsp),%rdi
mov    0x20(%rsp),%rsi
je     1514 <main+0x334>
mov    0x8(%rsp),%rax
mov    0x14(%rax),%edi
mov    0xc(%rax),%edx
mov    0x10(%rax),%esi
call   1100 <socket@plt>
cmp    $0xffffffff,%eax
je     15b3 <main+0x3d3>
mov    %eax,%ebp
movl   $0x1,0x14(%rsp)
mov    0x2b9a(%rip),%rax
mov    (%rax),%esi
mov    0x2b51(%rip),%rax
mov    (%rax),%edx
lea    0x14(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1060 <setsockopt@plt>
mov    0x8(%rsp),%rax
mov    0x4(%rax),%edx
mov    0x8(%rax),%esi
mov    %ebp,%edi
call   10b0 <bind@plt>
test   %rax,%rax
jne    15c9 <main+0x3e9>
lea    0xca7(%rip),%rsi
mov    %r15,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     14e0 <main+0x300>
lea    0xc9a(%rip),%rsi
mov    %r15,%rdi
call   1090 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    1307 <main+0x127>
mov    0x18(%rsp),%rax
mov    0x4(%rax),%edx
mov    0x8(%rax),%esi
mov    %ebp,%edi
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
je     15df <main+0x3ff>
mov    %ebp,%edi
call   1040 <probe@plt>
jmp    1307 <main+0x127>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <serve1@plt>
mov    $0x3d090,%edi
call   10f0 <usleep@plt>
jmp    14e0 <main+0x300>
mov    0x2ab6(%rip),%rax
mov    (%rax),%edi
lea    0xc9e(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x6,%eax
jmp    1307 <main+0x127>
xor    %eax,%eax
cmpl   $0x0,(%r14)
sete   %al
and    %eax,0x30(%rsp)
lea    0x30(%rsp),%rdx
lea    0x18(%rsp),%rcx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
je     1561 <main+0x381>
mov    0x2a75(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xcb6(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xd,%eax
jmp    1307 <main+0x127>
mov    0x18(%rsp),%rax
test   %rax,%rax
je     1592 <main+0x3b2>
cmpq   $0x0,0x18(%rax)
je     1421 <main+0x241>
mov    0x2a33(%rip),%rax
mov    (%rax),%edi
lea    0xcb3(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1421 <main+0x241>
mov    0x2a17(%rip),%rax
mov    (%rax),%edi
lea    0xc72(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xf,%eax
jmp    1307 <main+0x127>
lea    0xcbe(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x7,%eax
jmp    1307 <main+0x127>
lea    0xcaf(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x5,%eax
jmp    1307 <main+0x127>
lea    0xc9e(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x6,%eax
jmp    1307 <main+0x127>

LLVM IR (-O0):
%struct.sigaction = type { i32, i32, i32, i32, i32, i32, i64, i32 }
%struct.addrinfo = type { i32, i32, i32, i32, i32, i32, i64, i32 }
@stderr = global i32 0
@.str = [8 x i8] c"Usage:\0A\00"
@.str.1 = [54 x i8] c" udptimeoutchecker serve listen_addr listen_port \0A\00"
@.str.2 = [75 x i8] c" udptimeoutchecker probe bind_addr bind_port connect_addr connect_port\0A\00"
@.str.3 = [63 x i8] c"Probes time for which UDP connection though a NAT stays open.\0A\00"
@.str.4 = [10 x i8] c"Example:\0A\00"
@.str.5 = [41 x i8] c" udptimeoutchecker serve 0.0.0.0 909\0A\00"
@.str.6 = [57 x i8] c" udptimeoutchecker probe 0.0.0.0 0 vi-server.org 909\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [6 x i8] c"serve\00"
@.str.9 = [6 x i8] c"probe\00"
@.str.10 = [38 x i8] c"Command should be 'serve' or 'probe'\0A\00"
@.str.11 = [40 x i8] c"Not enough arguments for probe command\0A\00"
@SIG_IGN = global i32 0
@SIGCHLD = global i32 0
@SOCK_DGRAM = global i32 0
@AF_INET = global i32 0
@AI_PASSIVE = global i32 0
@.str.12 = [19 x i8] c"getaddrinfo 1: %s\0A\00"
@.str.13 = [35 x i8] c"getaddrinfo returned no addresses\0A\00"
@.str.14 = [61 x i8] c"Warning: using only one of addresses retuned by getaddrinfo\0A\00"
@.str.15 = [19 x i8] c"getaddrinfo 2: %s\0A\00"
@.str.16 = [37 x i8] c"getaddrinfo 2 returned no addresses\0A\00"
@.str.17 = [63 x i8] c"Warning: using only one of addresses retuned by getaddrinfo 2\0A\00"
@.str.18 = [7 x i8] c"socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.19 = [5 x i8] c"bind\00"
@.str.20 = [8 x i8] c"connect\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca %struct.sigaction
%12 = alloca %struct.addrinfo
%13 = alloca %struct.addrinfo*
%14 = alloca %struct.addrinfo*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 4
br i1 %19, label %20, label %40
20: ; preds = %2
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 6
br i1 %22, label %23, label %40
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0))
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.6, i64 0, i64 0))
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %214
40: ; preds = %20, %2
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
store i8* %43, i8** %6
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
store i8* %46, i8** %7
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 3
%49 = load i8*, i8** %48
store i8* %49, i8** %8
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 4
%52 = load i8*, i8** %51
store i8* %52, i8** %9
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 5
%55 = load i8*, i8** %54
store i8* %55, i8** %10
%56 = load i8*, i8** %6
%57 = call i32 @strcmp(i8* %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %66
59: ; preds = %40
%60 = load i8*, i8** %6
%61 = call i32 @strcmp(i8* %60, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %3
br label %214
66: ; preds = %59, %40
%67 = load i8*, i8** %6
%68 = call i32 @strcmp(i8* %67, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%69 = icmp ne i32 %68, 0
br i1 %69, label %76, label %70
70: ; preds = %66
%71 = load i32, i32* %4
%72 = icmp ne i32 %71, 6
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %3
br label %214
76: ; preds = %70, %66
%77 = call i32 @memset(%struct.sigaction* %11, i32 0, i32 40)
%78 = load i32, i32* @SIG_IGN
%79 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %11, i32 0, i32 7
store i32 %78, i32* %79
%80 = load i32, i32* @SIGCHLD
%81 = call i32 @sigaction(i32 %80, %struct.sigaction* %11, i32* null)
%82 = bitcast %struct.addrinfo* %12 to %struct.sigaction*
%83 = call i32 @memset(%struct.sigaction* %82, i32 0, i32 40)
%84 = load i32, i32* @SOCK_DGRAM
%85 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 4
store i32 %84, i32* %85
%86 = load i32, i32* @AF_INET
%87 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 5
store i32 %86, i32* %87
%88 = load i32, i32* @AI_PASSIVE
%89 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 0
store i32 %88, i32* %89
%90 = load i8*, i8** %7
%91 = load i8*, i8** %8
%92 = bitcast %struct.addrinfo* %12 to %struct.sigaction*
%93 = bitcast %struct.addrinfo** %13 to %struct.sigaction**
%94 = call i32 @getaddrinfo(i8* %90, i8* %91, %struct.sigaction* %92, %struct.sigaction** %93)
store i32 %94, i32* %15
%95 = load i32, i32* %15
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %102
97: ; preds = %76
%98 = load i32, i32* @stderr
%99 = load i32, i32* %15
%100 = call i8* @gai_strerror(i32 %99)
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i8* %100)
store i32 4, i32* %3
br label %214
102: ; preds = %76
%103 = load %struct.addrinfo*, %struct.addrinfo** %13
%104 = icmp ne %struct.addrinfo* %103, null
br i1 %104, label %108, label %105
105: ; preds = %102
%106 = load i32, i32* @stderr
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0))
store i32 6, i32* %3
br label %214
108: ; preds = %102
%109 = load %struct.addrinfo*, %struct.addrinfo** %13
%110 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %109, i32 0, i32 6
%111 = load i64, i64* %110
%112 = icmp ne i64 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %108
%114 = load i32, i32* @stderr
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.14, i64 0, i64 0))
br label %116
116: ; preds = %113, %108
%117 = load i8*, i8** %6
%118 = call i32 @strcmp(i8* %117, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%119 = icmp ne i32 %118, 0
br i1 %119, label %155, label %120
120: ; preds = %116
%121 = load i32, i32* @AI_PASSIVE
%122 = icmp ne i32 %121, 0
%123 = xor i1 %122, true
%124 = zext i1 %123 to i32
%125 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 0
%126 = load i32, i32* %125
%127 = and i32 %126, %124
store i32 %127, i32* %125
%128 = load i8*, i8** %9
%129 = load i8*, i8** %10
%130 = bitcast %struct.addrinfo* %12 to %struct.sigaction*
%131 = bitcast %struct.addrinfo** %14 to %struct.sigaction**
%132 = call i32 @getaddrinfo(i8* %128, i8* %129, %struct.sigaction* %130, %struct.sigaction** %131)
store i32 %132, i32* %15
%133 = load i32, i32* %15
%134 = icmp ne i32 %133, 0
br i1 %134, label %135, label %140
135: ; preds = %120
%136 = load i32, i32* @stderr
%137 = load i32, i32* %15
%138 = call i8* @gai_strerror(i32 %137)
%139 = call i32 (i32, i8*, ...) @fprintf(i32 %136, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i8* %138)
store i32 13, i32* %3
br label %214
140: ; preds = %120
%141 = load %struct.addrinfo*, %struct.addrinfo** %14
%142 = icmp ne %struct.addrinfo* %141, null
br i1 %142, label %146, label %143
143: ; preds = %140
%144 = load i32, i32* @stderr
%145 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.16, i64 0, i64 0))
store i32 15, i32* %3
br label %214
146: ; preds = %140
%147 = load %struct.addrinfo*, %struct.addrinfo** %14
%148 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %147, i32 0, i32 6
%149 = load i64, i64* %148
%150 = icmp ne i64 %149, 0
br i1 %150, label %151, label %154
151: ; preds = %146
%152 = load i32, i32* @stderr
%153 = call i32 (i32, i8*, ...) @fprintf(i32 %152, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.17, i64 0, i64 0))
br label %154
154: ; preds = %151, %146
br label %155
155: ; preds = %154, %116
%156 = load %struct.addrinfo*, %struct.addrinfo** %13
%157 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %156, i32 0, i32 5
%158 = load i32, i32* %157
%159 = load %struct.addrinfo*, %struct.addrinfo** %13
%160 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %159, i32 0, i32 4
%161 = load i32, i32* %160
%162 = load %struct.addrinfo*, %struct.addrinfo** %13
%163 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %162, i32 0, i32 3
%164 = load i32, i32* %163
%165 = call i32 @socket(i32 %158, i32 %161, i32 %164)
store i32 %165, i32* %16
%166 = load i32, i32* %16
%167 = icmp eq i32 %166, -1
br i1 %167, label %168, label %170
168: ; preds = %155
%169 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i64 0, i64 0))
store i32 7, i32* %3
br label %214
170: ; preds = %155
store i32 1, i32* %17
%171 = load i32, i32* %16
%172 = load i32, i32* @SOL_SOCKET
%173 = load i32, i32* @SO_REUSEADDR
%174 = call i32 @setsockopt(i32 %171, i32 %172, i32 %173, i32* %17, i32 4)
%175 = load i32, i32* %16
%176 = load %struct.addrinfo*, %struct.addrinfo** %13
%177 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %176, i32 0, i32 2
%178 = load i32, i32* %177
%179 = load %struct.addrinfo*, %struct.addrinfo** %13
%180 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %179, i32 0, i32 1
%181 = load i32, i32* %180
%182 = call i64 @bind(i32 %175, i32 %178, i32 %181)
%183 = icmp ne i64 %182, 0
br i1 %183, label %184, label %186
184: ; preds = %170
%185 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0))
store i32 5, i32* %3
br label %214
186: ; preds = %170
%187 = load i8*, i8** %6
%188 = call i32 @strcmp(i8* %187, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%189 = icmp ne i32 %188, 0
br i1 %189, label %195, label %190
190: ; preds = %186
br label %191
191: ; preds = %191, %190
%192 = load i32, i32* %16
%193 = call i32 @serve1(i32 %192)
%194 = call i32 @usleep(i32 250000)
br label %191
195: ; preds = %186
%196 = load i8*, i8** %6
%197 = call i32 @strcmp(i8* %196, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%198 = icmp ne i32 %197, 0
br i1 %198, label %214, label %199
199: ; preds = %195
%200 = load i32, i32* %16
%201 = load %struct.addrinfo*, %struct.addrinfo** %14
%202 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %201, i32 0, i32 2
%203 = load i32, i32* %202
%204 = load %struct.addrinfo*, %struct.addrinfo** %14
%205 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %204, i32 0, i32 1
%206 = load i32, i32* %205
%207 = call i32 @connect(i32 %200, i32 %203, i32 %206)
%208 = icmp eq i32 -1, %207
br i1 %208, label %209, label %211
209: ; preds = %199
%210 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0))
store i32 6, i32* %3
br label %214
211: ; preds = %199
%212 = load i32, i32* %16
%213 = call i32 @probe(i32 %212)
store i32 %213, i32* %3
br label %214
214: ; preds = %23, %63, %73, %97, %105, %135, %143, %168, %184, %209, %211, %195
%215 = load i32, i32* %3
ret i32 %215
}

LLVM IR (-O2):
%struct.sigaction = type { i32, i32, i32, i32, i32, i32, i64, i32 }
%struct.addrinfo = type { i32, i32, i32, i32, i32, i32, i64, i32 }
@stderr = global i32 0
@.str = [8 x i8] c"Usage:\0A\00"
@.str.1 = [54 x i8] c" udptimeoutchecker serve listen_addr listen_port \0A\00"
@.str.2 = [75 x i8] c" udptimeoutchecker probe bind_addr bind_port connect_addr connect_port\0A\00"
@.str.3 = [63 x i8] c"Probes time for which UDP connection though a NAT stays open.\0A\00"
@.str.4 = [10 x i8] c"Example:\0A\00"
@.str.5 = [41 x i8] c" udptimeoutchecker serve 0.0.0.0 909\0A\00"
@.str.6 = [57 x i8] c" udptimeoutchecker probe 0.0.0.0 0 vi-server.org 909\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [6 x i8] c"serve\00"
@.str.9 = [6 x i8] c"probe\00"
@.str.10 = [38 x i8] c"Command should be 'serve' or 'probe'\0A\00"
@.str.11 = [40 x i8] c"Not enough arguments for probe command\0A\00"
@SIG_IGN = global i32 0
@SIGCHLD = global i32 0
@SOCK_DGRAM = global i32 0
@AF_INET = global i32 0
@AI_PASSIVE = global i32 0
@.str.12 = [19 x i8] c"getaddrinfo 1: %s\0A\00"
@.str.13 = [35 x i8] c"getaddrinfo returned no addresses\0A\00"
@.str.14 = [61 x i8] c"Warning: using only one of addresses retuned by getaddrinfo\0A\00"
@.str.15 = [19 x i8] c"getaddrinfo 2: %s\0A\00"
@.str.16 = [37 x i8] c"getaddrinfo 2 returned no addresses\0A\00"
@.str.17 = [63 x i8] c"Warning: using only one of addresses retuned by getaddrinfo 2\0A\00"
@.str.18 = [7 x i8] c"socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.19 = [5 x i8] c"bind\00"
@.str.20 = [8 x i8] c"connect\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sigaction
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = alloca %struct.addrinfo*
%7 = alloca i32
%8 = icmp ne i32 %0, 6
%9 = and i32 %0, -3
%10 = icmp eq i32 %9, 4
br i1 %10, label %28, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.6, i64 0, i64 0))
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %170
28: ; preds = %2
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8*, i8** %1, i64 3
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8*, i8** %1, i64 4
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8*, i8** %1, i64 5
%38 = load i8*, i8** %37
%39 = tail call i32 @strcmp(i8* dereferenceable(1) %30, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%40 = icmp eq i32 %39, 0
br i1 %40, label %47, label %41
41: ; preds = %28
%42 = tail call i32 @strcmp(i8* dereferenceable(1) %30, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%43 = icmp eq i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0))
br label %170
47: ; preds = %41, %28
%48 = tail call i32 @strcmp(i8* dereferenceable(1) %30, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%49 = icmp eq i32 %48, 0
%50 = and i1 %8, %49
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = load i32, i32* @stderr
%53 = tail call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0))
br label %170
54: ; preds = %47
%55 = bitcast %struct.sigaction* %3 to i8*
%56 = call i32 @memset(%struct.sigaction* %3, i32 0, i32 40)
%57 = load i32, i32* @SIG_IGN
%58 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 7
store i32 %57, i32* %58
%59 = load i32, i32* @SIGCHLD
%60 = call i32 @sigaction(i32 %59, %struct.sigaction* %3, i32* null)
%61 = bitcast %struct.addrinfo* %4 to i8*
%62 = bitcast %struct.addrinfo** %5 to i8*
%63 = bitcast %struct.addrinfo** %6 to i8*
%64 = bitcast %struct.addrinfo* %4 to %struct.sigaction*
%65 = call i32 @memset(%struct.sigaction* %64, i32 0, i32 40)
%66 = load i32, i32* @SOCK_DGRAM
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %66, i32* %67
%68 = load i32, i32* @AF_INET
%69 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 5
store i32 %68, i32* %69
%70 = load i32, i32* @AI_PASSIVE
%71 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 0
store i32 %70, i32* %71
%72 = bitcast %struct.addrinfo** %5 to %struct.sigaction**
%73 = call i32 @getaddrinfo(i8* %32, i8* %34, %struct.sigaction* %64, %struct.sigaction** %72)
%74 = icmp eq i32 %73, 0
br i1 %74, label %79, label %75
75: ; preds = %54
%76 = load i32, i32* @stderr
%77 = call i8* @gai_strerror(i32 %73)
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i8* %77)
br label %168
79: ; preds = %54
%80 = load %struct.addrinfo*, %struct.addrinfo** %5
%81 = icmp eq %struct.addrinfo* %80, null
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0))
br label %168
85: ; preds = %79
%86 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %80, i64 0, i32 6
%87 = load i64, i64* %86
%88 = icmp eq i64 %87, 0
br i1 %88, label %92, label %89
89: ; preds = %85
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.14, i64 0, i64 0))
br label %92
92: ; preds = %89, %85
%93 = call i32 @strcmp(i8* dereferenceable(1) %30, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %121
95: ; preds = %92
%96 = load i32, i32* @AI_PASSIVE
%97 = icmp eq i32 %96, 0
%98 = zext i1 %97 to i32
%99 = load i32, i32* %71
%100 = and i32 %99, %98
store i32 %100, i32* %71
%101 = bitcast %struct.addrinfo** %6 to %struct.sigaction**
%102 = call i32 @getaddrinfo(i8* %36, i8* %38, %struct.sigaction* %64, %struct.sigaction** %101)
%103 = icmp eq i32 %102, 0
br i1 %103, label %108, label %104
104: ; preds = %95
%105 = load i32, i32* @stderr
%106 = call i8* @gai_strerror(i32 %102)
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i8* %106)
br label %168
108: ; preds = %95
%109 = load %struct.addrinfo*, %struct.addrinfo** %6
%110 = icmp eq %struct.addrinfo* %109, null
br i1 %110, label %111, label %114
111: ; preds = %108
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.16, i64 0, i64 0))
br label %168
114: ; preds = %108
%115 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %109, i64 0, i32 6
%116 = load i64, i64* %115
%117 = icmp eq i64 %116, 0
br i1 %117, label %121, label %118
118: ; preds = %114
%119 = load i32, i32* @stderr
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.17, i64 0, i64 0))
br label %121
121: ; preds = %114, %118, %92
%122 = load %struct.addrinfo*, %struct.addrinfo** %5
%123 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %122, i64 0, i32 5
%124 = load i32, i32* %123
%125 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %122, i64 0, i32 4
%126 = load i32, i32* %125
%127 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %122, i64 0, i32 3
%128 = load i32, i32* %127
%129 = call i32 @socket(i32 %124, i32 %126, i32 %128)
%130 = icmp eq i32 %129, -1
br i1 %130, label %131, label %133
131: ; preds = %121
%132 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i64 0, i64 0))
br label %168
133: ; preds = %121
%134 = bitcast i32* %7 to i8*
store i32 1, i32* %7
%135 = load i32, i32* @SOL_SOCKET
%136 = load i32, i32* @SO_REUSEADDR
%137 = call i32 @setsockopt(i32 %129, i32 %135, i32 %136, i32* %7, i32 4)
%138 = load %struct.addrinfo*, %struct.addrinfo** %5
%139 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %138, i64 0, i32 2
%140 = load i32, i32* %139
%141 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %138, i64 0, i32 1
%142 = load i32, i32* %141
%143 = call i64 @bind(i32 %129, i32 %140, i32 %142)
%144 = icmp eq i64 %143, 0
br i1 %144, label %147, label %145
145: ; preds = %133
%146 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0))
br label %168
147: ; preds = %133
%148 = call i32 @strcmp(i8* dereferenceable(1) %30, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%149 = icmp eq i32 %148, 0
br i1 %149, label %150, label %153
150: ; preds = %147, %150
%151 = call i32 @serve1(i32 %129)
%152 = call i32 @usleep(i32 250000)
br label %150
153: ; preds = %147
%154 = call i32 @strcmp(i8* dereferenceable(1) %30, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%155 = icmp eq i32 %154, 0
br i1 %155, label %156, label %168
156: ; preds = %153
%157 = load %struct.addrinfo*, %struct.addrinfo** %6
%158 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %157, i64 0, i32 2
%159 = load i32, i32* %158
%160 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %157, i64 0, i32 1
%161 = load i32, i32* %160
%162 = call i32 @connect(i32 %129, i32 %159, i32 %161)
%163 = icmp eq i32 %162, -1
br i1 %163, label %164, label %166
164: ; preds = %156
%165 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0))
br label %168
166: ; preds = %156
%167 = call i32 @probe(i32 %129)
br label %168
168: ; preds = %131, %145, %164, %166, %153, %111, %104, %82, %75
%169 = phi i32 [ 4, %75 ], [ 13, %104 ], [ 15, %111 ], [ 6, %82 ], [ 7, %131 ], [ 5, %145 ], [ 6, %164 ], [ %167, %166 ], [ 0, %153 ]
br label %170
170: ; preds = %44, %51, %168, %11
%171 = phi i32 [ 1, %11 ], [ 1, %44 ], [ 1, %51 ], [ %169, %168 ]
ret i32 %171
}