#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 sockaddr {
  int dummy;
};
struct addrinfo {
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
};

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ connect(int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ get_in_addr(struct sockaddr *);
int /*<<< orphan*/ getaddrinfo(char *, char *, struct addrinfo *,
                               struct addrinfo **);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/, char *,
                             int);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char *argv[]) {
  int sockfd, numbytes;
  char buf[100];
  struct addrinfo hints, *servinfo, *p;
  int rv;
  char s[INET6_ADDRSTRLEN];
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  getaddrinfo(argv[1], "3491", &hints, &servinfo);
  sockfd =
      socket(servinfo->ai_family, servinfo->ai_socktype, servinfo->ai_protocol);
  connect(sockfd, servinfo->ai_addr, servinfo->ai_addrlen);
  inet_ntop(servinfo->ai_family,
            get_in_addr((struct sockaddr *)servinfo->ai_addr), s, sizeof s);
  printf("client: connecting to %s\n", s);
  freeaddrinfo(servinfo);
  numbytes = recv(sockfd, buf, 100 - 1, 0);
  buf[numbytes] = '\0';
  printf("client: received '%s'\n", buf);
  send(sockfd, argv[2], strlen(argv[2]), 0);
  char *msg = (char *)malloc(1001);
  for (;;) {
  get_in:
    printf("\n> ");
    fgets(msg, 1001, stdin);
    if ((strlen(msg) > 0) && (msg[strlen(msg) - 1] == '\n'))
      msg[strlen(msg) - 1] = '\0';
    if (send(sockfd, msg, strlen(msg), 0) == -1) {
      printf("error in send");
      goto get_in;
    }
    printf("waiting for reply...\n");
    numbytes = recv(sockfd, buf, 100 - 1, 0);
    buf[numbytes] = '\0';
    printf("chetan: %s\n", buf);
  }
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2df8(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xe8(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0xb8(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xe0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xc0(%rbp)
lea    -0x98(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    0x2da1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x90(%rbp)
mov    0x2d7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd9b(%rip),%rsi
lea    -0x98(%rbp),%rdx
lea    -0xa0(%rbp),%rcx
call   10d0 <getaddrinfo@plt>
mov    -0xa0(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0xa0(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0xa0(%rbp),%rax
mov    0x10(%rax),%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0xa0(%rbp),%rax
mov    (%rax),%rsi
mov    -0xa0(%rbp),%rax
mov    0xc(%rax),%edx
call   10c0 <connect@plt>
mov    -0xa0(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0xec(%rbp)
mov    -0xa0(%rbp),%rax
mov    (%rax),%rdi
call   1050 <get_in_addr@plt>
mov    -0xec(%rbp),%edi
mov    -0xe0(%rbp),%rdx
mov    %eax,%esi
mov    -0xe8(%rbp),%rax
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0xe0(%rbp),%rsi
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0xa0(%rbp),%rdi
call   10e0 <freeaddrinfo@plt>
mov    -0x14(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rsi
lea    0xcde(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0xd4(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <strlen@plt>
mov    -0xd4(%rbp),%edi
mov    -0xd0(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    $0x3e9,%edi
call   10b0 <malloc@plt>
mov    %rax,-0xc8(%rbp)
jmp    1399 <main+0x1c9>
lea    0xc96(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0xc8(%rbp),%rdi
mov    0x2c23(%rip),%rax
mov    (%rax),%edx
mov    $0x3e9,%esi
call   10a0 <fgets@plt>
mov    -0xc8(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%eax
jle    1439 <main+0x269>
mov    -0xc8(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0xc8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xf8(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1439 <main+0x269>
mov    -0xc8(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0xc8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x100(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10c(%rbp)
mov    -0xc8(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    -0xc8(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x10c(%rbp),%edi
mov    -0x108(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
jne    148e <main+0x2be>
lea    0xbb8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1399 <main+0x1c9>
lea    0xbb3(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rsi
lea    0xb98(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1394 <main+0x1c4>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%r15
mov    0x2dea(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rbx
mov    %r14,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x48(%rbp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
mov    0x2db1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x8(%r15),%rdi
lea    0xdb5(%rip),%rsi
lea    -0x30(%rbp),%rcx
mov    %r12,%rdx
call   10e0 <getaddrinfo@plt>
mov    -0x30(%rbp),%rax
mov    0x14(%rax),%esi
mov    0x8(%rax),%edi
mov    0x10(%rax),%edx
call   1100 <socket@plt>
mov    %eax,%r12d
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
mov    0xc(%rax),%edx
mov    %r12d,%edi
call   10d0 <connect@plt>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%r13d
mov    (%rax),%rdi
call   1050 <get_in_addr@plt>
mov    %r13d,%edi
mov    %eax,%esi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1030 <inet_ntop@plt>
lea    0xd60(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    -0x30(%rbp),%rdi
call   10f0 <freeaddrinfo@plt>
lea    -0xb0(%rbp),%r14
mov    %r12d,%edi
mov    %r14,%rsi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
cltq
movb   $0x0,-0xb0(%rbp,%rax,1)
lea    0xd3d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x10(%r15),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    $0x3e9,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
lea    0xd1b(%rip),%r15
mov    0x2cb6(%rip),%r13
jmp    1389 <main+0x1a9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0xffffffff,%eax
je     13e0 <main+0x200>
lea    0xcfd(%rip),%rdi
call   1060 <puts@plt>
mov    %r12d,%edi
mov    %r14,%rsi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
cltq
movb   $0x0,-0xb0(%rbp,%rax,1)
lea    0xcc9(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x3e9,%esi
call   10b0 <fgets@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
test   %eax,%eax
jle    1330 <main+0x150>
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1330 <main+0x150>
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
jmp    1330 <main+0x150>
nopl   0x0(%rax)
lea    0xc53(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    1389 <main+0x1a9>

LLVM IR (-O0):
%struct.addrinfo = type { i64, i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str = [5 x i8] c"3491\00"
@.str.1 = [26 x i8] c"client: connecting to %s\0A\00"
@.str.2 = [23 x i8] c"client: received '%s'\0A\00"
@.str.3 = [4 x i8] c"\0A> \00"
@stdin = global i32 0
@.str.4 = [14 x i8] c"error in send\00"
@.str.5 = [22 x i8] c"waiting for reply...\0A\00"
@.str.6 = [12 x i8] c"chetan: %s\0A\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 [100 x i8]
%9 = alloca %struct.addrinfo
%10 = alloca %struct.addrinfo*
%11 = alloca %struct.addrinfo*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* @INET6_ADDRSTRLEN
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %13
%19 = alloca i8, i64 %17
store i64 %17, i64* %14
%20 = call i32 @memset(%struct.addrinfo* %9, i32 0, i32 24)
%21 = load i32, i32* @AF_UNSPEC
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 1
store i32 %21, i32* %22
%23 = load i32, i32* @SOCK_STREAM
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 4
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, i64 0, i64 0), %struct.addrinfo* %9, %struct.addrinfo** %10)
%29 = load %struct.addrinfo*, %struct.addrinfo** %10
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %29, i32 0, i32 1
%31 = load i32, i32* %30
%32 = load %struct.addrinfo*, %struct.addrinfo** %10
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i32 0, i32 4
%34 = load i32, i32* %33
%35 = load %struct.addrinfo*, %struct.addrinfo** %10
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %35, i32 0, i32 3
%37 = load i32, i32* %36
%38 = call i32 @socket(i32 %31, i32 %34, i32 %37)
store i32 %38, i32* %6
%39 = load i32, i32* %6
%40 = load %struct.addrinfo*, %struct.addrinfo** %10
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i32 0, i32 0
%42 = load i64, i64* %41
%43 = load %struct.addrinfo*, %struct.addrinfo** %10
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i32 0, i32 2
%45 = load i32, i32* %44
%46 = call i32 @connect(i32 %39, i64 %42, i32 %45)
%47 = load %struct.addrinfo*, %struct.addrinfo** %10
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %47, i32 0, i32 1
%49 = load i32, i32* %48
%50 = load %struct.addrinfo*, %struct.addrinfo** %10
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i32 0, i32 0
%52 = load i64, i64* %51
%53 = inttoptr i64 %52 to %struct.sockaddr*
%54 = call i32 @get_in_addr(%struct.sockaddr* %53)
%55 = trunc i64 %17 to i32
%56 = call i32 @inet_ntop(i32 %49, i32 %54, i8* %19, i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%58 = load %struct.addrinfo*, %struct.addrinfo** %10
%59 = call i32 @freeaddrinfo(%struct.addrinfo* %58)
%60 = load i32, i32* %6
%61 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%62 = call i32 @recv(i32 %60, i8* %61, i32 99, i32 0)
store i32 %62, i32* %7
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %64
store i8 0, i8* %65
%66 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %66)
%68 = load i32, i32* %6
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 2
%71 = load i8*, i8** %70
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 2
%74 = load i8*, i8** %73
%75 = call i32 @strlen(i8* %74)
%76 = call i32 @send(i32 %68, i8* %71, i32 %75, i32 0)
%77 = call i64 @malloc(i32 1001)
%78 = inttoptr i64 %77 to i8*
store i8* %78, i8** %15
br label %79
79: ; preds = %114, %2
br label %80
80: ; preds = %112, %79
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%82 = load i8*, i8** %15
%83 = load i32, i32* @stdin
%84 = call i32 @fgets(i8* %82, i32 1001, i32 %83)
%85 = load i8*, i8** %15
%86 = call i32 @strlen(i8* %85)
%87 = icmp sgt i32 %86, 0
br i1 %87, label %88, label %105
88: ; preds = %80
%89 = load i8*, i8** %15
%90 = load i8*, i8** %15
%91 = call i32 @strlen(i8* %90)
%92 = sub nsw i32 %91, 1
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %89, i64 %93
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp eq i32 %96, 10
br i1 %97, label %98, label %105
98: ; preds = %88
%99 = load i8*, i8** %15
%100 = load i8*, i8** %15
%101 = call i32 @strlen(i8* %100)
%102 = sub nsw i32 %101, 1
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i8, i8* %99, i64 %103
store i8 0, i8* %104
br label %105
105: ; preds = %98, %88, %80
%106 = load i32, i32* %6
%107 = load i8*, i8** %15
%108 = load i8*, i8** %15
%109 = call i32 @strlen(i8* %108)
%110 = call i32 @send(i32 %106, i8* %107, i32 %109, i32 0)
%111 = icmp eq i32 %110, -1
br i1 %111, label %112, label %114
112: ; preds = %105
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %80
114: ; preds = %105
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%116 = load i32, i32* %6
%117 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%118 = call i32 @recv(i32 %116, i8* %117, i32 99, i32 0)
store i32 %118, i32* %7
%119 = load i32, i32* %7
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %120
store i8 0, i8* %121
%122 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %122)
br label %79
}

LLVM IR (-O2):
%struct.addrinfo = type { i64, i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str = [5 x i8] c"3491\00"
@.str.1 = [26 x i8] c"client: connecting to %s\0A\00"
@.str.2 = [23 x i8] c"client: received '%s'\0A\00"
@.str.3 = [4 x i8] c"\0A> \00"
@stdin = global i32 0
@.str.4 = [14 x i8] c"error in send\00"
@.str.6 = [12 x i8] c"chetan: %s\0A\00"
@str = [21 x i8] c"waiting for reply...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.addrinfo* %4 to i8*
%8 = bitcast %struct.addrinfo** %5 to i8*
%9 = load i32, i32* @INET6_ADDRSTRLEN
%10 = zext i32 %9 to i64
%11 = alloca i8, i64 %10
%12 = call i32 @memset(%struct.addrinfo* %4, i32 0, i32 24)
%13 = load i32, i32* @AF_UNSPEC
%14 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 1
store i32 %13, i32* %14
%15 = load i32, i32* @SOCK_STREAM
%16 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %15, i32* %16
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @getaddrinfo(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %4, %struct.addrinfo** %5)
%20 = load %struct.addrinfo*, %struct.addrinfo** %5
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %20, i64 0, i32 1
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %20, i64 0, i32 4
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %20, i64 0, i32 3
%26 = load i32, i32* %25
%27 = call i32 @socket(i32 %22, i32 %24, i32 %26)
%28 = load %struct.addrinfo*, %struct.addrinfo** %5
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %28, i64 0, i32 0
%30 = load i64, i64* %29
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %28, i64 0, i32 2
%32 = load i32, i32* %31
%33 = call i32 @connect(i32 %27, i64 %30, i32 %32)
%34 = load %struct.addrinfo*, %struct.addrinfo** %5
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 1
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 0
%38 = load i64, i64* %37
%39 = inttoptr i64 %38 to %struct.sockaddr*
%40 = call i32 @get_in_addr(%struct.sockaddr* %39)
%41 = call i32 @inet_ntop(i32 %36, i32 %40, i8* %11, i32 %9)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%43 = load %struct.addrinfo*, %struct.addrinfo** %5
%44 = call i32 @freeaddrinfo(%struct.addrinfo* %43)
%45 = call i32 @recv(i32 %27, i8* %6, i32 99, i32 0)
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %46
store i8 0, i8* %47
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%49 = getelementptr inbounds i8*, i8** %1, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @strlen(i8* %50)
%52 = call i32 @send(i32 %27, i8* %50, i32 %51, i32 0)
%53 = call i64 @malloc(i32 1001)
%54 = inttoptr i64 %53 to i8*
br label %55
55: ; preds = %79, %2
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%57 = load i32, i32* @stdin
%58 = call i32 @fgets(i8* %54, i32 1001, i32 %57)
%59 = call i32 @strlen(i8* %54)
%60 = icmp sgt i32 %59, 0
br i1 %60, label %61, label %73
61: ; preds = %55
%62 = call i32 @strlen(i8* %54)
%63 = add nsw i32 %62, -1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %54, i64 %64
%66 = load i8, i8* %65
%67 = icmp eq i8 %66, 10
br i1 %67, label %68, label %73
68: ; preds = %61
%69 = call i32 @strlen(i8* %54)
%70 = add nsw i32 %69, -1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %54, i64 %71
store i8 0, i8* %72
br label %73
73: ; preds = %68, %61, %55
%74 = call i32 @strlen(i8* %54)
%75 = call i32 @send(i32 %27, i8* %54, i32 %74, i32 0)
%76 = icmp eq i32 %75, -1
br i1 %76, label %77, label %80
77: ; preds = %73
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %79
79: ; preds = %77, %80
br label %55
80: ; preds = %73
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%82 = call i32 @recv(i32 %27, i8* %6, i32 99, i32 0)
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %83
store i8 0, i8* %84
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %6)
br label %79
}