#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;
  int ai_addrlen;
  scalar_t__ ai_addr;
  struct addrinfo *ai_next;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
};

/* Variables and functions */
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char const *gai_strerror(int);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
scalar_t__ isMulticast(struct sockaddr_storage *);
scalar_t__ joinGroup(int, int, int, struct sockaddr_storage *);
int /*<<< orphan*/ memcpy(struct sockaddr_storage *, scalar_t__, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int socket(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int Multicast_send_socket(const char *hostname, const char *listenport,
                          int family, unsigned int wmem_size,
                          struct sockaddr_storage *addr, int *addrlen) {
  struct addrinfo hints, *res, *ressave;
  int error, sockfd;
  if (!listenport || !hostname) {
    fprintf(stderr, "hostname and listen port required!\n");
    syslog(LOG_ERR, "hostname and listen port required!\n");
    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));
    syslog(LOG_ERR, "getaddrinfo error:: [%s]\n", 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);
    syslog(LOG_ERR, "Could not create a socket for [%s:%s]\n", hostname,
           listenport);
    freeaddrinfo(ressave);
    return -1;
  }
  if (isMulticast((struct sockaddr_storage *)res->ai_addr) < 0) {
    fprintf(stderr, "Not a multicast address [%s]\n", hostname);
    syslog(LOG_ERR, "Not a multicast address [%s]\n", hostname);
    freeaddrinfo(ressave);
    return -1;
  }
  close(sockfd);
  sockfd = socket(res->ai_family, SOCK_DGRAM, 0);
  *addrlen = res->ai_addrlen;
  memcpy(addr, res->ai_addr, res->ai_addrlen);
  if (joinGroup(sockfd, 1, 1, (struct sockaddr_storage *)res->ai_addr) < 0) {
    close(sockfd);
    freeaddrinfo(ressave);
    return -1;
  }
  freeaddrinfo(ressave);
  return sockfd;
}


