#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 msghdr {
  int msg_namelen;
  int msg_iovlen;
  char *msg_control;
  int msg_controllen;
  char *msg_flags;
  struct sockaddr_storage *msg_name;
  struct iovec *msg_iov;
};
struct iovec {
  char *iov_base;
  int iov_len;
};
struct addrinfo {
  int ai_flags;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
};
typedef scalar_t__ ssize_t;
typedef int /*<<< orphan*/ src_addr;
typedef int /*<<< orphan*/ n;
typedef int /*<<< orphan*/ hints;
typedef int /*<<< orphan*/ control;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int AI_ADDRCONFIG;
int AI_PASSIVE;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
scalar_t__ bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ recvmsg(int, struct msghdr *, int /*<<< orphan*/);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, scalar_t__);
int main(void) {
  int fd, n, err, i;
  char buffer[548];
  struct sockaddr_storage src_addr;
  struct iovec iov[1];
  struct msghdr message;
  char control[72];
  const char *hostname = 0;
  const char *portname = "1234";
  struct addrinfo hints;
  struct addrinfo *res = 0;
  iov[0].iov_base = buffer;
  iov[0].iov_len = sizeof(buffer);
  message.msg_name = &src_addr;
  message.msg_namelen = sizeof(src_addr);
  message.msg_iov = iov;
  message.msg_iovlen = 1;
  message.msg_control = control;
  message.msg_controllen = sizeof(control);
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_protocol = 0;
  hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
  err = getaddrinfo(hostname, portname, &hints, &res);
  if (err != 0) {
    perror("Could not resolve addr");
    exit(1);
  }
  fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  n = 1;
  setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n));
  if (bind(fd, res->ai_addr, res->ai_addrlen) < 0) {
    perror("bind");
    exit(1);
  }
  ssize_t recv_count;
  recv_count = recvmsg(fd, &message, 0);
  if (recv_count < 0)
    perror("recving failed");
  printf("got msg: %zd  flags %d\n", recv_count, message.msg_flags);
  printf("control: %zu\n", message.msg_controllen);
  for (i = 0; i < message.msg_namelen; i++)
    printf("%x ", ((char *)message.msg_name)[i]);
  printf("\n");
  for (i = 0; i < message.msg_iovlen; i++)
    printf("{%zu, %s}, ", iov[i].iov_len, (char *)iov[i].iov_base);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x320,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x2e8(%rbp)
