#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;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  struct addrinfo *ai_next;
  scalar_t__ ai_flags;
};
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
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, char *);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, scalar_t__);
int /*<<< orphan*/ stderr;
int strlen(char *);
size_t write(int, char *, size_t);
int main(int argc, char *argv[]) {
  struct addrinfo hints;
  struct addrinfo *result, *rp;
  int sfd, s, j;
  size_t len;
  ssize_t nread;
  char buf[500];
  if (argc < 3) {
    fprintf(stderr, "Usage: %s host port msg...\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = 0;
  hints.ai_protocol = 0;
  s = getaddrinfo(argv[1], argv[2], &hints, &result);
  if (s != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
    exit(EXIT_FAILURE);
  }
  for (rp = result; rp != NULL; rp = rp->ai_next) {
    sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
    if (sfd == -1)
      continue;
    if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1)
      break;
    close(sfd);
  }
  if (rp == NULL) {
    fprintf(stderr, "Could not connect\n");
    exit(EXIT_FAILURE);
  }
  freeaddrinfo(result);
  for (j = 3; j < argc; j++) {
    len = strlen(argv[j]) + 1;
    if (len + 1 > 500) {
      fprintf(stderr, "Ignoring long message in argument %d\n", j);
      continue;
    }
    if (write(sfd, argv[j], len) != len) {
      fprintf(stderr, "partial/failed write\n");
      exit(EXIT_FAILURE);
    }
    nread = read(sfd, buf, 500);
    if (nread == -1) {
      perror("read");
      exit(EXIT_FAILURE);
    }
    printf("Received %zd bytes: %s\n", nread, buf);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    122f <main+0x4f>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
je     12cd <main+0xed>
mov    0x2d38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x264(%rbp)
mov    -0x50(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    -0x264(%rbp),%edi
mov    %rax,%rdx
lea    0xd64(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1349 <main+0x169>
mov    -0x48(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%rdx
call   1100 <socket@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0xffffffff,-0x4c(%rbp)
jne    130d <main+0x12d>
jmp    1338 <main+0x158>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x48(%rbp),%rax
mov    (%rax),%edx
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
je     1330 <main+0x150>
jmp    1349 <main+0x169>
mov    -0x4c(%rbp),%edi
call   1080 <close@plt>
mov    -0x48(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    12d5 <main+0xf5>
cmpq   $0x0,-0x48(%rbp)
jne    1379 <main+0x199>
mov    0x2c75(%rip),%rax
mov    (%rax),%edi
lea    0xcc9(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x40(%rbp),%rdi
call   10f0 <freeaddrinfo@plt>
movl   $0x3,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1488 <main+0x2a8>
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
cmp    $0x1f4,%rax
jbe    13e2 <main+0x202>
mov    0x2c06(%rip),%rax
mov    (%rax),%edi
mov    -0x54(%rbp),%edx
lea    0xc6a(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    147a <main+0x29a>
mov    -0x4c(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x60(%rbp),%rdx
call   1030 <write@plt>
cmp    -0x60(%rbp),%rax
je     1429 <main+0x249>
mov    0x2bc5(%rip),%rax
mov    (%rax),%edi
lea    0xc52(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2ba6(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x4c(%rbp),%edi
lea    -0x260(%rbp),%rsi
mov    $0x1f4,%edx
call   1090 <read@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    1464 <main+0x284>
lea    0xc2b(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2b6b(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x64(%rbp),%esi
lea    -0x260(%rbp),%rdx
lea    0xc0c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1389 <main+0x1a9>
mov    0x2b31(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
mov    %rsi,%r15
cmp    $0x2,%edi
jg     1211 <main+0x31>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xdf4(%rip),%rsi
jmp    137b <main+0x19b>
mov    %edi,%r14d
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
movq   $0x0,0x28(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x8(%r15),%rdi
mov    0x10(%r15),%rsi
mov    %rsp,%rcx
mov    %rbx,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
jne    135f <main+0x17f>
mov    (%rsp),%rbx
jmp    128b <main+0xab>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
call   1080 <close@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
je     1384 <main+0x1a4>
mov    0x14(%rbx),%edi
mov    0x10(%rbx),%esi
mov    0x8(%rbx),%rdx
call   1100 <socket@plt>
cmp    $0xffffffff,%eax
je     1287 <main+0xa7>
mov    %eax,%ebp
mov    (%rbx),%edx
mov    0x4(%rbx),%esi
mov    %eax,%edi
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
je     1280 <main+0xa0>
mov    (%rsp),%rdi
call   10f0 <freeaddrinfo@plt>
cmp    $0x4,%r14d
jl     13a9 <main+0x1c9>
mov    %r14d,%r13d
mov    $0x3,%ebx
lea    0x30(%rsp),%r12
jmp    1306 <main+0x126>
nopl   (%rax)
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
lea    0xd50(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
je     13a9 <main+0x1c9>
mov    (%r15,%rbx,8),%rdi
call   1040 <strlen@plt>
movslq %eax,%r14
lea    -0x1f3(%r14),%rax
cmp    $0xfffffffffffffe0a,%rax
jbe    12e0 <main+0x100>
add    $0x1,%r14
mov    (%r15,%rbx,8),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
call   1030 <write@plt>
cmp    %r14,%rax
jne    13b7 <main+0x1d7>
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x1f4,%edx
call   1090 <read@plt>
cmp    $0xffffffff,%eax
je     13c9 <main+0x1e9>
lea    0xd2e(%rip),%rdi
mov    %eax,%esi
mov    %r12,%rdx
call   1050 <printf@plt>
jmp    12f9 <main+0x119>
mov    0x2c6a(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <gai_strerror@plt>
lea    0xca6(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    139b <main+0x1bb>
mov    0x2c45(%rip),%rax
mov    (%rax),%edi
lea    0xc99(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2c26(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2c10(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
lea    0xc9f(%rip),%rsi
jmp    1394 <main+0x1b4>
lea    0xcac(%rip),%rdi
call   10b0 <perror@plt>
jmp    139b <main+0x1bb>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i64, i32, i32, %struct.addrinfo*, i64 }
@stderr = global i32 0
@.str = [28 x i8] c"Usage: %s host port msg...\0A\00"
@EXIT_FAILURE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [19 x i8] c"Could not connect\0A\00"
@.str.3 = [38 x i8] c"Ignoring long message in argument %d\0A\00"
@.str.4 = [22 x i8] c"partial/failed write\0A\00"
@.str.5 = [5 x i8] c"read\00"
@.str.6 = [24 x i8] c"Received %zd bytes: %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 %struct.addrinfo
%7 = alloca %struct.addrinfo*
%8 = alloca %struct.addrinfo*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
%13 = alloca i32
%14 = alloca [500 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 3
br i1 %16, label %17, label %25
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
%26 = call i32 @memset(%struct.addrinfo* %6, i32 0, i32 40)
%27 = load i32, i32* @AF_UNSPEC
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 4
store i32 %27, i32* %28
%29 = load i32, i32* @SOCK_DGRAM
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 3
store i32 %29, i32* %30
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 6
store i64 0, i64* %31
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 2
store i64 0, i64* %32
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @getaddrinfo(i8* %35, i8* %38, %struct.addrinfo* %6, %struct.addrinfo** %7)
store i32 %39, i32* %10
%40 = load i32, i32* %10
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %25
%43 = load i32, i32* @stderr
%44 = load i32, i32* %10
%45 = call i8* @gai_strerror(i32 %44)
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %45)
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %25
%50 = load %struct.addrinfo*, %struct.addrinfo** %7
store %struct.addrinfo* %50, %struct.addrinfo** %8
br label %51
51: ; preds = %82, %49
%52 = load %struct.addrinfo*, %struct.addrinfo** %8
%53 = icmp ne %struct.addrinfo* %52, null
br i1 %53, label %54, label %86
54: ; preds = %51
%55 = load %struct.addrinfo*, %struct.addrinfo** %8
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i32 0, i32 4
%57 = load i32, i32* %56
%58 = load %struct.addrinfo*, %struct.addrinfo** %8
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 3
%60 = load i32, i32* %59
%61 = load %struct.addrinfo*, %struct.addrinfo** %8
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i32 0, i32 2
%63 = load i64, i64* %62
%64 = call i32 @socket(i32 %57, i32 %60, i64 %63)
store i32 %64, i32* %9
%65 = load i32, i32* %9
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %68
67: ; preds = %54
br label %82
68: ; preds = %54
%69 = load i32, i32* %9
%70 = load %struct.addrinfo*, %struct.addrinfo** %8
%71 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %70, i32 0, i32 1
%72 = load i32, i32* %71
%73 = load %struct.addrinfo*, %struct.addrinfo** %8
%74 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %73, i32 0, i32 0
%75 = load i32, i32* %74
%76 = call i32 @connect(i32 %69, i32 %72, i32 %75)
%77 = icmp ne i32 %76, -1
br i1 %77, label %78, label %79
78: ; preds = %68
br label %86
79: ; preds = %68
%80 = load i32, i32* %9
%81 = call i32 @close(i32 %80)
br label %82
82: ; preds = %79, %67
%83 = load %struct.addrinfo*, %struct.addrinfo** %8
%84 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %83, i32 0, i32 5
%85 = load %struct.addrinfo*, %struct.addrinfo** %84
store %struct.addrinfo* %85, %struct.addrinfo** %8
br label %51
86: ; preds = %78, %51
%87 = load %struct.addrinfo*, %struct.addrinfo** %8
%88 = icmp eq %struct.addrinfo* %87, null
br i1 %88, label %89, label %94
89: ; preds = %86
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%92 = load i32, i32* @EXIT_FAILURE
%93 = call i32 @exit(i32 %92)
unreachable
94: ; preds = %86
%95 = load %struct.addrinfo*, %struct.addrinfo** %7
%96 = call i32 @freeaddrinfo(%struct.addrinfo* %95)
store i32 3, i32* %11
br label %97
97: ; preds = %147, %94
%98 = load i32, i32* %11
%99 = load i32, i32* %4
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %150
101: ; preds = %97
%102 = load i8**, i8*** %5
%103 = load i32, i32* %11
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8*, i8** %102, i64 %104
%106 = load i8*, i8** %105
%107 = call i32 @strlen(i8* %106)
%108 = add nsw i32 %107, 1
%109 = sext i32 %108 to i64
store i64 %109, i64* %12
%110 = load i64, i64* %12
%111 = add i64 %110, 1
%112 = icmp ugt i64 %111, 500
br i1 %112, label %113, label %117
113: ; preds = %101
%114 = load i32, i32* @stderr
%115 = load i32, i32* %11
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %115)
br label %147
117: ; preds = %101
%118 = load i32, i32* %9
%119 = load i8**, i8*** %5
%120 = load i32, i32* %11
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i8*, i8** %119, i64 %121
%123 = load i8*, i8** %122
%124 = load i64, i64* %12
%125 = call i64 @write(i32 %118, i8* %123, i64 %124)
%126 = load i64, i64* %12
%127 = icmp ne i64 %125, %126
br i1 %127, label %128, label %133
128: ; preds = %117
%129 = load i32, i32* @stderr
%130 = call i32 (i32, i8*, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%131 = load i32, i32* @EXIT_FAILURE
%132 = call i32 @exit(i32 %131)
unreachable
133: ; preds = %117
%134 = load i32, i32* %9
%135 = getelementptr inbounds [500 x i8], [500 x i8]* %14, i64 0, i64 0
%136 = call i32 @read(i32 %134, i8* %135, i32 500)
store i32 %136, i32* %13
%137 = load i32, i32* %13
%138 = icmp eq i32 %137, -1
br i1 %138, label %139, label %143
139: ; preds = %133
%140 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%141 = load i32, i32* @EXIT_FAILURE
%142 = call i32 @exit(i32 %141)
unreachable
143: ; preds = %133
%144 = load i32, i32* %13
%145 = getelementptr inbounds [500 x i8], [500 x i8]* %14, i64 0, i64 0
%146 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %144, i8* %145)
br label %147
147: ; preds = %143, %113
%148 = load i32, i32* %11
%149 = add nsw i32 %148, 1
store i32 %149, i32* %11
br label %97
150: ; preds = %97
%151 = load i32, i32* @EXIT_SUCCESS
%152 = call i32 @exit(i32 %151)
unreachable
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i64, i32, i32, %struct.addrinfo*, i64 }
@stderr = global i32 0
@.str = [28 x i8] c"Usage: %s host port msg...\0A\00"
@EXIT_FAILURE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [19 x i8] c"Could not connect\0A\00"
@.str.3 = [38 x i8] c"Ignoring long message in argument %d\0A\00"
@.str.4 = [22 x i8] c"partial/failed write\0A\00"
@.str.5 = [5 x i8] c"read\00"
@.str.6 = [24 x i8] c"Received %zd bytes: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca [500 x i8]
%6 = bitcast %struct.addrinfo* %3 to i8*
%7 = bitcast %struct.addrinfo** %4 to i8*
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%9 = icmp slt i32 %0, 3
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%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 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 6
store i64 0, i64* %22
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 2
store i64 0, i64* %23
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @getaddrinfo(i8* %25, i8* %27, %struct.addrinfo* %3, %struct.addrinfo** %4)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %16
%31 = load %struct.addrinfo*, %struct.addrinfo** %4
%32 = icmp eq %struct.addrinfo* %31, null
br i1 %32, label %62, label %39
33: ; preds = %16
%34 = load i32, i32* @stderr
%35 = call i8* @gai_strerror(i32 %28)
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %30, %58
%40 = phi %struct.addrinfo* [ %60, %58 ], [ %31, %30 ]
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 4
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 3
%44 = load i32, i32* %43
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 2
%46 = load i64, i64* %45
%47 = call i32 @socket(i32 %42, i32 %44, i64 %46)
%48 = icmp eq i32 %47, -1
br i1 %48, label %58, label %49
49: ; preds = %39
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 1
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 0
%53 = load i32, i32* %52
%54 = call i32 @connect(i32 %47, i32 %51, i32 %53)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %67
56: ; preds = %49
%57 = call i32 @close(i32 %47)
br label %58
58: ; preds = %39, %56
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 5
%60 = load %struct.addrinfo*, %struct.addrinfo** %59
%61 = icmp eq %struct.addrinfo* %60, null
br i1 %61, label %62, label %39
62: ; preds = %58, %30
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %49
%68 = load %struct.addrinfo*, %struct.addrinfo** %4
%69 = call i32 @freeaddrinfo(%struct.addrinfo* %68)
%70 = icmp sgt i32 %0, 3
br i1 %70, label %71, label %107
71: ; preds = %67
%72 = zext i32 %0 to i64
br label %73
73: ; preds = %71, %104
%74 = phi i64 [ 3, %71 ], [ %105, %104 ]
%75 = getelementptr inbounds i8*, i8** %1, i64 %74
%76 = load i8*, i8** %75
%77 = call i32 @strlen(i8* %76)
%78 = add nsw i32 %77, 1
%79 = sext i32 %78 to i64
%80 = add nsw i64 %79, -500
%81 = icmp ult i64 %80, -501
br i1 %81, label %82, label %86
82: ; preds = %73
%83 = load i32, i32* @stderr
%84 = trunc i64 %74 to i32
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %84)
br label %104
86: ; preds = %73
%87 = load i8*, i8** %75
%88 = call i64 @write(i32 %47, i8* %87, i64 %79)
%89 = icmp eq i64 %88, %79
br i1 %89, label %95, label %90
90: ; preds = %86
%91 = load i32, i32* @stderr
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%93 = load i32, i32* @EXIT_FAILURE
%94 = call i32 @exit(i32 %93)
unreachable
95: ; preds = %86
%96 = call i32 @read(i32 %47, i8* %8, i32 500)
%97 = icmp eq i32 %96, -1
br i1 %97, label %98, label %102
98: ; preds = %95
%99 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%100 = load i32, i32* @EXIT_FAILURE
%101 = call i32 @exit(i32 %100)
unreachable
102: ; preds = %95
%103 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %96, i8* %8)
br label %104
104: ; preds = %102, %82
%105 = add nuw nsw i64 %74, 1
%106 = icmp eq i64 %105, %72
br i1 %106, label %107, label %73
107: ; preds = %104, %67
%108 = load i32, i32* @EXIT_SUCCESS
%109 = call i32 @exit(i32 %108)
unreachable
}