#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 */
struct sockaddr_storage {
  int dummy;
};
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_addr;
  void *sin6_port;
  int /*<<< orphan*/ sin6_family;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ opt;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AF_INET6;
scalar_t__ AddDropMulticastMembership(int, char const *, int,
                                      int /*<<< orphan*/);
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ PF_INET6;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
void *htons(int);
int /*<<< orphan*/ in6addr_any;
int /*<<< orphan*/ memset(struct sockaddr_storage *, int /*<<< orphan*/, int);
int /*<<< orphan*/ set_non_blocking(int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int OpenAndConfSSDPReceiveSocket(int n_listen_addr, const char **listen_addr,
                                 int ipv6) {
  int s;
  int opt = 1;
  struct sockaddr_storage sockname;
  socklen_t sockname_len;
  if ((s = socket(ipv6 ? PF_INET6 : PF_INET, SOCK_DGRAM, 0)) < 0) {
    syslog(LOG_ERR, "socket(udp): %m");
    return -1;
  }
  if (!set_non_blocking(s)) {
    syslog(LOG_WARNING, "Failed to set SSDP socket non blocking : %m");
  }
  memset(&sockname, 0, sizeof(struct sockaddr_storage));
  if (ipv6) {
    struct sockaddr_in6 *sa = (struct sockaddr_in6 *)&sockname;
    sa->sin6_family = AF_INET6;
    sa->sin6_port = htons((1900));
    sa->sin6_addr = in6addr_any;
    sockname_len = sizeof(struct sockaddr_in6);
  } else {
    struct sockaddr_in *sa = (struct sockaddr_in *)&sockname;
    sa->sin_family = AF_INET;
    sa->sin_port = htons((1900));
    sa->sin_addr.s_addr = htonl(INADDR_ANY);
    sockname_len = sizeof(struct sockaddr_in);
  }
  if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
    syslog(LOG_WARNING, "setsockopt(SO_REUSEADDR): %m");
  }
  if (bind(s, (struct sockaddr *)&sockname, sockname_len) < 0) {
    syslog(LOG_ERR, "bind(udp%s): %m", ipv6 ? "6" : "");
    close(s);
    return -1;
  }
  while (n_listen_addr > 0) {
    n_listen_addr--;
    if (AddDropMulticastMembership(s, listen_addr[n_listen_addr], ipv6, 0) <
        0) {
      syslog(LOG_WARNING,
             "Failed to add IPv%d multicast membership for interface %s.",
             ipv6 ? 6 : 4, listen_addr[n_listen_addr]);
    }
  }
  return s;
}


