#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 *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
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) {
    bzero(recv_buf, sizeof(recv_buf));
    n = read(master_sock, recv_buf, sizeof(recv_buf) - 1);
    if (0 == strncmp(recv_buf, "Refuse", strlen("Refuse"))) {
      printf("server refuse your connection.\n");
      close(master_sock);
      exit(0);
    } else if (0 == n) {
      printf("server has closed.\n");
      close(master_sock);
      exit(0);
    } else if (n < 0) {
      perror("read");
      exit(-1);
    }
    printf("Receive message: %s.\n", recv_buf);
    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 client.\n");
      close(master_sock);
      exit(0);
    }
    n = write(master_sock, send_buf, strlen(send_buf));
    if (n < 0) {
      perror("write");
      exit(-1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1242 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
mov    0x2d7e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    127e <main+0x7e>
lea    0xda8(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <gethostbyname@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
jne    12b1 <main+0xb1>
lea    0xd7c(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
lea    -0x28(%rbp),%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    0x2d22(%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   10d0 <bcopy@plt>
mov    $0x2711,%edi
call   1060 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   1110 <connect@plt>
cmp    $0x0,%rax
jge    1324 <main+0x124>
lea    0xd17(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
jmp    1329 <main+0x129>
lea    -0x230(%rbp),%rdi
mov    $0x100,%esi
call   10f0 <bzero@plt>
mov    -0x14(%rbp),%edi
lea    -0x230(%rbp),%rsi
mov    $0xff,%edx
call   1090 <read@plt>
mov    %eax,-0x18(%rbp)
lea    -0x230(%rbp),%rax
mov    %rax,-0x238(%rbp)
lea    0xcce(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x238(%rbp),%rdi
mov    %eax,%edx
lea    0xcb9(%rip),%rsi
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    13ab <main+0x1ab>
lea    0xca6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %edi,%edi
call   1100 <exit@plt>
xor    %eax,%eax
cmp    -0x18(%rbp),%eax
jne    13d3 <main+0x1d3>
lea    0xc9e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %edi,%edi
call   1100 <exit@plt>
cmpl   $0x0,-0x18(%rbp)
jge    13f3 <main+0x1f3>
lea    0xc8b(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
jmp    13f8 <main+0x1f8>
jmp    13fd <main+0x1fd>
lea    -0x230(%rbp),%rsi
lea    0xc69(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xc71(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x130(%rbp),%rdi
mov    $0x100,%esi
call   10f0 <bzero@plt>
lea    -0x130(%rbp),%rdi
mov    0x2ba1(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   10a0 <fgets@plt>
lea    -0x130(%rbp),%rdi
lea    0xc4b(%rip),%rsi
call   10b0 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1489 <main+0x289>
lea    0xc37(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %edi,%edi
call   1100 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x244(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x240(%rbp)
lea    -0x130(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x244(%rbp),%edi
mov    -0x240(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    14e3 <main+0x2e3>
lea    0xbe4(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
jmp    1329 <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     1244 <main+0x34>
mov    (%rbx),%rsi
lea    0xdcd(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
mov    0x2d9d(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d7b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
test   %eax,%eax
jns    126b <main+0x5b>
lea    0xdae(%rip),%rdi
jmp    12d8 <main+0xc8>
mov    %eax,%r13d
mov    0x8(%rbx),%rdi
call   10d0 <gethostbyname@plt>
test   %rax,%rax
jne    1285 <main+0x75>
lea    0xd9b(%rip),%rdi
jmp    12d8 <main+0xc8>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%rbx),%rsi
lea    0x4(%rsp),%rdi
mov    (%rbx),%edx
call   10e0 <memmove@plt>
mov    $0x2711,%edi
call   1070 <htons@plt>
mov    %eax,(%rsp)
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
test   %rax,%rax
jns    12e7 <main+0xd7>
lea    0xd54(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
lea    0x10(%rsp),%rbx
lea    0xd41(%rip),%r14
lea    0x110(%rsp),%rbp
lea    0xd6e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x100,%esi
call   1100 <bzero@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0xff,%edx
call   10a0 <read@plt>
mov    %eax,%r12d
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     13d8 <main+0x1c8>
test   %r12d,%r12d
je     13e1 <main+0x1d1>
js     13ea <main+0x1da>
lea    0xcdc(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xce1(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
mov    $0x100,%esi
call   1100 <bzero@plt>
mov    0x2c50(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0xff,%esi
call   10b0 <fgets@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     13f6 <main+0x1e6>
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   %eax,%eax
jns    1310 <main+0x100>
lea    0xca3(%rip),%rdi
jmp    12d8 <main+0xc8>
lea    0xcbd(%rip),%rdi
jmp    13fd <main+0x1ed>
lea    0xca1(%rip),%rdi
jmp    13fd <main+0x1ed>
lea    0xc4a(%rip),%rdi
jmp    12d8 <main+0xc8>
lea    0xc7f(%rip),%rdi
call   1040 <puts@plt>
mov    %r13d,%edi
call   1090 <close@plt>
xor    %edi,%edi
call   1110 <exit@plt>

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 = [7 x i8] c"Refuse\00"
@.str.5 = [32 x i8] c"server refuse your connection.\0A\00"
@.str.6 = [20 x i8] c"server has closed.\0A\00"
@.str.7 = [5 x i8] c"read\00"
@.str.8 = [22 x i8] c"Receive message: %s.\0A\00"
@.str.9 = [26 x i8] c"Please enter the mssage: \00"
@stdin = global i32 0
@.str.10 = [6 x i8] c"exit\0A\00"
@.str.11 = [14 x i8] c"exit client.\0A\00"
@.str.12 = [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 %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, %124
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%67 = call i32 @bzero(i8* %66, i32 256)
%68 = load i32, i32* %6
%69 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%70 = call i32 @read(i32 %68, i8* %69, i32 255)
store i32 %70, i32* %7
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%72 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%73 = call i64 @strncmp(i8* %71, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %72)
%74 = icmp eq i64 0, %73
br i1 %74, label %75, label %80
75: ; preds = %65
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, 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* %7
%82 = icmp eq i32 0, %81
br i1 %82, label %83, label %88
83: ; preds = %80
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%85 = load i32, i32* %6
%86 = call i32 @close(i32 %85)
%87 = call i32 @exit(i32 0)
unreachable
88: ; preds = %80
%89 = load i32, i32* %7
%90 = icmp slt i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %88
%92 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%93 = call i32 @exit(i32 -1)
unreachable
94: ; preds = %88
br label %95
95: ; preds = %94
br label %96
96: ; preds = %95
%97 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %97)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%100 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%101 = call i32 @bzero(i8* %100, i32 256)
%102 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%103 = load i32, i32* @stdin
%104 = call i32 @fgets(i8* %102, i32 255, i32 %103)
%105 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%106 = call i64 @strcmp(i8* %105, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%107 = icmp eq i64 0, %106
br i1 %107, label %108, label %113
108: ; preds = %96
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
%110 = load i32, i32* %6
%111 = call i32 @close(i32 %110)
%112 = call i32 @exit(i32 0)
unreachable
113: ; preds = %96
%114 = load i32, i32* %6
%115 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%116 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%117 = call i32 @strlen(i8* %116)
%118 = call i32 @write(i32 %114, i8* %115, i32 %117)
store i32 %118, i32* %7
%119 = load i32, i32* %7
%120 = icmp slt i32 %119, 0
br i1 %120, label %121, label %124
121: ; preds = %113
%122 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%123 = call i32 @exit(i32 -1)
unreachable
124: ; preds = %113
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 = [7 x i8] c"Refuse\00"
@.str.7 = [5 x i8] c"read\00"
@.str.8 = [22 x i8] c"Receive message: %s.\0A\00"
@.str.9 = [26 x i8] c"Please enter the mssage: \00"
@stdin = global i32 0
@.str.10 = [6 x i8] c"exit\0A\00"
@.str.12 = [6 x i8] c"write\00"
@str = [13 x i8] c"exit client.\00"
@str.13 = [19 x i8] c"server has closed.\00"
@str.14 = [31 x i8] c"server refuse your connection.\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 %46, label %49
46: ; preds = %30
%47 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%48 = call i32 @exit(i32 -1)
unreachable
49: ; preds = %30, %82
%50 = call i32 @bzero(i8* %8, i32 256)
%51 = call i32 @read(i32 %17, i8* %8, i32 255)
%52 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%53 = call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %52)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %49
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.14, i64 0, i64 0))
%57 = call i32 @close(i32 %17)
%58 = call i32 @exit(i32 0)
unreachable
59: ; preds = %49
%60 = icmp eq i32 %51, 0
br i1 %60, label %61, label %65
61: ; preds = %59
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.13, i64 0, i64 0))
%63 = call i32 @close(i32 %17)
%64 = call i32 @exit(i32 0)
unreachable
65: ; preds = %59
%66 = icmp slt i32 %51, 0
br i1 %66, label %67, label %70
67: ; preds = %65
%68 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%69 = call i32 @exit(i32 -1)
unreachable
70: ; preds = %65
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %8)
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%73 = call i32 @bzero(i8* %7, i32 256)
%74 = load i32, i32* @stdin
%75 = call i32 @fgets(i8* %7, i32 255, i32 %74)
%76 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %70
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%80 = call i32 @close(i32 %17)
%81 = call i32 @exit(i32 0)
unreachable
82: ; preds = %70
%83 = call i32 @strlen(i8* %7)
%84 = call i32 @write(i32 %17, i8* %7, i32 %83)
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %49
86: ; preds = %82
%87 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%88 = call i32 @exit(i32 -1)
unreachable
}