lea    0xe3c(%rip),%rax
mov    %rax,-0x2f0(%rbp)
movq   $0x0,-0x318(%rbp)
lea    -0x240(%rbp),%rax
mov    %rax,-0x260(%rbp)
movl   $0x224,-0x258(%rbp)
lea    -0x248(%rbp),%rax
mov    %rax,-0x270(%rbp)
movl   $0x4,-0x290(%rbp)
lea    -0x260(%rbp),%rax
mov    %rax,-0x268(%rbp)
movl   $0x1,-0x28c(%rbp)
lea    -0x2e0(%rbp),%rax
mov    %rax,-0x288(%rbp)
movl   $0x48,-0x280(%rbp)
lea    -0x310(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2f4(%rbp)
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2f8(%rbp)
movq   $0x0,-0x300(%rbp)
mov    0x2d67(%rip),%rax
mov    (%rax),%eax
mov    0x2d2e(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x310(%rbp)
mov    -0x2e8(%rbp),%rdi
mov    -0x2f0(%rbp),%rsi
lea    -0x310(%rbp),%rdx
lea    -0x318(%rbp),%rcx
call   10b0 <getaddrinfo@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     12ce <main+0x12e>
lea    0xd46(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x318(%rbp),%rax
mov    0x1c(%rax),%edi
mov    -0x318(%rbp),%rax
mov    0x18(%rax),%esi
mov    -0x318(%rbp),%rax
mov    0x10(%rax),%rdx
call   10c0 <socket@plt>
mov    %eax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ce2(%rip),%rax
mov    (%rax),%esi
mov    0x2cb1(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    -0x8(%rbp),%edi
mov    -0x318(%rbp),%rax
mov    0x8(%rax),%esi
mov    -0x318(%rbp),%rax
mov    0x4(%rax),%edx
call   1080 <bind@plt>
cmp    $0x0,%rax
jge    135c <main+0x1bc>
lea    0xccf(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x290(%rbp),%rsi
xor    %edx,%edx
call   1070 <recvmsg@plt>
mov    %rax,-0x320(%rbp)
cmpq   $0x0,-0x320(%rbp)
jge    138e <main+0x1ee>
lea    0xc98(%rip),%rdi
call   1090 <perror@plt>
mov    -0x320(%rbp),%rsi
mov    -0x278(%rbp),%rdx
lea    0xc8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x280(%rbp),%esi
lea    0xc91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x290(%rbp),%eax
jge    13ff <main+0x25f>
mov    -0x270(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xc6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13c5 <main+0x225>
lea    0xc40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x28c(%rbp),%eax
jge    1469 <main+0x2c9>
movslq -0x14(%rbp),%rcx
lea    -0x260(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%esi
movslq -0x14(%rbp),%rcx
lea    -0x260(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rdx
lea    0xc06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1414 <main+0x274>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x320,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x300,%rsp
movq   $0x0,(%rsp)
lea    0xd0(%rsp),%rax
mov    %rax,0x10(%rsp)
movl   $0x224,0x18(%rsp)
lea    0x58(%rsp),%rax
mov    %rax,0x48(%rsp)
movabs $0x100000004,%rax
mov    %rax,0x28(%rsp)
lea    0x10(%rsp),%rax
mov    %rax,0x50(%rsp)
lea    0x80(%rsp),%rax
mov    %rax,0x30(%rsp)
movl   $0x48,0x38(%rsp)
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x7c(%rsp)
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x78(%rsp)
movq   $0x0,0x70(%rsp)
mov    0x2d92(%rip),%rax
mov    0x2d5b(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %ecx,0x60(%rsp)
lea    0xd9c(%rip),%rsi
mov    %rsp,%rcx
xor    %edi,%edi
mov    %rbx,%rdx
call   10c0 <getaddrinfo@plt>
test   %eax,%eax
jne    13b3 <main+0x203>
mov    (%rsp),%rax
mov    0x1c(%rax),%edi
mov    0x18(%rax),%esi
mov    0x10(%rax),%rdx
call   10d0 <socket@plt>
mov    %eax,%r14d
movl   $0x1,0xc(%rsp)
mov    0x2d4a(%rip),%rax
mov    (%rax),%esi
mov    0x2d19(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %r14d,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    (%rsp),%rax
mov    0x4(%rax),%edx
mov    0x8(%rax),%esi
mov    %r14d,%edi
call   1090 <bind@plt>
test   %rax,%rax
js     13bc <main+0x20c>
lea    0x28(%rsp),%rsi
mov    %r14d,%edi
xor    %edx,%edx
call   1080 <recvmsg@plt>
mov    %rax,%rbx
test   %rax,%rax
js     13a2 <main+0x1f2>
mov    0x40(%rsp),%rdx
lea    0xd32(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x38(%rsp),%esi
lea    0xd35(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x28(%rsp)
jle    1351 <main+0x1a1>
lea    0xd2e(%rip),%rbx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    0x48(%rsp),%rax
movsbl (%rax,%rbp,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
movslq 0x28(%rsp),%rax
cmp    %rax,%rbp
jl     1330 <main+0x180>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x2c(%rsp)
jle    138c <main+0x1dc>
lea    0xcf1(%rip),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    0x18(%rsp),%esi
mov    0x10(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    0x2c(%rsp),%ebp
jl     1370 <main+0x1c0>
mov    %r14d,%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x300,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xc78(%rip),%rdi
call   10a0 <perror@plt>
jmp    12f2 <main+0x142>
lea    0xc4b(%rip),%rdi
jmp    13c3 <main+0x213>
lea    0xc59(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.iovec = type { i8*, i32 }
%struct.msghdr = type { i32, i32, i8*, i32, i8*, %struct.sockaddr_storage*, %struct.iovec* }
%struct.addrinfo = type { i32, i32, i32, i64, i32, i32 }
@.str = [5 x i8] c"1234\00"
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_PASSIVE = global i32 0
@AI_ADDRCONFIG = global i32 0
@.str.1 = [23 x i8] c"Could not resolve addr\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [5 x i8] c"bind\00"
@.str.3 = [15 x i8] c"recving failed\00"
@.str.4 = [24 x i8] c"got msg: %zd flags %d\0A\00"
@.str.5 = [14 x i8] c"control: %zu\0A\00"
@.str.6 = [4 x i8] c"%x \00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [12 x i8] c"{%zu, %s}, \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [548 x i8]
%7 = alloca %struct.sockaddr_storage
%8 = alloca [1 x %struct.iovec]
%9 = alloca %struct.msghdr
%10 = alloca [72 x i8]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca %struct.addrinfo
%14 = alloca %struct.addrinfo*
%15 = alloca i64
store i32 0, i32* %1
store i8* null, i8** %11
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %12
store %struct.addrinfo* null, %struct.addrinfo** %14
%16 = getelementptr inbounds [548 x i8], [548 x i8]* %6, i64 0, i64 0
%17 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %8, i64 0, i64 0
%18 = getelementptr inbounds %struct.iovec, %struct.iovec* %17, i32 0, i32 0
store i8* %16, i8** %18
%19 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %8, i64 0, i64 0
%20 = getelementptr inbounds %struct.iovec, %struct.iovec* %19, i32 0, i32 1
store i32 548, i32* %20
%21 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 5
store %struct.sockaddr_storage* %7, %struct.sockaddr_storage** %21
%22 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 0
store i32 4, i32* %22
%23 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %8, i64 0, i64 0
%24 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 6
store %struct.iovec* %23, %struct.iovec** %24
%25 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 1
store i32 1, i32* %25
%26 = getelementptr inbounds [72 x i8], [72 x i8]* %10, i64 0, i64 0
%27 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 2
store i8* %26, i8** %27
%28 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 3
store i32 72, i32* %28
%29 = call i32 @memset(%struct.addrinfo* %13, i32 0, i32 32)
%30 = load i32, i32* @AF_UNSPEC
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %13, i32 0, i32 5
store i32 %30, i32* %31
%32 = load i32, i32* @SOCK_DGRAM
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %13, i32 0, i32 4
store i32 %32, i32* %33
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %13, i32 0, i32 3
store i64 0, i64* %34
%35 = load i32, i32* @AI_PASSIVE
%36 = load i32, i32* @AI_ADDRCONFIG
%37 = or i32 %35, %36
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %13, i32 0, i32 0
store i32 %37, i32* %38
%39 = load i8*, i8** %11
%40 = load i8*, i8** %12
%41 = call i32 @getaddrinfo(i8* %39, i8* %40, %struct.addrinfo* %13, %struct.addrinfo** %14)
store i32 %41, i32* %4
%42 = load i32, i32* %4
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %0
%45 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %0
%48 = load %struct.addrinfo*, %struct.addrinfo** %14
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %48, i32 0, i32 5
%50 = load i32, i32* %49
%51 = load %struct.addrinfo*, %struct.addrinfo** %14
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %51, i32 0, i32 4
%53 = load i32, i32* %52
%54 = load %struct.addrinfo*, %struct.addrinfo** %14
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %54, i32 0, i32 3
%56 = load i64, i64* %55
%57 = call i32 @socket(i32 %50, i32 %53, i64 %56)
store i32 %57, i32* %2
store i32 1, i32* %3
%58 = load i32, i32* %2
%59 = load i32, i32* @SOL_SOCKET
%60 = load i32, i32* @SO_REUSEADDR
%61 = call i32 @setsockopt(i32 %58, i32 %59, i32 %60, i32* %3, i32 4)
%62 = load i32, i32* %2
%63 = load %struct.addrinfo*, %struct.addrinfo** %14
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %63, i32 0, i32 2
%65 = load i32, i32* %64
%66 = load %struct.addrinfo*, %struct.addrinfo** %14
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %66, i32 0, i32 1
%68 = load i32, i32* %67
%69 = call i64 @bind(i32 %62, i32 %65, i32 %68)
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %47
%72 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %47
%75 = load i32, i32* %2
%76 = call i64 @recvmsg(i32 %75, %struct.msghdr* %9, i32 0)
store i64 %76, i64* %15
%77 = load i64, i64* %15
%78 = icmp slt i64 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %74
%80 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %81
81: ; preds = %79, %74
%82 = load i64, i64* %15
%83 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 4
%84 = load i8*, i8** %83
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i64 %82, i8* %84)
%86 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 3
%87 = load i32, i32* %86
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %87)
store i32 0, i32* %5
br label %89
89: ; preds = %104, %81
%90 = load i32, i32* %5
%91 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 0
%92 = load i32, i32* %91
%93 = icmp slt i32 %90, %92
br i1 %93, label %94, label %107
94: ; preds = %89
%95 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 5
%96 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %95
%97 = bitcast %struct.sockaddr_storage* %96 to i8*
%98 = load i32, i32* %5
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %97, i64 %99
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %102)
br label %104
104: ; preds = %94
%105 = load i32, i32* %5
%106 = add nsw i32 %105, 1
store i32 %106, i32* %5
br label %89
107: ; preds = %89
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %5
br label %109
109: ; preds = %126, %107
%110 = load i32, i32* %5
%111 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 1
%112 = load i32, i32* %111
%113 = icmp slt i32 %110, %112
br i1 %113, label %114, label %129
114: ; preds = %109
%115 = load i32, i32* %5
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %8, i64 0, i64 %116
%118 = getelementptr inbounds %struct.iovec, %struct.iovec* %117, i32 0, i32 1
%119 = load i32, i32* %118
%120 = load i32, i32* %5
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %8, i64 0, i64 %121
%123 = getelementptr inbounds %struct.iovec, %struct.iovec* %122, i32 0, i32 0
%124 = load i8*, i8** %123
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i32 %119, i8* %124)
br label %126
126: ; preds = %114
%127 = load i32, i32* %5
%128 = add nsw i32 %127, 1
store i32 %128, i32* %5
br label %109
129: ; preds = %109
%130 = load i32, i32* %2
%131 = call i32 @close(i32 %130)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.iovec = type { i8*, i32 }
%struct.msghdr = type { i32, i32, i8*, i32, i8*, %struct.sockaddr_storage*, %struct.iovec* }
%struct.addrinfo = type { i32, i32, i32, i64, i32, i32 }
@.str = [5 x i8] c"1234\00"
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_PASSIVE = global i32 0
@AI_ADDRCONFIG = global i32 0
@.str.1 = [23 x i8] c"Could not resolve addr\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [5 x i8] c"bind\00"
@.str.3 = [15 x i8] c"recving failed\00"
@.str.4 = [24 x i8] c"got msg: %zd flags %d\0A\00"
@.str.5 = [14 x i8] c"control: %zu\0A\00"
@.str.6 = [4 x i8] c"%x \00"
@.str.8 = [12 x i8] c"{%zu, %s}, \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [548 x i8]
%3 = alloca %struct.sockaddr_storage
%4 = alloca [1 x %struct.iovec]
%5 = alloca %struct.msghdr
%6 = alloca [72 x i8]
%7 = alloca %struct.addrinfo
%8 = alloca %struct.addrinfo*
%9 = bitcast i32* %1 to i8*
%10 = getelementptr inbounds [548 x i8], [548 x i8]* %2, i64 0, i64 0
%11 = bitcast %struct.sockaddr_storage* %3 to i8*
%12 = bitcast [1 x %struct.iovec]* %4 to i8*
%13 = bitcast %struct.msghdr* %5 to i8*
%14 = getelementptr inbounds [72 x i8], [72 x i8]* %6, i64 0, i64 0
%15 = bitcast %struct.addrinfo* %7 to i8*
%16 = bitcast %struct.addrinfo** %8 to i8*
store %struct.addrinfo* null, %struct.addrinfo** %8
%17 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %4, i64 0, i64 0
%18 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %4, i64 0, i64 0, i32 0
store i8* %10, i8** %18
%19 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %4, i64 0, i64 0, i32 1
store i32 548, i32* %19
%20 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 5
store %struct.sockaddr_storage* %3, %struct.sockaddr_storage** %20
%21 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 0
store i32 4, i32* %21
%22 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 6
store %struct.iovec* %17, %struct.iovec** %22
%23 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 1
store i32 1, i32* %23
%24 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 2
store i8* %14, i8** %24
%25 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 3
store i32 72, i32* %25
%26 = call i32 @memset(%struct.addrinfo* %7, i32 0, i32 32)
%27 = load i32, i32* @AF_UNSPEC
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 5
store i32 %27, i32* %28
%29 = load i32, i32* @SOCK_DGRAM
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 4
store i32 %29, i32* %30
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 3
store i64 0, i64* %31
%32 = load i32, i32* @AI_PASSIVE
%33 = load i32, i32* @AI_ADDRCONFIG
%34 = or i32 %33, %32
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 0
store i32 %34, i32* %35
%36 = call i32 @getaddrinfo(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %7, %struct.addrinfo** %8)
%37 = icmp eq i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %0
%39 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %0
%42 = load %struct.addrinfo*, %struct.addrinfo** %8
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i64 0, i32 5
%44 = load i32, i32* %43
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i64 0, i32 4
%46 = load i32, i32* %45
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i64 0, i32 3
%48 = load i64, i64* %47
%49 = call i32 @socket(i32 %44, i32 %46, i64 %48)
store i32 1, i32* %1
%50 = load i32, i32* @SOL_SOCKET
%51 = load i32, i32* @SO_REUSEADDR
%52 = call i32 @setsockopt(i32 %49, i32 %50, i32 %51, i32* %1, i32 4)
%53 = load %struct.addrinfo*, %struct.addrinfo** %8
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i64 0, i32 2
%55 = load i32, i32* %54
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i64 0, i32 1
%57 = load i32, i32* %56
%58 = call i64 @bind(i32 %49, i32 %55, i32 %57)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %41
%61 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %41
%64 = call i64 @recvmsg(i32 %49, %struct.msghdr* %5, i32 0)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %63
%67 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %68
68: ; preds = %66, %63
%69 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 4
%70 = load i8*, i8** %69
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i64 %64, i8* %70)
%72 = load i32, i32* %25
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %72)
%74 = load i32, i32* %21
%75 = icmp sgt i32 %74, 0
br i1 %75, label %76, label %89
76: ; preds = %68
%77 = bitcast %struct.sockaddr_storage** %20 to i8**
br label %78
78: ; preds = %76, %78
%79 = phi i64 [ 0, %76 ], [ %85, %78 ]
%80 = load i8*, i8** %77
%81 = getelementptr inbounds i8, i8* %80, i64 %79
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %83)
%85 = add nuw nsw i64 %79, 1
%86 = load i32, i32* %21
%87 = sext i32 %86 to i64
%88 = icmp slt i64 %85, %87
br i1 %88, label %78, label %89
89: ; preds = %78, %68
%90 = call i32 @putchar(i32 10)
%91 = load i32, i32* %23
%92 = icmp sgt i32 %91, 0
br i1 %92, label %93, label %101
93: ; preds = %89, %93
%94 = phi i32 [ %98, %93 ], [ 0, %89 ]
%95 = load i32, i32* %19
%96 = load i8*, i8** %18
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i32 %95, i8* %96)
%98 = add nuw nsw i32 %94, 1
%99 = load i32, i32* %23
%100 = icmp slt i32 %98, %99
br i1 %100, label %93, label %101
101: ; preds = %93, %89
%102 = call i32 @close(i32 %49)
ret i32 0
}