#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 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 /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
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 /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, int /*<<< orphan*/ *,
             int /*<<< orphan*/ *);
int sendto(int, char *, int /*<<< orphan*/, int /*<<< orphan*/,
           int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  int sockfd;
  struct addrinfo hints, *servinfo, *p;
  int rv;
  int numbytes;
  if (argc != 3) {
    fprintf(stderr, "usage: talker hostname message\n");
    exit(1);
  }
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_DGRAM;
  if ((rv = getaddrinfo(argv[1], "7447", &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 create socket\n");
    return 2;
  }
  if ((numbytes = sendto(sockfd, argv[2], strlen(argv[2]), 0, p->ai_addr,
                         p->ai_addrlen)) == -1) {
    perror("talker: sendto");
    exit(1);
  }
  printf("talker: sent %d bytes to %s\n", numbytes, argv[1]);
  printf("listener: waiting to recvfrom...\n");
  char buf[2000];
  if ((numbytes = recvfrom(sockfd, buf, 1999, 0, NULL, NULL)) == -1) {
    perror("recvfrom");
    exit(1);
  }
  printf("listener: packet is %d bytes long\n", numbytes);
  buf[numbytes] = '\0';
  printf("listener: packet contains \"%s\"\n", buf);
  if ((numbytes = sendto(sockfd, argv[2], strlen(argv[2]), 0, p->ai_addr,
                         p->ai_addrlen)) == -1) {
    perror("talker: sendto");
    exit(1);
  }
  printf("talker: sent %d bytes to %s\n", numbytes, argv[1]);
  printf("listener: waiting to recvfrom...\n");
  if ((numbytes = recvfrom(sockfd, buf, 1999, 0, NULL, NULL)) == -1) {
    perror("recvfrom");
    exit(1);
  }
  printf("listener: packet is %d bytes long\n", numbytes);
  buf[numbytes] = '\0';
  printf("listener: packet contains \"%s\"\n", buf);
  freeaddrinfo(servinfo);
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1214 <main+0x44>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xdfd(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2da9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd5(%rip),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   10d0 <getaddrinfo@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
je     129e <main+0xce>
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x824(%rbp)
mov    -0x4c(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x824(%rbp),%edi
mov    %rax,%rdx
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    154e <main+0x37e>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     12fe <main+0x12e>
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x48(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    12e8 <main+0x118>
lea    0xd58(%rip),%rdi
call   10b0 <perror@plt>
jmp    12ed <main+0x11d>
jmp    12fe <main+0x12e>
mov    -0x48(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    12a6 <main+0xd6>
cmpq   $0x0,-0x48(%rbp)
jne    132c <main+0x15c>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
lea    0xd2c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    154e <main+0x37e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x834(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x830(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x834(%rbp),%edi
mov    -0x830(%rbp),%rsi
mov    %eax,%edx
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x48(%rbp),%rax
mov    (%rax),%r9d
xor    %ecx,%ecx
call   1070 <sendto@plt>
mov    %eax,-0x50(%rbp)
cmp    $0xffffffff,%eax
jne    1398 <main+0x1c8>
lea    0xcdd(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x50(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xccb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x7cf,%edx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   10a0 <recvfrom@plt>
mov    %eax,-0x50(%rbp)
cmp    $0xffffffff,%eax
jne    13ff <main+0x22f>
lea    0xcc4(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x50(%rbp),%esi
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x50(%rbp),%rax
movb   $0x0,-0x820(%rbp,%rax,1)
lea    -0x820(%rbp),%rsi
lea    0xcb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x844(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x840(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x844(%rbp),%edi
mov    -0x840(%rbp),%rsi
mov    %eax,%edx
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x48(%rbp),%rax
mov    (%rax),%r9d
xor    %ecx,%ecx
call   1070 <sendto@plt>
mov    %eax,-0x50(%rbp)
cmp    $0xffffffff,%eax
jne    149d <main+0x2cd>
lea    0xbd8(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x50(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xbc6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xbd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x7cf,%edx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   10a0 <recvfrom@plt>
mov    %eax,-0x50(%rbp)
cmp    $0xffffffff,%eax
jne    1504 <main+0x334>
lea    0xbbf(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x50(%rbp),%esi
lea    0xbaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x50(%rbp),%rax
movb   $0x0,-0x820(%rbp,%rax,1)
lea    -0x820(%rbp),%rsi
lea    0xbb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
call   10e0 <freeaddrinfo@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
cmp    $0x3,%edi
jne    1425 <main+0x245>
mov    %rsi,%r15
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
mov    0x8(%r15),%rdi
lea    0xdec(%rip),%rsi
lea    0x8(%rsp),%rcx
mov    %rbx,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
je     1272 <main+0x92>
mov    0x2d84(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <gai_strerror@plt>
lea    0xdc9(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%ebx
jmp    1413 <main+0x233>
mov    0x8(%rsp),%rbp
test   %rbp,%rbp
je     12a7 <main+0xc7>
lea    0xdb3(%rip),%r14
mov    0x10(%rbp),%edi
mov    0x8(%rbp),%edx
mov    0xc(%rbp),%esi
call   1100 <socket@plt>
cmp    $0xffffffff,%eax
jne    12c8 <main+0xe8>
mov    %r14,%rdi
call   10c0 <perror@plt>
mov    0x18(%rbp),%rbp
test   %rbp,%rbp
jne    1283 <main+0xa3>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
lea    0xd8e(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x2,%ebx
jmp    1413 <main+0x233>
mov    %eax,%r12d
mov    0x10(%r15),%rbx
mov    %rbx,%rdi
call   1040 <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
je     1446 <main+0x266>
mov    0x8(%r15),%rdx
lea    0xd73(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdcc(%rip),%rdi
call   1030 <puts@plt>
lea    0x30(%rsp),%rsi
mov    %r12d,%edi
mov    $0x7cf,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   10b0 <recvfrom@plt>
cmp    $0xffffffff,%eax
je     144f <main+0x26f>
mov    %eax,%ebx
lea    0xd58(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq %ebx,%rax
movb   $0x0,0x30(%rsp,%rax,1)
lea    0xd63(%rip),%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%r15),%rbx
mov    %rbx,%rdi
call   1040 <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
je     1446 <main+0x266>
mov    0x8(%r15),%rdx
lea    0xcd7(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd2e(%rip),%rdi
call   1030 <puts@plt>
lea    0x30(%rsp),%rsi
mov    %r12d,%edi
mov    $0x7cf,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   10b0 <recvfrom@plt>
cmp    $0xffffffff,%eax
je     144f <main+0x26f>
mov    %eax,%ebp
lea    0xcbe(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq %ebp,%rax
movb   $0x0,0x30(%rsp,%rax,1)
lea    0xcc9(%rip),%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   10f0 <freeaddrinfo@plt>
mov    %r12d,%edi
call   1090 <close@plt>
mov    %ebx,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ba4(%rip),%rax
mov    (%rax),%edi
lea    0xbcb(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xc19(%rip),%rdi
jmp    1456 <main+0x276>
lea    0xc3c(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo* }
@stderr = global i32 0
@.str = [32 x i8] c"usage: talker hostname message\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [5 x i8] c"7447\00"
@.str.2 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.3 = [15 x i8] c"talker: socket\00"
@.str.4 = [33 x i8] c"talker: failed to create socket\0A\00"
@.str.5 = [15 x i8] c"talker: sendto\00"
@.str.6 = [29 x i8] c"talker: sent %d bytes to %s\0A\00"
@.str.7 = [34 x i8] c"listener: waiting to recvfrom...\0A\00"
@.str.8 = [9 x i8] c"recvfrom\00"
@.str.9 = [35 x i8] c"listener: packet is %d bytes long\0A\00"
@.str.10 = [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 [2000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = call i32 @memset(%struct.addrinfo* %7, i32 0, i32 32)
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 4
store i32 %21, i32* %22
%23 = load i32, i32* @SOCK_DGRAM
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 3
store i32 %23, i32* %24
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @getaddrinfo(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.addrinfo* %7, %struct.addrinfo** %8)
store i32 %28, i32* %10
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %19
%31 = load i32, i32* @stderr
%32 = load i32, i32* %10
%33 = call i8* @gai_strerror(i32 %32)
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %33)
store i32 1, i32* %3
br label %152
35: ; preds = %19
%36 = load %struct.addrinfo*, %struct.addrinfo** %8
store %struct.addrinfo* %36, %struct.addrinfo** %9
br label %37
37: ; preds = %55, %35
%38 = load %struct.addrinfo*, %struct.addrinfo** %9
%39 = icmp ne %struct.addrinfo* %38, null
br i1 %39, label %40, label %59
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 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %55
54: ; preds = %40
br label %59
55: ; preds = %52
%56 = load %struct.addrinfo*, %struct.addrinfo** %9
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 5
%58 = load %struct.addrinfo*, %struct.addrinfo** %57
store %struct.addrinfo* %58, %struct.addrinfo** %9
br label %37
59: ; preds = %54, %37
%60 = load %struct.addrinfo*, %struct.addrinfo** %9
%61 = icmp eq %struct.addrinfo* %60, null
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %3
br label %152
65: ; preds = %59
%66 = load i32, i32* %6
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 2
%69 = load i8*, i8** %68
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 2
%72 = load i8*, i8** %71
%73 = call i32 @strlen(i8* %72)
%74 = load %struct.addrinfo*, %struct.addrinfo** %9
%75 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %74, i32 0, i32 1
%76 = load i32, i32* %75
%77 = load %struct.addrinfo*, %struct.addrinfo** %9
%78 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %77, i32 0, i32 0
%79 = load i32, i32* %78
%80 = call i32 @sendto(i32 %66, i8* %69, i32 %73, i32 0, i32 %76, i32 %79)
store i32 %80, i32* %11
%81 = icmp eq i32 %80, -1
br i1 %81, label %82, label %85
82: ; preds = %65
%83 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %65
%86 = load i32, i32* %11
%87 = load i8**, i8*** %5
%88 = getelementptr inbounds i8*, i8** %87, i64 1
%89 = load i8*, i8** %88
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %86, i8* %89)
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%92 = load i32, i32* %6
%93 = getelementptr inbounds [2000 x i8], [2000 x i8]* %12, i64 0, i64 0
%94 = call i32 @recvfrom(i32 %92, i8* %93, i32 1999, i32 0, i32* null, i32* null)
store i32 %94, i32* %11
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %99
96: ; preds = %85
%97 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%98 = call i32 @exit(i32 1)
unreachable
99: ; preds = %85
%100 = load i32, i32* %11
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %100)
%102 = load i32, i32* %11
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [2000 x i8], [2000 x i8]* %12, i64 0, i64 %103
store i8 0, i8* %104
%105 = getelementptr inbounds [2000 x i8], [2000 x i8]* %12, i64 0, i64 0
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %105)
%107 = load i32, i32* %6
%108 = load i8**, i8*** %5
%109 = getelementptr inbounds i8*, i8** %108, i64 2
%110 = load i8*, i8** %109
%111 = load i8**, i8*** %5
%112 = getelementptr inbounds i8*, i8** %111, i64 2
%113 = load i8*, i8** %112
%114 = call i32 @strlen(i8* %113)
%115 = load %struct.addrinfo*, %struct.addrinfo** %9
%116 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %115, i32 0, i32 1
%117 = load i32, i32* %116
%118 = load %struct.addrinfo*, %struct.addrinfo** %9
%119 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %118, i32 0, i32 0
%120 = load i32, i32* %119
%121 = call i32 @sendto(i32 %107, i8* %110, i32 %114, i32 0, i32 %117, i32 %120)
store i32 %121, i32* %11
%122 = icmp eq i32 %121, -1
br i1 %122, label %123, label %126
123: ; preds = %99
%124 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%125 = call i32 @exit(i32 1)
unreachable
126: ; preds = %99
%127 = load i32, i32* %11
%128 = load i8**, i8*** %5
%129 = getelementptr inbounds i8*, i8** %128, i64 1
%130 = load i8*, i8** %129
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %127, i8* %130)
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%133 = load i32, i32* %6
%134 = getelementptr inbounds [2000 x i8], [2000 x i8]* %12, i64 0, i64 0
%135 = call i32 @recvfrom(i32 %133, i8* %134, i32 1999, i32 0, i32* null, i32* null)
store i32 %135, i32* %11
%136 = icmp eq i32 %135, -1
br i1 %136, label %137, label %140
137: ; preds = %126
%138 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%139 = call i32 @exit(i32 1)
unreachable
140: ; preds = %126
%141 = load i32, i32* %11
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %141)
%143 = load i32, i32* %11
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds [2000 x i8], [2000 x i8]* %12, i64 0, i64 %144
store i8 0, i8* %145
%146 = getelementptr inbounds [2000 x i8], [2000 x i8]* %12, i64 0, i64 0
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %146)
%148 = load %struct.addrinfo*, %struct.addrinfo** %8
%149 = call i32 @freeaddrinfo(%struct.addrinfo* %148)
%150 = load i32, i32* %6
%151 = call i32 @close(i32 %150)
store i32 0, i32* %3
br label %152
152: ; preds = %140, %62, %30
%153 = load i32, i32* %3
ret i32 %153
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo* }
@stderr = global i32 0
@.str = [32 x i8] c"usage: talker hostname message\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [5 x i8] c"7447\00"
@.str.2 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.3 = [15 x i8] c"talker: socket\00"
@.str.4 = [33 x i8] c"talker: failed to create socket\0A\00"
@.str.5 = [15 x i8] c"talker: sendto\00"
@.str.6 = [29 x i8] c"talker: sent %d bytes to %s\0A\00"
@.str.8 = [9 x i8] c"recvfrom\00"
@.str.9 = [35 x i8] c"listener: packet is %d bytes long\0A\00"
@.str.10 = [32 x i8] c"listener: packet contains \22%s\22\0A\00"
@str.11 = [33 x i8] c"listener: waiting to recvfrom...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca [2000 x i8]
%6 = bitcast %struct.addrinfo* %3 to i8*
%7 = bitcast %struct.addrinfo** %4 to i8*
%8 = icmp eq i32 %0, 3
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 32)
%15 = load i32, i32* @AF_INET
%16 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %15, i32* %16
%17 = load i32, i32* @SOCK_DGRAM
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %17, i32* %18
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @getaddrinfo(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.addrinfo* %3, %struct.addrinfo** %4)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %13
%24 = load %struct.addrinfo*, %struct.addrinfo** %4
%25 = icmp eq %struct.addrinfo* %24, null
br i1 %25, label %45, label %30
26: ; preds = %13
%27 = load i32, i32* @stderr
%28 = call i8* @gai_strerror(i32 %21)
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %102
30: ; preds = %23, %40
%31 = phi %struct.addrinfo* [ %43, %40 ], [ %24, %23 ]
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %31, i64 0, i32 4
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %31, i64 0, i32 3
%35 = load i32, i32* %34
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %31, i64 0, i32 2
%37 = load i32, i32* %36
%38 = call i32 @socket(i32 %33, i32 %35, i32 %37)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %48
40: ; preds = %30
%41 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %31, i64 0, i32 5
%43 = load %struct.addrinfo*, %struct.addrinfo** %42
%44 = icmp eq %struct.addrinfo* %43, null
br i1 %44, label %45, label %30
45: ; preds = %40, %23
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %102
48: ; preds = %30
%49 = getelementptr inbounds i8*, i8** %1, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @strlen(i8* %50)
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %31, i64 0, i32 1
%53 = load i32, i32* %52
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %31, i64 0, i32 0
%55 = load i32, i32* %54
%56 = call i32 @sendto(i32 %38, i8* %50, i32 %51, i32 0, i32 %53, i32 %55)
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %61
58: ; preds = %48
%59 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %48
%62 = load i8*, i8** %19
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %56, i8* %62)
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.11, i64 0, i64 0))
%65 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%66 = call i32 @recvfrom(i32 %38, i8* %65, i32 1999, i32 0, i32* null, i32* null)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %71
68: ; preds = %61
%69 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %61
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %66)
%73 = sext i32 %66 to i64
%74 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 %73
store i8 0, i8* %74
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %65)
%76 = load i8*, i8** %49
%77 = call i32 @strlen(i8* %76)
%78 = load i32, i32* %52
%79 = load i32, i32* %54
%80 = call i32 @sendto(i32 %38, i8* %76, i32 %77, i32 0, i32 %78, i32 %79)
%81 = icmp eq i32 %80, -1
br i1 %81, label %82, label %85
82: ; preds = %71
%83 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %71
%86 = load i8*, i8** %19
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %80, i8* %86)
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.11, i64 0, i64 0))
%89 = call i32 @recvfrom(i32 %38, i8* %65, i32 1999, i32 0, i32* null, i32* null)
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %94
91: ; preds = %85
%92 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %85
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %89)
%96 = sext i32 %89 to i64
%97 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 %96
store i8 0, i8* %97
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %65)
%99 = load %struct.addrinfo*, %struct.addrinfo** %4
%100 = call i32 @freeaddrinfo(%struct.addrinfo* %99)
%101 = call i32 @close(i32 %38)
br label %102
102: ; preds = %94, %45, %26
%103 = phi i32 [ 1, %26 ], [ 2, %45 ], [ 0, %94 ]
ret i32 %103
}