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

/* Forward declarations */

/* Type definitions */
struct sockaddr_storage {
  int dummy;
};
struct addrinfo {
  int ai_family;
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_addrlen;
  struct addrinfo *ai_next;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ sockbuflen;
typedef int /*<<< orphan*/ p;

/* Variables and functions */
scalar_t__ AF_INET;
scalar_t__ AF_INET6;
int /*<<< orphan*/ LogError(char *, ...);
int /*<<< orphan*/ LogInfo(char *, ...);
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVBUF;
scalar_t__ bind(int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
int /*<<< orphan*/ getsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int *);
scalar_t__ isMulticast(struct sockaddr_storage *);
scalar_t__ joinGroup(int, int, int, struct sockaddr_storage *);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int Multicast_receive_socket(const char *hostname, const char *listenport,
                             int family, int sockbuflen) {
  struct addrinfo hints, *res, *ressave;
  socklen_t optlen;
  int p, error, sockfd;
  if (!listenport) {
    fprintf(stderr, "listen port required!\n");
    LogError("listen port required!");
    return -1;
  }
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = family;
  hints.ai_socktype = SOCK_DGRAM;
  error = getaddrinfo(hostname, listenport, &hints, &res);
  if (error) {
    fprintf(stderr, "getaddrinfo error:: [%s]\n", gai_strerror(error));
    LogError("getaddrinfo error:: [%s]", gai_strerror(error));
    return -1;
  }
  sockfd = -1;
  ressave = res;
  while (res) {
    sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
    if (sockfd < 0) {
      res = res->ai_next;
      continue;
    }
    break;
  }
  if (sockfd < 0) {
    fprintf(stderr, "Could not create a socket for [%s:%s]\n", hostname,
            listenport);
    LogError("Could not create a socket for [%s:%s]", hostname, listenport);
    freeaddrinfo(ressave);
    return -1;
  }
  if (isMulticast((struct sockaddr_storage *)res->ai_addr) < 0) {
    fprintf(stderr, "Not a multicast address [%s]\n", hostname);
    LogError("Not a multicast address [%s]", hostname);
    freeaddrinfo(ressave);
    return -1;
  }
  close(sockfd);
  sockfd = socket(res->ai_family, SOCK_DGRAM, 0);
  if (bind(sockfd, res->ai_addr, res->ai_addrlen) < 0) {
    fprintf(stderr, "bind: %s\n", strerror(errno));
    LogError("bind: %s", strerror(errno));
    close(sockfd);
    freeaddrinfo(ressave);
    return -1;
  }
  if (joinGroup(sockfd, 1, 1, (struct sockaddr_storage *)res->ai_addr) < 0) {
    close(sockfd);
    freeaddrinfo(ressave);
    return -1;
  }
  if (res->ai_family == AF_INET)
    LogInfo("Joined IPv4 multicast group: %s Port: %s", hostname, listenport);
  if (res->ai_family == AF_INET6)
    LogInfo("Joined IPv6 multicat group: %s Port: %s", hostname, listenport);
  freeaddrinfo(ressave);
  if (sockbuflen) {
    if (sockbuflen < 65536) {
      sockbuflen = 65536;
      LogInfo("I want at least %i bytes as socket buffer", sockbuflen);
    }
    optlen = sizeof(p);
    getsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &p, &optlen);
    LogInfo("Standard setsockopt, SO_RCVBUF is %i Requested length is %i bytes",
            p, sockbuflen);
    if ((setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &sockbuflen,
                    sizeof(sockbuflen)) != 0)) {
      fprintf(stderr, "setsockopt(SO_RCVBUF,%d): %s\n", sockbuflen,
              strerror(errno));
      LogError("setsockopt(SO_RCVBUF,%d): %s", sockbuflen, strerror(errno));
      close(sockfd);
      return -1;
    } else {
      getsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &p, &optlen);
      LogInfo("System set setsockopt, SO_RCVBUF to %d bytes", p);
    }
  }
  return sockfd;
}


