#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 uint32_t;
struct sockaddr_storage {
  int /*<<< orphan*/ member_0;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s6_addr;
};
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_scope_id;
  TYPE_1__ sin6_addr;
  void *sin6_port;
  void *sin6_family;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
struct option {
  char *member_0;
  int member_1;
  char member_3;
  char *name;
  int /*<<< orphan*/ *member_2;
};
typedef int socklen_t;
typedef int in_port_t;

/* Variables and functions */
void *AF_INET;
void *AF_INET6;
int EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ IN6_IS_ADDR_MULTICAST(int /*<<< orphan*/ *);
int /*<<< orphan*/ discover(int, char const *, struct sockaddr_storage *,
                            int *);
scalar_t__ errno;
int getopt_long(int, char **, char *, struct option const *, int *);
int getpid();
int /*<<< orphan*/ help();
void *htons(int);
int /*<<< orphan*/ if_nametoindex(char const *);
scalar_t__ inet_pton(void *, char *, char **);
int /*<<< orphan*/ memcpy(TYPE_1__ *, char *, int);
char *optarg;
scalar_t__ opterr;
int optind;
int optopt;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ session(struct sockaddr const *, int, int);
int /*<<< orphan*/ srand(int);
void *strtoul(char *, int /*<<< orphan*/ *, int);
int time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  const struct option options[] = {{"heartbeat", 1, NULL, 'H'},
                                   {"interface", 1, NULL, 'I'},
                                   {"help", 0, NULL, 'h'},
                                   {"ipv6", 0, NULL, '6'},
                                   {0}};
  int c;
  int longindex = -1;
  int use_ipv6 = 0;
  struct sockaddr_storage address = {0};
  socklen_t address_length = 0;
  uint32_t router_heartbeat_interval = 30;
  const char *iface = NULL;
  opterr = 0;
  while ((c = getopt_long(argc, argv, ":h6H:I:", options, &longindex)) != -1) {
    switch (c) {
    case 'I':
      iface = optarg;
      break;
    case '6':
      use_ipv6 = 1;
      break;
    case 'H':
      router_heartbeat_interval = strtoul(optarg, NULL, 10);
      router_heartbeat_interval *= 1000;
      break;
    case 'h':
      help();
      return EXIT_SUCCESS;
    case ':':
      if (longindex >= 0 && options[longindex].name)
        printf("Missing argument to %s\n", options[longindex].name);
      else
        printf("Missing argument to -%c\n", optopt);
      help();
      return EXIT_FAILURE;
    case '?':
    default:
      printf("Unknown option '-%c'\n", optopt);
      help();
      return EXIT_FAILURE;
    }
  }
  if (argc > optind + 2) {
    printf("Too many arguments\n");
    help();
    return EXIT_FAILURE;
  }
  if (optind < argc) {
    char address_buffer[16] = {0};
    in_port_t port = 854;
    if (optind + 1 < argc) {
      port = strtoul(argv[optind + 1], NULL, 10);
      if (errno) {
        printf("Failed to parse modem port number %s\n", argv[optind + 1]);
        return EXIT_FAILURE;
      }
    }
    if (use_ipv6 || inet_pton(AF_INET6, argv[optind], &address_buffer)) {
      ((struct sockaddr_in6 *)&address)->sin6_family = AF_INET6;
      ((struct sockaddr_in6 *)&address)->sin6_port = htons(port);
      address_length = sizeof(struct sockaddr_in6);
      memcpy(&((struct sockaddr_in6 *)&address)->sin6_addr, address_buffer, 16);
      if (IN6_IS_ADDR_MULTICAST(
              &((struct sockaddr_in6 *)&address)->sin6_addr.s6_addr)) {
        if (!iface) {
          printf("Interface name required with IPv6 link-local modem address, "
                 "use -I\n");
          return EXIT_FAILURE;
        }
        ((struct sockaddr_in6 *)&address)->sin6_scope_id =
            if_nametoindex(iface);
      }
      use_ipv6 = 1;
    }
    if (!use_ipv6 || inet_pton(AF_INET, argv[optind], &address_buffer)) {
      ((struct sockaddr_in *)&address)->sin_family = AF_INET;
      ((struct sockaddr_in *)&address)->sin_port = htons(port);
      address_length = sizeof(struct sockaddr_in);
      memcpy(&((struct sockaddr_in *)&address)->sin_addr, address_buffer, 4);
      use_ipv6 = 0;
    } else {
      printf("Modem address %s not recognised\n", argv[optind]);
      return EXIT_FAILURE;
    }
  }
  srand(time(NULL) ^ getpid());
  printf("dlep_router - A logging DLEP router\n"
         "  Version 0.1.2\n"
         "  Copyright (c) 2017 Airbus DS Limited\n\n");
  for (;;) {
    if (optind == argc) {
      if (!discover(use_ipv6, iface, &address, &address_length))
        return EXIT_FAILURE;
    }
    if (session((const struct sockaddr *)&address, address_length,
                router_heartbeat_interval) != 0)
      return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0x2b19(%rip),%rsi
mov    $0xa0,%edx
call   10a0 <memcpy@plt>
movl   $0xffffffff,-0xb8(%rbp)
ff ff ff
movl   $0x0,-0xbc(%rbp)
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1070 <memset@plt>
movl   $0x0,-0xc4(%rbp)
movl   $0x1e,-0xc8(%rbp)
movq   $0x0,-0xd0(%rbp)
mov    0x2d32(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0xb0(%rbp),%rcx
lea    0xe60(%rip),%rdx
lea    -0xb8(%rbp),%r8
call   1040 <getopt_long@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0xffffffff,%eax
je     1408 <main+0x218>
mov    -0xb4(%rbp),%eax
add    $0xffffffca,%eax
mov    %eax,%ecx
mov    %rcx,-0xf0(%rbp)
sub    $0x32,%eax
ja     13d4 <main+0x1e4>
mov    -0xf0(%rbp),%rax
lea    0xd32(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d12(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xd0(%rbp)
jmp    1403 <main+0x213>
movl   $0x1,-0xbc(%rbp)
jmp    1403 <main+0x213>
mov    0x2ced(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
mov    %eax,-0xc8(%rbp)
imul   $0x3e8,-0xc8(%rbp),%eax
mov    %eax,-0xc8(%rbp)
jmp    1403 <main+0x213>
mov    $0x0,%al
call   1100 <help@plt>
mov    0x2c5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    176e <main+0x57e>
cmpl   $0x0,-0xb8(%rbp)
jl     13a0 <main+0x1b0>
movslq -0xb8(%rbp),%rcx
lea    -0xb0(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
cmpq   $0x0,0x10(%rax)
je     13a0 <main+0x1b0>
movslq -0xb8(%rbp),%rcx
lea    -0xb0(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
mov    0x10(%rax),%rsi
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13b7 <main+0x1c7>
mov    0x2c29(%rip),%rax
mov    (%rax),%esi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1100 <help@plt>
mov    0x2be3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    176e <main+0x57e>
jmp    13d4 <main+0x1e4>
mov    0x2bf5(%rip),%rax
mov    (%rax),%esi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1100 <help@plt>
mov    0x2baf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    176e <main+0x57e>
jmp    1275 <main+0x85>
mov    -0x8(%rbp),%eax
mov    0x2bb6(%rip),%rcx
mov    (%rcx),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jle    1445 <main+0x255>
lea    0xd13(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1100 <help@plt>
mov    0x2b6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    176e <main+0x57e>
mov    0x2b7c(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    16b4 <main+0x4c4>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1070 <memset@plt>
movl   $0x356,-0xe4(%rbp)
mov    0x2b4d(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    1500 <main+0x310>
mov    -0x10(%rbp),%rax
mov    0x2b34(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
mov    %eax,-0xe4(%rbp)
mov    0x2af5(%rip),%rax
cmpq   $0x0,(%rax)
je     14fb <main+0x30b>
mov    -0x10(%rbp),%rax
mov    0x2af8(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xc6a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2ab7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    176e <main+0x57e>
jmp    1500 <main+0x310>
cmpl   $0x0,-0xbc(%rbp)
jne    153f <main+0x34f>
mov    0x2aac(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x2aa6(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    -0xe0(%rbp),%rdx
call   10b0 <inet_pton@plt>
cmp    $0x0,%rax
je     15eb <main+0x3fb>
mov    0x2a7a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xb0(%rbp)
mov    -0xe4(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,-0xb8(%rbp)
movl   $0x18,-0xc4(%rbp)
lea    -0xc0(%rbp),%rdi
add    $0x4,%rdi
lea    -0xe0(%rbp),%rsi
mov    $0x10,%edx
call   10a0 <memcpy@plt>
lea    -0xc0(%rbp),%rdi
add    $0x4,%rdi
call   10d0 <IN6_IS_ADDR_MULTICAST@plt>
cmp    $0x0,%rax
je     15e1 <main+0x3f1>
cmpq   $0x0,-0xd0(%rbp)
jne    15cf <main+0x3df>
lea    0xbbc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x29e3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    176e <main+0x57e>
mov    -0xd0(%rbp),%rdi
call   1090 <if_nametoindex@plt>
mov    %eax,-0xc0(%rbp)
movl   $0x1,-0xbc(%rbp)
cmpl   $0x0,-0xbc(%rbp)
je     162a <main+0x43a>
mov    0x29d9(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x29bb(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    -0xe0(%rbp),%rdx
call   10b0 <inet_pton@plt>
cmp    $0x0,%rax
je     167e <main+0x48e>
mov    0x29a7(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xb0(%rbp)
mov    -0xe4(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,-0xb8(%rbp)
movl   $0x18,-0xc4(%rbp)
lea    -0xc0(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
movl   $0x0,-0xbc(%rbp)
jmp    16af <main+0x4bf>
mov    -0x10(%rbp),%rax
mov    0x293f(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xb20(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2903(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    176e <main+0x57e>
jmp    16b4 <main+0x4c4>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0xf4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xf4(%rbp),%edi
xor    %eax,%edi
call   1080 <srand@plt>
lea    0xafa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x28dc(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    1736 <main+0x546>
mov    -0xbc(%rbp),%edi
mov    -0xd0(%rbp),%rsi
lea    -0xc0(%rbp),%rdx
lea    -0xc4(%rbp),%rcx
call   1110 <discover@plt>
cmp    $0x0,%eax
jne    1731 <main+0x541>
mov    0x2881(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    176e <main+0x57e>
jmp    1736 <main+0x546>
lea    -0xc0(%rbp),%rdi
mov    -0xc4(%rbp),%esi
mov    -0xc8(%rbp),%edx
call   10e0 <session@plt>
cmp    $0x0,%rax
je     1769 <main+0x579>
mov    0x2849(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    176e <main+0x57e>
jmp    16e5 <main+0x4f5>
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rsi,%r13
mov    %edi,%ebp
lea    0x2b23(%rip),%rsi
lea    0x40(%rsp),%rbx
mov    $0xa0,%edx
mov    %rbx,%rdi
call   10a0 <memcpy@plt>
movl   $0xffffffff,0x1c(%rsp)
ff
movl   $0x0,0x8(%rsp)
movl   $0x0,0x10(%rsp)
mov    0x2d62(%rip),%rax
movq   $0x0,(%rax)
movl   $0x1e,0x18(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
mov    $0x1,%al
mov    %eax,0x14(%rsp)
lea    0xdbd(%rip),%r15
lea    0x1c(%rsp),%r12
xor    %r14d,%r14d
jmp    127a <main+0x8a>
nopl   0x0(%rax,%rax,1)
mov    0x2d79(%rip),%rax
mov    (%rax),%r14
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r12,%r8
call   1050 <getopt_long@plt>
cmp    $0x49,%eax
je     1270 <main+0x80>
cmp    $0x39,%eax
jle    12c3 <main+0xd3>
cmp    $0x3a,%eax
je     12f6 <main+0x106>
cmp    $0x48,%eax
jne    12e1 <main+0xf1>
mov    0x2d48(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
imul   $0x3e8,%eax,%eax
mov    %eax,0x18(%rsp)
jmp    127a <main+0x8a>
cmp    $0xffffffff,%eax
je     131c <main+0x12c>
cmp    $0x36,%eax
jne    133c <main+0x14c>
mov    $0x1,%eax
mov    %rax,0x20(%rsp)
movl   $0x0,0x14(%rsp)
jmp    127a <main+0x8a>
cmp    $0x68,%eax
jne    133c <main+0x14c>
xor    %eax,%eax
call   1100 <help@plt>
mov    0x2ca4(%rip),%rax
jmp    1373 <main+0x183>
mov    0x1c(%rsp),%eax
test   %eax,%eax
js     134e <main+0x15e>
shl    $0x5,%rax
mov    0x50(%rsp,%rax,1),%rsi
test   %rsi,%rsi
je     134e <main+0x15e>
lea    0xd13(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1365 <main+0x175>
mov    0x2ca5(%rip),%r12
movslq (%r12),%rax
lea    0x2(%rax),%ecx
cmp    %ebp,%ecx
jge    1387 <main+0x197>
lea    0xe1e(%rip),%rdi
call   1030 <puts@plt>
jmp    1365 <main+0x175>
mov    0x2c8d(%rip),%rax
mov    (%rax),%esi
lea    0xd0b(%rip),%rdi
jmp    135e <main+0x16e>
mov    0x2c7b(%rip),%rax
mov    (%rax),%esi
lea    0xce0(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1100 <help@plt>
mov    0x2c35(%rip),%rax
mov    (%rax),%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    %ebp,%eax
mov    %r14,0x28(%rsp)
mov    0x18(%rsp),%r14d
jge    14cb <main+0x2db>
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x1(%rax),%ecx
mov    $0x356,%r15d
cmp    %ebp,%ecx
mov    %r13,%rbx
jge    13e7 <main+0x1f7>
mov    0x8(%rbx,%rax,8),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
mov    %rax,%r15
mov    0x2be4(%rip),%rax
cmpq   $0x0,(%rax)
je     13e7 <main+0x1f7>
movslq (%r12),%rax
mov    0x8(%rbx,%rax,8),%rsi
lea    0xc8b(%rip),%rdi
jmp    155a <main+0x36a>
testb  $0x1,0x14(%rsp)
je     140f <main+0x21f>
mov    0x2bcb(%rip),%rax
mov    (%rax),%rdi
movslq (%r12),%rax
mov    (%rbx,%rax,8),%rsi
lea    0x30(%rsp),%rdx
call   10b0 <inet_pton@plt>
test   %rax,%rax
je     148c <main+0x29c>
mov    0x2baa(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x18(%rsp)
mov    %r15d,%edi
call   1060 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0xc(%rsp),%rbx
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   10a0 <memcpy@plt>
mov    %rbx,%rdi
call   10d0 <IN6_IS_ADDR_MULTICAST@plt>
test   %rax,%rax
je     1466 <main+0x276>
mov    0x28(%rsp),%rdi
test   %rdi,%rdi
je     1566 <main+0x376>
call   1090 <if_nametoindex@plt>
mov    %eax,0x8(%rsp)
mov    0x2b6b(%rip),%rax
mov    (%rax),%rdi
movslq (%r12),%rax
mov    0x0(%r13,%rax,8),%rsi
lea    0x30(%rsp),%rdx
call   10b0 <inet_pton@plt>
test   %rax,%rax
je     154a <main+0x35a>
mov    0x2b45(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x18(%rsp)
mov    %r15d,%edi
call   1060 <htons@plt>
mov    %rax,0x10(%rsp)
movl   $0x18,0x10(%rsp)
lea    0x8(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
xor    %eax,%eax
mov    %rax,0x20(%rsp)
xor    %edi,%edi
call   10c0 <time@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
xor    %eax,%ebx
mov    %ebx,%edi
call   1080 <srand@plt>
lea    0xbc9(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rbx
lea    0x10(%rsp),%r15
mov    0x28(%rsp),%r13
jmp    1528 <main+0x338>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
mov    %r14d,%edx
call   10e0 <session@plt>
test   %rax,%rax
jne    136c <main+0x17c>
cmp    %ebp,(%r12)
jne    1510 <main+0x320>
mov    0x20(%rsp),%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1110 <discover@plt>
test   %eax,%eax
jne    1510 <main+0x320>
jmp    136c <main+0x17c>
movslq (%r12),%rax
mov    0x0(%r13,%rax,8),%rsi
lea    0xb39(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    136c <main+0x17c>
lea    0xba3(%rip),%rdi
call   1030 <puts@plt>
jmp    136c <main+0x17c>

LLVM IR (-O0):
%struct.option = type { i8*, i32, i8, i8*, i32* }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr_in6 = type { i32, %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.sockaddr = type { i32 }
@.str = [10 x i8] c"heartbeat\00"
@.str.1 = [10 x i8] c"interface\00"
@.str.2 = [5 x i8] c"help\00"
@.str.3 = [5 x i8] c"ipv6\00"
@__const.main.options = [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i32 1, i8 0, i8* inttoptr (i64 72 to i8*), i32* null }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i32 1, i8 0, i8* inttoptr (i64 73 to i8*), i32* null }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i32 0, i8 0, i8* inttoptr (i64 104 to i8*), i32* null }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i32 0, i8 0, i8* inttoptr (i64 54 to i8*), i32* null }, %struct.option zeroinitializer]
@opterr = global i64 0
@.str.4 = [8 x i8] c":h6H:I:\00"
@optarg = global i8* null
@EXIT_SUCCESS = global i32 0
@.str.5 = [24 x i8] c"Missing argument to %s\0A\00"
@.str.6 = [25 x i8] c"Missing argument to -%c\0A\00"
@optopt = global i32 0
@EXIT_FAILURE = global i32 0
@.str.7 = [22 x i8] c"Unknown option '-%c'\0A\00"
@optind = global i32 0
@.str.8 = [20 x i8] c"Too many arguments\0A\00"
@errno = global i64 0
@.str.9 = [38 x i8] c"Failed to parse modem port number %s\0A\00"
@AF_INET6 = global i8* null
@.str.10 = [68 x i8] c"Interface name required with IPv6 link-local modem address, use -I\0A\00"
@AF_INET = global i8* null
@.str.11 = [33 x i8] c"Modem address %s not recognised\0A\00"
@.str.12 = [93 x i8] c"dlep_router - A logging DLEP router\0A Version 0.1.2\0A Copyright (c) 2017 Airbus DS Limited\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x %struct.option]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_storage
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca [16 x i8]
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = bitcast [5 x %struct.option]* %6 to i8*
store i32 -1, i32* %8
store i32 0, i32* %9
%17 = bitcast %struct.sockaddr_storage* %10 to i8*
store i32 0, i32* %11
store i32 30, i32* %12
store i8* null, i8** %13
store i64 0, i64* @opterr
br label %18
18: ; preds = %67, %2
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 0
%22 = call i32 @getopt_long(i32 %19, i8** %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %struct.option* %21, i32* %8)
store i32 %22, i32* %7
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %68
24: ; preds = %18
%25 = load i32, i32* %7
switch i32 %25, label %62 [
i32 73, label %26
i32 54, label %28
i32 72, label %29
i32 104, label %35
i32 58, label %38
i32 63, label %61
]
26: ; preds = %24
%27 = load i8*, i8** @optarg
store i8* %27, i8** %13
br label %67
28: ; preds = %24
store i32 1, i32* %9
br label %67
29: ; preds = %24
%30 = load i8*, i8** @optarg
%31 = call i8* @strtoul(i8* %30, i32* null, i32 10)
%32 = ptrtoint i8* %31 to i32
store i32 %32, i32* %12
%33 = load i32, i32* %12
%34 = mul nsw i32 %33, 1000
store i32 %34, i32* %12
br label %67
35: ; preds = %24
%36 = call i32 (...) @help()
%37 = load i32, i32* @EXIT_SUCCESS
store i32 %37, i32* %3
br label %211
38: ; preds = %24
%39 = load i32, i32* %8
%40 = icmp sge i32 %39, 0
br i1 %40, label %41, label %55
41: ; preds = %38
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 %43
%45 = getelementptr inbounds %struct.option, %struct.option* %44, i32 0, i32 3
%46 = load i8*, i8** %45
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %55
48: ; preds = %41
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 %50
%52 = getelementptr inbounds %struct.option, %struct.option* %51, i32 0, i32 3
%53 = load i8*, i8** %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %53)
br label %58
55: ; preds = %41, %38
%56 = load i32, i32* @optopt
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %55, %48
%59 = call i32 (...) @help()
%60 = load i32, i32* @EXIT_FAILURE
store i32 %60, i32* %3
br label %211
61: ; preds = %24
br label %62
62: ; preds = %24, %61
%63 = load i32, i32* @optopt
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %63)
%65 = call i32 (...) @help()
%66 = load i32, i32* @EXIT_FAILURE
store i32 %66, i32* %3
br label %211
67: ; preds = %29, %28, %26
br label %18
68: ; preds = %18
%69 = load i32, i32* %4
%70 = load i32, i32* @optind
%71 = add nsw i32 %70, 2
%72 = icmp sgt i32 %69, %71
br i1 %72, label %73, label %77
73: ; preds = %68
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%75 = call i32 (...) @help()
%76 = load i32, i32* @EXIT_FAILURE
store i32 %76, i32* %3
br label %211
77: ; preds = %68
%78 = load i32, i32* @optind
%79 = load i32, i32* %4
%80 = icmp slt i32 %78, %79
br i1 %80, label %81, label %184
81: ; preds = %77
%82 = bitcast [16 x i8]* %14 to i8*
store i32 854, i32* %15
%83 = load i32, i32* @optind
%84 = add nsw i32 %83, 1
%85 = load i32, i32* %4
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %108
87: ; preds = %81
%88 = load i8**, i8*** %5
%89 = load i32, i32* @optind
%90 = add nsw i32 %89, 1
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8*, i8** %88, i64 %91
%93 = load i8*, i8** %92
%94 = call i8* @strtoul(i8* %93, i32* null, i32 10)
%95 = ptrtoint i8* %94 to i32
store i32 %95, i32* %15
%96 = load i64, i64* @errno
%97 = icmp ne i64 %96, 0
br i1 %97, label %98, label %107
98: ; preds = %87
%99 = load i8**, i8*** %5
%100 = load i32, i32* @optind
%101 = add nsw i32 %100, 1
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8*, i8** %99, i64 %102
%104 = load i8*, i8** %103
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i8* %104)
%106 = load i32, i32* @EXIT_FAILURE
store i32 %106, i32* %3
br label %211
107: ; preds = %87
br label %108
108: ; preds = %107, %81
%109 = load i32, i32* %9
%110 = icmp ne i32 %109, 0
br i1 %110, label %121, label %111
111: ; preds = %108
%112 = load i8*, i8** @AF_INET6
%113 = load i8**, i8*** %5
%114 = load i32, i32* @optind
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8*, i8** %113, i64 %115
%117 = load i8*, i8** %116
%118 = bitcast [16 x i8]* %14 to i8**
%119 = call i64 @inet_pton(i8* %112, i8* %117, i8** %118)
%120 = icmp ne i64 %119, 0
br i1 %120, label %121, label %150
121: ; preds = %111, %108
%122 = load i8*, i8** @AF_INET6
%123 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr_in6*
%124 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %123, i32 0, i32 3
store i8* %122, i8** %124
%125 = load i32, i32* %15
%126 = call i8* @htons(i32 %125)
%127 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr_in6*
%128 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %127, i32 0, i32 2
store i8* %126, i8** %128
store i32 24, i32* %11
%129 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr_in6*
%130 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %129, i32 0, i32 1
%131 = getelementptr inbounds [16 x i8], [16 x i8]* %14, i64 0, i64 0
%132 = call i32 @memcpy(%struct.TYPE_2__* %130, i8* %131, i32 16)
%133 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr_in6*
%134 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %133, i32 0, i32 1
%135 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %134, i32 0, i32 0
%136 = call i64 @IN6_IS_ADDR_MULTICAST(i32* %135)
%137 = icmp ne i64 %136, 0
br i1 %137, label %138, label %149
138: ; preds = %121
%139 = load i8*, i8** %13
%140 = icmp ne i8* %139, null
br i1 %140, label %144, label %141
141: ; preds = %138
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.10, i64 0, i64 0))
%143 = load i32, i32* @EXIT_FAILURE
store i32 %143, i32* %3
br label %211
144: ; preds = %138
%145 = load i8*, i8** %13
%146 = call i32 @if_nametoindex(i8* %145)
%147 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr_in6*
%148 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %147, i32 0, i32 0
store i32 %146, i32* %148
br label %149
149: ; preds = %144, %121
store i32 1, i32* %9
br label %150
150: ; preds = %149, %111
%151 = load i32, i32* %9
%152 = icmp ne i32 %151, 0
br i1 %152, label %153, label %163
153: ; preds = %150
%154 = load i8*, i8** @AF_INET
%155 = load i8**, i8*** %5
%156 = load i32, i32* @optind
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds i8*, i8** %155, i64 %157
%159 = load i8*, i8** %158
%160 = bitcast [16 x i8]* %14 to i8**
%161 = call i64 @inet_pton(i8* %154, i8* %159, i8** %160)
%162 = icmp ne i64 %161, 0
br i1 %162, label %163, label %175
163: ; preds = %153, %150
%164 = load i8*, i8** @AF_INET
%165 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr_in*
%166 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %165, i32 0, i32 2
store i8* %164, i8** %166
%167 = load i32, i32* %15
%168 = call i8* @htons(i32 %167)
%169 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr_in*
%170 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %169, i32 0, i32 1
store i8* %168, i8** %170
store i32 24, i32* %11
%171 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr_in*
%172 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %171, i32 0, i32 0
%173 = getelementptr inbounds [16 x i8], [16 x i8]* %14, i64 0, i64 0
%174 = call i32 @memcpy(%struct.TYPE_2__* %172, i8* %173, i32 4)
store i32 0, i32* %9
br label %183
175: ; preds = %153
%176 = load i8**, i8*** %5
%177 = load i32, i32* @optind
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds i8*, i8** %176, i64 %178
%180 = load i8*, i8** %179
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i8* %180)
%182 = load i32, i32* @EXIT_FAILURE
store i32 %182, i32* %3
br label %211
183: ; preds = %163
br label %184
184: ; preds = %183, %77
%185 = call i32 @time(i32* null)
%186 = call i32 (...) @getpid()
%187 = xor i32 %185, %186
%188 = call i32 @srand(i32 %187)
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.12, i64 0, i64 0))
br label %190
190: ; preds = %210, %184
%191 = load i32, i32* @optind
%192 = load i32, i32* %4
%193 = icmp eq i32 %191, %192
br i1 %193, label %194, label %202
194: ; preds = %190
%195 = load i32, i32* %9
%196 = load i8*, i8** %13
%197 = call i32 @discover(i32 %195, i8* %196, %struct.sockaddr_storage* %10, i32* %11)
%198 = icmp ne i32 %197, 0
br i1 %198, label %201, label %199
199: ; preds = %194
%200 = load i32, i32* @EXIT_FAILURE
store i32 %200, i32* %3
br label %211
201: ; preds = %194
br label %202
202: ; preds = %201, %190
%203 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr*
%204 = load i32, i32* %11
%205 = load i32, i32* %12
%206 = call i64 @session(%struct.sockaddr* %203, i32 %204, i32 %205)
%207 = icmp ne i64 %206, 0
br i1 %207, label %208, label %210
208: ; preds = %202
%209 = load i32, i32* @EXIT_FAILURE
store i32 %209, i32* %3
br label %211
210: ; preds = %202
br label %190
211: ; preds = %208, %199, %175, %141, %98, %73, %62, %58, %35
%212 = load i32, i32* %3
ret i32 %212
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i8, i8*, i32* }
%struct.sockaddr_storage = type { i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [10 x i8] c"heartbeat\00"
@.str.1 = [10 x i8] c"interface\00"
@.str.2 = [5 x i8] c"help\00"
@.str.3 = [5 x i8] c"ipv6\00"
@__const.main.options = [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i32 1, i8 0, i8* inttoptr (i64 72 to i8*), i32* null }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i32 1, i8 0, i8* inttoptr (i64 73 to i8*), i32* null }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i32 0, i8 0, i8* inttoptr (i64 104 to i8*), i32* null }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i32 0, i8 0, i8* inttoptr (i64 54 to i8*), i32* null }, %struct.option zeroinitializer]
@opterr = global i64 0
@.str.4 = [8 x i8] c":h6H:I:\00"
@optarg = global i8* null
@EXIT_SUCCESS = global i32 0
@.str.5 = [24 x i8] c"Missing argument to %s\0A\00"
@.str.6 = [25 x i8] c"Missing argument to -%c\0A\00"
@optopt = global i32 0
@EXIT_FAILURE = global i32 0
@.str.7 = [22 x i8] c"Unknown option '-%c'\0A\00"
@optind = global i32 0
@errno = global i64 0
@.str.9 = [38 x i8] c"Failed to parse modem port number %s\0A\00"
@AF_INET6 = global i8* null
@AF_INET = global i8* null
@.str.11 = [33 x i8] c"Modem address %s not recognised\0A\00"
@str = [92 x i8] c"dlep_router - A logging DLEP router\0A Version 0.1.2\0A Copyright (c) 2017 Airbus DS Limited\0A\00"
@str.13 = [67 x i8] c"Interface name required with IPv6 link-local modem address, use -I\00"
@str.14 = [19 x i8] c"Too many arguments\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [5 x %struct.option]
%4 = alloca i32
%5 = alloca %struct.sockaddr_storage
%6 = alloca i32
%7 = alloca [16 x i8]
%8 = bitcast [5 x %struct.option]* %3 to i8*
%9 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
%10 = bitcast %struct.sockaddr_storage* %5 to i8*
%11 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 0, i32 0
store i32 0, i32* %11
%12 = bitcast i32* %6 to i8*
store i32 0, i32* %6
store i64 0, i64* @opterr
%13 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 0
br label %14
14: ; preds = %22, %2
%15 = phi i1 [ true, %2 ], [ false, %22 ]
%16 = phi i32 [ 0, %2 ], [ 1, %22 ]
%17 = phi i32 [ 30, %2 ], [ %20, %22 ]
%18 = phi i8* [ null, %2 ], [ %23, %22 ]
br label %19
19: ; preds = %14, %27
%20 = phi i32 [ %17, %14 ], [ %32, %27 ]
%21 = phi i8* [ %18, %14 ], [ %23, %27 ]
br label %22
22: ; preds = %19, %25
%23 = phi i8* [ %26, %25 ], [ %21, %19 ]
%24 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %struct.option* %13, i32* %4)
switch i32 %24, label %52 [
i32 -1, label %57
i32 73, label %25
i32 54, label %14
i32 72, label %27
i32 104, label %33
i32 58, label %36
]
25: ; preds = %22
%26 = load i8*, i8** @optarg
br label %22
27: ; preds = %22
%28 = load i8*, i8** @optarg
%29 = call i8* @strtoul(i8* nocapture %28, i32* null, i32 10)
%30 = ptrtoint i8* %29 to i64
%31 = trunc i64 %30 to i32
%32 = mul nsw i32 %31, 1000
br label %19
33: ; preds = %22
%34 = call i32 (...) @help()
%35 = load i32, i32* @EXIT_SUCCESS
br label %165
36: ; preds = %22
%37 = load i32, i32* %4
%38 = icmp sgt i32 %37, -1
br i1 %38, label %39, label %46
39: ; preds = %36
%40 = zext i32 %37 to i64
%41 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 %40, i32 3
%42 = load i8*, i8** %41
%43 = icmp eq i8* %42, null
br i1 %43, label %46, label %44
44: ; preds = %39
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %42)
br label %49
46: ; preds = %39, %36
%47 = load i32, i32* @optopt
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %46, %44
%50 = call i32 (...) @help()
%51 = load i32, i32* @EXIT_FAILURE
br label %165
52: ; preds = %22
%53 = load i32, i32* @optopt
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %53)
%55 = call i32 (...) @help()
%56 = load i32, i32* @EXIT_FAILURE
br label %165
57: ; preds = %22
%58 = load i32, i32* @optind
%59 = add nsw i32 %58, 2
%60 = icmp slt i32 %59, %0
br i1 %60, label %61, label %65
61: ; preds = %57
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.14, i64 0, i64 0))
%63 = call i32 (...) @help()
%64 = load i32, i32* @EXIT_FAILURE
br label %165
65: ; preds = %57
%66 = icmp slt i32 %58, %0
br i1 %66, label %67, label %143
67: ; preds = %65
%68 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%69 = add nsw i32 %58, 1
%70 = icmp slt i32 %69, %0
br i1 %70, label %71, label %87
71: ; preds = %67
%72 = sext i32 %69 to i64
%73 = getelementptr inbounds i8*, i8** %1, i64 %72
%74 = load i8*, i8** %73
%75 = call i8* @strtoul(i8* nocapture %74, i32* null, i32 10)
%76 = ptrtoint i8* %75 to i64
%77 = trunc i64 %76 to i32
%78 = load i64, i64* @errno
%79 = icmp eq i64 %78, 0
br i1 %79, label %87, label %80
80: ; preds = %71
%81 = load i32, i32* @optind
%82 = add nsw i32 %81, 1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %1, i64 %83
%85 = load i8*, i8** %84
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i8* %85)
br label %132
87: ; preds = %71, %67
%88 = phi i32 [ %77, %71 ], [ 854, %67 ]
br i1 %15, label %89, label %98
89: ; preds = %87
%90 = load i8*, i8** @AF_INET6
%91 = load i32, i32* @optind
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8*, i8** %1, i64 %92
%94 = load i8*, i8** %93
%95 = bitcast [16 x i8]* %7 to i8**
%96 = call i64 @inet_pton(i8* %90, i8* %94, i8** %95)
%97 = icmp eq i64 %96, 0
br i1 %97, label %134, label %98
98: ; preds = %89, %87
%99 = load i8*, i8** @AF_INET6
%100 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 4
%101 = bitcast %struct.sockaddr_storage* %100 to i8**
store i8* %99, i8** %101
%102 = call i8* @htons(i32 %88)
%103 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 2
%104 = bitcast %struct.sockaddr_storage* %103 to i8**
store i8* %102, i8** %104
%105 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 1
%106 = bitcast %struct.sockaddr_storage* %105 to %struct.TYPE_2__*
%107 = call i32 @memcpy(%struct.TYPE_2__* %106, i8* %68, i32 16)
%108 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %105, i64 0, i32 0
%109 = call i64 @IN6_IS_ADDR_MULTICAST(i32* %108)
%110 = icmp eq i64 %109, 0
br i1 %110, label %117, label %111
111: ; preds = %98
%112 = icmp eq i8* %23, null
br i1 %112, label %113, label %115
113: ; preds = %111
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.13, i64 0, i64 0))
br label %132
115: ; preds = %111
%116 = call i32 @if_nametoindex(i8* %23)
store i32 %116, i32* %11
br label %117
117: ; preds = %115, %98
%118 = load i8*, i8** @AF_INET
%119 = load i32, i32* @optind
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8*, i8** %1, i64 %120
%122 = load i8*, i8** %121
%123 = bitcast [16 x i8]* %7 to i8**
%124 = call i64 @inet_pton(i8* %118, i8* %122, i8** %123)
%125 = icmp eq i64 %124, 0
br i1 %125, label %126, label %134
126: ; preds = %117
%127 = load i32, i32* @optind
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i8*, i8** %1, i64 %128
%130 = load i8*, i8** %129
%131 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i8* %130)
br label %132
132: ; preds = %80, %126, %113
%133 = load i32, i32* @EXIT_FAILURE
br label %165
134: ; preds = %89, %117
%135 = load i8*, i8** @AF_INET
%136 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 4
%137 = bitcast %struct.sockaddr_storage* %136 to i8**
store i8* %135, i8** %137
%138 = call i8* @htons(i32 %88)
%139 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 2
%140 = bitcast %struct.sockaddr_storage* %139 to i8**
store i8* %138, i8** %140
store i32 24, i32* %6
%141 = bitcast %struct.sockaddr_storage* %5 to %struct.TYPE_2__*
%142 = call i32 @memcpy(%struct.TYPE_2__* %141, i8* %68, i32 4)
br label %143
143: ; preds = %134, %65
%144 = phi i32 [ 0, %134 ], [ %16, %65 ]
%145 = call i32 @time(i32* null)
%146 = call i32 (...) @getpid()
%147 = xor i32 %146, %145
%148 = call i32 @srand(i32 %147)
%149 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([92 x i8], [92 x i8]* @str, i64 0, i64 0))
%150 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
br label %151
151: ; preds = %159, %143
%152 = load i32, i32* @optind
%153 = icmp eq i32 %152, %0
br i1 %153, label %154, label %159
154: ; preds = %151
%155 = call i32 @discover(i32 %144, i8* %23, %struct.sockaddr_storage* %5, i32* %6)
%156 = icmp eq i32 %155, 0
br i1 %156, label %157, label %159
157: ; preds = %154
%158 = load i32, i32* @EXIT_FAILURE
br label %165
159: ; preds = %154, %151
%160 = load i32, i32* %6
%161 = call i64 @session(%struct.sockaddr* %150, i32 %160, i32 %20)
%162 = icmp eq i64 %161, 0
br i1 %162, label %151, label %163
163: ; preds = %159
%164 = load i32, i32* @EXIT_FAILURE
br label %165
165: ; preds = %132, %163, %157, %61, %52, %49, %33
%166 = phi i32 [ %56, %52 ], [ %51, %49 ], [ %35, %33 ], [ %64, %61 ], [ %164, %163 ], [ %158, %157 ], [ %133, %132 ]
ret i32 %166
}