#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 {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ serverAddress;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memcpy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, char, 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*/ stderr;
int /*<<< orphan*/ stdin;
size_t strcspn(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  int socketFD, portNumber, charsWritten, charsRead;
  struct sockaddr_in serverAddress;
  struct hostent *serverHostInfo;
  char buffer[256];
  if (argc < 3) {
    fprintf(stderr, "USAGE: %s hostname port\n", argv[0]);
    exit(0);
  }
  memset((char *)&serverAddress, '\0', sizeof(serverAddress));
  portNumber = atoi(argv[2]);
  serverAddress.sin_family = AF_INET;
  serverAddress.sin_port = htons(portNumber);
  serverHostInfo = gethostbyname(argv[1]);
  if (serverHostInfo == NULL) {
    fprintf(stderr, "CLIENT: ERROR, no such host\n");
    exit(0);
  }
  memcpy((char *)&serverAddress.sin_addr.s_addr, (char *)serverHostInfo->h_addr,
         serverHostInfo->h_length);
  socketFD = socket(AF_INET, SOCK_STREAM, 0);
  if (socketFD < 0)
    error("CLIENT: ERROR opening socket");
  if (connect(socketFD, (struct sockaddr *)&serverAddress,
              sizeof(serverAddress)) < 0)
    error("CLIENT: ERROR connecting");
  printf("CLIENT: Enter text to send to the server, and then hit enter: ");
  memset(buffer, '\0', sizeof(buffer));
  fgets(buffer, sizeof(buffer) - 1, stdin);
  buffer[strcspn(buffer, "\n")] = '\0';
  charsWritten = send(socketFD, buffer, strlen(buffer), 0);
  if (charsWritten < 0)
    error("CLIENT: ERROR writing to socket");
  if (charsWritten < strlen(buffer))
    printf("CLIENT: WARNING: Not all data written to socket!\n");
  memset(buffer, '\0', sizeof(buffer));
  charsRead = recv(socketFD, buffer, sizeof(buffer) - 1, 0);
  if (charsRead < 0)
    error("CLIENT: ERROR reading from socket");
  printf("CLIENT: I received this from the server: \"%s\"\n", buffer);
  close(socketFD);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1258 <main+0x48>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <gethostbyname@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12c9 <main+0xb9>
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
lea    0xd5e(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
call   10e0 <memcpy@plt>
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
mov    0x2cd8(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1312 <main+0x102>
lea    0xd29(%rip),%rdi
call   10f0 <error@plt>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
cmp    $0x0,%rax
jge    1339 <main+0x129>
lea    0xd1f(%rip),%rdi
call   10f0 <error@plt>
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
lea    -0x140(%rbp),%rdi
mov    0x2c78(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   10b0 <fgets@plt>
lea    -0x140(%rbp),%rdi
lea    0xd79(%rip),%rsi
call   10a0 <strcspn@plt>
movb   $0x0,-0x140(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
mov    %eax,-0x14c(%rbp)
lea    -0x140(%rbp),%rax
mov    %rax,-0x148(%rbp)
lea    -0x140(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x14c(%rbp),%edi
mov    -0x148(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    13e1 <main+0x1d1>
lea    0xccf(%rip),%rdi
call   10f0 <error@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x150(%rbp)
lea    -0x140(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x150(%rbp),%eax
cmp    %ecx,%eax
jge    1414 <main+0x204>
lea    0xcbe(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
mov    -0x14(%rbp),%edi
lea    -0x140(%rbp),%rsi
mov    $0xff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1456 <main+0x246>
lea    0xcac(%rip),%rdi
call   10f0 <error@plt>
lea    -0x140(%rbp),%rsi
lea    0xcbb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    13b4 <main+0x194>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x10(%rbx),%rdi
call   1110 <atoi@plt>
mov    0x2d94(%rip),%rbp
mov    0x0(%rbp),%ecx
mov    %ecx,0x8(%rsp)
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%rdi
call   10d0 <gethostbyname@plt>
test   %rax,%rax
je     13d5 <main+0x1b5>
mov    0x8(%rax),%rsi
mov    (%rax),%edx
mov    %rsp,%rdi
call   10f0 <memcpy@plt>
mov    0x0(%rbp),%edi
mov    0x2d38(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    12ab <main+0x8b>
lea    0xd90(%rip),%rdi
call   1100 <error@plt>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0xc,%edx
call   1130 <connect@plt>
test   %rax,%rax
jns    12cb <main+0xab>
lea    0xd8d(%rip),%rdi
call   1100 <error@plt>
lea    0xd9a(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1090 <memset@plt>
mov    0x2cec(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   10c0 <fgets@plt>
lea    0xe10(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strcspn@plt>
movb   $0x0,0x10(%rsp,%rax,1)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    133f <main+0x11f>
lea    0xd71(%rip),%rdi
call   1100 <error@plt>
lea    0x10(%rsp),%rdi
call   1050 <strlen@plt>
cmp    %eax,%ebx
jge    1359 <main+0x139>
lea    0xdc8(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1090 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jns    138e <main+0x16e>
lea    0xd42(%rip),%rdi
call   1100 <error@plt>
lea    0xd58(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebp,%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xc39(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
mov    0x2bf4(%rip),%rax
mov    (%rax),%edi
lea    0xc34(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [25 x i8] c"USAGE: %s hostname port\0A\00"
@AF_INET = global i32 0
@.str.1 = [29 x i8] c"CLIENT: ERROR, no such host\0A\00"
@SOCK_STREAM = global i32 0
@.str.2 = [29 x i8] c"CLIENT: ERROR opening socket\00"
@.str.3 = [25 x i8] c"CLIENT: ERROR connecting\00"
@.str.4 = [63 x i8] c"CLIENT: Enter text to send to the server, and then hit enter: \00"
@stdin = global i32 0
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [32 x i8] c"CLIENT: ERROR writing to socket\00"
@.str.7 = [50 x i8] c"CLIENT: WARNING: Not all data written to socket!\0A\00"
@.str.8 = [34 x i8] c"CLIENT: ERROR reading from socket\00"
@.str.9 = [47 x i8] c"CLIENT: I received this from the server: \22%s\22\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 i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.hostent*
%12 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %2
%23 = bitcast %struct.sockaddr_in* %10 to i8*
%24 = call i32 @memset(i8* %23, i8 signext 0, i32 12)
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %7
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %29, i32* %30
%31 = load i32, i32* %7
%32 = call i32 @htons(i32 %31)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %32, i32* %33
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call %struct.hostent* @gethostbyname(i8* %36)
store %struct.hostent* %37, %struct.hostent** %11
%38 = load %struct.hostent*, %struct.hostent** %11
%39 = icmp eq %struct.hostent* %38, null
br i1 %39, label %40, label %44
40: ; preds = %22
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %22
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%46 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %45, i32 0, i32 0
%47 = bitcast i32* %46 to i8*
%48 = load %struct.hostent*, %struct.hostent** %11
%49 = getelementptr inbounds %struct.hostent, %struct.hostent* %48, i32 0, i32 1
%50 = load i64, i64* %49
%51 = inttoptr i64 %50 to i8*
%52 = load %struct.hostent*, %struct.hostent** %11
%53 = getelementptr inbounds %struct.hostent, %struct.hostent* %52, i32 0, i32 0
%54 = load i32, i32* %53
%55 = call i32 @memcpy(i8* %47, i8* %51, i32 %54)
%56 = load i32, i32* @AF_INET
%57 = load i32, i32* @SOCK_STREAM
%58 = call i32 @socket(i32 %56, i32 %57, i32 0)
store i32 %58, i32* %6
%59 = load i32, i32* %6
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %44
%62 = call i32 @error(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %63
63: ; preds = %61, %44
%64 = load i32, i32* %6
%65 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%66 = call i64 @connect(i32 %64, %struct.sockaddr* %65, i32 12)
%67 = icmp slt i64 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %63
%69 = call i32 @error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %70
70: ; preds = %68, %63
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0))
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%73 = call i32 @memset(i8* %72, i8 signext 0, i32 256)
%74 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%75 = load i32, i32* @stdin
%76 = call i32 @fgets(i8* %74, i32 255, i32 %75)
%77 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%78 = call i64 @strcspn(i8* %77, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 %78
store i8 0, i8* %79
%80 = load i32, i32* %6
%81 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%83 = call i32 @strlen(i8* %82)
%84 = call i32 @send(i32 %80, i8* %81, i32 %83, i32 0)
store i32 %84, i32* %8
%85 = load i32, i32* %8
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %70
%88 = call i32 @error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
br label %89
89: ; preds = %87, %70
%90 = load i32, i32* %8
%91 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%92 = call i32 @strlen(i8* %91)
%93 = icmp slt i32 %90, %92
br i1 %93, label %94, label %96
94: ; preds = %89
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0))
br label %96
96: ; preds = %94, %89
%97 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%98 = call i32 @memset(i8* %97, i8 signext 0, i32 256)
%99 = load i32, i32* %6
%100 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%101 = call i32 @recv(i32 %99, i8* %100, i32 255, i32 0)
store i32 %101, i32* %9
%102 = load i32, i32* %9
%103 = icmp slt i32 %102, 0
br i1 %103, label %104, label %106
104: ; preds = %96
%105 = call i32 @error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
br label %106
106: ; preds = %104, %96
%107 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.9, i64 0, i64 0), i8* %107)
%109 = load i32, i32* %6
%110 = call i32 @close(i32 %109)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [25 x i8] c"USAGE: %s hostname port\0A\00"
@AF_INET = global i32 0
@.str.1 = [29 x i8] c"CLIENT: ERROR, no such host\0A\00"
@SOCK_STREAM = global i32 0
@.str.2 = [29 x i8] c"CLIENT: ERROR opening socket\00"
@.str.3 = [25 x i8] c"CLIENT: ERROR connecting\00"
@.str.4 = [63 x i8] c"CLIENT: Enter text to send to the server, and then hit enter: \00"
@stdin = global i32 0
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [32 x i8] c"CLIENT: ERROR writing to socket\00"
@.str.8 = [34 x i8] c"CLIENT: ERROR reading from socket\00"
@.str.9 = [47 x i8] c"CLIENT: I received this from the server: \22%s\22\0A\00"
@str = [49 x i8] c"CLIENT: WARNING: Not all data written to socket!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [256 x i8]
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %2
%14 = call i32 @memset(i8* %5, i8 signext 0, i32 12)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
%18 = load i32, i32* @AF_INET
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %18, i32* %19
%20 = call i32 @htons(i32 %17)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %20, i32* %21
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = call %struct.hostent* @gethostbyname(i8* %23)
%25 = icmp eq %struct.hostent* %24, null
br i1 %25, label %26, label %30
26: ; preds = %13
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %13
%31 = getelementptr inbounds %struct.hostent, %struct.hostent* %24, i64 0, i32 1
%32 = load i64, i64* %31
%33 = inttoptr i64 %32 to i8*
%34 = getelementptr inbounds %struct.hostent, %struct.hostent* %24, i64 0, i32 0
%35 = load i32, i32* %34
%36 = call i32 @memcpy(i8* %5, i8* %33, i32 %35)
%37 = load i32, i32* @AF_INET
%38 = load i32, i32* @SOCK_STREAM
%39 = call i32 @socket(i32 %37, i32 %38, i32 0)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %30
%42 = call i32 @error(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %41, %30
%44 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%45 = call i64 @connect(i32 %39, %struct.sockaddr* %44, i32 12)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 @error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0))
%51 = call i32 @memset(i8* %6, i8 signext 0, i32 256)
%52 = load i32, i32* @stdin
%53 = call i32 @fgets(i8* %6, i32 255, i32 %52)
%54 = call i64 @strcspn(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %54
store i8 0, i8* %55
%56 = call i32 @strlen(i8* %6)
%57 = call i32 @send(i32 %39, i8* %6, i32 %56, i32 0)
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %49
%60 = call i32 @error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
br label %61
61: ; preds = %59, %49
%62 = call i32 @strlen(i8* %6)
%63 = icmp slt i32 %57, %62
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
br label %66
66: ; preds = %64, %61
%67 = call i32 @memset(i8* %6, i8 signext 0, i32 256)
%68 = call i32 @recv(i32 %39, i8* %6, i32 255, i32 0)
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = call i32 @error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
br label %72
72: ; preds = %70, %66
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.9, i64 0, i64 0), i8* %6)
%74 = call i32 @close(i32 %39)
ret i32 0
}