#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*/ LogError(char *, ...);
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 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");
    LogError("hostname and 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);
  *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    1215 <Multicast_send_socket+0x65>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1080 <LogError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143c <Multicast_send_socket+0x28c>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    0x2db6(%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     12a6 <Multicast_send_socket+0xf6>
mov    0x2d78(%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    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x64(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    %rax,%rsi
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1080 <LogError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143c <Multicast_send_socket+0x28c>
movl   $0xffffffff,-0x68(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     12fc <Multicast_send_socket+0x14c>
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    12f7 <Multicast_send_socket+0x147>
mov    -0x58(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    12b5 <Multicast_send_socket+0x105>
jmp    12fc <Multicast_send_socket+0x14c>
cmpl   $0x0,-0x68(%rbp)
jge    1350 <Multicast_send_socket+0x1a0>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xd5c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1080 <LogError@plt>
mov    -0x60(%rbp),%rdi
call   10c0 <freeaddrinfo@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143c <Multicast_send_socket+0x28c>
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <isMulticast@plt>
cmp    $0x0,%rax
jge    13a9 <Multicast_send_socket+0x1f9>
mov    0x2c6a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd4c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rsi
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1080 <LogError@plt>
mov    -0x60(%rbp),%rdi
call   10c0 <freeaddrinfo@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143c <Multicast_send_socket+0x28c>
mov    -0x68(%rbp),%edi
call   1070 <close@plt>
mov    -0x58(%rbp),%rax
mov    (%rax),%edi
mov    0x2c2a(%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   10a0 <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    142d <Multicast_send_socket+0x27d>
mov    -0x68(%rbp),%edi
call   1070 <close@plt>
mov    -0x60(%rbp),%rdi
call   10c0 <freeaddrinfo@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143c <Multicast_send_socket+0x28c>
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     125a <Multicast_send_socket+0xaa>
mov    %rsi,%rbx
test   %rsi,%rsi
je     125a <Multicast_send_socket+0xaa>
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     1281 <Multicast_send_socket+0xd1>
mov    %eax,%ebp
mov    0x2db7(%rip),%rax
mov    (%rax),%ebx
mov    %ebp,%edi
call   1050 <gai_strerror@plt>
lea    0xe16(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %ebp,%edi
call   1050 <gai_strerror@plt>
lea    0xe16(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <LogError@plt>
jmp    12ed <Multicast_send_socket+0x13d>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xd96(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xdac(%rip),%rdi
xor    %eax,%eax
call   1080 <LogError@plt>
jmp    12ed <Multicast_send_socket+0x13d>
mov    (%rsp),%r14
test   %r14,%r14
je     12b4 <Multicast_send_socket+0x104>
mov    %r14,%rax
nopl   (%rax)
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    1303 <Multicast_send_socket+0x153>
mov    0x10(%rax),%rax
mov    %rax,(%rsp)
test   %rax,%rax
jne    1290 <Multicast_send_socket+0xe0>
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xdc9(%rip),%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <LogError@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     1372 <Multicast_send_socket+0x1c2>
mov    %ebp,%edi
call   1070 <close@plt>
mov    (%rsp),%rax
mov    (%rax),%edi
mov    0x2cc3(%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   10a0 <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     13a2 <Multicast_send_socket+0x1f2>
mov    %r14,%rdi
call   10c0 <freeaddrinfo@plt>
jmp    12f2 <Multicast_send_socket+0x142>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
lea    0xd45(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xd52(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <LogError@plt>
jmp    12e5 <Multicast_send_socket+0x135>
mov    %ebx,%edi
call   1070 <close@plt>
jmp    12e5 <Multicast_send_socket+0x135>

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

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"
@.str.1 = [35 x i8] c"hostname and 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"
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 %18, 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 = tail call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %90
18: ; preds = %6
%19 = call i32 @memset(%struct.addrinfo* %7, i32 0, i32 32)
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 0
store i32 %2, i32* %20
%21 = load i32, i32* @SOCK_DGRAM
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 5
store i32 %21, i32* %22
%23 = call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %7, %struct.addrinfo** %8)
%24 = icmp eq i32 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = call i8* @gai_strerror(i32 %23)
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = call i8* @gai_strerror(i32 %23)
%30 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %90
31: ; preds = %18
%32 = load %struct.addrinfo*, %struct.addrinfo** %8
%33 = icmp eq %struct.addrinfo* %32, null
br i1 %33, label %49, label %34
34: ; preds = %31, %45
%35 = phi %struct.addrinfo* [ %47, %45 ], [ %32, %31 ]
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %35, i64 0, i32 0
%37 = load i32, i32* %36
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %35, i64 0, i32 5
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %35, i64 0, i32 4
%41 = load i32, i32* %40
%42 = call i32 @socket(i32 %37, i32 %39, i32 %41)
%43 = icmp slt i32 %42, 0
%44 = load %struct.addrinfo*, %struct.addrinfo** %8
br i1 %43, label %45, label %54
45: ; preds = %34
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i64 0, i32 3
%47 = load %struct.addrinfo*, %struct.addrinfo** %46
store %struct.addrinfo* %47, %struct.addrinfo** %8
%48 = icmp eq %struct.addrinfo* %47, null
br i1 %48, label %49, label %34
49: ; preds = %45, %31
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %1)
%52 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %0, i8* %1)
%53 = call i32 @freeaddrinfo(%struct.addrinfo* %32)
br label %90
54: ; preds = %34
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i64 0, i32 2
%56 = load i64, i64* %55
%57 = inttoptr i64 %56 to %struct.sockaddr_storage*
%58 = call i64 @isMulticast(%struct.sockaddr_storage* %57)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %54
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* %0)
%63 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %0)
%64 = call i32 @freeaddrinfo(%struct.addrinfo* %32)
br label %90
65: ; preds = %54
%66 = call i32 @close(i32 %42)
%67 = load %struct.addrinfo*, %struct.addrinfo** %8
%68 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %67, i64 0, i32 0
%69 = load i32, i32* %68
%70 = load i32, i32* @SOCK_DGRAM
%71 = call i32 @socket(i32 %69, i32 %70, i32 0)
%72 = load %struct.addrinfo*, %struct.addrinfo** %8
%73 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %72, i64 0, i32 1
%74 = load i32, i32* %73
store i32 %74, i32* %5
%75 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %72, i64 0, i32 2
%76 = load i64, i64* %75
%77 = load i32, i32* %73
%78 = call i32 @memcpy(%struct.sockaddr_storage* %4, i64 %76, i32 %77)
%79 = load %struct.addrinfo*, %struct.addrinfo** %8
%80 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %79, i64 0, i32 2
%81 = load i64, i64* %80
%82 = inttoptr i64 %81 to %struct.sockaddr_storage*
%83 = call i64 @joinGroup(i32 %71, i32 1, i32 1, %struct.sockaddr_storage* %82)
%84 = icmp slt i64 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %65
%86 = call i32 @close(i32 %71)
%87 = call i32 @freeaddrinfo(%struct.addrinfo* %32)
br label %90
88: ; preds = %65
%89 = call i32 @freeaddrinfo(%struct.addrinfo* %32)
br label %90
90: ; preds = %88, %85, %60, %49, %25, %14
%91 = phi i32 [ -1, %25 ], [ -1, %49 ], [ -1, %60 ], [ -1, %85 ], [ %71, %88 ], [ -1, %14 ]
ret i32 %91
}