#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*/ their_addr;
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*/ s;
typedef int /*<<< orphan*/ hints;

/* 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*/ 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);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  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, "6000", &hints, &servinfo)) != 0) {
    printf("Listener: getaddrinfo() error: %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) {
      printf("Listener: Error creating Socket Descriptor\n");
      continue;
    }
    if (bind(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
      close(sockfd);
      printf(
          "Listener: Error binding Socket Decriptor to IP Address and Port\n");
      continue;
    }
    break;
  }
  if (p == NULL) {
    printf("Listener: Socket Creation and Bind failed\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) {
    printf("Listener: recvfrom() failed");
    exit(1);
  }
  inet_ntop(their_addr.ss_family, get_in_addr((struct sockaddr *)&their_addr),
            s, sizeof(s));
  printf("Listener: Got packet from %s\n", 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    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x100(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0xe0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xf8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xe8(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2d9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdac(%rip),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   10c0 <getaddrinfo@plt>
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
je     129c <main+0xdc>
mov    -0x54(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    %rax,%rsi
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xec(%rbp)
jmp    145b <main+0x29b>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1337 <main+0x177>
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   10e0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    12e8 <main+0x128>
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1326 <main+0x166>
mov    -0x14(%rbp),%edi
mov    -0x50(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x50(%rbp),%rax
mov    (%rax),%edx
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1321 <main+0x161>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1326 <main+0x166>
jmp    1337 <main+0x177>
mov    -0x50(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x50(%rbp)
jmp    12a4 <main+0xe4>
cmpq   $0x0,-0x50(%rbp)
jne    1366 <main+0x1a6>
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0xec(%rbp)
jmp    145b <main+0x29b>
mov    -0x48(%rbp),%rdi
call   10d0 <freeaddrinfo@plt>
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x4,-0xd4(%rbp)
mov    -0x14(%rbp),%edi
lea    -0xd0(%rbp),%rsi
lea    -0x60(%rbp),%r8
mov    $0x63,%edx
xor    %ecx,%ecx
lea    -0xd4(%rbp),%r9
call   1090 <recvfrom@plt>
mov    %eax,-0x58(%rbp)
cmp    $0xffffffff,%eax
jne    13cc <main+0x20c>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x60(%rbp),%eax
mov    %eax,-0x104(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <get_in_addr@plt>
mov    -0x104(%rbp),%edi
mov    -0xf8(%rbp),%rdx
mov    %eax,%esi
mov    -0x100(%rbp),%rax
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0xf8(%rbp),%rsi
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%esi
lea    0xd04(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movslq -0x58(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
lea    -0xd0(%rbp),%rsi
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xec(%rbp)
mov    -0xe0(%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,%r14
mov    0x2dfa(%rip),%rax
mov    (%rax),%ebx
mov    %rsp,%r15
lea    0xf(%rbx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    -0x78(%rbp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    0x2da9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
lea    0xdc1(%rip),%rsi
lea    -0x48(%rbp),%rcx
xor    %edi,%edi
mov    %r12,%rdx
call   10d0 <getaddrinfo@plt>
test   %eax,%eax
je     1274 <main+0xa4>
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xda6(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%r12d
jmp    13af <main+0x1df>
mov    %rbx,-0x50(%rbp)
mov    %r14,-0x40(%rbp)
mov    -0x48(%rbp),%rbx
test   %rbx,%rbx
je     12e5 <main+0x115>
lea    0xea6(%rip),%r12
lea    0xe5f(%rip),%r14
jmp    12ae <main+0xde>
cs nopw 0x0(%rax,%rax,1)
nop
call   1050 <puts@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
je     12e5 <main+0x115>
mov    0x10(%rbx),%edi
mov    0x8(%rbx),%edx
mov    0xc(%rbx),%esi
call   10f0 <socket@plt>
mov    %r12,%rdi
cmp    $0xffffffff,%eax
je     12a0 <main+0xd0>
mov    %eax,%r13d
mov    (%rbx),%edx
mov    0x4(%rbx),%esi
mov    %eax,%edi
call   10b0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12fc <main+0x12c>
mov    %r13d,%edi
call   1090 <close@plt>
mov    %r14,%rdi
jmp    12a0 <main+0xd0>
lea    0xddc(%rip),%rdi
call   1050 <puts@plt>
mov    $0x2,%r12d
jmp    13ab <main+0x1db>
mov    -0x48(%rbp),%rdi
call   10e0 <freeaddrinfo@plt>
lea    0xd99(%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    %r13d,%edi
mov    $0x63,%edx
xor    %ecx,%ecx
call   10a0 <recvfrom@plt>
cmp    $0xffffffff,%eax
je     13c4 <main+0x1f4>
mov    %eax,%ebx
mov    -0x30(%rbp),%r14d
lea    -0x30(%rbp),%rdi
call   1040 <get_in_addr@plt>
mov    %r14d,%edi
mov    %eax,%esi
mov    %r15,%rdx
mov    -0x50(%rbp),%rcx
call   1030 <inet_ntop@plt>
lea    0xcdb(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xce8(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movslq %ebx,%rax
movb   $0x0,-0xe0(%rbp,%rax,1)
lea    0xcf0(%rip),%rdi
lea    -0xe0(%rbp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13d,%edi
call   1090 <close@plt>
mov    -0x40(%rbp),%r14
mov    %r14,%rsp
mov    %r12d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc5d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10c0 <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"6000\00"
@.str.1 = [35 x i8] c"Listener: getaddrinfo() error: %s\0A\00"
@.str.2 = [44 x i8] c"Listener: Error creating Socket Descriptor\0A\00"
@.str.3 = [65 x i8] c"Listener: Error binding Socket Decriptor to IP Address and Port\0A\00"
@.str.4 = [43 x i8] c"Listener: Socket Creation and Bind failed\0A\00"
@.str.5 = [36 x i8] c"Listener: waiting to recvfrom()...\0A\00"
@.str.6 = [28 x i8] c"Listener: recvfrom() failed\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(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.addrinfo
%8 = alloca %struct.addrinfo*
%9 = alloca %struct.addrinfo*
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.sockaddr_storage
%13 = alloca [100 x i8]
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* @INET6_ADDRSTRLEN
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %15
%21 = alloca i8, i64 %19
store i64 %19, i64* %16
%22 = call i32 @memset(%struct.addrinfo* %7, i32 0, i32 40)
%23 = load i32, i32* @AF_UNSPEC
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 4
store i32 %23, i32* %24
%25 = load i32, i32* @SOCK_DGRAM
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 3
store i32 %25, i32* %26
%27 = load i32, i32* @AI_PASSIVE
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 6
store i32 %27, i32* %28
%29 = call i32 @getaddrinfo(i32* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %7, %struct.addrinfo** %8)
store i32 %29, i32* %10
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %2
%32 = load i32, i32* %10
%33 = call i8* @gai_strerror(i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %33)
store i32 1, i32* %3
store i32 1, i32* %17
br label %107
35: ; preds = %2
%36 = load %struct.addrinfo*, %struct.addrinfo** %8
store %struct.addrinfo* %36, %struct.addrinfo** %9
br label %37
37: ; preds = %69, %35
%38 = load %struct.addrinfo*, %struct.addrinfo** %9
%39 = icmp ne %struct.addrinfo* %38, null
br i1 %39, label %40, label %73
40: ; preds = %37
%41 = load %struct.addrinfo*, %struct.addrinfo** %9
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i32 0, i32 4
%43 = load i32, i32* %42
%44 = load %struct.addrinfo*, %struct.addrinfo** %9
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i32 0, i32 3
%46 = load i32, i32* %45
%47 = load %struct.addrinfo*, %struct.addrinfo** %9
%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* %6
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %54
52: ; preds = %40
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %69
54: ; preds = %40
%55 = load i32, i32* %6
%56 = load %struct.addrinfo*, %struct.addrinfo** %9
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 1
%58 = load i32, i32* %57
%59 = load %struct.addrinfo*, %struct.addrinfo** %9
%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* %6
%66 = call i32 @close(i32 %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 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** %9
%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** %9
br label %37
73: ; preds = %68, %37
%74 = load %struct.addrinfo*, %struct.addrinfo** %9
%75 = icmp eq %struct.addrinfo* %74, null
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %3
store i32 1, i32* %17
br label %107
78: ; preds = %73
%79 = load %struct.addrinfo*, %struct.addrinfo** %8
%80 = call i32 @freeaddrinfo(%struct.addrinfo* %79)
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
store i32 4, i32* %14
%82 = load i32, i32* %6
%83 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%84 = bitcast %struct.sockaddr_storage* %12 to %struct.sockaddr*
%85 = call i32 @recvfrom(i32 %82, i8* %83, i32 99, i32 0, %struct.sockaddr* %84, i32* %14)
store i32 %85, i32* %11
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %90
87: ; preds = %78
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %78
%91 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %12, i32 0, i32 0
%92 = load i32, i32* %91
%93 = bitcast %struct.sockaddr_storage* %12 to %struct.sockaddr*
%94 = call i32 @get_in_addr(%struct.sockaddr* %93)
%95 = trunc i64 %19 to i32
%96 = call i32 @inet_ntop(i32 %92, i32 %94, i8* %21, i32 %95)
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %21)
%98 = load i32, i32* %11
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i32 %98)
%100 = load i32, i32* %11
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 %101
store i8 0, i8* %102
%103 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0), i8* %103)
%105 = load i32, i32* %6
%106 = call i32 @close(i32 %105)
store i32 0, i32* %3
store i32 1, i32* %17
br label %107
107: ; preds = %90, %76, %31
%108 = load i8*, i8** %15
%109 = load i32, i32* %3
ret i32 %109
}

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"6000\00"
@.str.1 = [35 x i8] c"Listener: getaddrinfo() error: %s\0A\00"
@.str.6 = [28 x i8] c"Listener: recvfrom() failed\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 = [35 x i8] c"Listener: waiting to recvfrom()...\00"
@str.10 = [42 x i8] c"Listener: Socket Creation and Bind failed\00"
@str.11 = [64 x i8] c"Listener: Error binding Socket Decriptor to IP Address and Port\00"
@str.12 = [43 x i8] c"Listener: Error creating Socket Descriptor\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca %struct.sockaddr_storage
%6 = alloca [100 x i8]
%7 = alloca i32
%8 = bitcast %struct.addrinfo* %3 to i8*
%9 = bitcast %struct.addrinfo** %4 to i8*
%10 = bitcast %struct.sockaddr_storage* %5 to i8*
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%12 = bitcast i32* %7 to i8*
%13 = load i32, i32* @INET6_ADDRSTRLEN
%14 = zext i32 %13 to i64
%15 = tail call i8* @llvm.stacksave()
%16 = alloca i8, i64 %14
%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 @getaddrinfo(i32* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %3, %struct.addrinfo** %4)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %2
%27 = load %struct.addrinfo*, %struct.addrinfo** %4
%28 = icmp eq %struct.addrinfo* %27, null
br i1 %28, label %57, label %32
29: ; preds = %2
%30 = call i8* @gai_strerror(i32 %24)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %80
32: ; preds = %26, %51
%33 = phi %struct.addrinfo* [ %55, %51 ], [ %27, %26 ]
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %33, i64 0, i32 4
%35 = load i32, i32* %34
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %33, i64 0, i32 3
%37 = load i32, i32* %36
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %33, i64 0, i32 2
%39 = load i32, i32* %38
%40 = call i32 @socket(i32 %35, i32 %37, i32 %39)
%41 = icmp eq i32 %40, -1
br i1 %41, label %51, label %42
42: ; preds = %32
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %33, i64 0, i32 1
%44 = load i32, i32* %43
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %33, i64 0, i32 0
%46 = load i32, i32* %45
%47 = call i32 @bind(i32 %40, i32 %44, i32 %46)
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %59
49: ; preds = %42
%50 = call i32 @close(i32 %40)
br label %51
51: ; preds = %32, %49
%52 = phi i8* [ getelementptr inbounds ([64 x i8], [64 x i8]* @str.11, i64 0, i64 0), %49 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @str.12, i64 0, i64 0), %32 ]
%53 = call i32 @puts(i8* dereferenceable(1) %52)
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %33, i64 0, i32 5
%55 = load %struct.addrinfo*, %struct.addrinfo** %54
%56 = icmp eq %struct.addrinfo* %55, null
br i1 %56, label %57, label %32
57: ; preds = %51, %26
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.10, i64 0, i64 0))
br label %80
59: ; preds = %42
%60 = load %struct.addrinfo*, %struct.addrinfo** %4
%61 = call i32 @freeaddrinfo(%struct.addrinfo* %60)
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
store i32 4, i32* %7
%63 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
%64 = call i32 @recvfrom(i32 %40, i8* %11, i32 99, i32 0, %struct.sockaddr* %63, i32* %7)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %69
66: ; preds = %59
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 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* %5, i64 0, i32 0
%71 = load i32, i32* %70
%72 = call i32 @get_in_addr(%struct.sockaddr* %63)
%73 = call i32 @inet_ntop(i32 %71, i32 %72, i8* %16, i32 %13)
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %16)
%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]* %6, 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* %11)
%79 = call i32 @close(i32 %40)
br label %80
80: ; preds = %69, %57, %29
%81 = phi i32 [ 1, %29 ], [ 2, %57 ], [ 0, %69 ]
ret i32 %81
}