#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ send_buf;
typedef int /*<<< orphan*/ recv_buf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ bcopy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int master_sock, n;
  struct sockaddr_in serv_addr;
  struct hostent *server;
  char send_buf[256];
  char recv_buf[256];
  if (argc < 2) {
    printf("Usage: %s <HOSTNAME>.\n", argv[0]);
    exit(-1);
  }
  master_sock = socket(AF_INET, SOCK_STREAM, 0);
  if (master_sock < 0) {
    perror("socket");
    exit(-1);
  }
  server = gethostbyname(argv[1]);
  if (NULL == server) {
    perror("gethostbyname");
    exit(-1);
  }
  bzero((char *)&serv_addr, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  bcopy((char *)server->h_addr, (char *)&(serv_addr.sin_addr.s_addr),
        server->h_length);
  serv_addr.sin_port = htons(10001);
  if (connect(master_sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) <
      0) {
    perror("connect");
    exit(-1);
  }
  while (1) {
    printf("Please enter the mssage: ");
    bzero(send_buf, sizeof(send_buf));
    fgets(send_buf, sizeof(send_buf) - 1, stdin);
    if (0 == strcmp(send_buf, "exit\n")) {
      printf("exit!\n");
      close(master_sock);
      exit(0);
    }
    n = write(master_sock, send_buf, strlen(send_buf));
    if (n < 0) {
      perror("write");
      exit(-1);
    }
  loop:
    bzero(recv_buf, sizeof(recv_buf));
    n = read(master_sock, recv_buf, sizeof(recv_buf));
    if (0 == n) {
      printf("server has closed.\n");
      close(master_sock);
      exit(0);
    } else if (n < 0) {
      perror("read");
      exit(-1);
    } else {
      if (recv_buf[n] == '\0') {
        printf("Read Over\n");
      } else {
        goto loop;
      }
    }
    printf("Receive message: %s.\n", recv_buf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1232 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    126e <main+0x7e>
lea    0xdb8(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <gethostbyname@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
jne    12a1 <main+0xb1>
lea    0xd8c(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
lea    -0x28(%rbp),%rdi
mov    $0xc,%esi
call   10e0 <bzero@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x28(%rbp),%rsi
add    $0x4,%rsi
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
call   10c0 <bcopy@plt>
mov    $0x2711,%edi
call   1050 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   1100 <connect@plt>
cmp    $0x0,%rax
jge    1314 <main+0x124>
lea    0xd27(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
jmp    1319 <main+0x129>
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x130(%rbp),%rdi
mov    $0x100,%esi
call   10e0 <bzero@plt>
lea    -0x130(%rbp),%rdi
mov    0x2c9a(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   1090 <fgets@plt>
lea    -0x130(%rbp),%rdi
lea    0xcee(%rip),%rsi
call   10a0 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1390 <main+0x1a0>
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x23c(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x238(%rbp)
lea    -0x130(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x23c(%rbp),%edi
mov    -0x238(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    13ea <main+0x1fa>
lea    0xc80(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
jmp    13ef <main+0x1ff>
lea    -0x230(%rbp),%rdi
mov    $0x100,%esi
call   10e0 <bzero@plt>
mov    -0x14(%rbp),%edi
lea    -0x230(%rbp),%rsi
mov    $0x100,%edx
call   1080 <read@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%eax
jne    143f <main+0x24f>
lea    0xc38(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
cmpl   $0x0,-0x18(%rbp)
jge    145f <main+0x26f>
lea    0xc25(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
movslq -0x18(%rbp),%rax
movsbl -0x230(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    1487 <main+0x297>
lea    0xbff(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    148c <main+0x29c>
jmp    13ef <main+0x1ff>
jmp    1491 <main+0x2a1>
jmp    1496 <main+0x2a6>
lea    -0x230(%rbp),%rsi
lea    0xbe1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1319 <main+0x129>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1234 <main+0x34>
mov    (%rbx),%rsi
lea    0xddd(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
mov    0x2dad(%rip),%r15
mov    (%r15),%edi
mov    0x2d8b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
test   %eax,%eax
jns    125b <main+0x5b>
lea    0xdbe(%rip),%rdi
jmp    12c6 <main+0xc6>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
call   10c0 <gethostbyname@plt>
test   %rax,%rax
jne    1274 <main+0x74>
lea    0xdac(%rip),%rdi
jmp    12c6 <main+0xc6>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    (%r15),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%rbx),%rsi
lea    0x4(%rsp),%rdi
mov    (%rbx),%edx
call   10d0 <memmove@plt>
mov    $0x2711,%edi
call   1060 <htons@plt>
mov    %eax,(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1110 <connect@plt>
test   %rax,%rax
jns    12d5 <main+0xd5>
lea    0xd66(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
lea    0xd58(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x110(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   10f0 <bzero@plt>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   10a0 <fgets@plt>
lea    0xd39(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    132e <main+0x12e>
lea    0xd69(%rip),%rdi
jmp    1405 <main+0x205>
lea    0x110(%rsp),%r14
lea    0x10(%rsp),%rbx
lea    0xd1d(%rip),%r12
lea    0xceb(%rip),%r13
lea    0xcfe(%rip),%r15
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %eax,%eax
js     1424 <main+0x224>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x100,%esi
call   10f0 <bzero@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1090 <read@plt>
test   %eax,%eax
je     13fe <main+0x1fe>
js     1418 <main+0x218>
mov    %eax,%eax
cmpb   $0x0,0x10(%rsp,%rax,1)
jne    1370 <main+0x170>
lea    0xccf(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
mov    $0x100,%esi
call   10f0 <bzero@plt>
mov    0x2c0a(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0xff,%esi
call   10a0 <fgets@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    1350 <main+0x150>
jmp    1322 <main+0x122>
lea    0xc7a(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
call   1080 <close@plt>
xor    %edi,%edi
call   1100 <exit@plt>
lea    0xc3b(%rip),%rdi
jmp    12c6 <main+0xc6>
lea    0xc29(%rip),%rdi
jmp    12c6 <main+0xc6>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [23 x i8] c"Usage: %s <HOSTNAME>.\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [14 x i8] c"gethostbyname\00"
@.str.3 = [8 x i8] c"connect\00"
@.str.4 = [26 x i8] c"Please enter the mssage: \00"
@stdin = global i32 0
@.str.5 = [6 x i8] c"exit\0A\00"
@.str.6 = [7 x i8] c"exit!\0A\00"
@.str.7 = [6 x i8] c"write\00"
@.str.8 = [20 x i8] c"server has closed.\0A\00"
@.str.9 = [5 x i8] c"read\00"
@.str.10 = [11 x i8] c"Read Over\0A\00"
@.str.11 = [22 x i8] c"Receive message: %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 %struct.sockaddr_in
%9 = alloca %struct.hostent*
%10 = alloca [256 x i8]
%11 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %2
%21 = load i32, i32* @AF_INET
%22 = load i32, i32* @SOCK_STREAM
%23 = call i32 @socket(i32 %21, i32 %22, i32 0)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %20
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call %struct.hostent* @gethostbyname(i8* %32)
store %struct.hostent* %33, %struct.hostent** %9
%34 = load %struct.hostent*, %struct.hostent** %9
%35 = icmp eq %struct.hostent* null, %34
br i1 %35, label %36, label %39
36: ; preds = %29
%37 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @exit(i32 -1)
unreachable
39: ; preds = %29
%40 = bitcast %struct.sockaddr_in* %8 to i8*
%41 = call i32 @bzero(i8* %40, i32 12)
%42 = load i32, i32* @AF_INET
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %42, i32* %43
%44 = load %struct.hostent*, %struct.hostent** %9
%45 = getelementptr inbounds %struct.hostent, %struct.hostent* %44, i32 0, i32 1
%46 = load i64, i64* %45
%47 = inttoptr i64 %46 to i8*
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%49 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %48, i32 0, i32 0
%50 = bitcast i32* %49 to i8*
%51 = load %struct.hostent*, %struct.hostent** %9
%52 = getelementptr inbounds %struct.hostent, %struct.hostent* %51, i32 0, i32 0
%53 = load i32, i32* %52
%54 = call i32 @bcopy(i8* %47, i8* %50, i32 %53)
%55 = call i32 @htons(i32 10001)
%56 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %55, i32* %56
%57 = load i32, i32* %6
%58 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%59 = call i64 @connect(i32 %57, %struct.sockaddr* %58, i32 12)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %39
%62 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%63 = call i32 @exit(i32 -1)
unreachable
64: ; preds = %39
br label %65
65: ; preds = %64, %123
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%68 = call i32 @bzero(i8* %67, i32 256)
%69 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%70 = load i32, i32* @stdin
%71 = call i32 @fgets(i8* %69, i32 255, i32 %70)
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%73 = call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%74 = icmp eq i64 0, %73
br i1 %74, label %75, label %80
75: ; preds = %65
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%77 = load i32, i32* %6
%78 = call i32 @close(i32 %77)
%79 = call i32 @exit(i32 0)
unreachable
80: ; preds = %65
%81 = load i32, i32* %6
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%83 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%84 = call i32 @strlen(i8* %83)
%85 = call i32 @write(i32 %81, i8* %82, i32 %84)
store i32 %85, i32* %7
%86 = load i32, i32* %7
%87 = icmp slt i32 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %80
%89 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%90 = call i32 @exit(i32 -1)
unreachable
91: ; preds = %80
br label %92
92: ; preds = %120, %91
%93 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%94 = call i32 @bzero(i8* %93, i32 256)
%95 = load i32, i32* %6
%96 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%97 = call i32 @read(i32 %95, i8* %96, i32 256)
store i32 %97, i32* %7
%98 = load i32, i32* %7
%99 = icmp eq i32 0, %98
br i1 %99, label %100, label %105
100: ; preds = %92
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%102 = load i32, i32* %6
%103 = call i32 @close(i32 %102)
%104 = call i32 @exit(i32 0)
unreachable
105: ; preds = %92
%106 = load i32, i32* %7
%107 = icmp slt i32 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %105
%109 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%110 = call i32 @exit(i32 -1)
unreachable
111: ; preds = %105
%112 = load i32, i32* %7
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 %113
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = icmp eq i32 %116, 0
br i1 %117, label %118, label %120
118: ; preds = %111
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
br label %121
120: ; preds = %111
br label %92
121: ; preds = %118
br label %122
122: ; preds = %121
br label %123
123: ; preds = %122
%124 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* %124)
br label %65
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [23 x i8] c"Usage: %s <HOSTNAME>.\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [14 x i8] c"gethostbyname\00"
@.str.3 = [8 x i8] c"connect\00"
@.str.4 = [26 x i8] c"Please enter the mssage: \00"
@stdin = global i32 0
@.str.5 = [6 x i8] c"exit\0A\00"
@.str.7 = [6 x i8] c"write\00"
@.str.9 = [5 x i8] c"read\00"
@.str.11 = [22 x i8] c"Receive message: %s.\0A\00"
@str = [10 x i8] c"Read Over\00"
@str.12 = [19 x i8] c"server has closed.\00"
@str.13 = [6 x i8] c"exit!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = bitcast %struct.sockaddr_in* %3 to i8*
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 -1)
unreachable
14: ; preds = %2
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call i32 @exit(i32 -1)
unreachable
22: ; preds = %14
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call %struct.hostent* @gethostbyname(i8* %24)
%26 = icmp eq %struct.hostent* %25, null
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%29 = tail call i32 @exit(i32 -1)
unreachable
30: ; preds = %22
%31 = call i32 @bzero(i8* %6, i32 12)
%32 = load i32, i32* @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %32, i32* %33
%34 = getelementptr inbounds %struct.hostent, %struct.hostent* %25, i64 0, i32 1
%35 = load i64, i64* %34
%36 = inttoptr i64 %35 to i8*
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
%38 = bitcast i32* %37 to i8*
%39 = getelementptr inbounds %struct.hostent, %struct.hostent* %25, i64 0, i32 0
%40 = load i32, i32* %39
%41 = tail call i32 @htons(i32 10001)
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %41, i32* %42
%43 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%44 = call i64 @connect(i32 %17, %struct.sockaddr* %43, i32 12)
%45 = icmp slt i64 %44, 0
br i1 %45, label %53, label %46
46: ; preds = %30
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%48 = call i32 @bzero(i8* %7, i32 256)
%49 = load i32, i32* @stdin
%50 = call i32 @fgets(i8* %7, i32 255, i32 %49)
%51 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %56, label %60
53: ; preds = %30
%54 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%55 = call i32 @exit(i32 -1)
unreachable
56: ; preds = %85, %46
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.13, i64 0, i64 0))
%58 = call i32 @close(i32 %17)
%59 = call i32 @exit(i32 0)
unreachable
60: ; preds = %46, %85
%61 = call i32 @strlen(i8* %7)
%62 = call i32 @write(i32 %17, i8* %7, i32 %61)
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%66 = call i32 @exit(i32 -1)
unreachable
67: ; preds = %60, %80
%68 = call i32 @bzero(i8* %8, i32 256)
%69 = call i32 @read(i32 %17, i8* %8, i32 256)
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %75
71: ; preds = %67
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.12, i64 0, i64 0))
%73 = call i32 @close(i32 %17)
%74 = call i32 @exit(i32 0)
unreachable
75: ; preds = %67
%76 = icmp slt i32 %69, 0
br i1 %76, label %77, label %80
77: ; preds = %75
%78 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%79 = call i32 @exit(i32 -1)
unreachable
80: ; preds = %75
%81 = zext i32 %69 to i64
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = icmp eq i8 %83, 0
br i1 %84, label %85, label %67
85: ; preds = %80
%86 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* %8)
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%89 = call i32 @bzero(i8* %7, i32 256)
%90 = load i32, i32* @stdin
%91 = call i32 @fgets(i8* %7, i32 255, i32 %90)
%92 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%93 = icmp eq i64 %92, 0
br i1 %93, label %56, label %60
}