x86 assembly (clang, -O0):
<Multicast_send_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11e4 <Multicast_send_socket+0x34>
cmpq   $0x0,-0x10(%rbp)
jne    121e <Multicast_send_socket+0x6e>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1466 <Multicast_send_socket+0x2b6>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   10b0 <getaddrinfo@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
je     12be <Multicast_send_socket+0x10e>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    -0x64(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x70(%rbp),%edi
mov    %rax,%rdx
lea    0xda1(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x64(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x6c(%rbp),%edi
mov    %rax,%rdx
lea    0xd79(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1466 <Multicast_send_socket+0x2b6>
movl   $0xffffffff,-0x68(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1314 <Multicast_send_socket+0x164>
mov    -0x58(%rbp),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rax
mov    0x1c(%rax),%esi
mov    -0x58(%rbp),%rax
mov    0x18(%rax),%edx
call   10d0 <socket@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x68(%rbp)
jge    130f <Multicast_send_socket+0x15f>
mov    -0x58(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    12cd <Multicast_send_socket+0x11d>
jmp    1314 <Multicast_send_socket+0x164>
cmpl   $0x0,-0x68(%rbp)
jge    1371 <Multicast_send_socket+0x1c1>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xd08(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xce9(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
mov    -0x60(%rbp),%rdi
call   10c0 <freeaddrinfo@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1466 <Multicast_send_socket+0x2b6>
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <isMulticast@plt>
cmp    $0x0,%rax
jge    13d3 <Multicast_send_socket+0x223>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xcc9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c1e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xcae(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
mov    -0x60(%rbp),%rdi
call   10c0 <freeaddrinfo@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1466 <Multicast_send_socket+0x2b6>
mov    -0x68(%rbp),%edi
call   1070 <close@plt>
mov    -0x58(%rbp),%rax
mov    (%rax),%edi
mov    0x2c00(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,-0x68(%rbp)
mov    -0x58(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x58(%rbp),%rax
mov    0x4(%rax),%edx
call   1090 <memcpy@plt>
mov    -0x68(%rbp),%edi
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <joinGroup@plt>
cmp    $0x0,%rax
jge    1457 <Multicast_send_socket+0x2a7>
mov    -0x68(%rbp),%edi
call   1070 <close@plt>
mov    -0x60(%rbp),%rdi
call   10c0 <freeaddrinfo@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1466 <Multicast_send_socket+0x2b6>
mov    -0x60(%rbp),%rdi
call   10c0 <freeaddrinfo@plt>
mov    -0x68(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Multicast_send_socket>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %rdi,%rdi
je     1264 <Multicast_send_socket+0xb4>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1264 <Multicast_send_socket+0xb4>
mov    %r9,%r12
mov    %r8,%r15
mov    %edx,%ebp
mov    %rdi,%r13
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    %ebp,0x8(%rsp)
mov    0x2deb(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
mov    %rsp,%rcx
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10b0 <getaddrinfo@plt>
test   %eax,%eax
je     1293 <Multicast_send_socket+0xe3>
mov    %eax,%ebp
mov    0x2db7(%rip),%rax
mov    (%rax),%ebx
mov    %ebp,%edi
call   1050 <gai_strerror@plt>
lea    0xdf3(%rip),%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2d81(%rip),%rax
mov    (%rax),%ebx
mov    %ebp,%edi
call   1050 <gai_strerror@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <syslog@plt>
jmp    1305 <Multicast_send_socket+0x155>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
lea    0xd8c(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <syslog@plt>
jmp    1305 <Multicast_send_socket+0x155>
mov    (%rsp),%r14
test   %r14,%r14
je     12c4 <Multicast_send_socket+0x114>
mov    %r14,%rax
nop
mov    0x1c(%rax),%esi
mov    (%rax),%edi
mov    0x18(%rax),%edx
call   10d0 <socket@plt>
mov    %eax,%ebp
mov    (%rsp),%rax
test   %ebp,%ebp
jns    131b <Multicast_send_socket+0x16b>
mov    0x10(%rax),%rax
mov    %rax,(%rsp)
test   %rax,%rax
jne    12a0 <Multicast_send_socket+0xf0>
mov    0x2d0d(%rip),%rax
mov    (%rax),%edi
lea    0xd6a(%rip),%rbp
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   10a0 <syslog@plt>
mov    %r14,%rdi
call   10c0 <freeaddrinfo@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x28,%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     138a <Multicast_send_socket+0x1da>
mov    %ebp,%edi
call   1070 <close@plt>
mov    (%rsp),%rax
mov    (%rax),%edi
mov    0x2cab(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,%ebx
mov    (%rsp),%rax
mov    0x4(%rax),%ecx
mov    %ecx,(%r12)
mov    0x8(%rax),%rsi
mov    0x4(%rax),%edx
mov    %r15,%rdi
call   1090 <memcpy@plt>
mov    (%rsp),%rax
mov    0x8(%rax),%rcx
mov    %ebx,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <joinGroup@plt>
test   %rax,%rax
js     13c2 <Multicast_send_socket+0x212>
mov    %r14,%rdi
call   10c0 <freeaddrinfo@plt>
jmp    130a <Multicast_send_socket+0x15a>
mov    0x2c47(%rip),%rax
mov    (%rax),%edi
lea    0xccb(%rip),%rbx
mov    %rbx,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10a0 <syslog@plt>
jmp    12fd <Multicast_send_socket+0x14d>
mov    %ebx,%edi
call   1070 <close@plt>
jmp    12fd <Multicast_send_socket+0x14d>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i64, %struct.addrinfo*, i32, i32 }
@stderr = global i32 0
@.str = [36 x i8] c"hostname and listen port required!\0A\00"
@LOG_ERR = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [26 x i8] c"getaddrinfo error:: [%s]\0A\00"
@.str.2 = [39 x i8] c"Could not create a socket for [%s:%s]\0A\00"
@.str.3 = [30 x i8] c"Not a multicast address [%s]\0A\00"
define i32 @Multicast_send_socket(i8* %0, i8* %1, i32 %2, i32 %3, %struct.sockaddr_storage* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.sockaddr_storage*
%13 = alloca i32*
%14 = alloca %struct.addrinfo
%15 = alloca %struct.addrinfo*
%16 = alloca %struct.addrinfo*
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store %struct.sockaddr_storage* %4, %struct.sockaddr_storage** %12
store i32* %5, i32** %13
%19 = load i8*, i8** %9
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %6
%22 = load i8*, i8** %8
%23 = icmp ne i8* %22, null
br i1 %23, label %29, label %24
24: ; preds = %21, %6
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%27 = load i32, i32* @LOG_ERR
%28 = call i32 (i32, i8*, ...) @syslog(i32 %27, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %7
br label %138
29: ; preds = %21
%30 = call i32 @memset(%struct.addrinfo* %14, i32 0, i32 32)
%31 = load i32, i32* %10
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %14, i32 0, i32 0
store i32 %31, i32* %32
%33 = load i32, i32* @SOCK_DGRAM
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %14, i32 0, i32 5
store i32 %33, i32* %34
%35 = load i8*, i8** %8
%36 = load i8*, i8** %9
%37 = call i32 @getaddrinfo(i8* %35, i8* %36, %struct.addrinfo* %14, %struct.addrinfo** %15)
store i32 %37, i32* %17
%38 = load i32, i32* %17
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %49
40: ; preds = %29
%41 = load i32, i32* @stderr
%42 = load i32, i32* %17
%43 = call i8* @gai_strerror(i32 %42)
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = load i32, i32* @LOG_ERR
%46 = load i32, i32* %17
%47 = call i8* @gai_strerror(i32 %46)
%48 = call i32 (i32, i8*, ...) @syslog(i32 %45, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %47)
store i32 -1, i32* %7
br label %138
49: ; preds = %29
store i32 -1, i32* %18
%50 = load %struct.addrinfo*, %struct.addrinfo** %15
store %struct.addrinfo* %50, %struct.addrinfo** %16
br label %51
51: ; preds = %67, %49
%52 = load %struct.addrinfo*, %struct.addrinfo** %15
%53 = icmp ne %struct.addrinfo* %52, null
br i1 %53, label %54, label %72
54: ; preds = %51
%55 = load %struct.addrinfo*, %struct.addrinfo** %15
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i32 0, i32 0
%57 = load i32, i32* %56
%58 = load %struct.addrinfo*, %struct.addrinfo** %15
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 5
%60 = load i32, i32* %59
%61 = load %struct.addrinfo*, %struct.addrinfo** %15
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i32 0, i32 4
%63 = load i32, i32* %62
%64 = call i32 @socket(i32 %57, i32 %60, i32 %63)
store i32 %64, i32* %18
%65 = load i32, i32* %18
%66 = icmp slt i32 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %54
%68 = load %struct.addrinfo*, %struct.addrinfo** %15
%69 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %68, i32 0, i32 3
%70 = load %struct.addrinfo*, %struct.addrinfo** %69
store %struct.addrinfo* %70, %struct.addrinfo** %15
br label %51
71: ; preds = %54
br label %72
72: ; preds = %71, %51
%73 = load i32, i32* %18
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %86
75: ; preds = %72
%76 = load i32, i32* @stderr
%77 = load i8*, i8** %8
%78 = load i8*, i8** %9
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %77, i8* %78)
%80 = load i32, i32* @LOG_ERR
%81 = load i8*, i8** %8
%82 = load i8*, i8** %9
%83 = call i32 (i32, i8*, ...) @syslog(i32 %80, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %81, i8* %82)
%84 = load %struct.addrinfo*, %struct.addrinfo** %16
%85 = call i32 @freeaddrinfo(%struct.addrinfo* %84)
store i32 -1, i32* %7
br label %138
86: ; preds = %72
%87 = load %struct.addrinfo*, %struct.addrinfo** %15
%88 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %87, i32 0, i32 2
%89 = load i64, i64* %88
%90 = inttoptr i64 %89 to %struct.sockaddr_storage*
%91 = call i64 @isMulticast(%struct.sockaddr_storage* %90)
%92 = icmp slt i64 %91, 0
br i1 %92, label %93, label %102
93: ; preds = %86
%94 = load i32, i32* @stderr
%95 = load i8*, i8** %8
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %95)
%97 = load i32, i32* @LOG_ERR
%98 = load i8*, i8** %8
%99 = call i32 (i32, i8*, ...) @syslog(i32 %97, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %98)
%100 = load %struct.addrinfo*, %struct.addrinfo** %16
%101 = call i32 @freeaddrinfo(%struct.addrinfo* %100)
store i32 -1, i32* %7
br label %138
102: ; preds = %86
%103 = load i32, i32* %18
%104 = call i32 @close(i32 %103)
%105 = load %struct.addrinfo*, %struct.addrinfo** %15
%106 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %105, i32 0, i32 0
%107 = load i32, i32* %106
%108 = load i32, i32* @SOCK_DGRAM
%109 = call i32 @socket(i32 %107, i32 %108, i32 0)
store i32 %109, i32* %18
%110 = load %struct.addrinfo*, %struct.addrinfo** %15
%111 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %110, i32 0, i32 1
%112 = load i32, i32* %111
%113 = load i32*, i32** %13
store i32 %112, i32* %113
%114 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %12
%115 = load %struct.addrinfo*, %struct.addrinfo** %15
%116 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %115, i32 0, i32 2
%117 = load i64, i64* %116
%118 = load %struct.addrinfo*, %struct.addrinfo** %15
%119 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %118, i32 0, i32 1
%120 = load i32, i32* %119
%121 = call i32 @memcpy(%struct.sockaddr_storage* %114, i64 %117, i32 %120)
%122 = load i32, i32* %18
%123 = load %struct.addrinfo*, %struct.addrinfo** %15
%124 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %123, i32 0, i32 2
%125 = load i64, i64* %124
%126 = inttoptr i64 %125 to %struct.sockaddr_storage*
%127 = call i64 @joinGroup(i32 %122, i32 1, i32 1, %struct.sockaddr_storage* %126)
%128 = icmp slt i64 %127, 0
br i1 %128, label %129, label %134
129: ; preds = %102
%130 = load i32, i32* %18
%131 = call i32 @close(i32 %130)
%132 = load %struct.addrinfo*, %struct.addrinfo** %16
%133 = call i32 @freeaddrinfo(%struct.addrinfo* %132)
store i32 -1, i32* %7
br label %138
134: ; preds = %102
%135 = load %struct.addrinfo*, %struct.addrinfo** %16
%136 = call i32 @freeaddrinfo(%struct.addrinfo* %135)
%137 = load i32, i32* %18
store i32 %137, i32* %7
br label %138
138: ; preds = %134, %129, %93, %75, %40, %24
%139 = load i32, i32* %7
ret i32 %139
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i64, %struct.addrinfo*, i32, i32 }
@stderr = global i32 0
@.str = [36 x i8] c"hostname and listen port required!\0A\00"
@LOG_ERR = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [26 x i8] c"getaddrinfo error:: [%s]\0A\00"
@.str.2 = [39 x i8] c"Could not create a socket for [%s:%s]\0A\00"
@.str.3 = [30 x i8] c"Not a multicast address [%s]\0A\00"
define i32 @Multicast_send_socket(i8* %0, i8* %1, i32 %2, i32 %3, %struct.sockaddr_storage* %4, i32* nocapture writeonly %5) {
%7 = alloca %struct.addrinfo
%8 = alloca %struct.addrinfo*
%9 = bitcast %struct.addrinfo* %7 to i8*
%10 = bitcast %struct.addrinfo** %8 to i8*
%11 = icmp ne i8* %1, null
%12 = icmp ne i8* %0, null
%13 = and i1 %12, %11
br i1 %13, label %19, label %14
14: ; preds = %6
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @LOG_ERR
%18 = tail call i32 (i32, i8*, ...) @syslog(i32 %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %94
19: ; preds = %6
%20 = call i32 @memset(%struct.addrinfo* %7, i32 0, i32 32)
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 0
store i32 %2, i32* %21
%22 = load i32, i32* @SOCK_DGRAM
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 5
store i32 %22, i32* %23
%24 = call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %7, %struct.addrinfo** %8)
%25 = icmp eq i32 %24, 0
br i1 %25, label %33, 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.1, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @LOG_ERR
%31 = call i8* @gai_strerror(i32 %24)
%32 = call i32 (i32, i8*, ...) @syslog(i32 %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %31)
br label %94
33: ; preds = %19
%34 = load %struct.addrinfo*, %struct.addrinfo** %8
%35 = icmp eq %struct.addrinfo* %34, null
br i1 %35, label %51, label %36
36: ; preds = %33, %47
%37 = phi %struct.addrinfo* [ %49, %47 ], [ %34, %33 ]
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 0
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 5
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 4
%43 = load i32, i32* %42
%44 = call i32 @socket(i32 %39, i32 %41, i32 %43)
%45 = icmp slt i32 %44, 0
%46 = load %struct.addrinfo*, %struct.addrinfo** %8
br i1 %45, label %47, label %57
47: ; preds = %36
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i64 0, i32 3
%49 = load %struct.addrinfo*, %struct.addrinfo** %48
store %struct.addrinfo* %49, %struct.addrinfo** %8
%50 = icmp eq %struct.addrinfo* %49, null
br i1 %50, label %51, label %36
51: ; preds = %47, %33
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
%54 = load i32, i32* @LOG_ERR
%55 = call i32 (i32, i8*, ...) @syslog(i32 %54, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
%56 = call i32 @freeaddrinfo(%struct.addrinfo* %34)
br label %94
57: ; preds = %36
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i64 0, i32 2
%59 = load i64, i64* %58
%60 = inttoptr i64 %59 to %struct.sockaddr_storage*
%61 = call i64 @isMulticast(%struct.sockaddr_storage* %60)
%62 = icmp slt i64 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %57
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%66 = load i32, i32* @LOG_ERR
%67 = call i32 (i32, i8*, ...) @syslog(i32 %66, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%68 = call i32 @freeaddrinfo(%struct.addrinfo* %34)
br label %94
69: ; preds = %57
%70 = call i32 @close(i32 %44)
%71 = load %struct.addrinfo*, %struct.addrinfo** %8
%72 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %71, i64 0, i32 0
%73 = load i32, i32* %72
%74 = load i32, i32* @SOCK_DGRAM
%75 = call i32 @socket(i32 %73, i32 %74, i32 0)
%76 = load %struct.addrinfo*, %struct.addrinfo** %8
%77 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %76, i64 0, i32 1
%78 = load i32, i32* %77
store i32 %78, i32* %5
%79 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %76, i64 0, i32 2
%80 = load i64, i64* %79
%81 = load i32, i32* %77
%82 = call i32 @memcpy(%struct.sockaddr_storage* %4, i64 %80, i32 %81)
%83 = load %struct.addrinfo*, %struct.addrinfo** %8
%84 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %83, i64 0, i32 2
%85 = load i64, i64* %84
%86 = inttoptr i64 %85 to %struct.sockaddr_storage*
%87 = call i64 @joinGroup(i32 %75, i32 1, i32 1, %struct.sockaddr_storage* %86)
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %69
%90 = call i32 @close(i32 %75)
%91 = call i32 @freeaddrinfo(%struct.addrinfo* %34)
br label %94
92: ; preds = %69
%93 = call i32 @freeaddrinfo(%struct.addrinfo* %34)
br label %94
94: ; preds = %92, %89, %63, %51, %26, %14
%95 = phi i32 [ -1, %26 ], [ -1, %51 ], [ -1, %63 ], [ -1, %89 ], [ %75, %92 ], [ -1, %14 ]
ret i32 %95
}