#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 */
typedef int /*<<< orphan*/ wmem_size;
struct sockaddr_storage {
  int dummy;
};
struct addrinfo {
  int ai_family;
  int ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  struct addrinfo *ai_next;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int /*<<< orphan*/ LogError(char *, ...);
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_SNDBUF;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
scalar_t__ geteuid();
int /*<<< orphan*/ getsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              unsigned int *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(struct sockaddr_storage *, int /*<<< orphan*/, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              unsigned int *, int);
int socket(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int Unicast_send_socket(const char *hostname, const char *sendport, int family,
                        unsigned int wmem_size, struct sockaddr_storage *addr,
                        int *addrlen) {
  struct addrinfo hints, *res, *ressave;
  int n, sockfd;
  unsigned int wmem_actual;
  socklen_t optlen;
  if (!hostname || !sendport) {
    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;
  n = getaddrinfo(hostname, sendport, &hints, &res);
  if (n < 0) {
    fprintf(stderr, "getaddrinfo error: [%s]\n", strerror(errno));
    return -1;
  }
  ressave = res;
  sockfd = -1;
  while (res) {
    sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
    if (!(sockfd < 0)) {
      if (connect(sockfd, res->ai_addr, res->ai_addrlen) == 0) {
        close(sockfd);
        sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
        break;
      }
      close(sockfd);
      sockfd = -1;
    }
    res = res->ai_next;
  }
  if (sockfd < 0) {
    freeaddrinfo(ressave);
    fprintf(stderr,
            "Send socket error: could not open the requested socket: %s\n",
            strerror(errno));
    LogError("Send socket error: could not open the requested socket: %s",
             strerror(errno));
    return -1;
  }
  *addrlen = res->ai_addrlen;
  memcpy(addr, res->ai_addr, res->ai_addrlen);
  freeaddrinfo(ressave);
  if (wmem_size > 0) {
    if (geteuid() == 0) {
      setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &wmem_size, sizeof(wmem_size));
      getsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &wmem_actual, &optlen);
      if (wmem_size != wmem_actual) {
        printf("Warning: Socket write buffer size requested: %u set: %u\n",
               wmem_size, wmem_actual);
      }
    } else {
      printf("Warning: Socket buffer size can only be changed by root!\n");
    }
  }
  return sockfd;
}


x86 assembly (clang, -O0):
<Unicast_send_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)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1217 <Unicast_send_socket+0x37>
cmpq   $0x0,-0x18(%rbp)
jne    1248 <Unicast_send_socket+0x68>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1090 <LogError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14a7 <Unicast_send_socket+0x2c7>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    0x2d73(%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   10d0 <getaddrinfo@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jge    12c6 <Unicast_send_socket+0xe6>
mov    0x2d35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x74(%rbp),%edi
mov    %rax,%rdx
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14a7 <Unicast_send_socket+0x2c7>
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
movl   $0xffffffff,-0x68(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     136f <Unicast_send_socket+0x18f>
mov    -0x58(%rbp),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rax
mov    0x1c(%rax),%esi
mov    -0x58(%rbp),%rax
mov    0x18(%rax),%edx
call   1100 <socket@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x68(%rbp)
jl     135e <Unicast_send_socket+0x17e>
mov    -0x68(%rbp),%edi
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%esi
mov    -0x58(%rbp),%rax
mov    0x4(%rax),%edx
call   10c0 <connect@plt>
cmp    $0x0,%rax
jne    134f <Unicast_send_socket+0x16f>
mov    -0x68(%rbp),%edi
call   1070 <close@plt>
mov    -0x58(%rbp),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rax
mov    0x1c(%rax),%esi
mov    -0x58(%rbp),%rax
mov    0x18(%rax),%edx
call   1100 <socket@plt>
mov    %eax,-0x68(%rbp)
jmp    136f <Unicast_send_socket+0x18f>
mov    -0x68(%rbp),%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x68(%rbp)
mov    -0x58(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    12d5 <Unicast_send_socket+0xf5>
cmpl   $0x0,-0x68(%rbp)
jge    13db <Unicast_send_socket+0x1fb>
mov    -0x60(%rbp),%rdi
call   10f0 <freeaddrinfo@plt>
mov    0x2c3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
mov    0x2c2b(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x78(%rbp),%edi
mov    %rax,%rdx
lea    0xcb7(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c09(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rsi
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1090 <LogError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14a7 <Unicast_send_socket+0x2c7>
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),%esi
mov    -0x58(%rbp),%rax
mov    0x4(%rax),%edx
call   10b0 <memcpy@plt>
mov    -0x60(%rbp),%rdi
call   10f0 <freeaddrinfo@plt>
cmpl   $0x0,-0x20(%rbp)
jbe    14a1 <Unicast_send_socket+0x2c1>
mov    $0x0,%al
call   1060 <geteuid@plt>
cmp    $0x0,%rax
jne    148e <Unicast_send_socket+0x2ae>
mov    -0x68(%rbp),%edi
mov    0x2bbb(%rip),%rax
mov    (%rax),%esi
mov    0x2baa(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    -0x68(%rbp),%edi
mov    0x2b97(%rip),%rax
mov    (%rax),%esi
mov    0x2b86(%rip),%rax
mov    (%rax),%edx
lea    -0x6c(%rbp),%rcx
lea    -0x70(%rbp),%r8
call   1080 <getsockopt@plt>
mov    -0x20(%rbp),%eax
cmp    -0x6c(%rbp),%eax
je     1489 <Unicast_send_socket+0x2a9>
mov    -0x20(%rbp),%esi
mov    -0x6c(%rbp),%edx
lea    0xc55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    149c <Unicast_send_socket+0x2bc>
lea    0xc7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14a1 <Unicast_send_socket+0x2c1>
mov    -0x68(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Unicast_send_socket>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %ecx,0x10(%rsp)
test   %rdi,%rdi
je     1330 <Unicast_send_socket+0x140>
mov    %rsi,%rbp
test   %rsi,%rsi
je     1330 <Unicast_send_socket+0x140>
mov    %r9,%r15
mov    %ecx,%r13d
mov    %edx,%r12d
mov    %rdi,%rbx
mov    %r8,0x18(%rsp)
lea    0x28(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    %r12d,0x28(%rsp)
mov    0x2d90(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x44(%rsp)
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
js     13a5 <Unicast_send_socket+0x1b5>
mov    0x8(%rsp),%r12
test   %r12,%r12
je     1357 <Unicast_send_socket+0x167>
mov    %r12,%rax
jmp    1297 <Unicast_send_socket+0xa7>
nopl   0x0(%rax)
mov    0x8(%rsp),%rax
mov    0x10(%rax),%rax
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1357 <Unicast_send_socket+0x167>
mov    0x1c(%rax),%esi
mov    (%rax),%edi
mov    0x18(%rax),%edx
call   1110 <socket@plt>
test   %eax,%eax
js     1280 <Unicast_send_socket+0x90>
mov    %eax,%ebx
mov    0x8(%rsp),%rax
mov    0x4(%rax),%edx
mov    0x8(%rax),%esi
mov    %ebx,%edi
call   10d0 <connect@plt>
mov    %rax,%rbp
mov    %ebx,%edi
call   1080 <close@plt>
test   %rbp,%rbp
jne    1280 <Unicast_send_socket+0x90>
mov    0x8(%rsp),%rax
mov    0x1c(%rax),%esi
mov    (%rax),%edi
mov    0x18(%rax),%edx
call   1110 <socket@plt>
test   %eax,%eax
js     1357 <Unicast_send_socket+0x167>
mov    %eax,%ebp
mov    0x8(%rsp),%rax
mov    0x4(%rax),%ecx
mov    %ecx,(%r15)
mov    0x4(%rax),%edx
mov    0x8(%rax),%esi
mov    0x18(%rsp),%rdi
call   10c0 <memcpy@plt>
mov    %r12,%rdi
call   1100 <freeaddrinfo@plt>
test   %r13d,%r13d
je     13d4 <Unicast_send_socket+0x1e4>
xor    %eax,%eax
call   1070 <geteuid@plt>
test   %rax,%rax
je     13e5 <Unicast_send_socket+0x1f5>
lea    0xdea(%rip),%rdi
call   1030 <puts@plt>
jmp    13d4 <Unicast_send_socket+0x1e4>
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
lea    0xcc0(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xcd6(%rip),%rdi
xor    %eax,%eax
call   10a0 <LogError@plt>
jmp    13cf <Unicast_send_socket+0x1df>
mov    %r12,%rdi
call   1100 <freeaddrinfo@plt>
mov    0x2c62(%rip),%rax
mov    (%rax),%ebx
mov    0x2c51(%rip),%rbp
mov    0x0(%rbp),%edi
call   10f0 <strerror@plt>
lea    0xce2(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x0(%rbp),%edi
call   10f0 <strerror@plt>
lea    0xd03(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10a0 <LogError@plt>
jmp    13cf <Unicast_send_socket+0x1df>
mov    0x2c1c(%rip),%rax
mov    (%rax),%ebx
mov    0x2c0b(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xc84(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bfc(%rip),%r14
mov    (%r14),%esi
mov    0x2bea(%rip),%rbx
mov    (%rbx),%edx
lea    0x10(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    (%r14),%esi
mov    (%rbx),%edx
lea    0x14(%rsp),%rcx
lea    0x24(%rsp),%r8
mov    %ebp,%edi
call   1090 <getsockopt@plt>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
cmp    %edx,%esi
je     13d4 <Unicast_send_socket+0x1e4>
lea    0xca4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    13d4 <Unicast_send_socket+0x1e4>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i32, %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 = [25 x i8] c"getaddrinfo error: [%s]\0A\00"
@errno = global i32 0
@.str.3 = [60 x i8] c"Send socket error: could not open the requested socket: %s\0A\00"
@.str.4 = [59 x i8] c"Send socket error: could not open the requested socket: %s\00"
@SOL_SOCKET = global i32 0
@SO_SNDBUF = global i32 0
@.str.5 = [57 x i8] c"Warning: Socket write buffer size requested: %u set: %u\0A\00"
@.str.6 = [58 x i8] c"Warning: Socket buffer size can only be changed by root!\0A\00"
define i32 @Unicast_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
%19 = alloca i32
%20 = 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
%21 = load i8*, i8** %8
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %6
%24 = load i8*, i8** %9
%25 = icmp ne i8* %24, null
br i1 %25, label %30, label %26
26: ; preds = %23, %6
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%29 = 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 %149
30: ; preds = %23
%31 = call i32 @memset(%struct.addrinfo* %14, i32 0, i32 32)
%32 = load i32, i32* %10
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %14, i32 0, i32 0
store i32 %32, i32* %33
%34 = load i32, i32* @SOCK_DGRAM
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %14, i32 0, i32 5
store i32 %34, i32* %35
%36 = load i8*, i8** %8
%37 = load i8*, i8** %9
%38 = call i32 @getaddrinfo(i8* %36, i8* %37, %struct.addrinfo* %14, %struct.addrinfo** %15)
store i32 %38, i32* %17
%39 = load i32, i32* %17
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %30
%42 = load i32, i32* @stderr
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %44)
store i32 -1, i32* %7
br label %149
46: ; preds = %30
%47 = load %struct.addrinfo*, %struct.addrinfo** %15
store %struct.addrinfo* %47, %struct.addrinfo** %16
store i32 -1, i32* %18
br label %48
48: ; preds = %90, %46
%49 = load %struct.addrinfo*, %struct.addrinfo** %15
%50 = icmp ne %struct.addrinfo* %49, null
br i1 %50, label %51, label %94
51: ; preds = %48
%52 = load %struct.addrinfo*, %struct.addrinfo** %15
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %52, i32 0, i32 0
%54 = load i32, i32* %53
%55 = load %struct.addrinfo*, %struct.addrinfo** %15
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i32 0, i32 5
%57 = load i32, i32* %56
%58 = load %struct.addrinfo*, %struct.addrinfo** %15
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 4
%60 = load i32, i32* %59
%61 = call i32 @socket(i32 %54, i32 %57, i32 %60)
store i32 %61, i32* %18
%62 = load i32, i32* %18
%63 = icmp slt i32 %62, 0
br i1 %63, label %90, label %64
64: ; preds = %51
%65 = load i32, i32* %18
%66 = load %struct.addrinfo*, %struct.addrinfo** %15
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %66, i32 0, i32 2
%68 = load i32, i32* %67
%69 = load %struct.addrinfo*, %struct.addrinfo** %15
%70 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %69, i32 0, i32 1
%71 = load i32, i32* %70
%72 = call i64 @connect(i32 %65, i32 %68, i32 %71)
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %87
74: ; preds = %64
%75 = load i32, i32* %18
%76 = call i32 @close(i32 %75)
%77 = load %struct.addrinfo*, %struct.addrinfo** %15
%78 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %77, i32 0, i32 0
%79 = load i32, i32* %78
%80 = load %struct.addrinfo*, %struct.addrinfo** %15
%81 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %80, i32 0, i32 5
%82 = load i32, i32* %81
%83 = load %struct.addrinfo*, %struct.addrinfo** %15
%84 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %83, i32 0, i32 4
%85 = load i32, i32* %84
%86 = call i32 @socket(i32 %79, i32 %82, i32 %85)
store i32 %86, i32* %18
br label %94
87: ; preds = %64
%88 = load i32, i32* %18
%89 = call i32 @close(i32 %88)
store i32 -1, i32* %18
br label %90
90: ; preds = %87, %51
%91 = load %struct.addrinfo*, %struct.addrinfo** %15
%92 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %91, i32 0, i32 3
%93 = load %struct.addrinfo*, %struct.addrinfo** %92
store %struct.addrinfo* %93, %struct.addrinfo** %15
br label %48
94: ; preds = %74, %48
%95 = load i32, i32* %18
%96 = icmp slt i32 %95, 0
br i1 %96, label %97, label %107
97: ; preds = %94
%98 = load %struct.addrinfo*, %struct.addrinfo** %16
%99 = call i32 @freeaddrinfo(%struct.addrinfo* %98)
%100 = load i32, i32* @stderr
%101 = load i32, i32* @errno
%102 = call i8* @strerror(i32 %101)
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0), i8* %102)
%104 = load i32, i32* @errno
%105 = call i8* @strerror(i32 %104)
%106 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0), i8* %105)
store i32 -1, i32* %7
br label %149
107: ; preds = %94
%108 = load %struct.addrinfo*, %struct.addrinfo** %15
%109 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %108, i32 0, i32 1
%110 = load i32, i32* %109
%111 = load i32*, i32** %13
store i32 %110, i32* %111
%112 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %12
%113 = load %struct.addrinfo*, %struct.addrinfo** %15
%114 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %113, i32 0, i32 2
%115 = load i32, i32* %114
%116 = load %struct.addrinfo*, %struct.addrinfo** %15
%117 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %116, i32 0, i32 1
%118 = load i32, i32* %117
%119 = call i32 @memcpy(%struct.sockaddr_storage* %112, i32 %115, i32 %118)
%120 = load %struct.addrinfo*, %struct.addrinfo** %16
%121 = call i32 @freeaddrinfo(%struct.addrinfo* %120)
%122 = load i32, i32* %11
%123 = icmp ugt i32 %122, 0
br i1 %123, label %124, label %147
124: ; preds = %107
%125 = call i64 (...) @geteuid()
%126 = icmp eq i64 %125, 0
br i1 %126, label %127, label %144
127: ; preds = %124
%128 = load i32, i32* %18
%129 = load i32, i32* @SOL_SOCKET
%130 = load i32, i32* @SO_SNDBUF
%131 = call i32 @setsockopt(i32 %128, i32 %129, i32 %130, i32* %11, i32 4)
%132 = load i32, i32* %18
%133 = load i32, i32* @SOL_SOCKET
%134 = load i32, i32* @SO_SNDBUF
%135 = call i32 @getsockopt(i32 %132, i32 %133, i32 %134, i32* %19, i32* %20)
%136 = load i32, i32* %11
%137 = load i32, i32* %19
%138 = icmp ne i32 %136, %137
br i1 %138, label %139, label %143
139: ; preds = %127
%140 = load i32, i32* %11
%141 = load i32, i32* %19
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i32 %140, i32 %141)
br label %143
143: ; preds = %139, %127
br label %146
144: ; preds = %124
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0))
br label %146
146: ; preds = %144, %143
br label %147
147: ; preds = %146, %107
%148 = load i32, i32* %18
store i32 %148, i32* %7
br label %149
149: ; preds = %147, %97, %41, %26
%150 = load i32, i32* %7
ret i32 %150
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i32, %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 = [25 x i8] c"getaddrinfo error: [%s]\0A\00"
@errno = global i32 0
@.str.3 = [60 x i8] c"Send socket error: could not open the requested socket: %s\0A\00"
@.str.4 = [59 x i8] c"Send socket error: could not open the requested socket: %s\00"
@SOL_SOCKET = global i32 0
@SO_SNDBUF = global i32 0
@.str.5 = [57 x i8] c"Warning: Socket write buffer size requested: %u set: %u\0A\00"
@str = [57 x i8] c"Warning: Socket buffer size can only be changed by root!\00"
define i32 @Unicast_send_socket(i8* %0, i8* %1, i32 %2, i32 %3, %struct.sockaddr_storage* %4, i32* nocapture writeonly %5) {
%7 = alloca i32
%8 = alloca %struct.addrinfo
%9 = alloca %struct.addrinfo*
%10 = alloca i32
%11 = alloca i32
store i32 %3, i32* %7
%12 = bitcast %struct.addrinfo* %8 to i8*
%13 = bitcast %struct.addrinfo** %9 to i8*
%14 = bitcast i32* %10 to i8*
%15 = bitcast i32* %11 to i8*
%16 = icmp ne i8* %0, null
%17 = icmp ne i8* %1, null
%18 = and i1 %16, %17
br i1 %18, label %23, label %19
19: ; preds = %6
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%22 = tail call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %108
23: ; preds = %6
%24 = call i32 @memset(%struct.addrinfo* %8, i32 0, i32 32)
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 0
store i32 %2, i32* %25
%26 = load i32, i32* @SOCK_DGRAM
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 5
store i32 %26, i32* %27
%28 = call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %8, %struct.addrinfo** %9)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %33)
br label %108
35: ; preds = %23
%36 = load %struct.addrinfo*, %struct.addrinfo** %9
%37 = icmp eq %struct.addrinfo* %36, null
br i1 %37, label %72, label %38
38: ; preds = %35, %57
%39 = phi %struct.addrinfo* [ %60, %57 ], [ %36, %35 ]
%40 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 0
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 5
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 4
%45 = load i32, i32* %44
%46 = call i32 @socket(i32 %41, i32 %43, i32 %45)
%47 = icmp slt i32 %46, 0
br i1 %47, label %57, label %48
48: ; preds = %38
%49 = load %struct.addrinfo*, %struct.addrinfo** %9
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %49, i64 0, i32 2
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %49, i64 0, i32 1
%53 = load i32, i32* %52
%54 = call i64 @connect(i32 %46, i32 %51, i32 %53)
%55 = icmp eq i64 %54, 0
%56 = call i32 @close(i32 %46)
br i1 %55, label %62, label %57
57: ; preds = %48, %38
%58 = load %struct.addrinfo*, %struct.addrinfo** %9
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i64 0, i32 3
%60 = load %struct.addrinfo*, %struct.addrinfo** %59
store %struct.addrinfo* %60, %struct.addrinfo** %9
%61 = icmp eq %struct.addrinfo* %60, null
br i1 %61, label %72, label %38
62: ; preds = %48
%63 = load %struct.addrinfo*, %struct.addrinfo** %9
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %63, i64 0, i32 0
%65 = load i32, i32* %64
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %63, i64 0, i32 5
%67 = load i32, i32* %66
%68 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %63, i64 0, i32 4
%69 = load i32, i32* %68
%70 = call i32 @socket(i32 %65, i32 %67, i32 %69)
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %81
72: ; preds = %57, %35, %62
%73 = call i32 @freeaddrinfo(%struct.addrinfo* %36)
%74 = load i32, i32* @stderr
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0), i8* %76)
%78 = load i32, i32* @errno
%79 = call i8* @strerror(i32 %78)
%80 = call i32 (i8*, ...) @LogError(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0), i8* %79)
br label %108
81: ; preds = %62
%82 = load %struct.addrinfo*, %struct.addrinfo** %9
%83 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %82, i64 0, i32 1
%84 = load i32, i32* %83
store i32 %84, i32* %5
%85 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %82, i64 0, i32 2
%86 = load i32, i32* %85
%87 = load i32, i32* %83
%88 = call i32 @memcpy(%struct.sockaddr_storage* %4, i32 %86, i32 %87)
%89 = call i32 @freeaddrinfo(%struct.addrinfo* %36)
%90 = icmp eq i32 %3, 0
br i1 %90, label %108, label %91
91: ; preds = %81
%92 = call i64 (...) @geteuid()
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %106
94: ; preds = %91
%95 = load i32, i32* @SOL_SOCKET
%96 = load i32, i32* @SO_SNDBUF
%97 = call i32 @setsockopt(i32 %70, i32 %95, i32 %96, i32* %7, i32 4)
%98 = load i32, i32* @SOL_SOCKET
%99 = load i32, i32* @SO_SNDBUF
%100 = call i32 @getsockopt(i32 %70, i32 %98, i32 %99, i32* %10, i32* %11)
%101 = load i32, i32* %7
%102 = load i32, i32* %10
%103 = icmp eq i32 %101, %102
br i1 %103, label %108, label %104
104: ; preds = %94
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i32 %101, i32 %102)
br label %108
106: ; preds = %91
%107 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
br label %108
108: ; preds = %81, %94, %104, %106, %72, %30, %19
%109 = phi i32 [ -1, %30 ], [ -1, %72 ], [ -1, %19 ], [ %70, %106 ], [ %70, %104 ], [ %70, %94 ], [ %70, %81 ]
ret i32 %109
}