#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 size_t ssize_t;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, 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 *, ...);
size_t read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strlen(char *);
size_t write(int, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int s, sfd, r;
  struct addrinfo hints;
  struct addrinfo *result, *rp;
  char buf[512], *pt;
  ssize_t nread, nwrite;
  if (argc != 3) {
    printf("Usage: %s nom_machine_distante port_serveur\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  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;
    r = connect(sfd, result->ai_addr, result->ai_addrlen);
    if (r != -1)
      break;
    close(sfd);
  }
  if (rp == NULL) {
    perror("connect");
    exit(EXIT_FAILURE);
  }
  freeaddrinfo(result);
  for (;;) {
    nread = read(sfd, buf, 512);
    if (nread == 0) {
      printf("Connexion rompue\n");
      exit(EXIT_SUCCESS);
    } else if (nread < 0) {
      perror("read");
      exit(EXIT_FAILURE);
    }
    buf[nread] = '\0';
    printf("Message recu '%s'", buf);
    pt = fgets(buf, 512, stdin);
    if (pt == NULL) {
      printf("Sortie du client\n");
      exit(EXIT_SUCCESS);
    }
    nwrite = write(sfd, buf, strlen(buf));
    if (nwrite < 0) {
      perror("write");
      exit(EXIT_FAILURE);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x290,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1236 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x48(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   10f0 <getaddrinfo@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12d2 <main+0xe2>
mov    0x2d31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x27c(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    -0x27c(%rbp),%edi
mov    %rax,%rdx
lea    0xd6e(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1352 <main+0x162>
mov    -0x58(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x58(%rbp),%rax
mov    0x10(%rax),%esi
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rdx
call   1110 <socket@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1312 <main+0x122>
jmp    1341 <main+0x151>
mov    -0x18(%rbp),%edi
mov    -0x50(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x50(%rbp),%rax
mov    (%rax),%edx
call   10e0 <connect@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
je     1339 <main+0x149>
jmp    1352 <main+0x162>
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
mov    -0x58(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    12da <main+0xea>
cmpq   $0x0,-0x58(%rbp)
jne    1377 <main+0x187>
lea    0xcda(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2c50(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x50(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
mov    -0x18(%rbp),%edi
lea    -0x260(%rbp),%rsi
mov    $0x200,%edx
call   1090 <read@plt>
mov    %rax,-0x270(%rbp)
cmpq   $0x0,-0x270(%rbp)
jne    13c5 <main+0x1d5>
lea    0xc96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
cmpq   $0x0,-0x270(%rbp)
jae    13ed <main+0x1fd>
lea    0xc7e(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
jmp    13f2 <main+0x202>
mov    -0x270(%rbp),%rax
movb   $0x0,-0x260(%rbp,%rax,1)
lea    -0x260(%rbp),%rsi
lea    0xc4e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x260(%rbp),%rdi
mov    0x2bbc(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   10a0 <fgets@plt>
mov    %rax,-0x268(%rbp)
cmpq   $0x0,-0x268(%rbp)
jne    1461 <main+0x271>
lea    0xc23(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b5e(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28c(%rbp)
lea    -0x260(%rbp),%rax
mov    %rax,-0x288(%rbp)
lea    -0x260(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28c(%rbp),%edi
mov    -0x288(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %rax,-0x278(%rbp)
cmpq   $0x0,-0x278(%rbp)
jae    14c7 <main+0x2d7>
lea    0xbcd(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2b00(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
jmp    1380 <main+0x190>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x230,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    12bd <main+0xbd>
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
mov    0x2d85(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
movq   $0x0,0x28(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
mov    %rsp,%rcx
mov    %r14,%rdx
call   1100 <getaddrinfo@plt>
test   %eax,%eax
jne    12d0 <main+0xd0>
mov    (%rsp),%rbx
jmp    1284 <main+0x84>
nopl   0x0(%rax,%rax,1)
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
je     12f3 <main+0xf3>
mov    0x14(%rbx),%edi
mov    0x10(%rbx),%esi
mov    0x8(%rbx),%rdx
call   1120 <socket@plt>
cmp    $0xffffffff,%eax
je     1280 <main+0x80>
mov    %eax,%ebp
mov    (%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %ebp,%edi
call   10f0 <connect@plt>
cmp    $0xffffffff,%eax
jne    130d <main+0x10d>
mov    %ebp,%edi
call   1090 <close@plt>
jmp    1280 <main+0x80>
mov    (%rbx),%rsi
lea    0xd39(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12ff <main+0xff>
mov    0x2cf9(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xd46(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10c0 <fprintf@plt>
jmp    12ff <main+0xff>
lea    0xd44(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    (%rsp),%rdi
call   1110 <freeaddrinfo@plt>
lea    0x30(%rsp),%rsi
mov    %ebp,%edi
mov    $0x200,%edx
call   10a0 <read@plt>
test   %rax,%rax
je     1390 <main+0x190>
lea    0xd13(%rip),%r14
lea    0x30(%rsp),%r15
mov    0x2ca1(%rip),%r12
nop
movb   $0x0,0x30(%rsp,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r12),%edx
mov    %r15,%rdi
mov    $0x200,%esi
call   10b0 <fgets@plt>
test   %rax,%rax
je     1399 <main+0x199>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x200,%edx
call   10a0 <read@plt>
test   %rax,%rax
jne    1340 <main+0x140>
lea    0xcd2(%rip),%rdi
jmp    13a0 <main+0x1a0>
lea    0xcb8(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c0c(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i64, i32, i32, %struct.addrinfo*, i64 }
@.str = [45 x i8] c"Usage: %s nom_machine_distante port_serveur\0A\00"
@EXIT_FAILURE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [8 x i8] c"connect\00"
@.str.3 = [18 x i8] c"Connexion rompue\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [5 x i8] c"read\00"
@.str.5 = [18 x i8] c"Message recu '%s'\00"
@stdin = global i32 0
@.str.6 = [18 x i8] c"Sortie du client\0A\00"
@.str.7 = [6 x i8] c"write\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.addrinfo
%10 = alloca %struct.addrinfo*
%11 = alloca %struct.addrinfo*
%12 = alloca [512 x i8]
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 3
br i1 %17, label %18, label %25
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 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* %9, i32 0, i32 40)
%27 = load i32, i32* @AF_UNSPEC
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 4
store i32 %27, i32* %28
%29 = load i32, i32* @SOCK_STREAM
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 3
store i32 %29, i32* %30
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 6
store i64 0, i64* %31
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, 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* %9, %struct.addrinfo** %10)
store i32 %39, i32* %6
%40 = load i32, i32* %6
%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* %6
%45 = call i8* @gai_strerror(i32 %44)
%46 = call i32 @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** %10
store %struct.addrinfo* %50, %struct.addrinfo** %11
br label %51
51: ; preds = %83, %49
%52 = load %struct.addrinfo*, %struct.addrinfo** %11
%53 = icmp ne %struct.addrinfo* %52, null
br i1 %53, label %54, label %87
54: ; preds = %51
%55 = load %struct.addrinfo*, %struct.addrinfo** %11
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i32 0, i32 4
%57 = load i32, i32* %56
%58 = load %struct.addrinfo*, %struct.addrinfo** %11
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 3
%60 = load i32, i32* %59
%61 = load %struct.addrinfo*, %struct.addrinfo** %11
%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* %7
%65 = load i32, i32* %7
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %68
67: ; preds = %54
br label %83
68: ; preds = %54
%69 = load i32, i32* %7
%70 = load %struct.addrinfo*, %struct.addrinfo** %10
%71 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %70, i32 0, i32 1
%72 = load i32, i32* %71
%73 = load %struct.addrinfo*, %struct.addrinfo** %10
%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)
store i32 %76, i32* %8
%77 = load i32, i32* %8
%78 = icmp ne i32 %77, -1
br i1 %78, label %79, label %80
79: ; preds = %68
br label %87
80: ; preds = %68
%81 = load i32, i32* %7
%82 = call i32 @close(i32 %81)
br label %83
83: ; preds = %80, %67
%84 = load %struct.addrinfo*, %struct.addrinfo** %11
%85 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %84, i32 0, i32 5
%86 = load %struct.addrinfo*, %struct.addrinfo** %85
store %struct.addrinfo* %86, %struct.addrinfo** %11
br label %51
87: ; preds = %79, %51
%88 = load %struct.addrinfo*, %struct.addrinfo** %11
%89 = icmp eq %struct.addrinfo* %88, null
br i1 %89, label %90, label %94
90: ; preds = %87
%91 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%92 = load i32, i32* @EXIT_FAILURE
%93 = call i32 @exit(i32 %92)
unreachable
94: ; preds = %87
%95 = load %struct.addrinfo*, %struct.addrinfo** %10
%96 = call i32 @freeaddrinfo(%struct.addrinfo* %95)
br label %97
97: ; preds = %141, %94
%98 = load i32, i32* %7
%99 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%100 = call i64 @read(i32 %98, i8* %99, i32 512)
store i64 %100, i64* %14
%101 = load i64, i64* %14
%102 = icmp eq i64 %101, 0
br i1 %102, label %103, label %107
103: ; preds = %97
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%105 = load i32, i32* @EXIT_SUCCESS
%106 = call i32 @exit(i32 %105)
unreachable
107: ; preds = %97
%108 = load i64, i64* %14
%109 = icmp ult i64 %108, 0
br i1 %109, label %110, label %114
110: ; preds = %107
%111 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%112 = load i32, i32* @EXIT_FAILURE
%113 = call i32 @exit(i32 %112)
unreachable
114: ; preds = %107
br label %115
115: ; preds = %114
%116 = load i64, i64* %14
%117 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 %116
store i8 0, i8* %117
%118 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %118)
%120 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%121 = load i32, i32* @stdin
%122 = call i8* @fgets(i8* %120, i32 512, i32 %121)
store i8* %122, i8** %13
%123 = load i8*, i8** %13
%124 = icmp eq i8* %123, null
br i1 %124, label %125, label %129
125: ; preds = %115
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%127 = load i32, i32* @EXIT_SUCCESS
%128 = call i32 @exit(i32 %127)
unreachable
129: ; preds = %115
%130 = load i32, i32* %7
%131 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%132 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%133 = call i32 @strlen(i8* %132)
%134 = call i64 @write(i32 %130, i8* %131, i32 %133)
store i64 %134, i64* %15
%135 = load i64, i64* %15
%136 = icmp ult i64 %135, 0
br i1 %136, label %137, label %141
137: ; preds = %129
%138 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%139 = load i32, i32* @EXIT_FAILURE
%140 = call i32 @exit(i32 %139)
unreachable
141: ; preds = %129
br label %97
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i64, i32, i32, %struct.addrinfo*, i64 }
@.str = [45 x i8] c"Usage: %s nom_machine_distante port_serveur\0A\00"
@EXIT_FAILURE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [8 x i8] c"connect\00"
@EXIT_SUCCESS = global i32 0
@.str.5 = [18 x i8] c"Message recu '%s'\00"
@stdin = global i32 0
@str = [17 x i8] c"Sortie du client\00"
@str.8 = [17 x i8] c"Connexion rompue\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca [512 x i8]
%6 = bitcast %struct.addrinfo* %3 to i8*
%7 = bitcast %struct.addrinfo** %4 to i8*
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 3
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 40)
%17 = load i32, i32* @AF_UNSPEC
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %17, i32* %18
%19 = load i32, i32* @SOCK_STREAM
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %19, i32* %20
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 6
store i64 0, i64* %21
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 2
store i64 0, i64* %22
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @getaddrinfo(i8* %24, i8* %26, %struct.addrinfo* %3, %struct.addrinfo** %4)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %15
%30 = load %struct.addrinfo*, %struct.addrinfo** %4
%31 = icmp eq %struct.addrinfo* %30, null
br i1 %31, label %62, label %38
32: ; preds = %15
%33 = load i32, i32* @stderr
%34 = call i8* @gai_strerror(i32 %27)
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %29, %58
%39 = phi %struct.addrinfo* [ %60, %58 ], [ %30, %29 ]
%40 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 4
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 3
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 2
%45 = load i64, i64* %44
%46 = call i32 @socket(i32 %41, i32 %43, i64 %45)
%47 = icmp eq i32 %46, -1
br i1 %47, label %58, label %48
48: ; preds = %38
%49 = load %struct.addrinfo*, %struct.addrinfo** %4
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %49, i64 0, i32 1
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %49, i64 0, i32 0
%53 = load i32, i32* %52
%54 = call i32 @connect(i32 %46, i32 %51, i32 %53)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %66
56: ; preds = %48
%57 = call i32 @close(i32 %46)
br label %58
58: ; preds = %38, %56
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 5
%60 = load %struct.addrinfo*, %struct.addrinfo** %59
%61 = icmp eq %struct.addrinfo* %60, null
br i1 %61, label %62, label %38
62: ; preds = %58, %29
%63 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %48
%67 = load %struct.addrinfo*, %struct.addrinfo** %4
%68 = call i32 @freeaddrinfo(%struct.addrinfo* %67)
%69 = call i64 @read(i32 %46, i8* %8, i32 512)
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %75
71: ; preds = %86, %66
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
%73 = load i32, i32* @EXIT_SUCCESS
%74 = call i32 @exit(i32 %73)
unreachable
75: ; preds = %66, %86
%76 = phi i64 [ %89, %86 ], [ %69, %66 ]
%77 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %76
store i8 0, i8* %77
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %8)
%79 = load i32, i32* @stdin
%80 = call i8* @fgets(i8* %8, i32 512, i32 %79)
%81 = icmp eq i8* %80, null
br i1 %81, label %82, label %86
82: ; preds = %75
%83 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%84 = load i32, i32* @EXIT_SUCCESS
%85 = call i32 @exit(i32 %84)
unreachable
86: ; preds = %75
%87 = call i32 @strlen(i8* %8)
%88 = call i64 @write(i32 %46, i8* %8, i32 %87)
%89 = call i64 @read(i32 %46, i8* %8, i32 512)
%90 = icmp eq i64 %89, 0
br i1 %90, label %71, label %75
}