#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 timespec {
  double tv_nsec;
  scalar_t__ tv_sec;
};
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*/ senderAddr;
typedef int /*<<< orphan*/ ipString;
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ SOCK_DGRAM;
int bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int /*<<< orphan*/ getIpAsString(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*/ nanosleep(struct timespec *, struct timespec *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
long recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int socketFileDesc;
  struct addrinfo hints, *serverInfo, *aiPtr;
  int getInfoResult, bindResult;
  long numBytes;
  struct sockaddr_storage senderAddr;
  char message[100];
  socklen_t addressLength;
  char ipString[INET6_ADDRSTRLEN];
  struct timespec sleepTime, sleepTimeResult;
  sleepTime.tv_sec = 0;
  sleepTime.tv_nsec = .001 * 1000000000;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = AI_PASSIVE;
  getInfoResult = getaddrinfo(NULL, "8675", &hints, &serverInfo);
  if (getInfoResult != 0) {
    fprintf(stderr, "RoboClient Error: getaddrinfo: %s\n",
            gai_strerror(getInfoResult));
    exit(EXIT_FAILURE);
  }
  for (aiPtr = serverInfo; aiPtr != NULL; aiPtr = aiPtr->ai_next) {
    bindResult = -1;
    socketFileDesc =
        socket(aiPtr->ai_family, aiPtr->ai_socktype, aiPtr->ai_protocol);
    if (socketFileDesc == -1) {
      perror("RoboClient: socket error");
    } else {
      bindResult = bind(socketFileDesc, aiPtr->ai_addr, aiPtr->ai_addrlen);
      if (bindResult == -1) {
        close(socketFileDesc);
        perror("RoboClient: bind error.");
      }
    }
    if (socketFileDesc != -1 && bindResult != -1) {
      break;
    }
  }
  if (aiPtr == NULL) {
    fprintf(stderr, "RoboClient: failed to bind socket\n");
    exit(EXIT_FAILURE);
  }
  freeaddrinfo(serverInfo);
  printf("Starting listen loop. Waiting to 'recvfrom'...\n");
  addressLength = sizeof(senderAddr);
  while (strcmp(message, "exit") != 0) {
    numBytes = recvfrom(socketFileDesc, message, 100 - 1, 0,
                        (struct sockaddr *)&senderAddr, &addressLength);
    if (numBytes == -1) {
      perror("RoboClient: recvfrom problem");
      exit(EXIT_FAILURE);
    }
    message[numBytes] = '\0';
    inet_ntop(senderAddr.ss_family,
              getIpAsString((struct sockaddr *)&senderAddr), ipString,
              sizeof(ipString));
    printf("Got %d bytes from %s: %s\n", (int)numBytes, ipString, message);
    nanosleep(&sleepTime, &sleepTimeResult);
  }
  close(socketFileDesc);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x118(%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,-0x110(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xe8(%rbp)
movq   $0x0,-0xf0(%rbp)
movsd  0xd98(%rip),%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    0x2d51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2d41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd59(%rip),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1100 <getaddrinfo@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     1305 <main+0x105>
mov    0x2cf0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x11c(%rbp)
mov    -0x54(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0x11c(%rbp),%edi
mov    %rax,%rdx
lea    0xd1d(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     13c1 <main+0x1c1>
movl   $0xffffffff,-0x58(%rbp)
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)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1357 <main+0x157>
lea    0xce3(%rip),%rdi
call   10e0 <perror@plt>
jmp    1392 <main+0x192>
mov    -0x14(%rbp),%edi
mov    -0x50(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x50(%rbp),%rax
mov    (%rax),%edx
call   10d0 <bind@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0xffffffff,-0x58(%rbp)
jne    138d <main+0x18d>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    0xcc1(%rip),%rdi
call   10e0 <perror@plt>
jmp    1392 <main+0x192>
cmpl   $0xffffffff,-0x14(%rbp)
je     13ab <main+0x1ab>
cmpl   $0xffffffff,-0x58(%rbp)
je     13ab <main+0x1ab>
jmp    13c1 <main+0x1c1>
jmp    13b0 <main+0x1b0>
mov    -0x50(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x50(%rbp)
jmp    130d <main+0x10d>
cmpq   $0x0,-0x50(%rbp)
jne    13f1 <main+0x1f1>
mov    0x2bed(%rip),%rax
mov    (%rax),%edi
lea    0xc85(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2bce(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x48(%rbp),%rdi
call   1110 <freeaddrinfo@plt>
lea    0xc83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x4,-0xd4(%rbp)
lea    -0xd0(%rbp),%rdi
lea    0xc94(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     14ee <main+0x2ee>
mov    -0x14(%rbp),%edi
lea    -0xd0(%rbp),%rsi
lea    -0x68(%rbp),%r8
mov    $0x63,%edx
xor    %ecx,%ecx
lea    -0xd4(%rbp),%r9
call   10c0 <recvfrom@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0xffffffffffffffff,-0x60(%rbp)
jne    1479 <main+0x279>
lea    0xc53(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b46(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x60(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
mov    -0x68(%rbp),%eax
mov    %eax,-0x120(%rbp)
lea    -0x68(%rbp),%rdi
call   1050 <getIpAsString@plt>
mov    -0x120(%rbp),%edi
mov    -0x110(%rbp),%rdx
mov    %eax,%esi
mov    -0x118(%rbp),%rax
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x110(%rbp),%rdx
mov    -0x60(%rbp),%rax
mov    %eax,%esi
lea    -0xd0(%rbp),%rcx
lea    0xc07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xf8(%rbp),%rdi
lea    -0x108(%rbp),%rsi
call   1060 <nanosleep@plt>
jmp    1412 <main+0x212>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    0x2ab3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%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    $0xe8,%rsp
mov    %rsp,%r13
mov    0x2dba(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rax,-0x58(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
movq   $0x0,-0x60(%rbp)
movabs $0x412e848000000000,%rax
84 2e 41
mov    %rax,-0x68(%rbp)
lea    -0x90(%rbp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1090 <memset@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    0x2d49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
lea    0xd5d(%rip),%rsi
lea    -0x40(%rbp),%rcx
xor    %edi,%edi
mov    %rbx,%rdx
call   1110 <getaddrinfo@plt>
test   %eax,%eax
jne    1448 <main+0x238>
mov    -0x40(%rbp),%rbx
test   %rbx,%rbx
je     1313 <main+0x103>
lea    0xd5f(%rip),%r14
lea    0xd71(%rip),%r15
mov    0x10(%rbx),%edi
mov    0x8(%rbx),%edx
mov    0xc(%rbx),%esi
call   1130 <socket@plt>
mov    %r14,%rdi
cmp    $0xffffffff,%eax
je     1305 <main+0xf5>
mov    %eax,%r12d
mov    (%rbx),%edx
mov    0x4(%rbx),%esi
mov    %eax,%edi
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    132f <main+0x11f>
mov    %r12d,%edi
call   10a0 <close@plt>
mov    %r15,%rdi
call   10f0 <perror@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
jne    12d0 <main+0xc0>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
lea    0xd36(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    143a <main+0x22a>
mov    %r12d,-0x2c(%rbp)
mov    %r13,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
call   1120 <freeaddrinfo@plt>
lea    0xd71(%rip),%rdi
call   1040 <puts@plt>
movl   $0x4,-0x34(%rbp)
lea    0xd22(%rip),%rsi
lea    -0x110(%rbp),%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     140a <main+0x1fa>
lea    -0x110(%rbp),%r12
lea    -0x30(%rbp),%r13
mov    -0x50(%rbp),%rbx
xchg   %ax,%ax
mov    -0x2c(%rbp),%edi
mov    %r12,%rsi
mov    $0x63,%edx
xor    %ecx,%ecx
mov    %r13,%r8
lea    -0x34(%rbp),%r9
call   10d0 <recvfrom@plt>
cmp    $0xffffffffffffffff,%rax
je     142e <main+0x21e>
mov    %rax,%r14
movb   $0x0,-0x110(%rbp,%rax,1)
mov    -0x30(%rbp),%r15d
mov    %r13,%rdi
call   1060 <getIpAsString@plt>
mov    %r15d,%edi
mov    %eax,%esi
mov    %rbx,%rdx
mov    -0x58(%rbp),%rcx
call   1030 <inet_ntop@plt>
lea    0xccc(%rip),%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x68(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1070 <nanosleep@plt>
mov    %r12,%rdi
lea    0xc80(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    1380 <main+0x170>
mov    -0x2c(%rbp),%edi
call   10a0 <close@plt>
mov    0x2b97(%rip),%rax
mov    (%rax),%eax
mov    -0x48(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc4c(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    0x2b71(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1080 <gai_strerror@plt>
lea    0xba6(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    143a <main+0x22a>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.timespec = type { double, i64 }
%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"8675\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"RoboClient Error: getaddrinfo: %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [25 x i8] c"RoboClient: socket error\00"
@.str.3 = [24 x i8] c"RoboClient: bind error.\00"
@.str.4 = [35 x i8] c"RoboClient: failed to bind socket\0A\00"
@.str.5 = [48 x i8] c"Starting listen loop. Waiting to 'recvfrom'...\0A\00"
@.str.6 = [5 x i8] c"exit\00"
@.str.7 = [29 x i8] c"RoboClient: recvfrom problem\00"
@.str.8 = [26 x i8] c"Got %d bytes from %s: %s\0A\00"
@EXIT_SUCCESS = global i32 0
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 i64
%13 = alloca %struct.sockaddr_storage
%14 = alloca [100 x i8]
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i64
%18 = alloca %struct.timespec
%19 = alloca %struct.timespec
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* @INET6_ADDRSTRLEN
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %16
%23 = alloca i8, i64 %21
store i64 %21, i64* %17
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %18, i32 0, i32 1
store i64 0, i64* %24
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %18, i32 0, i32 0
store double 1.000000e+06, double* %25
%26 = call i32 @memset(%struct.addrinfo* %7, i32 0, i32 40)
%27 = load i32, i32* @AF_UNSPEC
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 4
store i32 %27, i32* %28
%29 = load i32, i32* @SOCK_DGRAM
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 3
store i32 %29, i32* %30
%31 = load i32, i32* @AI_PASSIVE
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 6
store i32 %31, i32* %32
%33 = 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 %33, i32* %10
%34 = load i32, i32* %10
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %2
%37 = load i32, i32* @stderr
%38 = load i32, i32* %10
%39 = call i8* @gai_strerror(i32 %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %2
%44 = load %struct.addrinfo*, %struct.addrinfo** %8
store %struct.addrinfo* %44, %struct.addrinfo** %9
br label %45
45: ; preds = %87, %43
%46 = load %struct.addrinfo*, %struct.addrinfo** %9
%47 = icmp ne %struct.addrinfo* %46, null
br i1 %47, label %48, label %91
48: ; preds = %45
store i32 -1, i32* %11
%49 = load %struct.addrinfo*, %struct.addrinfo** %9
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %49, i32 0, i32 4
%51 = load i32, i32* %50
%52 = load %struct.addrinfo*, %struct.addrinfo** %9
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %52, i32 0, i32 3
%54 = load i32, i32* %53
%55 = load %struct.addrinfo*, %struct.addrinfo** %9
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i32 0, i32 2
%57 = load i32, i32* %56
%58 = call i32 @socket(i32 %51, i32 %54, i32 %57)
store i32 %58, i32* %6
%59 = load i32, i32* %6
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %63
61: ; preds = %48
%62 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %79
63: ; preds = %48
%64 = load i32, i32* %6
%65 = load %struct.addrinfo*, %struct.addrinfo** %9
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i32 0, i32 1
%67 = load i32, i32* %66
%68 = load %struct.addrinfo*, %struct.addrinfo** %9
%69 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %68, i32 0, i32 0
%70 = load i32, i32* %69
%71 = call i32 @bind(i32 %64, i32 %67, i32 %70)
store i32 %71, i32* %11
%72 = load i32, i32* %11
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %78
74: ; preds = %63
%75 = load i32, i32* %6
%76 = call i32 @close(i32 %75)
%77 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %78
78: ; preds = %74, %63
br label %79
79: ; preds = %78, %61
%80 = load i32, i32* %6
%81 = icmp ne i32 %80, -1
br i1 %81, label %82, label %86
82: ; preds = %79
%83 = load i32, i32* %11
%84 = icmp ne i32 %83, -1
br i1 %84, label %85, label %86
85: ; preds = %82
br label %91
86: ; preds = %82, %79
br label %87
87: ; preds = %86
%88 = load %struct.addrinfo*, %struct.addrinfo** %9
%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** %9
br label %45
91: ; preds = %85, %45
%92 = load %struct.addrinfo*, %struct.addrinfo** %9
%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 ([35 x i8], [35 x i8]* @.str.4, 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** %8
%101 = call i32 @freeaddrinfo(%struct.addrinfo* %100)
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
store i32 4, i32* %15
br label %103
103: ; preds = %118, %99
%104 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%105 = call i64 @strcmp(i8* %104, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%106 = icmp ne i64 %105, 0
br i1 %106, label %107, label %132
107: ; preds = %103
%108 = load i32, i32* %6
%109 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%110 = bitcast %struct.sockaddr_storage* %13 to %struct.sockaddr*
%111 = call i64 @recvfrom(i32 %108, i8* %109, i32 99, i32 0, %struct.sockaddr* %110, i32* %15)
store i64 %111, i64* %12
%112 = load i64, i64* %12
%113 = icmp eq i64 %112, -1
br i1 %113, label %114, label %118
114: ; preds = %107
%115 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%116 = load i32, i32* @EXIT_FAILURE
%117 = call i32 @exit(i32 %116)
unreachable
118: ; preds = %107
%119 = load i64, i64* %12
%120 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 %119
store i8 0, i8* %120
%121 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %13, i32 0, i32 0
%122 = load i32, i32* %121
%123 = bitcast %struct.sockaddr_storage* %13 to %struct.sockaddr*
%124 = call i32 @getIpAsString(%struct.sockaddr* %123)
%125 = trunc i64 %21 to i32
%126 = call i32 @inet_ntop(i32 %122, i32 %124, i8* %23, i32 %125)
%127 = load i64, i64* %12
%128 = trunc i64 %127 to i32
%129 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %128, i8* %23, i8* %129)
%131 = call i32 @nanosleep(%struct.timespec* %18, %struct.timespec* %19)
br label %103
132: ; preds = %103
%133 = load i32, i32* %6
%134 = call i32 @close(i32 %133)
%135 = load i32, i32* @EXIT_SUCCESS
store i32 %135, i32* %3
%136 = load i8*, i8** %16
%137 = load i32, i32* %3
ret i32 %137
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.timespec = type { double, i64 }
%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"8675\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"RoboClient Error: getaddrinfo: %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [25 x i8] c"RoboClient: socket error\00"
@.str.3 = [24 x i8] c"RoboClient: bind error.\00"
@.str.4 = [35 x i8] c"RoboClient: failed to bind socket\0A\00"
@.str.6 = [5 x i8] c"exit\00"
@.str.7 = [29 x i8] c"RoboClient: recvfrom problem\00"
@.str.8 = [26 x i8] c"Got %d bytes from %s: %s\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [47 x i8] c"Starting listen loop. Waiting to 'recvfrom'...\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 = alloca %struct.timespec
%9 = alloca %struct.timespec
%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 [100 x i8], [100 x i8]* %6, i64 0, i64 0
%14 = bitcast i32* %7 to i8*
%15 = load i32, i32* @INET6_ADDRSTRLEN
%16 = zext i32 %15 to i64
%17 = tail call i8* @llvm.stacksave()
%18 = alloca i8, i64 %16
%19 = bitcast %struct.timespec* %8 to i8*
%20 = bitcast %struct.timespec* %9 to i8*
%21 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i64 0, i32 1
store i64 0, i64* %21
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i64 0, i32 0
store double 1.000000e+06, double* %22
%23 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 40)
%24 = load i32, i32* @AF_UNSPEC
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %24, i32* %25
%26 = load i32, i32* @SOCK_DGRAM
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %26, i32* %27
%28 = load i32, i32* @AI_PASSIVE
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 6
store i32 %28, i32* %29
%30 = 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)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %2
%33 = load %struct.addrinfo*, %struct.addrinfo** %4
%34 = icmp eq %struct.addrinfo* %33, null
br i1 %34, label %66, label %41
35: ; preds = %2
%36 = load i32, i32* @stderr
%37 = call i8* @gai_strerror(i32 %30)
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %37)
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %32, %60
%42 = phi %struct.addrinfo* [ %64, %60 ], [ %33, %32 ]
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i64 0, i32 4
%44 = load i32, i32* %43
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i64 0, i32 3
%46 = load i32, i32* %45
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i64 0, i32 2
%48 = load i32, i32* %47
%49 = call i32 @socket(i32 %44, i32 %46, i32 %48)
%50 = icmp eq i32 %49, -1
br i1 %50, label %60, label %51
51: ; preds = %41
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i64 0, i32 1
%53 = load i32, i32* %52
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i64 0, i32 0
%55 = load i32, i32* %54
%56 = call i32 @bind(i32 %49, i32 %53, i32 %55)
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %71
58: ; preds = %51
%59 = call i32 @close(i32 %49)
br label %60
60: ; preds = %41, %58
%61 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), %58 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), %41 ]
%62 = call i32 @perror(i8* %61)
%63 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i64 0, i32 5
%64 = load %struct.addrinfo*, %struct.addrinfo** %63
%65 = icmp eq %struct.addrinfo* %64, null
br i1 %65, label %66, label %41
66: ; preds = %60, %32
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %51
%72 = load %struct.addrinfo*, %struct.addrinfo** %4
%73 = call i32 @freeaddrinfo(%struct.addrinfo* %72)
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
store i32 4, i32* %7
%75 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %97, label %77
77: ; preds = %71
%78 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
%79 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 0, i32 0
br label %80
80: ; preds = %77, %87
%81 = call i64 @recvfrom(i32 %49, i8* %13, i32 99, i32 0, %struct.sockaddr* %78, i32* %7)
%82 = icmp eq i64 %81, -1
br i1 %82, label %83, label %87
83: ; preds = %80
%84 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%85 = load i32, i32* @EXIT_FAILURE
%86 = call i32 @exit(i32 %85)
unreachable
87: ; preds = %80
%88 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %81
store i8 0, i8* %88
%89 = load i32, i32* %79
%90 = call i32 @getIpAsString(%struct.sockaddr* %78)
%91 = call i32 @inet_ntop(i32 %89, i32 %90, i8* %18, i32 %15)
%92 = trunc i64 %81 to i32
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %92, i8* %18, i8* %13)
%94 = call i32 @nanosleep(%struct.timespec* %8, %struct.timespec* %9)
%95 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%96 = icmp eq i64 %95, 0
br i1 %96, label %97, label %80
97: ; preds = %87, %71
%98 = call i32 @close(i32 %49)
%99 = load i32, i32* @EXIT_SUCCESS
ret i32 %99
}