#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 pollfd {
  int fd;
  int events;
  int revents;
};
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;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int POLLIN;
int POLLRDNORM;
int /*<<< orphan*/ SHUT_WR;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int fileno(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *gai_strerror(int);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, int /*<<< orphan*/ *,
             int /*<<< orphan*/ *);
int sendto(int, char *, int, int /*<<< orphan*/, int /*<<< orphan*/,
           int /*<<< orphan*/);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char *argv[]) {
  int sockfd;
  char buf[10 * 1024];
  int n_read, nready, maxi;
  struct pollfd client[2 - 1];
  struct addrinfo hints, *servinfo, *p;
  char sendline[160], recvline[160];
  int rv;
  int numbytes;
  if (argc != 2) {
    fprintf(stderr, "usage: talker hostname/IP\n");
    exit(1);
  }
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_DGRAM;
  if ((rv = getaddrinfo(argv[1], "3300", &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("talker: socket");
      continue;
    }
    break;
  }
  if (p == NULL) {
    fprintf(stderr, "talker: failed to bind socket\n");
    return 2;
  }
  client[0].fd = sockfd;
  client[1].fd = fileno(stdin);
  client[0].events = POLLRDNORM;
  client[1].events = POLLIN;
  if ((numbytes = sendto(sockfd, NULL, 0, 0, p->ai_addr, p->ai_addrlen)) ==
      -1) {
    perror("talker: sendto");
  }
  printf("zero byte sent\n");
  while ((*sendline != 26)) {
    nready = poll(client, 2, 5);
    if (nready > 0) {
    }
    if (client[1].revents & POLLIN) {
      if (fgets(sendline, 160, stdin) == NULL) {
        shutdown(sockfd, SHUT_WR);
        continue;
      } else {
        sendline[strlen(sendline) - 1] = 0;
        if ((numbytes = sendto(sockfd, sendline, strlen(sendline), 0,
                               p->ai_addr, p->ai_addrlen)) == -1) {
          perror("talker: sendto");
          exit(1);
        }
      }
    } else if (client[0].revents & POLLRDNORM) {
      n_read = recvfrom(sockfd, buf, 10 * 1024, 0, NULL, NULL);
      if (n_read < 0) {
        perror("Problem in recvfrom");
        exit(1);
      }
      printf("%s\n", buf);
    }
  }
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x29d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1244 <main+0x44>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    -0x2858(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2848(%rbp)
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x284c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd97(%rip),%rsi
lea    -0x2858(%rbp),%rdx
lea    -0x2860(%rbp),%rcx
call   1110 <getaddrinfo@plt>
mov    %eax,-0x29b4(%rbp)
cmp    $0x0,%eax
je     12e3 <main+0xe3>
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x29bc(%rbp)
mov    -0x29b4(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    -0x29bc(%rbp),%edi
mov    %rax,%rdx
lea    0xd50(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15c8 <main+0x3c8>
mov    -0x2860(%rbp),%rax
mov    %rax,-0x2868(%rbp)
cmpq   $0x0,-0x2868(%rbp)
je     135b <main+0x15b>
mov    -0x2868(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x2868(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x2868(%rbp),%rax
mov    0x8(%rax),%edx
call   1120 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    133f <main+0x13f>
lea    0xcfc(%rip),%rdi
call   10f0 <perror@plt>
jmp    1344 <main+0x144>
jmp    135b <main+0x15b>
mov    -0x2868(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x2868(%rbp)
jmp    12f1 <main+0xf1>
cmpq   $0x0,-0x2868(%rbp)
jne    138c <main+0x18c>
mov    0x2c40(%rip),%rax
mov    (%rax),%edi
lea    0xcc7(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    15c8 <main+0x3c8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2838(%rbp)
mov    0x2c34(%rip),%rax
mov    (%rax),%edi
call   10c0 <fileno@plt>
mov    %eax,-0x282c(%rbp)
mov    0x2c30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2834(%rbp)
mov    0x2c01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2828(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x2868(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x2868(%rbp),%rax
mov    (%rax),%r9d
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1080 <sendto@plt>
mov    %eax,-0x29b8(%rbp)
cmp    $0xffffffff,%eax
jne    1407 <main+0x207>
lea    0xc5d(%rip),%rdi
call   10f0 <perror@plt>
lea    0xc60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsbl -0x2910(%rbp),%eax
cmp    $0x1a,%eax
je     15b9 <main+0x3b9>
lea    -0x2838(%rbp),%rdi
mov    $0x2,%esi
mov    $0x5,%edx
call   10e0 <poll@plt>
mov    %eax,-0x2828(%rbp)
cmpl   $0x0,-0x2828(%rbp)
jle    1453 <main+0x253>
jmp    1453 <main+0x253>
mov    -0x2824(%rbp),%eax
mov    0x2b60(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     153b <main+0x33b>
lea    -0x2910(%rbp),%rdi
mov    0x2b57(%rip),%rax
mov    (%rax),%edx
mov    $0xa0,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
jne    14a5 <main+0x2a5>
mov    -0x14(%rbp),%edi
mov    0x2b3f(%rip),%rax
mov    (%rax),%esi
call   1030 <shutdown@plt>
jmp    1415 <main+0x215>
lea    -0x2910(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x2910(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
mov    %eax,-0x29cc(%rbp)
lea    -0x2910(%rbp),%rax
mov    %rax,-0x29c8(%rbp)
lea    -0x2910(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x29cc(%rbp),%edi
mov    -0x29c8(%rbp),%rsi
mov    %eax,%edx
mov    -0x2868(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x2868(%rbp),%rax
mov    (%rax),%r9d
xor    %ecx,%ecx
call   1080 <sendto@plt>
mov    %eax,-0x29b8(%rbp)
cmp    $0xffffffff,%eax
jne    1531 <main+0x331>
lea    0xb3d(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
jmp    1536 <main+0x336>
jmp    15b4 <main+0x3b4>
mov    -0x2830(%rbp),%eax
mov    0x2a98(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     15af <main+0x3af>
mov    -0x14(%rbp),%edi
lea    -0x2820(%rbp),%rsi
mov    $0x2800,%edx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   10d0 <recvfrom@plt>
mov    %eax,-0x2824(%rbp)
cmpl   $0x0,-0x2824(%rbp)
jge    159a <main+0x39a>
lea    0xaf3(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    -0x2820(%rbp),%rsi
lea    0xa85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    15b4 <main+0x3b4>
jmp    1415 <main+0x215>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x29d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28e8,%rsp
cmp    $0x2,%edi
jne    1478 <main+0x278>
mov    %rsi,%rbx
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    0x2d83(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%rsp)
mov    0x8(%rbx),%rdi
lea    0xdc5(%rip),%rsi
lea    0x18(%rsp),%rcx
mov    %rbp,%rdx
call   1110 <getaddrinfo@plt>
test   %eax,%eax
je     1294 <main+0x94>
mov    0x2d42(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <gai_strerror@plt>
lea    0xda2(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%eax
jmp    1436 <main+0x236>
mov    0x18(%rsp),%rbp
test   %rbp,%rbp
je     12c9 <main+0xc9>
lea    0xd8c(%rip),%rbx
mov    0x10(%rbp),%edi
mov    0x8(%rbp),%edx
mov    0xc(%rbp),%esi
call   1120 <socket@plt>
cmp    $0xffffffff,%eax
jne    12ea <main+0xea>
mov    %rbx,%rdi
call   10f0 <perror@plt>
mov    0x18(%rbp),%rbp
test   %rbp,%rbp
jne    12a5 <main+0xa5>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
lea    0xd67(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x2,%eax
jmp    1436 <main+0x236>
mov    %eax,%r12d
mov    %eax,0x8(%rsp)
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
call   10c0 <fileno@plt>
mov    %eax,0x14(%rsp)
mov    0x2cd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2ca9(%rip),%r13
mov    0x0(%r13),%eax
mov    %eax,0x18(%rsp)
mov    0x0(%rbp),%r9d
mov    0x4(%rbp),%r8d
mov    %r12d,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1080 <sendto@plt>
cmp    $0xffffffff,%eax
je     1448 <main+0x248>
lea    0xd3d(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%r14
lea    0xe0(%rsp),%r15
lea    0x40(%rsp),%rbx
jmp    137c <main+0x17c>
xchg   %ax,%ax
mov    0x2c71(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
call   1040 <shutdown@plt>
cmpb   $0x1a,0x40(%rsp)
je     142c <main+0x22c>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x5,%edx
call   10e0 <poll@plt>
mov    0x0(%r13),%eax
test   %eax,0x1c(%rsp)
je     13f0 <main+0x1f0>
mov    0x2c31(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xa0,%esi
call   10a0 <fgets@plt>
test   %rax,%rax
je     1360 <main+0x160>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    0x0(%rbp),%r9d
mov    0x4(%rbp),%r8d
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <sendto@plt>
cmp    $0xffffffff,%eax
jne    1371 <main+0x171>
jmp    1459 <main+0x259>
nopl   0x0(%rax,%rax,1)
mov    0x2be9(%rip),%rax
mov    (%rax),%eax
test   %eax,0x10(%rsp)
je     1371 <main+0x171>
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x2800,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   10d0 <recvfrom@plt>
test   %eax,%eax
js     1462 <main+0x262>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    1371 <main+0x171>
mov    %r12d,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x28e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc10(%rip),%rdi
call   10f0 <perror@plt>
jmp    133e <main+0x13e>
lea    0xbff(%rip),%rdi
jmp    1469 <main+0x269>
lea    0xc05(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x2b31(%rip),%rax
mov    (%rax),%edi
lea    0xb78(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32 }
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo* }
@stderr = global i32 0
@.str = [27 x i8] c"usage: talker hostname/IP\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [5 x i8] c"3300\00"
@.str.2 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.3 = [15 x i8] c"talker: socket\00"
@.str.4 = [31 x i8] c"talker: failed to bind socket\0A\00"
@stdin = global i32 0
@POLLRDNORM = global i32 0
@POLLIN = global i32 0
@.str.5 = [15 x i8] c"talker: sendto\00"
@.str.6 = [16 x i8] c"zero byte sent\0A\00"
@SHUT_WR = global i32 0
@.str.7 = [20 x i8] c"Problem in recvfrom\00"
@.str.8 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [10240 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [1 x %struct.pollfd]
%12 = alloca %struct.addrinfo
%13 = alloca %struct.addrinfo*
%14 = alloca %struct.addrinfo*
%15 = alloca [160 x i8]
%16 = alloca [160 x i8]
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 2
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
%26 = call i32 @memset(%struct.addrinfo* %12, i32 0, i32 32)
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 4
store i32 %27, i32* %28
%29 = load i32, i32* @SOCK_DGRAM
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 3
store i32 %29, i32* %30
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @getaddrinfo(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.addrinfo* %12, %struct.addrinfo** %13)
store i32 %34, i32* %17
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %25
%37 = load i32, i32* @stderr
%38 = load i32, i32* %17
%39 = call i8* @gai_strerror(i32 %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %39)
store i32 1, i32* %3
br label %172
41: ; preds = %25
%42 = load %struct.addrinfo*, %struct.addrinfo** %13
store %struct.addrinfo* %42, %struct.addrinfo** %14
br label %43
43: ; preds = %61, %41
%44 = load %struct.addrinfo*, %struct.addrinfo** %14
%45 = icmp ne %struct.addrinfo* %44, null
br i1 %45, label %46, label %65
46: ; preds = %43
%47 = load %struct.addrinfo*, %struct.addrinfo** %14
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %47, i32 0, i32 4
%49 = load i32, i32* %48
%50 = load %struct.addrinfo*, %struct.addrinfo** %14
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i32 0, i32 3
%52 = load i32, i32* %51
%53 = load %struct.addrinfo*, %struct.addrinfo** %14
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 2
%55 = load i32, i32* %54
%56 = call i32 @socket(i32 %49, i32 %52, i32 %55)
store i32 %56, i32* %6
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %60
58: ; preds = %46
%59 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %61
60: ; preds = %46
br label %65
61: ; preds = %58
%62 = load %struct.addrinfo*, %struct.addrinfo** %14
%63 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %62, i32 0, i32 5
%64 = load %struct.addrinfo*, %struct.addrinfo** %63
store %struct.addrinfo* %64, %struct.addrinfo** %14
br label %43
65: ; preds = %60, %43
%66 = load %struct.addrinfo*, %struct.addrinfo** %14
%67 = icmp eq %struct.addrinfo* %66, null
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %3
br label %172
71: ; preds = %65
%72 = load i32, i32* %6
%73 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %11, i64 0, i64 0
%74 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %73, i32 0, i32 0
store i32 %72, i32* %74
%75 = load i32, i32* @stdin
%76 = call i32 @fileno(i32 %75)
%77 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %11, i64 0, i64 1
%78 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %77, i32 0, i32 0
store i32 %76, i32* %78
%79 = load i32, i32* @POLLRDNORM
%80 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %11, i64 0, i64 0
%81 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %80, i32 0, i32 1
store i32 %79, i32* %81
%82 = load i32, i32* @POLLIN
%83 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %11, i64 0, i64 1
%84 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %83, i32 0, i32 1
store i32 %82, i32* %84
%85 = load i32, i32* %6
%86 = load %struct.addrinfo*, %struct.addrinfo** %14
%87 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %86, i32 0, i32 1
%88 = load i32, i32* %87
%89 = load %struct.addrinfo*, %struct.addrinfo** %14
%90 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %89, i32 0, i32 0
%91 = load i32, i32* %90
%92 = call i32 @sendto(i32 %85, i8* null, i32 0, i32 0, i32 %88, i32 %91)
store i32 %92, i32* %18
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %96
94: ; preds = %71
%95 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %96
96: ; preds = %94, %71
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %98
98: ; preds = %168, %121, %96
%99 = getelementptr inbounds [160 x i8], [160 x i8]* %15, i64 0, i64 0
%100 = load i8, i8* %99
%101 = sext i8 %100 to i32
%102 = icmp ne i32 %101, 26
br i1 %102, label %103, label %169
103: ; preds = %98
%104 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %11, i64 0, i64 0
%105 = call i32 @poll(%struct.pollfd* %104, i32 2, i32 5)
store i32 %105, i32* %9
%106 = load i32, i32* %9
%107 = icmp sgt i32 %106, 0
br i1 %107, label %108, label %109
108: ; preds = %103
br label %109
109: ; preds = %108, %103
%110 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %11, i64 0, i64 1
%111 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %110, i32 0, i32 2
%112 = load i32, i32* %111
%113 = load i32, i32* @POLLIN
%114 = and i32 %112, %113
%115 = icmp ne i32 %114, 0
br i1 %115, label %116, label %148
116: ; preds = %109
%117 = getelementptr inbounds [160 x i8], [160 x i8]* %15, i64 0, i64 0
%118 = load i32, i32* @stdin
%119 = call i32* @fgets(i8* %117, i32 160, i32 %118)
%120 = icmp eq i32* %119, null
br i1 %120, label %121, label %125
121: ; preds = %116
%122 = load i32, i32* %6
%123 = load i32, i32* @SHUT_WR
%124 = call i32 @shutdown(i32 %122, i32 %123)
br label %98
125: ; preds = %116
%126 = getelementptr inbounds [160 x i8], [160 x i8]* %15, i64 0, i64 0
%127 = call i32 @strlen(i8* %126)
%128 = sub nsw i32 %127, 1
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [160 x i8], [160 x i8]* %15, i64 0, i64 %129
store i8 0, i8* %130
%131 = load i32, i32* %6
%132 = getelementptr inbounds [160 x i8], [160 x i8]* %15, i64 0, i64 0
%133 = getelementptr inbounds [160 x i8], [160 x i8]* %15, i64 0, i64 0
%134 = call i32 @strlen(i8* %133)
%135 = load %struct.addrinfo*, %struct.addrinfo** %14
%136 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %135, i32 0, i32 1
%137 = load i32, i32* %136
%138 = load %struct.addrinfo*, %struct.addrinfo** %14
%139 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %138, i32 0, i32 0
%140 = load i32, i32* %139
%141 = call i32 @sendto(i32 %131, i8* %132, i32 %134, i32 0, i32 %137, i32 %140)
store i32 %141, i32* %18
%142 = icmp eq i32 %141, -1
br i1 %142, label %143, label %146
143: ; preds = %125
%144 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%145 = call i32 @exit(i32 1)
unreachable
146: ; preds = %125
br label %147
147: ; preds = %146
br label %168
148: ; preds = %109
%149 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %11, i64 0, i64 0
%150 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %149, i32 0, i32 2
%151 = load i32, i32* %150
%152 = load i32, i32* @POLLRDNORM
%153 = and i32 %151, %152
%154 = icmp ne i32 %153, 0
br i1 %154, label %155, label %167
155: ; preds = %148
%156 = load i32, i32* %6
%157 = getelementptr inbounds [10240 x i8], [10240 x i8]* %7, i64 0, i64 0
%158 = call i32 @recvfrom(i32 %156, i8* %157, i32 10240, i32 0, i32* null, i32* null)
store i32 %158, i32* %8
%159 = load i32, i32* %8
%160 = icmp slt i32 %159, 0
br i1 %160, label %161, label %164
161: ; preds = %155
%162 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%163 = call i32 @exit(i32 1)
unreachable
164: ; preds = %155
%165 = getelementptr inbounds [10240 x i8], [10240 x i8]* %7, i64 0, i64 0
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %165)
br label %167
167: ; preds = %164, %148
br label %168
168: ; preds = %167, %147
br label %98
169: ; preds = %98
%170 = load i32, i32* %6
%171 = call i32 @close(i32 %170)
store i32 0, i32* %3
br label %172
172: ; preds = %169, %68, %36
%173 = load i32, i32* %3
ret i32 %173
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32 }
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo* }
@stderr = global i32 0
@.str = [27 x i8] c"usage: talker hostname/IP\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [5 x i8] c"3300\00"
@.str.2 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.3 = [15 x i8] c"talker: socket\00"
@.str.4 = [31 x i8] c"talker: failed to bind socket\0A\00"
@stdin = global i32 0
@POLLRDNORM = global i32 0
@POLLIN = global i32 0
@.str.5 = [15 x i8] c"talker: sendto\00"
@SHUT_WR = global i32 0
@.str.7 = [20 x i8] c"Problem in recvfrom\00"
@str = [15 x i8] c"zero byte sent\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10240 x i8]
%4 = alloca [1 x %struct.pollfd]
%5 = alloca %struct.addrinfo
%6 = alloca %struct.addrinfo*
%7 = alloca [160 x i8]
%8 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 0
%9 = bitcast [1 x %struct.pollfd]* %4 to i8*
%10 = bitcast %struct.addrinfo* %5 to i8*
%11 = bitcast %struct.addrinfo** %6 to i8*
%12 = getelementptr inbounds [160 x i8], [160 x i8]* %7, i64 0, i64 0
%13 = icmp eq i32 %0, 2
br i1 %13, label %18, label %14
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = call i32 @memset(%struct.addrinfo* %5, i32 0, i32 32)
%20 = load i32, i32* @AF_INET
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 4
store i32 %20, i32* %21
%22 = load i32, i32* @SOCK_DGRAM
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 3
store i32 %22, i32* %23
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @getaddrinfo(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.addrinfo* %5, %struct.addrinfo** %6)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %18
%29 = load %struct.addrinfo*, %struct.addrinfo** %6
%30 = icmp eq %struct.addrinfo* %29, null
br i1 %30, label %50, label %35
31: ; preds = %18
%32 = load i32, i32* @stderr
%33 = call i8* @gai_strerror(i32 %26)
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %33)
br label %119
35: ; preds = %28, %45
%36 = phi %struct.addrinfo* [ %48, %45 ], [ %29, %28 ]
%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 %45, label %53
45: ; preds = %35
%46 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 5
%48 = load %struct.addrinfo*, %struct.addrinfo** %47
%49 = icmp eq %struct.addrinfo* %48, null
br i1 %49, label %50, label %35
50: ; preds = %45, %28
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %119
53: ; preds = %35
%54 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %4, i64 0, i64 0
%55 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %4, i64 0, i64 0, i32 0
store i32 %43, i32* %55
%56 = load i32, i32* @stdin
%57 = call i32 @fileno(i32 %56)
%58 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %4, i64 0, i64 1, i32 0
store i32 %57, i32* %58
%59 = load i32, i32* @POLLRDNORM
%60 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %4, i64 0, i64 0, i32 1
store i32 %59, i32* %60
%61 = load i32, i32* @POLLIN
%62 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %4, i64 0, i64 1, i32 1
store i32 %61, i32* %62
%63 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 1
%64 = load i32, i32* %63
%65 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 0
%66 = load i32, i32* %65
%67 = call i32 @sendto(i32 %43, i8* null, i32 0, i32 0, i32 %64, i32 %66)
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %71
69: ; preds = %53
%70 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %71
71: ; preds = %53, %69
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%73 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %4, i64 0, i64 1, i32 2
%74 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %4, i64 0, i64 0, i32 2
br label %75
75: ; preds = %71, %88
%76 = call i32 @poll(%struct.pollfd* %54, i32 2, i32 5)
%77 = load i32, i32* %73
%78 = load i32, i32* @POLLIN
%79 = and i32 %78, %77
%80 = icmp eq i32 %79, 0
br i1 %80, label %104, label %81
81: ; preds = %75
%82 = load i32, i32* @stdin
%83 = call i32* @fgets(i8* %12, i32 160, i32 %82)
%84 = icmp eq i32* %83, null
br i1 %84, label %85, label %91
85: ; preds = %81
%86 = load i32, i32* @SHUT_WR
%87 = call i32 @shutdown(i32 %43, i32 %86)
br label %88
88: ; preds = %91, %115, %104, %85
%89 = load i8, i8* %12
%90 = icmp eq i8 %89, 26
br i1 %90, label %117, label %75
91: ; preds = %81
%92 = call i32 @strlen(i8* %12)
%93 = add nsw i32 %92, -1
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [160 x i8], [160 x i8]* %7, i64 0, i64 %94
store i8 0, i8* %95
%96 = call i32 @strlen(i8* %12)
%97 = load i32, i32* %63
%98 = load i32, i32* %65
%99 = call i32 @sendto(i32 %43, i8* %12, i32 %96, i32 0, i32 %97, i32 %98)
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %88
101: ; preds = %91
%102 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%103 = call i32 @exit(i32 1)
unreachable
104: ; preds = %75
%105 = load i32, i32* %74
%106 = load i32, i32* @POLLRDNORM
%107 = and i32 %106, %105
%108 = icmp eq i32 %107, 0
br i1 %108, label %88, label %109
109: ; preds = %104
%110 = call i32 @recvfrom(i32 %43, i8* %8, i32 10240, i32 0, i32* null, i32* null)
%111 = icmp slt i32 %110, 0
br i1 %111, label %112, label %115
112: ; preds = %109
%113 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%114 = call i32 @exit(i32 1)
unreachable
115: ; preds = %109
%116 = call i32 @puts(i8* %8)
br label %88
117: ; preds = %88
%118 = call i32 @close(i32 %43)
br label %119
119: ; preds = %117, %50, %31
%120 = phi i32 [ 1, %31 ], [ 2, %50 ], [ 0, %117 ]
ret i32 %120
}