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

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ INET6_ADDRSTRLEN;
int /*<<< orphan*/ SOCK_DGRAM;
int bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int /*<<< orphan*/ get_in_addr(struct sockaddr *);
int getaddrinfo(int /*<<< orphan*/ *, char *, struct addrinfo *,
                struct addrinfo **);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/, char *,
                             int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ **, char *, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int ntohl(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void listener(char *ip, int *port) {
  int sockfd;
  struct addrinfo hints, *servinfo, *p;
  int rv;
  int numbytes;
  struct sockaddr_storage their_addr;
  char buf[1024];
  socklen_t addr_len;
  uint32_t packet[2];
  char port_s[100];
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = AI_PASSIVE;
  snprintf(port_s, 100, "%d", 4950);
  if ((rv = getaddrinfo(NULL, port_s, &hints, &servinfo)) != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
    exit(1);
  }
  for (p = servinfo; p != NULL; p = p->ai_next) {
    if ((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
      perror("listener: socket");
      continue;
    }
    if (bind(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
      close(sockfd);
      perror("listener: bind");
      continue;
    }
    break;
  }
  if (p == NULL) {
    fprintf(stderr, "listener: failed to bind socket\n");
    exit(2);
  }
  freeaddrinfo(servinfo);
  addr_len = sizeof their_addr;
  int done = 0;
  while (!done) {
    if ((numbytes = recvfrom(sockfd, buf, 1024 - 1, 0,
                             (struct sockaddr *)&their_addr, &addr_len)) ==
        -1) {
      perror("recvfrom");
      exit(1);
    } else if (numbytes == sizeof(packet)) {
      inet_ntop(their_addr.ss_family,
                get_in_addr((struct sockaddr *)&their_addr), ip,
                INET6_ADDRSTRLEN);
      memcpy(&packet, buf, sizeof(packet));
      if (ntohl(packet[0]) == 3141593) {
        *port = ntohl(packet[1]);
        done = 1;
      }
    }
  }
  close(sockfd);
}


x86 assembly (clang, -O0):
<listener>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    -0x4d0(%rbp),%rdi
mov    $0x64,%esi
lea    0xda6(%rip),%rdx
mov    $0x1356,%ecx
call   1050 <snprintf@plt>
lea    -0x4d0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   10f0 <getaddrinfo@plt>
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
je     12c0 <listener+0xc0>
mov    0x2d31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4d8(%rbp)
mov    -0x54(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    -0x4d8(%rbp),%edi
mov    %rax,%rdx
lea    0xd54(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1357 <listener+0x157>
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x50(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%edx
call   1120 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    130a <listener+0x10a>
lea    0xd14(%rip),%rdi
call   10d0 <perror@plt>
jmp    1346 <listener+0x146>
mov    -0x14(%rbp),%edi
mov    -0x50(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x50(%rbp),%rax
mov    (%rax),%edx
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1341 <listener+0x141>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
lea    0xcee(%rip),%rdi
call   10d0 <perror@plt>
jmp    1346 <listener+0x146>
jmp    1357 <listener+0x157>
mov    -0x50(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x50(%rbp)
jmp    12c8 <listener+0xc8>
cmpq   $0x0,-0x50(%rbp)
jne    1383 <listener+0x183>
mov    0x2c57(%rip),%rax
mov    (%rax),%edi
lea    0xcc2(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x2,%edi
call   10e0 <exit@plt>
mov    -0x48(%rbp),%rdi
call   1110 <freeaddrinfo@plt>
movl   $0x4,-0x464(%rbp)
movl   $0x0,-0x4d4(%rbp)
cmpl   $0x0,-0x4d4(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    13b9 <listener+0x1b9>
jmp    1490 <listener+0x290>
mov    -0x14(%rbp),%edi
lea    -0x460(%rbp),%rsi
lea    -0x60(%rbp),%r8
mov    $0x3ff,%edx
xor    %ecx,%ecx
lea    -0x464(%rbp),%r9
call   10b0 <recvfrom@plt>
mov    %eax,-0x58(%rbp)
cmp    $0xffffffff,%eax
jne    13fc <listener+0x1fc>
lea    0xc68(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
movslq -0x58(%rbp),%rax
cmp    $0x8,%rax
jne    1486 <listener+0x286>
mov    -0x60(%rbp),%eax
mov    %eax,-0x4dc(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <get_in_addr@plt>
mov    -0x4dc(%rbp),%edi
mov    %eax,%esi
mov    -0x8(%rbp),%rdx
mov    0x2bb9(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
lea    -0x46c(%rbp),%rdi
lea    -0x460(%rbp),%rsi
mov    $0x8,%edx
call   10a0 <memcpy@plt>
mov    -0x46c(%rbp),%edi
call   1100 <ntohl@plt>
cmp    $0x2fefd9,%eax
jne    1481 <listener+0x281>
mov    -0x468(%rbp),%edi
call   1100 <ntohl@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4d4(%rbp)
jmp    1486 <listener+0x286>
jmp    148b <listener+0x28b>
jmp    13a0 <listener+0x1a0>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
add    $0x4e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<listener>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4c8,%rsp
mov    %rsi,%r12
mov    %rdi,0x20(%rsp)
lea    0x28(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x38(%rsp)
mov    0x2d8f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x34(%rsp)
mov    0x2d92(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x48(%rsp)
lea    0xda5(%rip),%rdx
lea    0x50(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x64,%esi
mov    $0x1356,%ecx
call   1050 <snprintf@plt>
lea    0x10(%rsp),%rcx
xor    %edi,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   10f0 <getaddrinfo@plt>
test   %eax,%eax
jne    13e8 <listener+0x1e8>
mov    0x10(%rsp),%rbx
test   %rbx,%rbx
je     12e5 <listener+0xe5>
lea    0xd77(%rip),%r14
lea    0xd81(%rip),%r15
mov    0x10(%rbx),%edi
mov    0x8(%rbx),%edx
mov    0xc(%rbx),%esi
call   1120 <socket@plt>
mov    %r14,%rdi
cmp    $0xffffffff,%eax
je     12d7 <listener+0xd7>
mov    %eax,%ebp
mov    (%rbx),%edx
mov    0x4(%rbx),%esi
mov    %eax,%edi
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1306 <listener+0x106>
mov    %ebp,%edi
call   1080 <close@plt>
mov    %r15,%rdi
call   10d0 <perror@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
jne    12a4 <listener+0xa4>
mov    0x2cd4(%rip),%rax
mov    (%rax),%edi
lea    0xd3f(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x2,%edi
call   10e0 <exit@plt>
mov    %r12,0x18(%rsp)
mov    0x10(%rsp),%rdi
call   1110 <freeaddrinfo@plt>
movl   $0x4,0x4(%rsp)
lea    0xc0(%rsp),%r12
mov    %rsp,%rbx
lea    0x4(%rsp),%r13
lea    0x8(%rsp),%r14
jmp    1349 <listener+0x149>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0xffffffff,%eax
je     13d2 <listener+0x1d2>
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x3ff,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r13,%r9
call   10b0 <recvfrom@plt>
cmp    $0x8,%eax
jne    1340 <listener+0x140>
mov    (%rsp),%r15d
mov    %rbx,%rdi
call   1040 <get_in_addr@plt>
mov    0x2c70(%rip),%rcx
mov    (%rcx),%ecx
mov    %r15d,%edi
mov    %eax,%esi
mov    0x20(%rsp),%rdx
call   1030 <inet_ntop@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x8,%edx
call   10a0 <memcpy@plt>
mov    0x8(%rsp),%edi
call   1100 <ntohl@plt>
cmp    $0x2fefd9,%eax
jne    1349 <listener+0x149>
mov    0xc(%rsp),%edi
call   1100 <ntohl@plt>
mov    0x18(%rsp),%rcx
mov    %eax,(%rcx)
mov    %ebp,%edi
call   1080 <close@plt>
add    $0x4c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc7c(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2bd1(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <gai_strerror@plt>
lea    0xc04(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [17 x i8] c"listener: socket\00"
@.str.3 = [15 x i8] c"listener: bind\00"
@.str.4 = [33 x i8] c"listener: failed to bind socket\0A\00"
@.str.5 = [9 x i8] c"recvfrom\00"
@INET6_ADDRSTRLEN = global i32 0
define void @listener(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%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 [1024 x i8]
%13 = alloca i32
%14 = alloca [2 x i32]
%15 = alloca [100 x i8]
%16 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%17 = call i32 @memset(%struct.addrinfo* %6, i32 0, i32 40)
%18 = load i32, i32* @AF_UNSPEC
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 4
store i32 %18, i32* %19
%20 = load i32, i32* @SOCK_DGRAM
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 3
store i32 %20, i32* %21
%22 = load i32, i32* @AI_PASSIVE
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 6
store i32 %22, i32* %23
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%25 = call i32 @snprintf(i8* %24, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 4950)
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%27 = call i32 @getaddrinfo(i32* null, i8* %26, %struct.addrinfo* %6, %struct.addrinfo** %7)
store i32 %27, i32* %9
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %2
%30 = load i32, i32* @stderr
%31 = load i32, i32* %9
%32 = call i8* @gai_strerror(i32 %31)
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %2
%36 = load %struct.addrinfo*, %struct.addrinfo** %7
store %struct.addrinfo* %36, %struct.addrinfo** %8
br label %37
37: ; preds = %69, %35
%38 = load %struct.addrinfo*, %struct.addrinfo** %8
%39 = icmp ne %struct.addrinfo* %38, null
br i1 %39, label %40, label %73
40: ; preds = %37
%41 = load %struct.addrinfo*, %struct.addrinfo** %8
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i32 0, i32 4
%43 = load i32, i32* %42
%44 = load %struct.addrinfo*, %struct.addrinfo** %8
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i32 0, i32 3
%46 = load i32, i32* %45
%47 = load %struct.addrinfo*, %struct.addrinfo** %8
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %47, i32 0, i32 2
%49 = load i32, i32* %48
%50 = call i32 @socket(i32 %43, i32 %46, i32 %49)
store i32 %50, i32* %5
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %54
52: ; preds = %40
%53 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %69
54: ; preds = %40
%55 = load i32, i32* %5
%56 = load %struct.addrinfo*, %struct.addrinfo** %8
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 1
%58 = load i32, i32* %57
%59 = load %struct.addrinfo*, %struct.addrinfo** %8
%60 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %59, i32 0, i32 0
%61 = load i32, i32* %60
%62 = call i32 @bind(i32 %55, i32 %58, i32 %61)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %68
64: ; preds = %54
%65 = load i32, i32* %5
%66 = call i32 @close(i32 %65)
%67 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %69
68: ; preds = %54
br label %73
69: ; preds = %64, %52
%70 = load %struct.addrinfo*, %struct.addrinfo** %8
%71 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %70, i32 0, i32 5
%72 = load %struct.addrinfo*, %struct.addrinfo** %71
store %struct.addrinfo* %72, %struct.addrinfo** %8
br label %37
73: ; preds = %68, %37
%74 = load %struct.addrinfo*, %struct.addrinfo** %8
%75 = icmp eq %struct.addrinfo* %74, null
br i1 %75, label %76, label %80
76: ; preds = %73
%77 = load i32, i32* @stderr
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%79 = call i32 @exit(i32 2)
unreachable
80: ; preds = %73
%81 = load %struct.addrinfo*, %struct.addrinfo** %7
%82 = call i32 @freeaddrinfo(%struct.addrinfo* %81)
store i32 4, i32* %13
store i32 0, i32* %16
br label %83
83: ; preds = %122, %80
%84 = load i32, i32* %16
%85 = icmp ne i32 %84, 0
%86 = xor i1 %85, true
br i1 %86, label %87, label %123
87: ; preds = %83
%88 = load i32, i32* %5
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%90 = bitcast %struct.sockaddr_storage* %11 to %struct.sockaddr*
%91 = call i32 @recvfrom(i32 %88, i8* %89, i32 1023, i32 0, %struct.sockaddr* %90, i32* %13)
store i32 %91, i32* %10
%92 = icmp eq i32 %91, -1
br i1 %92, label %93, label %96
93: ; preds = %87
%94 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%95 = call i32 @exit(i32 1)
unreachable
96: ; preds = %87
%97 = load i32, i32* %10
%98 = sext i32 %97 to i64
%99 = icmp eq i64 %98, 8
br i1 %99, label %100, label %121
100: ; preds = %96
%101 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %11, i32 0, i32 0
%102 = load i32, i32* %101
%103 = bitcast %struct.sockaddr_storage* %11 to %struct.sockaddr*
%104 = call i32 @get_in_addr(%struct.sockaddr* %103)
%105 = load i8*, i8** %3
%106 = load i32, i32* @INET6_ADDRSTRLEN
%107 = call i32 @inet_ntop(i32 %102, i32 %104, i8* %105, i32 %106)
%108 = bitcast [2 x i32]* %14 to i32**
%109 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%110 = call i32 @memcpy(i32** %108, i8* %109, i32 8)
%111 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%112 = load i32, i32* %111
%113 = call i32 @ntohl(i32 %112)
%114 = icmp eq i32 %113, 3141593
br i1 %114, label %115, label %120
115: ; preds = %100
%116 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%117 = load i32, i32* %116
%118 = call i32 @ntohl(i32 %117)
%119 = load i32*, i32** %4
store i32 %118, i32* %119
store i32 1, i32* %16
br label %120
120: ; preds = %115, %100
br label %121
121: ; preds = %120, %96
br label %122
122: ; preds = %121
br label %83
123: ; preds = %83
%124 = load i32, i32* %5
%125 = call i32 @close(i32 %124)
ret void
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [17 x i8] c"listener: socket\00"
@.str.3 = [15 x i8] c"listener: bind\00"
@.str.4 = [33 x i8] c"listener: failed to bind socket\0A\00"
@.str.5 = [9 x i8] c"recvfrom\00"
@INET6_ADDRSTRLEN = global i32 0
define void @listener(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca %struct.sockaddr_storage
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca i32*
%9 = alloca [100 x i8]
%10 = bitcast %struct.addrinfo* %3 to i8*
%11 = bitcast %struct.addrinfo** %4 to i8*
%12 = bitcast %struct.sockaddr_storage* %5 to i8*
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%14 = bitcast i32* %7 to i8*
%15 = bitcast i32** %8 to i8*
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%17 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 40)
%18 = load i32, i32* @AF_UNSPEC
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %18, i32* %19
%20 = load i32, i32* @SOCK_DGRAM
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %20, i32* %21
%22 = load i32, i32* @AI_PASSIVE
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 6
store i32 %22, i32* %23
%24 = call i32 @snprintf(i8* %16, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 4950)
%25 = call i32 @getaddrinfo(i32* null, i8* %16, %struct.addrinfo* %3, %struct.addrinfo** %4)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %2
%28 = load %struct.addrinfo*, %struct.addrinfo** %4
%29 = icmp eq %struct.addrinfo* %28, null
br i1 %29, label %60, label %35
30: ; preds = %2
%31 = load i32, i32* @stderr
%32 = call i8* @gai_strerror(i32 %25)
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %27, %54
%36 = phi %struct.addrinfo* [ %58, %54 ], [ %28, %27 ]
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 4
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 3
%40 = load i32, i32* %39
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 2
%42 = load i32, i32* %41
%43 = call i32 @socket(i32 %38, i32 %40, i32 %42)
%44 = icmp eq i32 %43, -1
br i1 %44, label %54, label %45
45: ; preds = %35
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 1
%47 = load i32, i32* %46
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 0
%49 = load i32, i32* %48
%50 = call i32 @bind(i32 %43, i32 %47, i32 %49)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %64
52: ; preds = %45
%53 = call i32 @close(i32 %43)
br label %54
54: ; preds = %35, %52
%55 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), %52 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %35 ]
%56 = call i32 @perror(i8* %55)
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 5
%58 = load %struct.addrinfo*, %struct.addrinfo** %57
%59 = icmp eq %struct.addrinfo* %58, null
br i1 %59, label %60, label %35
60: ; preds = %54, %27
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%63 = call i32 @exit(i32 2)
unreachable
64: ; preds = %45
%65 = load %struct.addrinfo*, %struct.addrinfo** %4
%66 = call i32 @freeaddrinfo(%struct.addrinfo* %65)
store i32 4, i32* %7
%67 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
%68 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 0, i32 0
%69 = bitcast i32** %8 to i32*
br label %70
70: ; preds = %72, %64
%71 = call i32 @recvfrom(i32 %43, i8* %13, i32 1023, i32 0, %struct.sockaddr* %67, i32* %7)
switch i32 %71, label %72 [
i32 -1, label %73
i32 8, label %76
]
72: ; preds = %70, %76
br label %70
73: ; preds = %70
%74 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %70
%77 = load i32, i32* %68
%78 = call i32 @get_in_addr(%struct.sockaddr* %67)
%79 = load i32, i32* @INET6_ADDRSTRLEN
%80 = call i32 @inet_ntop(i32 %77, i32 %78, i8* %0, i32 %79)
%81 = call i32 @memcpy(i32** %8, i8* %13, i32 8)
%82 = load i32, i32* %69
%83 = call i32 @ntohl(i32 %82)
%84 = icmp eq i32 %83, 3141593
br i1 %84, label %85, label %72
85: ; preds = %76
%86 = bitcast i32** %8 to [2 x i32]*
%87 = getelementptr inbounds [2 x i32], [2 x i32]* %86, i64 0, i64 1
%88 = load i32, i32* %87
%89 = call i32 @ntohl(i32 %88)
store i32 %89, i32* %1
%90 = call i32 @close(i32 %43)
ret void
}