#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 sockaddr {
  int dummy;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ *ai_addr;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  struct addrinfo *ai_next;
  int /*<<< orphan*/ *ai_canonname;
  int /*<<< orphan*/ ai_flags;
};
typedef int ssize_t;
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ EXIT_FAILURE;
int NI_MAXHOST;
int NI_MAXSERV;
int /*<<< orphan*/ NI_NUMERICSERV;
int /*<<< orphan*/ SOCK_DGRAM;
scalar_t__ bind(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(int /*<<< orphan*/ *, char *, struct addrinfo *,
                struct addrinfo **);
int getnameinfo(struct sockaddr *, int, char *, int, char *, int,
                int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
scalar_t__ sendto(int, char const *, scalar_t__, int /*<<< orphan*/,
                  struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strlen(char const *);
int main(int argc, char *argv[]) {
  struct addrinfo hints;
  struct addrinfo *result, *rp;
  int sfd, s;
  struct sockaddr_storage peer_addr;
  socklen_t peer_addr_len;
  ssize_t nread;
  char buf[500];
  const char *RESPONSE = "OK_RECEIVED";
  if (argc != 2) {
    fprintf(stderr, "Usage: %s port\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = AI_PASSIVE;
  hints.ai_protocol = 0;
  hints.ai_canonname = NULL;
  hints.ai_addr = NULL;
  hints.ai_next = NULL;
  s = getaddrinfo(NULL, argv[1], &hints, &result);
  if (s != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
    exit(EXIT_FAILURE);
  }
  for (rp = result; rp != NULL; rp = rp->ai_next) {
    sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
    if (sfd == -1)
      continue;
    if (bind(sfd, rp->ai_addr, rp->ai_addrlen) == 0)
      break;
    close(sfd);
  }
  if (rp == NULL) {
    fprintf(stderr, "Could not bind\n");
    exit(EXIT_FAILURE);
  }
  freeaddrinfo(result);
  for (;;) {
    peer_addr_len = sizeof(struct sockaddr_storage);
    nread = recvfrom(sfd, buf, 500, 0, (struct sockaddr *)&peer_addr,
                     &peer_addr_len);
    if (nread == -1)
      continue;
    char host[NI_MAXHOST], service[NI_MAXSERV];
    s = getnameinfo((struct sockaddr *)&peer_addr, peer_addr_len, host,
                    NI_MAXHOST, service, NI_MAXSERV, NI_NUMERICSERV);
    if (s == 0) {
      printf("Received %ld bytes from (%s, %s):\n", (long)nread, host, service);
      printf("%s\n", buf);
      fflush(stdout);
    } else
      fprintf(stderr, "getnameinfo: %s\n", gai_strerror(s));
    if (sendto(sfd, RESPONSE, strlen(RESPONSE), 0,
               (struct sockaddr *)&peer_addr,
               peer_addr_len) != strlen(RESPONSE))
      fprintf(stderr, "Error sending response\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdf0(%rip),%rax
mov    %rax,-0x278(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     124d <main+0x5d>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1060 <memset@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2d58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x48(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   10f0 <getaddrinfo@plt>
mov    %eax,-0x60(%rbp)
cmpl   $0x0,-0x60(%rbp)
je     1303 <main+0x113>
mov    0x2cea(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x294(%rbp)
mov    -0x60(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x294(%rbp),%edi
mov    %rax,%rdx
lea    0xd2e(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2cb4(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1381 <main+0x191>
mov    -0x58(%rbp),%rax
mov    0x1c(%rax),%edi
mov    -0x58(%rbp),%rax
mov    0x18(%rax),%esi
mov    -0x58(%rbp),%rax
mov    0x10(%rax),%rdx
call   1110 <socket@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0xffffffff,-0x5c(%rbp)
jne    1343 <main+0x153>
jmp    1370 <main+0x180>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x58(%rbp),%rax
mov    (%rax),%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
jne    1368 <main+0x178>
jmp    1381 <main+0x191>
mov    -0x5c(%rbp),%edi
call   1080 <close@plt>
mov    -0x58(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    130b <main+0x11b>
cmpq   $0x0,-0x58(%rbp)
jne    13b1 <main+0x1c1>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
lea    0xc91(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c06(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x50(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
movl   $0x4,-0x6c(%rbp)
mov    -0x5c(%rbp),%edi
lea    -0x270(%rbp),%rsi
lea    -0x68(%rbp),%r8
mov    $0x1f4,%edx
xor    %ecx,%ecx
lea    -0x6c(%rbp),%r9
call   10c0 <recvfrom@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0xffffffff,-0x70(%rbp)
jne    13f1 <main+0x201>
jmp    13ba <main+0x1ca>
mov    0x2ba8(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x280(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x2a8(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x288(%rbp)
mov    0x2ba3(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r8
sub    %rcx,%r8
mov    %r8,-0x2a0(%rbp)
mov    %r8,%rsp
mov    %rax,-0x290(%rbp)
lea    -0x68(%rbp),%rdi
mov    -0x6c(%rbp),%esi
mov    0x2b41(%rip),%rax
mov    (%rax),%ecx
mov    0x2b68(%rip),%rax
mov    (%rax),%r9d
mov    0x2b76(%rip),%rax
mov    (%rax),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1090 <getnameinfo@plt>
add    $0x10,%rsp
mov    %eax,-0x60(%rbp)
cmpl   $0x0,-0x60(%rbp)
jne    14d9 <main+0x2e9>
mov    -0x2a0(%rbp),%rcx
mov    -0x2a8(%rbp),%rdx
movslq -0x70(%rbp),%rsi
lea    0xb93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x270(%rbp),%rsi
lea    0xbae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2adb(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1507 <main+0x317>
mov    0x2ad8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2ac(%rbp)
mov    -0x60(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x2ac(%rbp),%edi
mov    %rax,%rdx
lea    0xb60(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x2c4(%rbp)
mov    -0x278(%rbp),%rax
mov    %rax,-0x2c0(%rbp)
mov    -0x278(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x2c4(%rbp),%edi
mov    -0x2c0(%rbp),%rsi
mov    %rax,%rdx
lea    -0x68(%rbp),%r8
mov    -0x6c(%rbp),%r9d
xor    %ecx,%ecx
call   1070 <sendto@plt>
mov    %rax,-0x2b8(%rbp)
mov    -0x278(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x2b8(%rbp),%rax
cmp    %rcx,%rax
je     1586 <main+0x396>
mov    0x2a42(%rip),%rax
mov    (%rax),%edi
lea    0xaf2(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x280(%rbp),%rax
mov    %rax,%rsp
jmp    13ba <main+0x1ca>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x248,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    142d <main+0x23d>
lea    -0x78(%rbp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1060 <memset@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    0x2d92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
xorps  %xmm0,%xmm0
movups %xmm0,-0x70(%rbp)
movups %xmm0,-0x58(%rbp)
mov    0x8(%rbx),%rsi
lea    -0x38(%rbp),%rcx
xor    %edi,%edi
mov    %r14,%rdx
call   10f0 <getaddrinfo@plt>
test   %eax,%eax
jne    1442 <main+0x252>
mov    -0x38(%rbp),%rbx
jmp    1284 <main+0x94>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x20(%rbx),%rbx
test   %rbx,%rbx
je     1408 <main+0x218>
mov    0x1c(%rbx),%edi
mov    0x18(%rbx),%esi
mov    0x10(%rbx),%rdx
call   1110 <socket@plt>
cmp    $0xffffffff,%eax
je     1280 <main+0x90>
mov    %eax,%r15d
mov    0x8(%rbx),%rsi
mov    (%rbx),%edx
mov    %eax,%edi
call   10d0 <bind@plt>
test   %rax,%rax
je     12c0 <main+0xd0>
mov    %r15d,%edi
call   1080 <close@plt>
jmp    1280 <main+0x90>
mov    -0x38(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
lea    -0x30(%rbp),%rbx
jmp    12d4 <main+0xe4>
nop
mov    -0x40(%rbp),%rsp
movl   $0x4,-0x2c(%rbp)
mov    %r15d,%edi
lea    -0x270(%rbp),%rsi
mov    $0x1f4,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
lea    -0x2c(%rbp),%r9
call   10c0 <recvfrom@plt>
cmp    $0xffffffff,%eax
je     12d4 <main+0xe4>
mov    %eax,%r13d
mov    %rsp,-0x40(%rbp)
mov    0x2c95(%rip),%rcx
mov    (%rcx),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    0x2cab(%rip),%rax
mov    (%rax),%r9d
mov    %rsp,%r14
mov    %r9,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x2c(%rbp),%esi
mov    (%rcx),%ecx
mov    0x2ca0(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %r14,%r8
push   %rax
call   1090 <getnameinfo@plt>
add    $0x10,%rsp
test   %eax,%eax
je     1390 <main+0x1a0>
mov    0x2c4c(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1050 <gai_strerror@plt>
mov    %ebx,%edi
lea    0xce2(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    13c1 <main+0x1d1>
nopw   0x0(%rax,%rax,1)
movslq %r13d,%rsi
lea    0xca3(%rip),%rdi
mov    %r12,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x270(%rbp),%rdi
call   1030 <puts@plt>
mov    0x2bee(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
mov    -0x2c(%rbp),%r9d
mov    $0xb,%edx
mov    %r15d,%edi
lea    0xc2c(%rip),%rsi
xor    %ecx,%ecx
lea    -0x30(%rbp),%rbx
mov    %rbx,%r8
call   1070 <sendto@plt>
cmp    $0xb,%rax
je     12d0 <main+0xe0>
mov    0x2bc5(%rip),%rax
mov    (%rax),%edi
lea    0xc75(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    12d0 <main+0xe0>
mov    0x2ba9(%rip),%rax
mov    (%rax),%edi
lea    0xc15(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2b8a(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2b84(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xbcc(%rip),%rsi
jmp    145e <main+0x26e>
mov    0x2b6f(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1050 <gai_strerror@plt>
lea    0xbc3(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    141f <main+0x22f>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32*, i64, i32, i32, %struct.addrinfo*, i32*, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"OK_RECEIVED\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"Usage: %s port\0A\00"
@EXIT_FAILURE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_PASSIVE = global i32 0
@.str.2 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.3 = [16 x i8] c"Could not bind\0A\00"
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@NI_NUMERICSERV = global i32 0
@.str.4 = [35 x i8] c"Received %ld bytes from (%s, %s):\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@stdout = global i32 0
@.str.6 = [17 x i8] c"getnameinfo: %s\0A\00"
@.str.7 = [24 x i8] c"Error sending response\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.addrinfo
%7 = alloca %struct.addrinfo*
%8 = alloca %struct.addrinfo*
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.sockaddr_storage
%12 = alloca i32
%13 = alloca i32
%14 = alloca [500 x i8]
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %15
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 2
br i1 %20, label %21, label %29
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %2
%30 = call i32 @memset(%struct.addrinfo* %6, i32 0, i32 56)
%31 = load i32, i32* @AF_UNSPEC
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 4
store i32 %31, i32* %32
%33 = load i32, i32* @SOCK_DGRAM
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 3
store i32 %33, i32* %34
%35 = load i32, i32* @AI_PASSIVE
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 7
store i32 %35, i32* %36
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 2
store i64 0, i64* %37
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 6
store i32* null, i32** %38
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 1
store i32* null, i32** %39
%40 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 5
store %struct.addrinfo* null, %struct.addrinfo** %40
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 @getaddrinfo(i32* null, i8* %43, %struct.addrinfo* %6, %struct.addrinfo** %7)
store i32 %44, i32* %10
%45 = load i32, i32* %10
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %54
47: ; preds = %29
%48 = load i32, i32* @stderr
%49 = load i32, i32* %10
%50 = call i8* @gai_strerror(i32 %49)
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %50)
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %29
%55 = load %struct.addrinfo*, %struct.addrinfo** %7
store %struct.addrinfo* %55, %struct.addrinfo** %8
br label %56
56: ; preds = %87, %54
%57 = load %struct.addrinfo*, %struct.addrinfo** %8
%58 = icmp ne %struct.addrinfo* %57, null
br i1 %58, label %59, label %91
59: ; preds = %56
%60 = load %struct.addrinfo*, %struct.addrinfo** %8
%61 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %60, i32 0, i32 4
%62 = load i32, i32* %61
%63 = load %struct.addrinfo*, %struct.addrinfo** %8
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %63, i32 0, i32 3
%65 = load i32, i32* %64
%66 = load %struct.addrinfo*, %struct.addrinfo** %8
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %66, i32 0, i32 2
%68 = load i64, i64* %67
%69 = call i32 @socket(i32 %62, i32 %65, i64 %68)
store i32 %69, i32* %9
%70 = load i32, i32* %9
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %73
72: ; preds = %59
br label %87
73: ; preds = %59
%74 = load i32, i32* %9
%75 = load %struct.addrinfo*, %struct.addrinfo** %8
%76 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i32 0, i32 1
%77 = load i32*, i32** %76
%78 = load %struct.addrinfo*, %struct.addrinfo** %8
%79 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %78, i32 0, i32 0
%80 = load i32, i32* %79
%81 = call i64 @bind(i32 %74, i32* %77, i32 %80)
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %84
83: ; preds = %73
br label %91
84: ; preds = %73
%85 = load i32, i32* %9
%86 = call i32 @close(i32 %85)
br label %87
87: ; preds = %84, %72
%88 = load %struct.addrinfo*, %struct.addrinfo** %8
%89 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %88, i32 0, i32 5
%90 = load %struct.addrinfo*, %struct.addrinfo** %89
store %struct.addrinfo* %90, %struct.addrinfo** %8
br label %56
91: ; preds = %83, %56
%92 = load %struct.addrinfo*, %struct.addrinfo** %8
%93 = icmp eq %struct.addrinfo* %92, null
br i1 %93, label %94, label %99
94: ; preds = %91
%95 = load i32, i32* @stderr
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%97 = load i32, i32* @EXIT_FAILURE
%98 = call i32 @exit(i32 %97)
unreachable
99: ; preds = %91
%100 = load %struct.addrinfo*, %struct.addrinfo** %7
%101 = call i32 @freeaddrinfo(%struct.addrinfo* %100)
br label %102
102: ; preds = %153, %109, %99
store i32 4, i32* %12
%103 = load i32, i32* %9
%104 = getelementptr inbounds [500 x i8], [500 x i8]* %14, i64 0, i64 0
%105 = bitcast %struct.sockaddr_storage* %11 to %struct.sockaddr*
%106 = call i32 @recvfrom(i32 %103, i8* %104, i32 500, i32 0, %struct.sockaddr* %105, i32* %12)
store i32 %106, i32* %13
%107 = load i32, i32* %13
%108 = icmp eq i32 %107, -1
br i1 %108, label %109, label %110
109: ; preds = %102
br label %102
110: ; preds = %102
%111 = load i32, i32* @NI_MAXHOST
%112 = zext i32 %111 to i64
%113 = call i8* @llvm.stacksave()
store i8* %113, i8** %16
%114 = alloca i8, i64 %112
store i64 %112, i64* %17
%115 = load i32, i32* @NI_MAXSERV
%116 = zext i32 %115 to i64
%117 = alloca i8, i64 %116
store i64 %116, i64* %18
%118 = bitcast %struct.sockaddr_storage* %11 to %struct.sockaddr*
%119 = load i32, i32* %12
%120 = load i32, i32* @NI_MAXHOST
%121 = load i32, i32* @NI_MAXSERV
%122 = load i32, i32* @NI_NUMERICSERV
%123 = call i32 @getnameinfo(%struct.sockaddr* %118, i32 %119, i8* %114, i32 %120, i8* %117, i32 %121, i32 %122)
store i32 %123, i32* %10
%124 = load i32, i32* %10
%125 = icmp eq i32 %124, 0
br i1 %125, label %126, label %134
126: ; preds = %110
%127 = load i32, i32* %13
%128 = sext i32 %127 to i64
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i64 %128, i8* %114, i8* %117)
%130 = getelementptr inbounds [500 x i8], [500 x i8]* %14, i64 0, i64 0
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %130)
%132 = load i32, i32* @stdout
%133 = call i32 @fflush(i32 %132)
br label %139
134: ; preds = %110
%135 = load i32, i32* @stderr
%136 = load i32, i32* %10
%137 = call i8* @gai_strerror(i32 %136)
%138 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %137)
br label %139
139: ; preds = %134, %126
%140 = load i32, i32* %9
%141 = load i8*, i8** %15
%142 = load i8*, i8** %15
%143 = call i64 @strlen(i8* %142)
%144 = bitcast %struct.sockaddr_storage* %11 to %struct.sockaddr*
%145 = load i32, i32* %12
%146 = call i64 @sendto(i32 %140, i8* %141, i64 %143, i32 0, %struct.sockaddr* %144, i32 %145)
%147 = load i8*, i8** %15
%148 = call i64 @strlen(i8* %147)
%149 = icmp ne i64 %146, %148
br i1 %149, label %150, label %153
150: ; preds = %139
%151 = load i32, i32* @stderr
%152 = call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %153
153: ; preds = %150, %139
%154 = load i8*, i8** %16
br label %102
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32*, i64, i32, i32, %struct.addrinfo*, i32*, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"OK_RECEIVED\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"Usage: %s port\0A\00"
@EXIT_FAILURE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_PASSIVE = global i32 0
@.str.2 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.3 = [16 x i8] c"Could not bind\0A\00"
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@NI_NUMERICSERV = global i32 0
@.str.4 = [35 x i8] c"Received %ld bytes from (%s, %s):\0A\00"
@stdout = global i32 0
@.str.6 = [17 x i8] c"getnameinfo: %s\0A\00"
@.str.7 = [24 x i8] c"Error sending response\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca %struct.sockaddr_storage
%6 = alloca i32
%7 = alloca [500 x i8]
%8 = bitcast %struct.addrinfo* %3 to i8*
%9 = bitcast %struct.addrinfo** %4 to i8*
%10 = bitcast %struct.sockaddr_storage* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%13 = icmp eq i32 %0, 2
br i1 %13, label %20, label %14
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 56)
%22 = load i32, i32* @AF_UNSPEC
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %22, i32* %23
%24 = load i32, i32* @SOCK_DGRAM
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %24, i32* %25
%26 = load i32, i32* @AI_PASSIVE
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 7
store i32 %26, i32* %27
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 1
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 5
%30 = getelementptr inbounds i8*, i8** %1, i64 1
%31 = bitcast i32** %28 to i8*
%32 = bitcast %struct.addrinfo** %29 to i8*
%33 = load i8*, i8** %30
%34 = call i32 @getaddrinfo(i32* null, i8* %33, %struct.addrinfo* %3, %struct.addrinfo** %4)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %20
%37 = load %struct.addrinfo*, %struct.addrinfo** %4
%38 = icmp eq %struct.addrinfo* %37, null
br i1 %38, label %68, label %45
39: ; preds = %20
%40 = load i32, i32* @stderr
%41 = call i8* @gai_strerror(i32 %34)
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %36, %64
%46 = phi %struct.addrinfo* [ %66, %64 ], [ %37, %36 ]
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i64 0, i32 4
%48 = load i32, i32* %47
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i64 0, i32 3
%50 = load i32, i32* %49
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i64 0, i32 2
%52 = load i64, i64* %51
%53 = call i32 @socket(i32 %48, i32 %50, i64 %52)
%54 = icmp eq i32 %53, -1
br i1 %54, label %64, label %55
55: ; preds = %45
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i64 0, i32 1
%57 = load i32*, i32** %56
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i64 0, i32 0
%59 = load i32, i32* %58
%60 = call i64 @bind(i32 %53, i32* %57, i32 %59)
%61 = icmp eq i64 %60, 0
br i1 %61, label %73, label %62
62: ; preds = %55
%63 = call i32 @close(i32 %53)
br label %64
64: ; preds = %45, %62
%65 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i64 0, i32 5
%66 = load %struct.addrinfo*, %struct.addrinfo** %65
%67 = icmp eq %struct.addrinfo* %66, null
br i1 %67, label %68, label %45
68: ; preds = %64, %36
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%71 = load i32, i32* @EXIT_FAILURE
%72 = call i32 @exit(i32 %71)
unreachable
73: ; preds = %55
%74 = load %struct.addrinfo*, %struct.addrinfo** %4
%75 = call i32 @freeaddrinfo(%struct.addrinfo* %74)
%76 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
br label %77
77: ; preds = %111, %73
store i32 4, i32* %6
%78 = call i32 @recvfrom(i32 %53, i8* %12, i32 500, i32 0, %struct.sockaddr* %76, i32* %6)
%79 = icmp eq i32 %78, -1
br i1 %79, label %111, label %80
80: ; preds = %77
%81 = load i32, i32* @NI_MAXHOST
%82 = zext i32 %81 to i64
%83 = call i8* @llvm.stacksave()
%84 = alloca i8, i64 %82
%85 = load i32, i32* @NI_MAXSERV
%86 = zext i32 %85 to i64
%87 = alloca i8, i64 %86
%88 = load i32, i32* %6
%89 = load i32, i32* @NI_MAXHOST
%90 = load i32, i32* @NI_NUMERICSERV
%91 = call i32 @getnameinfo(%struct.sockaddr* %76, i32 %88, i8* %84, i32 %89, i8* %87, i32 %85, i32 %90)
%92 = icmp eq i32 %91, 0
br i1 %92, label %93, label %99
93: ; preds = %80
%94 = sext i32 %78 to i64
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i64 %94, i8* %84, i8* %87)
%96 = call i32 @puts(i8* %12)
%97 = load i32, i32* @stdout
%98 = call i32 @fflush(i32 %97)
br label %103
99: ; preds = %80
%100 = load i32, i32* @stderr
%101 = call i8* @gai_strerror(i32 %91)
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %101)
br label %103
103: ; preds = %99, %93
%104 = load i32, i32* %6
%105 = call i64 @sendto(i32 %53, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 11, i32 0, %struct.sockaddr* %76, i32 %104)
%106 = icmp eq i64 %105, 11
br i1 %106, label %110, label %107
107: ; preds = %103
%108 = load i32, i32* @stderr
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %110
110: ; preds = %107, %103
br label %111
111: ; preds = %110, %77
br label %77
}