#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 /*<<< 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;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int 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 **);
char *inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(void) {
  int sockfd;
  struct addrinfo hints, *servinfo, *p;
  int rv;
  int numbytes;
  struct sockaddr_storage their_addr;
  char buf[100];
  socklen_t addr_len;
  char s[INET6_ADDRSTRLEN];
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = AI_PASSIVE;
  if ((rv = getaddrinfo(NULL, "4950", &hints, &servinfo)) != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
    return 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");
    return 2;
  }
  freeaddrinfo(servinfo);
  printf("listener: waiting to recvfrom...\n");
  addr_len = sizeof their_addr;
  if ((numbytes = recvfrom(sockfd, buf, 100 - 1, 0,
                           (struct sockaddr *)&their_addr, &addr_len)) == -1) {
    perror("recvfrom");
    exit(1);
  }
  printf("listener: got packet from %s\n",
         inet_ntop(their_addr.ss_family,
                   get_in_addr((struct sockaddr *)&their_addr), s, sizeof s));
  printf("listener: packet is %d bytes long\n", numbytes);
  buf[numbytes] = '\0';
  printf("listener: packet contains \"%s\"\n", buf);
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2def(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xf0(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0xd0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xe8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xd8(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd93(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
je     12ca <main+0xea>
mov    0x2d33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xf4(%rbp)
mov    -0x44(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    -0xf4(%rbp),%edi
mov    %rax,%rdx
lea    0xd58(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xdc(%rbp)
jmp    1488 <main+0x2a8>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1361 <main+0x181>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x40(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%edx
call   1100 <socket@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    1314 <main+0x134>
lea    0xd0c(%rip),%rdi
call   10c0 <perror@plt>
jmp    1350 <main+0x170>
mov    -0x8(%rbp),%edi
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x40(%rbp),%rax
mov    (%rax),%edx
call   10b0 <bind@plt>
cmp    $0xffffffff,%eax
jne    134b <main+0x16b>
mov    -0x8(%rbp),%edi
call   1080 <close@plt>
lea    0xce6(%rip),%rdi
call   10c0 <perror@plt>
jmp    1350 <main+0x170>
jmp    1361 <main+0x181>
mov    -0x40(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    12d2 <main+0xf2>
cmpq   $0x0,-0x40(%rbp)
jne    1399 <main+0x1b9>
mov    0x2c4d(%rip),%rax
mov    (%rax),%edi
lea    0xcba(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0xdc(%rbp)
jmp    1488 <main+0x2a8>
mov    -0x38(%rbp),%rdi
call   10f0 <freeaddrinfo@plt>
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x4,-0xc4(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xc0(%rbp),%rsi
lea    -0x50(%rbp),%r8
mov    $0x63,%edx
xor    %ecx,%ecx
lea    -0xc4(%rbp),%r9
call   10a0 <recvfrom@plt>
mov    %eax,-0x48(%rbp)
cmp    $0xffffffff,%eax
jne    13fd <main+0x21d>
lea    0xc8b(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x50(%rbp),%eax
mov    %eax,-0xf8(%rbp)
lea    -0x50(%rbp),%rdi
call   1040 <get_in_addr@plt>
mov    -0xf8(%rbp),%edi
mov    -0xe8(%rbp),%rdx
mov    %eax,%esi
mov    -0xf0(%rbp),%rax
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rsi
lea    0xc4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%esi
lea    0xc59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movslq -0x48(%rbp),%rax
movb   $0x0,-0xc0(%rbp,%rax,1)
lea    -0xc0(%rbp),%rsi
lea    0xc5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xdc(%rbp)
mov    -0xd0(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rsp,%r15
mov    0x2dda(%rip),%rax
mov    (%rax),%ebx
mov    %rsp,%r14
lea    0xf(%rbx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    -0x78(%rbp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    0x2d89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
lea    0xda1(%rip),%rsi
lea    -0x48(%rbp),%rcx
xor    %edi,%edi
mov    %r12,%rdx
call   10f0 <getaddrinfo@plt>
test   %eax,%eax
je     129f <main+0xaf>
mov    0x2d48(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xd7d(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%r12d
jmp    13d6 <main+0x1e6>
mov    %rbx,-0x50(%rbp)
mov    %r15,-0x40(%rbp)
mov    -0x48(%rbp),%rbx
test   %rbx,%rbx
je     1301 <main+0x111>
lea    0xd5f(%rip),%r12
lea    0xd69(%rip),%r13
mov    0x10(%rbx),%edi
mov    0x8(%rbx),%edx
mov    0xc(%rbx),%esi
call   1110 <socket@plt>
mov    %r12,%rdi
cmp    $0xffffffff,%eax
je     12f3 <main+0x103>
mov    %eax,%r15d
mov    (%rbx),%edx
mov    0x4(%rbx),%esi
mov    %eax,%edi
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1323 <main+0x133>
mov    %r15d,%edi
call   1090 <close@plt>
mov    %r13,%rdi
call   10d0 <perror@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
jne    12be <main+0xce>
mov    0x2cb8(%rip),%rax
mov    (%rax),%edi
lea    0xd25(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x2,%r12d
jmp    13d2 <main+0x1e2>
mov    -0x48(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
lea    0xd8e(%rip),%rdi
call   1050 <puts@plt>
movl   $0x4,-0x34(%rbp)
lea    -0xe0(%rbp),%rsi
xor    %r12d,%r12d
lea    -0x30(%rbp),%r8
lea    -0x34(%rbp),%r9
mov    %r15d,%edi
mov    $0x63,%edx
xor    %ecx,%ecx
call   10b0 <recvfrom@plt>
cmp    $0xffffffff,%eax
je     13eb <main+0x1fb>
mov    %eax,%r13d
mov    -0x30(%rbp),%ebx
lea    -0x30(%rbp),%rdi
call   1040 <get_in_addr@plt>
mov    %ebx,%edi
mov    %eax,%esi
mov    %r14,%rdx
mov    -0x50(%rbp),%rcx
call   1030 <inet_ntop@plt>
lea    0xcd1(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xcde(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movslq %r13d,%rax
movb   $0x0,-0xe0(%rbp,%rax,1)
lea    0xce5(%rip),%rdi
lea    -0xe0(%rbp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15d,%edi
call   1090 <close@plt>
mov    -0x40(%rbp),%r15
mov    %r15,%rsp
mov    %r12d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc65(%rip),%rdi
call   10d0 <perror@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 }
@INET6_ADDRSTRLEN = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [5 x i8] c"4950\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 = [34 x i8] c"listener: waiting to recvfrom...\0A\00"
@.str.6 = [9 x i8] c"recvfrom\00"
@.str.7 = [30 x i8] c"listener: got packet from %s\0A\00"
@.str.8 = [35 x i8] c"listener: packet is %d bytes long\0A\00"
@.str.9 = [32 x i8] c"listener: packet contains \22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca %struct.addrinfo*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_storage
%9 = alloca [100 x i8]
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
store i32 0, i32* %1
%14 = load i32, i32* @INET6_ADDRSTRLEN
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %11
%17 = alloca i8, i64 %15
store i64 %15, i64* %12
%18 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 40)
%19 = load i32, i32* @AF_UNSPEC
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i32 0, i32 4
store i32 %19, i32* %20
%21 = load i32, i32* @SOCK_DGRAM
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i32 0, i32 3
store i32 %21, i32* %22
%23 = load i32, i32* @AI_PASSIVE
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i32 0, i32 6
store i32 %23, i32* %24
%25 = call i32 @getaddrinfo(i32* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %3, %struct.addrinfo** %4)
store i32 %25, i32* %6
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %0
%28 = load i32, i32* @stderr
%29 = load i32, i32* %6
%30 = call i8* @gai_strerror(i32 %29)
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 1, i32* %1
store i32 1, i32* %13
br label %105
32: ; preds = %0
%33 = load %struct.addrinfo*, %struct.addrinfo** %4
store %struct.addrinfo* %33, %struct.addrinfo** %5
br label %34
34: ; preds = %66, %32
%35 = load %struct.addrinfo*, %struct.addrinfo** %5
%36 = icmp ne %struct.addrinfo* %35, null
br i1 %36, label %37, label %70
37: ; preds = %34
%38 = load %struct.addrinfo*, %struct.addrinfo** %5
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i32 0, i32 4
%40 = load i32, i32* %39
%41 = load %struct.addrinfo*, %struct.addrinfo** %5
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i32 0, i32 3
%43 = load i32, i32* %42
%44 = load %struct.addrinfo*, %struct.addrinfo** %5
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i32 0, i32 2
%46 = load i32, i32* %45
%47 = call i32 @socket(i32 %40, i32 %43, i32 %46)
store i32 %47, i32* %2
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %51
49: ; preds = %37
%50 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %66
51: ; preds = %37
%52 = load i32, i32* %2
%53 = load %struct.addrinfo*, %struct.addrinfo** %5
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 1
%55 = load i32, i32* %54
%56 = load %struct.addrinfo*, %struct.addrinfo** %5
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 0
%58 = load i32, i32* %57
%59 = call i32 @bind(i32 %52, i32 %55, i32 %58)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %65
61: ; preds = %51
%62 = load i32, i32* %2
%63 = call i32 @close(i32 %62)
%64 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %66
65: ; preds = %51
br label %70
66: ; preds = %61, %49
%67 = load %struct.addrinfo*, %struct.addrinfo** %5
%68 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %67, i32 0, i32 5
%69 = load %struct.addrinfo*, %struct.addrinfo** %68
store %struct.addrinfo* %69, %struct.addrinfo** %5
br label %34
70: ; preds = %65, %34
%71 = load %struct.addrinfo*, %struct.addrinfo** %5
%72 = icmp eq %struct.addrinfo* %71, null
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %1
store i32 1, i32* %13
br label %105
76: ; preds = %70
%77 = load %struct.addrinfo*, %struct.addrinfo** %4
%78 = call i32 @freeaddrinfo(%struct.addrinfo* %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
store i32 4, i32* %10
%80 = load i32, i32* %2
%81 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%82 = bitcast %struct.sockaddr_storage* %8 to %struct.sockaddr*
%83 = call i32 @recvfrom(i32 %80, i8* %81, i32 99, i32 0, %struct.sockaddr* %82, i32* %10)
store i32 %83, i32* %7
%84 = icmp eq i32 %83, -1
br i1 %84, label %85, label %88
85: ; preds = %76
%86 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %76
%89 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %8, i32 0, i32 0
%90 = load i32, i32* %89
%91 = bitcast %struct.sockaddr_storage* %8 to %struct.sockaddr*
%92 = call i32 @get_in_addr(%struct.sockaddr* %91)
%93 = trunc i64 %15 to i32
%94 = call i8* @inet_ntop(i32 %90, i32 %92, i8* %17, i32 %93)
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %94)
%96 = load i32, i32* %7
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i32 %96)
%98 = load i32, i32* %7
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %99
store i8 0, i8* %100
%101 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0), i8* %101)
%103 = load i32, i32* %2
%104 = call i32 @close(i32 %103)
store i32 0, i32* %1
store i32 1, i32* %13
br label %105
105: ; preds = %88, %73, %27
%106 = load i8*, i8** %11
%107 = load i32, i32* %1
ret i32 %107
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [5 x i8] c"4950\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.6 = [9 x i8] c"recvfrom\00"
@.str.7 = [30 x i8] c"listener: got packet from %s\0A\00"
@.str.8 = [35 x i8] c"listener: packet is %d bytes long\0A\00"
@.str.9 = [32 x i8] c"listener: packet contains \22%s\22\0A\00"
@str = [33 x i8] c"listener: waiting to recvfrom...\00"
define i32 @main() {
%1 = alloca %struct.addrinfo
%2 = alloca %struct.addrinfo*
%3 = alloca %struct.sockaddr_storage
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = bitcast %struct.addrinfo* %1 to i8*
%7 = bitcast %struct.addrinfo** %2 to i8*
%8 = bitcast %struct.sockaddr_storage* %3 to i8*
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%10 = bitcast i32* %5 to i8*
%11 = load i32, i32* @INET6_ADDRSTRLEN
%12 = zext i32 %11 to i64
%13 = tail call i8* @llvm.stacksave()
%14 = alloca i8, i64 %12
%15 = call i32 @memset(%struct.addrinfo* %1, i32 0, i32 40)
%16 = load i32, i32* @AF_UNSPEC
%17 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %1, i64 0, i32 4
store i32 %16, i32* %17
%18 = load i32, i32* @SOCK_DGRAM
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %1, i64 0, i32 3
store i32 %18, i32* %19
%20 = load i32, i32* @AI_PASSIVE
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %1, i64 0, i32 6
store i32 %20, i32* %21
%22 = call i32 @getaddrinfo(i32* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %1, %struct.addrinfo** %2)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %0
%25 = load %struct.addrinfo*, %struct.addrinfo** %2
%26 = icmp eq %struct.addrinfo* %25, null
br i1 %26, label %56, label %31
27: ; preds = %0
%28 = load i32, i32* @stderr
%29 = call i8* @gai_strerror(i32 %22)
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %80
31: ; preds = %24, %50
%32 = phi %struct.addrinfo* [ %54, %50 ], [ %25, %24 ]
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 4
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 3
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 2
%38 = load i32, i32* %37
%39 = call i32 @socket(i32 %34, i32 %36, i32 %38)
%40 = icmp eq i32 %39, -1
br i1 %40, label %50, label %41
41: ; preds = %31
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 0
%45 = load i32, i32* %44
%46 = call i32 @bind(i32 %39, i32 %43, i32 %45)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %59
48: ; preds = %41
%49 = call i32 @close(i32 %39)
br label %50
50: ; preds = %31, %48
%51 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), %48 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %31 ]
%52 = call i32 @perror(i8* %51)
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 5
%54 = load %struct.addrinfo*, %struct.addrinfo** %53
%55 = icmp eq %struct.addrinfo* %54, null
br i1 %55, label %56, label %31
56: ; preds = %50, %24
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %80
59: ; preds = %41
%60 = load %struct.addrinfo*, %struct.addrinfo** %2
%61 = call i32 @freeaddrinfo(%struct.addrinfo* %60)
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
store i32 4, i32* %5
%63 = bitcast %struct.sockaddr_storage* %3 to %struct.sockaddr*
%64 = call i32 @recvfrom(i32 %39, i8* %9, i32 99, i32 0, %struct.sockaddr* %63, i32* %5)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %69
66: ; preds = %59
%67 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %59
%70 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %3, i64 0, i32 0
%71 = load i32, i32* %70
%72 = call i32 @get_in_addr(%struct.sockaddr* %63)
%73 = call i8* @inet_ntop(i32 %71, i32 %72, i8* %14, i32 %11)
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %73)
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i32 %64)
%76 = sext i32 %64 to i64
%77 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %76
store i8 0, i8* %77
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0), i8* %9)
%79 = call i32 @close(i32 %39)
br label %80
80: ; preds = %69, %56, %27
%81 = phi i32 [ 1, %27 ], [ 2, %56 ], [ 0, %69 ]
ret i32 %81
}