x86 assembly (clang, -O0):
<Multicast_receive_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1245 <Multicast_receive_socket+0x55>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   10b0 <LogError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1671 <Multicast_receive_socket+0x481>
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x48(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
je     12d6 <Multicast_receive_socket+0xe6>
mov    0x2d28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x64(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0x6c(%rbp),%edi
mov    %rax,%rdx
lea    0xd83(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x64(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    %rax,%rsi
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   10b0 <LogError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1671 <Multicast_receive_socket+0x481>
movl   $0xffffffff,-0x68(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     132c <Multicast_receive_socket+0x13c>
mov    -0x50(%rbp),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rax
mov    0x24(%rax),%esi
mov    -0x50(%rbp),%rax
mov    0x20(%rax),%edx
call   1110 <socket@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x68(%rbp)
jge    1327 <Multicast_receive_socket+0x137>
mov    -0x50(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x50(%rbp)
jmp    12e5 <Multicast_receive_socket+0xf5>
jmp    132c <Multicast_receive_socket+0x13c>
cmpl   $0x0,-0x68(%rbp)
jge    1380 <Multicast_receive_socket+0x190>
mov    0x2c7b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xd12(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xd23(%rip),%rdi
mov    $0x0,%al
call   10b0 <LogError@plt>
mov    -0x58(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1671 <Multicast_receive_socket+0x481>
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <isMulticast@plt>
cmp    $0x0,%rax
jge    13d9 <Multicast_receive_socket+0x1e9>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd02(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x10(%rbp),%rsi
lea    0xd0e(%rip),%rdi
mov    $0x0,%al
call   10b0 <LogError@plt>
mov    -0x58(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1671 <Multicast_receive_socket+0x481>
mov    -0x68(%rbp),%edi
call   1090 <close@plt>
mov    -0x50(%rbp),%rax
mov    (%rax),%edi
mov    0x2bea(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%edi
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
jge    1485 <Multicast_receive_socket+0x295>
mov    0x2b96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    0x2b82(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x70(%rbp),%edi
mov    %rax,%rdx
lea    0xca6(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2b60(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    %rax,%rsi
lea    0xc91(%rip),%rdi
mov    $0x0,%al
call   10b0 <LogError@plt>
mov    -0x68(%rbp),%edi
call   1090 <close@plt>
mov    -0x58(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1671 <Multicast_receive_socket+0x481>
mov    -0x68(%rbp),%edi
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <joinGroup@plt>
cmp    $0x0,%rax
jge    14c3 <Multicast_receive_socket+0x2d3>
mov    -0x68(%rbp),%edi
call   1090 <close@plt>
mov    -0x58(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1671 <Multicast_receive_socket+0x481>
mov    -0x50(%rbp),%rax
movslq (%rax),%rax
mov    0x2b0f(%rip),%rcx
cmp    (%rcx),%rax
jne    14f0 <Multicast_receive_socket+0x300>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xc12(%rip),%rdi
mov    $0x0,%al
call   1060 <LogInfo@plt>
mov    -0x50(%rbp),%rax
movslq (%rax),%rax
mov    0x2ad2(%rip),%rcx
cmp    (%rcx),%rax
jne    151d <Multicast_receive_socket+0x32d>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xc0e(%rip),%rdi
mov    $0x0,%al
call   1060 <LogInfo@plt>
mov    -0x58(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
cmpl   $0x0,-0x20(%rbp)
je     166b <Multicast_receive_socket+0x47b>
cmpl   $0x10000,-0x20(%rbp)
jge    1555 <Multicast_receive_socket+0x365>
movl   $0x10000,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xbfe(%rip),%rdi
mov    $0x0,%al
call   1060 <LogInfo@plt>
movl   $0x4,-0x5c(%rbp)
mov    -0x68(%rbp),%edi
mov    0x2a82(%rip),%rax
mov    (%rax),%esi
mov    0x2a51(%rip),%rax
mov    (%rax),%edx
lea    -0x60(%rbp),%rcx
lea    -0x5c(%rbp),%r8
call   10a0 <getsockopt@plt>
mov    -0x60(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xbeb(%rip),%rdi
mov    $0x0,%al
call   1060 <LogInfo@plt>
mov    -0x68(%rbp),%edi
mov    0x2a4c(%rip),%rax
mov    (%rax),%esi
mov    0x2a1b(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
cmp    $0x0,%rax
je     1633 <Multicast_receive_socket+0x443>
mov    0x29f1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    0x29d7(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%edx
mov    %rax,%rcx
lea    0xbc8(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    0x29ac(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x74(%rbp),%esi
mov    %rax,%rdx
lea    0xbbe(%rip),%rdi
mov    $0x0,%al
call   10b0 <LogError@plt>
mov    -0x68(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1671 <Multicast_receive_socket+0x481>
mov    -0x68(%rbp),%edi
mov    0x29ab(%rip),%rax
mov    (%rax),%esi
mov    0x297a(%rip),%rax
mov    (%rax),%edx
lea    -0x60(%rbp),%rcx
lea    -0x5c(%rbp),%r8
call   10a0 <getsockopt@plt>
mov    -0x60(%rbp),%esi
lea    0xb94(%rip),%rdi
mov    $0x0,%al
call   1060 <LogInfo@plt>
jmp    166b <Multicast_receive_socket+0x47b>
mov    -0x68(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Multicast_receive_socket>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %ecx,0xc(%rsp)
test   %rsi,%rsi
je     1295 <Multicast_receive_socket+0xa5>
mov    %ecx,%r12d
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r13
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    %ebx,0x20(%rsp)
mov    0x2da3(%rip),%r15
mov    (%r15),%eax
mov    %eax,0x44(%rsp)
lea    0x10(%rsp),%rcx
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
je     12bc <Multicast_receive_socket+0xcc>
mov    %eax,%ebx
mov    0x2d5c(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1070 <gai_strerror@plt>
lea    0xdc1(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %ebx,%edi
call   1070 <gai_strerror@plt>
lea    0xdc1(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10b0 <LogError@plt>
jmp    132f <Multicast_receive_socket+0x13f>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
lea    0xd5b(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
lea    0xd64(%rip),%rdi
xor    %eax,%eax
call   10b0 <LogError@plt>
jmp    132f <Multicast_receive_socket+0x13f>
mov    0x10(%rsp),%rbp
test   %rbp,%rbp
je     12f6 <Multicast_receive_socket+0x106>
mov    %rbp,%rax
nopl   0x0(%rax)
mov    0x24(%rax),%esi
mov    (%rax),%edi
mov    0x20(%rax),%edx
call   1110 <socket@plt>
mov    %eax,%ebx
mov    0x10(%rsp),%rax
test   %ebx,%ebx
jns    1347 <Multicast_receive_socket+0x157>
mov    0x18(%rax),%rax
mov    %rax,0x10(%rsp)
test   %rax,%rax
jne    12d0 <Multicast_receive_socket+0xe0>
mov    0x2cbb(%rip),%rax
mov    (%rax),%edi
lea    0xd5a(%rip),%rsi
mov    %r13,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   10c0 <fprintf@plt>
lea    0xd6d(%rip),%rdi
mov    %r13,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   10b0 <LogError@plt>
mov    %rbp,%rdi
call   1100 <freeaddrinfo@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rax),%rdi
call   1040 <isMulticast@plt>
test   %rax,%rax
js     1500 <Multicast_receive_socket+0x310>
mov    %ebx,%edi
call   1090 <close@plt>
mov    0x10(%rsp),%rax
mov    (%rax),%edi
mov    (%r15),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,%r15d
mov    0x10(%rsp),%rax
mov    0x8(%rax),%rsi
mov    0x10(%rax),%edx
mov    %r15d,%edi
call   10d0 <bind@plt>
test   %rax,%rax
js     1530 <Multicast_receive_socket+0x340>
mov    0x10(%rsp),%rax
mov    0x8(%rax),%rcx
mov    %r15d,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <joinGroup@plt>
test   %rax,%rax
js     1574 <Multicast_receive_socket+0x384>
mov    0x10(%rsp),%rax
movslq (%rax),%rax
mov    0x2c1c(%rip),%rcx
cmp    %rax,(%rcx)
jne    13e5 <Multicast_receive_socket+0x1f5>
lea    0xd2b(%rip),%rdi
mov    %r13,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <LogInfo@plt>
mov    0x10(%rsp),%rax
movslq (%rax),%rax
mov    0x2be4(%rip),%rcx
cmp    %rax,(%rcx)
jne    1405 <Multicast_receive_socket+0x215>
lea    0xd2c(%rip),%rdi
mov    %r13,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <LogInfo@plt>
mov    %rbp,%rdi
call   1100 <freeaddrinfo@plt>
test   %r12d,%r12d
je     1335 <Multicast_receive_socket+0x145>
cmp    $0xffff,%r12d
jg     1440 <Multicast_receive_socket+0x250>
movl   $0x10000,0xc(%rsp)
lea    0xd1e(%rip),%rdi
mov    $0x10000,%r12d
mov    $0x10000,%esi
xor    %eax,%eax
call   1060 <LogInfo@plt>
movl   $0x4,0x1c(%rsp)
mov    0x2b99(%rip),%rbx
mov    (%rbx),%esi
mov    0x2b68(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x18(%rsp),%rcx
lea    0x1c(%rsp),%r8
mov    %r15d,%edi
call   10a0 <getsockopt@plt>
mov    0x18(%rsp),%esi
lea    0xcfe(%rip),%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1060 <LogInfo@plt>
mov    (%rbx),%esi
mov    0x0(%rbp),%edx
lea    0xc(%rsp),%rcx
mov    %r15d,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
test   %rax,%rax
je     1581 <Multicast_receive_socket+0x391>
mov    0x2b0e(%rip),%rax
mov    (%rax),%ebx
mov    0xc(%rsp),%ebp
mov    0x2af9(%rip),%r14
mov    (%r14),%edi
call   10f0 <strerror@plt>
lea    0xcf2(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0xc(%rsp),%ebx
mov    (%r14),%edi
call   10f0 <strerror@plt>
lea    0xcef(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <LogError@plt>
mov    %r15d,%edi
call   1090 <close@plt>
jmp    132f <Multicast_receive_socket+0x13f>
mov    0x2ab1(%rip),%rax
mov    (%rax),%edi
lea    0xb9d(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
lea    0xbaa(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10b0 <LogError@plt>
jmp    1327 <Multicast_receive_socket+0x137>
mov    0x2a81(%rip),%rax
mov    (%rax),%ebx
mov    0x2a70(%rip),%r14
mov    (%r14),%edi
call   10f0 <strerror@plt>
lea    0xb99(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    (%r14),%edi
call   10f0 <strerror@plt>
lea    0xb88(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10b0 <LogError@plt>
mov    %r15d,%edi
call   1090 <close@plt>
jmp    1327 <Multicast_receive_socket+0x137>
mov    (%rbx),%esi
mov    0x0(%rbp),%edx
lea    0x18(%rsp),%rcx
lea    0x1c(%rsp),%r8
mov    %r15d,%edi
call   10a0 <getsockopt@plt>
mov    0x18(%rsp),%esi
lea    0xc50(%rip),%rdi
xor    %eax,%eax
call   1060 <LogInfo@plt>
jmp    1335 <Multicast_receive_socket+0x145>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i64, i32, %struct.addrinfo*, i32, i32 }
%struct.sockaddr_storage = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"listen port required!\0A\00"
@.str.1 = [22 x i8] c"listen port required!\00"
@SOCK_DGRAM = global i32 0
@.str.2 = [26 x i8] c"getaddrinfo error:: [%s]\0A\00"
@.str.3 = [25 x i8] c"getaddrinfo error:: [%s]\00"
@.str.4 = [39 x i8] c"Could not create a socket for [%s:%s]\0A\00"
@.str.5 = [38 x i8] c"Could not create a socket for [%s:%s]\00"
@.str.6 = [30 x i8] c"Not a multicast address [%s]\0A\00"
@.str.7 = [29 x i8] c"Not a multicast address [%s]\00"
@.str.8 = [10 x i8] c"bind: %s\0A\00"
@errno = global i32 0
@.str.9 = [9 x i8] c"bind: %s\00"
@AF_INET = global i64 0
@.str.10 = [41 x i8] c"Joined IPv4 multicast group: %s Port: %s\00"
@AF_INET6 = global i64 0
@.str.11 = [40 x i8] c"Joined IPv6 multicat group: %s Port: %s\00"
@.str.12 = [42 x i8] c"I want at least %i bytes as socket buffer\00"
@SOL_SOCKET = global i32 0
@SO_RCVBUF = global i32 0
@.str.13 = [66 x i8] c"Standard setsockopt, SO_RCVBUF is %i Requested length is %i bytes\00"
@.str.14 = [30 x i8] c"setsockopt(SO_RCVBUF,%d): %s\0A\00"
@.str.15 = [29 x i8] c"setsockopt(SO_RCVBUF,%d): %s\00"
@.str.16 = [45 x i8] c"System set setsockopt, SO_RCVBUF to %d bytes\00"
define i32 @Multicast_receive_socket(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.addrinfo
%11 = alloca %struct.addrinfo*
%12 = alloca %struct.addrinfo*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%17 = load i8*, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %23, label %19
19: ; preds = %4
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%22 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %203
23: ; preds = %4
%24 = call i32 @memset(%struct.addrinfo* %10, i32 0, i32 40)
%25 = load i32, i32* %8
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 0
store i32 %25, i32* %26
%27 = load i32, i32* @SOCK_DGRAM
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 5
store i32 %27, i32* %28
%29 = load i8*, i8** %6
%30 = load i8*, i8** %7
%31 = call i32 @getaddrinfo(i8* %29, i8* %30, %struct.addrinfo* %10, %struct.addrinfo** %11)
store i32 %31, i32* %15
%32 = load i32, i32* %15
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %42
34: ; preds = %23
%35 = load i32, i32* @stderr
%36 = load i32, i32* %15
%37 = call i8* @gai_strerror(i32 %36)
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = load i32, i32* %15
%40 = call i8* @gai_strerror(i32 %39)
%41 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %40)
store i32 -1, i32* %5
br label %203
42: ; preds = %23
store i32 -1, i32* %16
%43 = load %struct.addrinfo*, %struct.addrinfo** %11
store %struct.addrinfo* %43, %struct.addrinfo** %12
br label %44
44: ; preds = %60, %42
%45 = load %struct.addrinfo*, %struct.addrinfo** %11
%46 = icmp ne %struct.addrinfo* %45, null
br i1 %46, label %47, label %65
47: ; preds = %44
%48 = load %struct.addrinfo*, %struct.addrinfo** %11
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %48, i32 0, i32 0
%50 = load i32, i32* %49
%51 = load %struct.addrinfo*, %struct.addrinfo** %11
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %51, i32 0, i32 5
%53 = load i32, i32* %52
%54 = load %struct.addrinfo*, %struct.addrinfo** %11
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %54, i32 0, i32 4
%56 = load i32, i32* %55
%57 = call i32 @socket(i32 %50, i32 %53, i32 %56)
store i32 %57, i32* %16
%58 = load i32, i32* %16
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %47
%61 = load %struct.addrinfo*, %struct.addrinfo** %11
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i32 0, i32 3
%63 = load %struct.addrinfo*, %struct.addrinfo** %62
store %struct.addrinfo* %63, %struct.addrinfo** %11
br label %44
64: ; preds = %47
br label %65
65: ; preds = %64, %44
%66 = load i32, i32* %16
%67 = icmp slt i32 %66, 0
br i1 %67, label %68, label %78
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = load i8*, i8** %6
%71 = load i8*, i8** %7
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %70, i8* %71)
%73 = load i8*, i8** %6
%74 = load i8*, i8** %7
%75 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %73, i8* %74)
%76 = load %struct.addrinfo*, %struct.addrinfo** %12
%77 = call i32 @freeaddrinfo(%struct.addrinfo* %76)
store i32 -1, i32* %5
br label %203
78: ; preds = %65
%79 = load %struct.addrinfo*, %struct.addrinfo** %11
%80 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %79, i32 0, i32 1
%81 = load i64, i64* %80
%82 = inttoptr i64 %81 to %struct.sockaddr_storage*
%83 = call i64 @isMulticast(%struct.sockaddr_storage* %82)
%84 = icmp slt i64 %83, 0
br i1 %84, label %85, label %93
85: ; preds = %78
%86 = load i32, i32* @stderr
%87 = load i8*, i8** %6
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* %87)
%89 = load i8*, i8** %6
%90 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %89)
%91 = load %struct.addrinfo*, %struct.addrinfo** %12
%92 = call i32 @freeaddrinfo(%struct.addrinfo* %91)
store i32 -1, i32* %5
br label %203
93: ; preds = %78
%94 = load i32, i32* %16
%95 = call i32 @close(i32 %94)
%96 = load %struct.addrinfo*, %struct.addrinfo** %11
%97 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %96, i32 0, i32 0
%98 = load i32, i32* %97
%99 = load i32, i32* @SOCK_DGRAM
%100 = call i32 @socket(i32 %98, i32 %99, i32 0)
store i32 %100, i32* %16
%101 = load i32, i32* %16
%102 = load %struct.addrinfo*, %struct.addrinfo** %11
%103 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %102, i32 0, i32 1
%104 = load i64, i64* %103
%105 = load %struct.addrinfo*, %struct.addrinfo** %11
%106 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %105, i32 0, i32 2
%107 = load i32, i32* %106
%108 = call i64 @bind(i32 %101, i64 %104, i32 %107)
%109 = icmp slt i64 %108, 0
br i1 %109, label %110, label %122
110: ; preds = %93
%111 = load i32, i32* @stderr
%112 = load i32, i32* @errno
%113 = call i8* @strerror(i32 %112)
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %113)
%115 = load i32, i32* @errno
%116 = call i8* @strerror(i32 %115)
%117 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %116)
%118 = load i32, i32* %16
%119 = call i32 @close(i32 %118)
%120 = load %struct.addrinfo*, %struct.addrinfo** %12
%121 = call i32 @freeaddrinfo(%struct.addrinfo* %120)
store i32 -1, i32* %5
br label %203
122: ; preds = %93
%123 = load i32, i32* %16
%124 = load %struct.addrinfo*, %struct.addrinfo** %11
%125 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %124, i32 0, i32 1
%126 = load i64, i64* %125
%127 = inttoptr i64 %126 to %struct.sockaddr_storage*
%128 = call i64 @joinGroup(i32 %123, i32 1, i32 1, %struct.sockaddr_storage* %127)
%129 = icmp slt i64 %128, 0
br i1 %129, label %130, label %135
130: ; preds = %122
%131 = load i32, i32* %16
%132 = call i32 @close(i32 %131)
%133 = load %struct.addrinfo*, %struct.addrinfo** %12
%134 = call i32 @freeaddrinfo(%struct.addrinfo* %133)
store i32 -1, i32* %5
br label %203
135: ; preds = %122
%136 = load %struct.addrinfo*, %struct.addrinfo** %11
%137 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %136, i32 0, i32 0
%138 = load i32, i32* %137
%139 = sext i32 %138 to i64
%140 = load i64, i64* @AF_INET
%141 = icmp eq i64 %139, %140
br i1 %141, label %142, label %146
142: ; preds = %135
%143 = load i8*, i8** %6
%144 = load i8*, i8** %7
%145 = call i32 (i8*, ...) @LogInfo(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0), i8* %143, i8* %144)
br label %146
146: ; preds = %142, %135
%147 = load %struct.addrinfo*, %struct.addrinfo** %11
%148 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %147, i32 0, i32 0
%149 = load i32, i32* %148
%150 = sext i32 %149 to i64
%151 = load i64, i64* @AF_INET6
%152 = icmp eq i64 %150, %151
br i1 %152, label %153, label %157
153: ; preds = %146
%154 = load i8*, i8** %6
%155 = load i8*, i8** %7
%156 = call i32 (i8*, ...) @LogInfo(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i8* %154, i8* %155)
br label %157
157: ; preds = %153, %146
%158 = load %struct.addrinfo*, %struct.addrinfo** %12
%159 = call i32 @freeaddrinfo(%struct.addrinfo* %158)
%160 = load i32, i32* %9
%161 = icmp ne i32 %160, 0
br i1 %161, label %162, label %201
162: ; preds = %157
%163 = load i32, i32* %9
%164 = icmp slt i32 %163, 65536
br i1 %164, label %165, label %168
165: ; preds = %162
store i32 65536, i32* %9
%166 = load i32, i32* %9
%167 = call i32 (i8*, ...) @LogInfo(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.12, i64 0, i64 0), i32 %166)
br label %168
168: ; preds = %165, %162
store i32 4, i32* %13
%169 = load i32, i32* %16
%170 = load i32, i32* @SOL_SOCKET
%171 = load i32, i32* @SO_RCVBUF
%172 = call i32 @getsockopt(i32 %169, i32 %170, i32 %171, i32* %14, i32* %13)
%173 = load i32, i32* %14
%174 = load i32, i32* %9
%175 = call i32 (i8*, ...) @LogInfo(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.13, i64 0, i64 0), i32 %173, i32 %174)
%176 = load i32, i32* %16
%177 = load i32, i32* @SOL_SOCKET
%178 = load i32, i32* @SO_RCVBUF
%179 = call i64 @setsockopt(i32 %176, i32 %177, i32 %178, i32* %9, i32 4)
%180 = icmp ne i64 %179, 0
br i1 %180, label %181, label %193
181: ; preds = %168
%182 = load i32, i32* @stderr
%183 = load i32, i32* %9
%184 = load i32, i32* @errno
%185 = call i8* @strerror(i32 %184)
%186 = call i32 (i32, i8*, ...) @fprintf(i32 %182, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i64 0, i64 0), i32 %183, i8* %185)
%187 = load i32, i32* %9
%188 = load i32, i32* @errno
%189 = call i8* @strerror(i32 %188)
%190 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.15, i64 0, i64 0), i32 %187, i8* %189)
%191 = load i32, i32* %16
%192 = call i32 @close(i32 %191)
store i32 -1, i32* %5
br label %203
193: ; preds = %168
%194 = load i32, i32* %16
%195 = load i32, i32* @SOL_SOCKET
%196 = load i32, i32* @SO_RCVBUF
%197 = call i32 @getsockopt(i32 %194, i32 %195, i32 %196, i32* %14, i32* %13)
%198 = load i32, i32* %14
%199 = call i32 (i8*, ...) @LogInfo(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.16, i64 0, i64 0), i32 %198)
br label %200
200: ; preds = %193
br label %201
201: ; preds = %200, %157
%202 = load i32, i32* %16
store i32 %202, i32* %5
br label %203
203: ; preds = %201, %181, %130, %110, %85, %68, %34, %19
%204 = load i32, i32* %5
ret i32 %204
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i64, i32, %struct.addrinfo*, i32, i32 }
%struct.sockaddr_storage = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"listen port required!\0A\00"
@.str.1 = [22 x i8] c"listen port required!\00"
@SOCK_DGRAM = global i32 0
@.str.2 = [26 x i8] c"getaddrinfo error:: [%s]\0A\00"
@.str.3 = [25 x i8] c"getaddrinfo error:: [%s]\00"
@.str.4 = [39 x i8] c"Could not create a socket for [%s:%s]\0A\00"
@.str.5 = [38 x i8] c"Could not create a socket for [%s:%s]\00"
@.str.6 = [30 x i8] c"Not a multicast address [%s]\0A\00"
@.str.7 = [29 x i8] c"Not a multicast address [%s]\00"
@.str.8 = [10 x i8] c"bind: %s\0A\00"
@errno = global i32 0
@.str.9 = [9 x i8] c"bind: %s\00"
@AF_INET = global i64 0
@.str.10 = [41 x i8] c"Joined IPv4 multicast group: %s Port: %s\00"
@AF_INET6 = global i64 0
@.str.11 = [40 x i8] c"Joined IPv6 multicat group: %s Port: %s\00"
@.str.12 = [42 x i8] c"I want at least %i bytes as socket buffer\00"
@SOL_SOCKET = global i32 0
@SO_RCVBUF = global i32 0
@.str.13 = [66 x i8] c"Standard setsockopt, SO_RCVBUF is %i Requested length is %i bytes\00"
@.str.14 = [30 x i8] c"setsockopt(SO_RCVBUF,%d): %s\0A\00"
@.str.15 = [29 x i8] c"setsockopt(SO_RCVBUF,%d): %s\00"
@.str.16 = [45 x i8] c"System set setsockopt, SO_RCVBUF to %d bytes\00"
define i32 @Multicast_receive_socket(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.addrinfo
%7 = alloca %struct.addrinfo*
%8 = alloca i32
%9 = alloca i32
store i32 %3, i32* %5
%10 = bitcast %struct.addrinfo* %6 to i8*
%11 = bitcast %struct.addrinfo** %7 to i8*
%12 = bitcast i32* %8 to i8*
%13 = bitcast i32* %9 to i8*
%14 = icmp eq i8* %1, null
br i1 %14, label %15, label %19
15: ; preds = %4
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %154
19: ; preds = %4
%20 = call i32 @memset(%struct.addrinfo* %6, i32 0, i32 40)
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i64 0, i32 0
store i32 %2, i32* %21
%22 = load i32, i32* @SOCK_DGRAM
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i64 0, i32 5
store i32 %22, i32* %23
%24 = call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %6, %struct.addrinfo** %7)
%25 = icmp eq i32 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = call i8* @gai_strerror(i32 %24)
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = call i8* @gai_strerror(i32 %24)
%31 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %30)
br label %154
32: ; preds = %19
%33 = load %struct.addrinfo*, %struct.addrinfo** %7
%34 = icmp eq %struct.addrinfo* %33, null
br i1 %34, label %50, label %35
35: ; preds = %32, %46
%36 = phi %struct.addrinfo* [ %48, %46 ], [ %33, %32 ]
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 0
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 5
%40 = load i32, i32* %39
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 4
%42 = load i32, i32* %41
%43 = call i32 @socket(i32 %38, i32 %40, i32 %42)
%44 = icmp slt i32 %43, 0
%45 = load %struct.addrinfo*, %struct.addrinfo** %7
br i1 %44, label %46, label %55
46: ; preds = %35
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i64 0, i32 3
%48 = load %struct.addrinfo*, %struct.addrinfo** %47
store %struct.addrinfo* %48, %struct.addrinfo** %7
%49 = icmp eq %struct.addrinfo* %48, null
br i1 %49, label %50, label %35
50: ; preds = %46, %32
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %1)
%53 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %0, i8* %1)
%54 = call i32 @freeaddrinfo(%struct.addrinfo* %33)
br label %154
55: ; preds = %35
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i64 0, i32 1
%57 = load i64, i64* %56
%58 = inttoptr i64 %57 to %struct.sockaddr_storage*
%59 = call i64 @isMulticast(%struct.sockaddr_storage* %58)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %55
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* %0)
%64 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %0)
%65 = call i32 @freeaddrinfo(%struct.addrinfo* %33)
br label %154
66: ; preds = %55
%67 = call i32 @close(i32 %43)
%68 = load %struct.addrinfo*, %struct.addrinfo** %7
%69 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %68, i64 0, i32 0
%70 = load i32, i32* %69
%71 = load i32, i32* @SOCK_DGRAM
%72 = call i32 @socket(i32 %70, i32 %71, i32 0)
%73 = load %struct.addrinfo*, %struct.addrinfo** %7
%74 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %73, i64 0, i32 1
%75 = load i64, i64* %74
%76 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %73, i64 0, i32 2
%77 = load i32, i32* %76
%78 = call i64 @bind(i32 %72, i64 %75, i32 %77)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %90
80: ; preds = %66
%81 = load i32, i32* @stderr
%82 = load i32, i32* @errno
%83 = call i8* @strerror(i32 %82)
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %83)
%85 = load i32, i32* @errno
%86 = call i8* @strerror(i32 %85)
%87 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %86)
%88 = call i32 @close(i32 %72)
%89 = call i32 @freeaddrinfo(%struct.addrinfo* %33)
br label %154
90: ; preds = %66
%91 = load %struct.addrinfo*, %struct.addrinfo** %7
%92 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %91, i64 0, i32 1
%93 = load i64, i64* %92
%94 = inttoptr i64 %93 to %struct.sockaddr_storage*
%95 = call i64 @joinGroup(i32 %72, i32 1, i32 1, %struct.sockaddr_storage* %94)
%96 = icmp slt i64 %95, 0
br i1 %96, label %97, label %100
97: ; preds = %90
%98 = call i32 @close(i32 %72)
%99 = call i32 @freeaddrinfo(%struct.addrinfo* %33)
br label %154
100: ; preds = %90
%101 = load %struct.addrinfo*, %struct.addrinfo** %7
%102 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %101, i64 0, i32 0
%103 = load i32, i32* %102
%104 = sext i32 %103 to i64
%105 = load i64, i64* @AF_INET
%106 = icmp eq i64 %105, %104
br i1 %106, label %107, label %113
107: ; preds = %100
%108 = call i32 (i8*, ...) @LogInfo(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0), i8* %0, i8* %1)
%109 = load %struct.addrinfo*, %struct.addrinfo** %7
%110 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %109, i64 0, i32 0
%111 = load i32, i32* %110
%112 = sext i32 %111 to i64
br label %113
113: ; preds = %107, %100
%114 = phi i64 [ %112, %107 ], [ %104, %100 ]
%115 = load i64, i64* @AF_INET6
%116 = icmp eq i64 %115, %114
br i1 %116, label %117, label %119
117: ; preds = %113
%118 = call i32 (i8*, ...) @LogInfo(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i8* %0, i8* %1)
br label %119
119: ; preds = %117, %113
%120 = call i32 @freeaddrinfo(%struct.addrinfo* %33)
%121 = icmp eq i32 %3, 0
br i1 %121, label %154, label %122
122: ; preds = %119
%123 = icmp slt i32 %3, 65536
br i1 %123, label %124, label %126
124: ; preds = %122
store i32 65536, i32* %5
%125 = call i32 (i8*, ...) @LogInfo(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.12, i64 0, i64 0), i32 65536)
br label %126
126: ; preds = %124, %122
%127 = phi i32 [ 65536, %124 ], [ %3, %122 ]
store i32 4, i32* %8
%128 = load i32, i32* @SOL_SOCKET
%129 = load i32, i32* @SO_RCVBUF
%130 = call i32 @getsockopt(i32 %72, i32 %128, i32 %129, i32* %9, i32* %8)
%131 = load i32, i32* %9
%132 = call i32 (i8*, ...) @LogInfo(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.13, i64 0, i64 0), i32 %131, i32 %127)
%133 = load i32, i32* @SOL_SOCKET
%134 = load i32, i32* @SO_RCVBUF
%135 = call i64 @setsockopt(i32 %72, i32 %133, i32 %134, i32* %5, i32 4)
%136 = icmp eq i64 %135, 0
br i1 %136, label %148, label %137
137: ; preds = %126
%138 = load i32, i32* @stderr
%139 = load i32, i32* %5
%140 = load i32, i32* @errno
%141 = call i8* @strerror(i32 %140)
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i64 0, i64 0), i32 %139, i8* %141)
%143 = load i32, i32* %5
%144 = load i32, i32* @errno
%145 = call i8* @strerror(i32 %144)
%146 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.15, i64 0, i64 0), i32 %143, i8* %145)
%147 = call i32 @close(i32 %72)
br label %154
148: ; preds = %126
%149 = load i32, i32* @SOL_SOCKET
%150 = load i32, i32* @SO_RCVBUF
%151 = call i32 @getsockopt(i32 %72, i32 %149, i32 %150, i32* %9, i32* %8)
%152 = load i32, i32* %9
%153 = call i32 (i8*, ...) @LogInfo(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.16, i64 0, i64 0), i32 %152)
br label %154
154: ; preds = %119, %148, %137, %97, %80, %61, %50, %26, %15
%155 = phi i32 [ -1, %26 ], [ -1, %50 ], [ -1, %61 ], [ -1, %80 ], [ -1, %97 ], [ -1, %137 ], [ -1, %15 ], [ %72, %148 ], [ %72, %119 ]
ret i32 %155
}