x86 assembly (clang, -O0):
<OpenAndConfSSDPReceiveSocket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11d4 <OpenAndConfSSDPReceiveSocket+0x34>
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
jmp    11e0 <OpenAndConfSSDPReceiveSocket+0x40>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
mov    0x2dd6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1222 <OpenAndConfSSDPReceiveSocket+0x82>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1413 <OpenAndConfSSDPReceiveSocket+0x273>
mov    -0x18(%rbp),%edi
call   10b0 <set_non_blocking@plt>
cmp    $0x0,%eax
jne    124a <OpenAndConfSSDPReceiveSocket+0xaa>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <memset@plt>
cmpl   $0x0,-0x14(%rbp)
je     12ac <OpenAndConfSSDPReceiveSocket+0x10c>
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2d3d(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    $0x76c,%edi
call   1040 <htons@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    0x2d58(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x18,-0x24(%rbp)
jmp    12f6 <OpenAndConfSSDPReceiveSocket+0x156>
lea    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x2d15(%rip),%rax
mov    (%rax),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    $0x76c,%edi
call   1040 <htons@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x18,-0x24(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2ce0(%rip),%rax
mov    (%rax),%esi
mov    0x2c8f(%rip),%rax
mov    (%rax),%edx
lea    -0x1c(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    133b <OpenAndConfSSDPReceiveSocket+0x19b>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
lea    0xd08(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   10a0 <bind@plt>
cmp    $0x0,%rax
jge    1397 <OpenAndConfSSDPReceiveSocket+0x1f7>
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%ecx
lea    0xd3e(%rip),%rdx
lea    0xcfb(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xcdd(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1413 <OpenAndConfSSDPReceiveSocket+0x273>
jmp    139c <OpenAndConfSSDPReceiveSocket+0x1fc>
cmpl   $0x0,-0x8(%rbp)
jle    140d <OpenAndConfSSDPReceiveSocket+0x26d>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x14(%rbp),%edx
xor    %ecx,%ecx
call   1070 <AddDropMulticastMembership@plt>
cmp    $0x0,%rax
jge    1408 <OpenAndConfSSDPReceiveSocket+0x268>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%ecx
mov    $0x4,%edx
mov    $0x6,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xc6a(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
jmp    139c <OpenAndConfSSDPReceiveSocket+0x1fc>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OpenAndConfSSDPReceiveSocket>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r13
mov    %edi,%r15d
movl   $0x1,0x4(%rsp)
test   %edx,%edx
jne    11c9 <OpenAndConfSSDPReceiveSocket+0x29>
mov    0x2dd9(%rip),%rax
jmp    11d0 <OpenAndConfSSDPReceiveSocket+0x30>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
test   %eax,%eax
js     1240 <OpenAndConfSSDPReceiveSocket+0xa0>
mov    %eax,%ebx
mov    %eax,%edi
call   10b0 <set_non_blocking@plt>
test   %eax,%eax
jne    120a <OpenAndConfSSDPReceiveSocket+0x6a>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
lea    0xe0d(%rip),%rsi
xor    %eax,%eax
call   1090 <syslog@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <memset@plt>
test   %r14d,%r14d
je     125c <OpenAndConfSSDPReceiveSocket+0xbc>
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    $0x76c,%edi
call   1040 <htons@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
jmp    1281 <OpenAndConfSSDPReceiveSocket+0xe1>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    0xdb0(%rip),%rsi
xor    %eax,%eax
call   1090 <syslog@plt>
jmp    1378 <OpenAndConfSSDPReceiveSocket+0x1d8>
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    $0x76c,%edi
call   1040 <htons@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,(%rsp)
mov    0x2d55(%rip),%rax
mov    (%rax),%esi
mov    0x2d04(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    12c4 <OpenAndConfSSDPReceiveSocket+0x124>
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
lea    0xd7f(%rip),%rsi
xor    %eax,%eax
call   1090 <syslog@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x18,%edx
call   10a0 <bind@plt>
test   %rax,%rax
js     1345 <OpenAndConfSSDPReceiveSocket+0x1a5>
test   %r15d,%r15d
jle    137d <OpenAndConfSSDPReceiveSocket+0x1dd>
xor    %eax,%eax
test   %r14d,%r14d
setne  %al
lea    (%rax,%rax,1),%r12d
add    $0x4,%r12d
mov    %r15d,%ebp
add    $0x1,%rbp
jmp    130a <OpenAndConfSSDPReceiveSocket+0x16a>
nopw   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
jbe    137d <OpenAndConfSSDPReceiveSocket+0x1dd>
lea    -0x2(%rbp),%r15d
mov    0x0(%r13,%r15,8),%rsi
mov    %ebx,%edi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1070 <AddDropMulticastMembership@plt>
test   %rax,%rax
jns    1300 <OpenAndConfSSDPReceiveSocket+0x160>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13,%r15,8),%rcx
lea    0xd32(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1090 <syslog@plt>
jmp    1300 <OpenAndConfSSDPReceiveSocket+0x160>
test   %r14d,%r14d
mov    0x2c39(%rip),%rax
mov    (%rax),%edi
lea    0xd4d(%rip),%rax
lea    0xd0a(%rip),%rdx
cmove  %rax,%rdx
lea    0xcef(%rip),%rsi
xor    %eax,%eax
call   1090 <syslog@plt>
mov    %ebx,%edi
call   1080 <close@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr_in6 = type { i32, i8*, i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET6 = global i32 0
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@LOG_ERR = global i32 0
@.str = [16 x i8] c"socket(udp): %m\00"
@LOG_WARNING = global i32 0
@.str.1 = [44 x i8] c"Failed to set SSDP socket non blocking : %m\00"
@AF_INET6 = global i32 0
@in6addr_any = global i32 0
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [29 x i8] c"setsockopt(SO_REUSEADDR): %m\00"
@.str.3 = [16 x i8] c"bind(udp%s): %m\00"
@.str.4 = [2 x i8] c"6\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [59 x i8] c"Failed to add IPv%d multicast membership for interface %s.\00"
define i32 @OpenAndConfSSDPReceiveSocket(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_storage
%11 = alloca i32
%12 = alloca %struct.sockaddr_in6*
%13 = alloca %struct.sockaddr_in*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i32 1, i32* %9
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load i32, i32* @PF_INET6
br label %20
18: ; preds = %3
%19 = load i32, i32* @PF_INET
br label %20
20: ; preds = %18, %16
%21 = phi i32 [ %17, %16 ], [ %19, %18 ]
%22 = load i32, i32* @SOCK_DGRAM
%23 = call i32 @socket(i32 %21, i32 %22, i32 0)
store i32 %23, i32* %8
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32, i32* @LOG_ERR
%27 = call i32 (i32, i8*, ...) @syslog(i32 %26, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %118
28: ; preds = %20
%29 = load i32, i32* %8
%30 = call i32 @set_non_blocking(i32 %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %28
%33 = load i32, i32* @LOG_WARNING
%34 = call i32 (i32, i8*, ...) @syslog(i32 %33, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %32, %28
%36 = call i32 @memset(%struct.sockaddr_storage* %10, i32 0, i32 4)
%37 = load i32, i32* %7
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %50
39: ; preds = %35
%40 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr_in6*
store %struct.sockaddr_in6* %40, %struct.sockaddr_in6** %12
%41 = load i32, i32* @AF_INET6
%42 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %12
%43 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %42, i32 0, i32 2
store i32 %41, i32* %43
%44 = call i8* @htons(i32 1900)
%45 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %12
%46 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %45, i32 0, i32 1
store i8* %44, i8** %46
%47 = load i32, i32* @in6addr_any
%48 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %12
%49 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %48, i32 0, i32 0
store i32 %47, i32* %49
store i32 24, i32* %11
br label %63
50: ; preds = %35
%51 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr_in*
store %struct.sockaddr_in* %51, %struct.sockaddr_in** %13
%52 = load i32, i32* @AF_INET
%53 = load %struct.sockaddr_in*, %struct.sockaddr_in** %13
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %53, i32 0, i32 2
store i32 %52, i32* %54
%55 = call i8* @htons(i32 1900)
%56 = load %struct.sockaddr_in*, %struct.sockaddr_in** %13
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %56, i32 0, i32 1
store i8* %55, i8** %57
%58 = load i32, i32* @INADDR_ANY
%59 = call i32 @htonl(i32 %58)
%60 = load %struct.sockaddr_in*, %struct.sockaddr_in** %13
%61 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %60, i32 0, i32 0
%62 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %61, i32 0, i32 0
store i32 %59, i32* %62
store i32 24, i32* %11
br label %63
63: ; preds = %50, %39
%64 = load i32, i32* %8
%65 = load i32, i32* @SOL_SOCKET
%66 = load i32, i32* @SO_REUSEADDR
%67 = call i64 @setsockopt(i32 %64, i32 %65, i32 %66, i32* %9, i32 4)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %63
%70 = load i32, i32* @LOG_WARNING
%71 = call i32 (i32, i8*, ...) @syslog(i32 %70, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %72
72: ; preds = %69, %63
%73 = load i32, i32* %8
%74 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr*
%75 = load i32, i32* %11
%76 = call i64 @bind(i32 %73, %struct.sockaddr* %74, i32 %75)
%77 = icmp slt i64 %76, 0
br i1 %77, label %78, label %87
78: ; preds = %72
%79 = load i32, i32* @LOG_ERR
%80 = load i32, i32* %7
%81 = icmp ne i32 %80, 0
%82 = zext i1 %81 to i64
%83 = select i1 %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0)
%84 = call i32 (i32, i8*, ...) @syslog(i32 %79, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %83)
%85 = load i32, i32* %8
%86 = call i32 @close(i32 %85)
store i32 -1, i32* %4
br label %118
87: ; preds = %72
br label %88
88: ; preds = %115, %87
%89 = load i32, i32* %5
%90 = icmp sgt i32 %89, 0
br i1 %90, label %91, label %116
91: ; preds = %88
%92 = load i32, i32* %5
%93 = add nsw i32 %92, -1
store i32 %93, i32* %5
%94 = load i32, i32* %8
%95 = load i8**, i8*** %6
%96 = load i32, i32* %5
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8*, i8** %95, i64 %97
%99 = load i8*, i8** %98
%100 = load i32, i32* %7
%101 = call i64 @AddDropMulticastMembership(i32 %94, i8* %99, i32 %100, i32 0)
%102 = icmp slt i64 %101, 0
br i1 %102, label %103, label %115
103: ; preds = %91
%104 = load i32, i32* @LOG_WARNING
%105 = load i32, i32* %7
%106 = icmp ne i32 %105, 0
%107 = zext i1 %106 to i64
%108 = select i1 %106, i32 6, i32 4
%109 = load i8**, i8*** %6
%110 = load i32, i32* %5
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8*, i8** %109, i64 %111
%113 = load i8*, i8** %112
%114 = call i32 (i32, i8*, ...) @syslog(i32 %104, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.6, i64 0, i64 0), i32 %108, i8* %113)
br label %115
115: ; preds = %103, %91
br label %88
116: ; preds = %88
%117 = load i32, i32* %8
store i32 %117, i32* %4
br label %118
118: ; preds = %116, %78, %25
%119 = load i32, i32* %4
ret i32 %119
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET6 = global i32 0
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@LOG_ERR = global i32 0
@.str = [16 x i8] c"socket(udp): %m\00"
@LOG_WARNING = global i32 0
@.str.1 = [44 x i8] c"Failed to set SSDP socket non blocking : %m\00"
@AF_INET6 = global i32 0
@in6addr_any = global i32 0
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [29 x i8] c"setsockopt(SO_REUSEADDR): %m\00"
@.str.3 = [16 x i8] c"bind(udp%s): %m\00"
@.str.4 = [2 x i8] c"6\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [59 x i8] c"Failed to add IPv%d multicast membership for interface %s.\00"
define i32 @OpenAndConfSSDPReceiveSocket(i32 %0, i8** nocapture %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.sockaddr_storage
%6 = bitcast i32* %4 to i8*
store i32 1, i32* %4
%7 = bitcast %struct.sockaddr_storage* %5 to i8*
%8 = icmp eq i32 %2, 0
%9 = load i32, i32* @PF_INET6
%10 = load i32, i32* @PF_INET
%11 = select i1 %8, i32 %10, i32 %9
%12 = load i32, i32* @SOCK_DGRAM
%13 = tail call i32 @socket(i32 %11, i32 %12, i32 0)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = load i32, i32* @LOG_ERR
%17 = tail call i32 (i32, i8*, ...) @syslog(i32 %16, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %75
18: ; preds = %3
%19 = tail call i32 @set_non_blocking(i32 %13)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @LOG_WARNING
%23 = tail call i32 (i32, i8*, ...) @syslog(i32 %22, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21, %18
%25 = call i32 @memset(%struct.sockaddr_storage* %5, i32 0, i32 4)
br i1 %8, label %31, label %26
26: ; preds = %24
%27 = load i32, i32* @AF_INET6
%28 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 4, i32 0
store i32 %27, i32* %28
%29 = call i8* @htons(i32 1900)
%30 = load i32, i32* @in6addr_any
br label %37
31: ; preds = %24
%32 = load i32, i32* @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 4, i32 0
store i32 %32, i32* %33
%34 = call i8* @htons(i32 1900)
%35 = load i32, i32* @INADDR_ANY
%36 = call i32 @htonl(i32 %35)
br label %37
37: ; preds = %31, %26
%38 = phi i32 [ %36, %31 ], [ %30, %26 ]
%39 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 0, i32 0
store i32 %38, i32* %39
%40 = load i32, i32* @SOL_SOCKET
%41 = load i32, i32* @SO_REUSEADDR
%42 = call i64 @setsockopt(i32 %13, i32 %40, i32 %41, i32* %4, i32 4)
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %37
%45 = load i32, i32* @LOG_WARNING
%46 = call i32 (i32, i8*, ...) @syslog(i32 %45, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %47
47: ; preds = %44, %37
%48 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
%49 = call i64 @bind(i32 %13, %struct.sockaddr* %48, i32 24)
%50 = icmp slt i64 %49, 0
br i1 %50, label %56, label %51
51: ; preds = %47
%52 = icmp sgt i32 %0, 0
br i1 %52, label %53, label %75
53: ; preds = %51
%54 = select i1 %8, i32 4, i32 6
%55 = zext i32 %0 to i64
br label %61
56: ; preds = %47
%57 = load i32, i32* @LOG_ERR
%58 = select i1 %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%59 = call i32 (i32, i8*, ...) @syslog(i32 %57, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %58)
%60 = call i32 @close(i32 %13)
br label %75
61: ; preds = %53, %73
%62 = phi i64 [ %55, %53 ], [ %63, %73 ]
%63 = add nsw i64 %62, -1
%64 = and i64 %63, 4294967295
%65 = getelementptr inbounds i8*, i8** %1, i64 %64
%66 = load i8*, i8** %65
%67 = call i64 @AddDropMulticastMembership(i32 %13, i8* %66, i32 %2, i32 0)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %61
%70 = load i32, i32* @LOG_WARNING
%71 = load i8*, i8** %65
%72 = call i32 (i32, i8*, ...) @syslog(i32 %70, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.6, i64 0, i64 0), i32 %54, i8* %71)
br label %73
73: ; preds = %69, %61
%74 = icmp ugt i64 %62, 1
br i1 %74, label %61, label %75
75: ; preds = %73, %51, %56, %15
%76 = phi i32 [ -1, %15 ], [ -1, %56 ], [ %13, %51 ], [ %13, %73 ]
ret i32 %76
}