#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;
};
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ msg;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, char *);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char buf[10];
  char msg[128];
  int sockfd;
  struct sockaddr_in serv_addr;
  int str_len, recv_len, ret;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s <ip> <port>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
    perror("socket() failed");
    exit(EXIT_FAILURE);
  }
  memset(&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = inet_addr(argv[1]);
  serv_addr.sin_port = htons(atoi(argv[2]));
  if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1) {
    fprintf(stderr, "connect() failed: %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  while (1) {
    fputs("Input message(Q/q to quit): ", stdout);
    fgets(msg, sizeof(msg), stdin);
    if (!strcmp(msg, "q\n") || !strcmp(msg, "Q\n"))
      break;
    str_len = write(sockfd, msg, strlen(msg));
    recv_len = 0;
    while (recv_len < str_len) {
      ret = read(sockfd, &buf[recv_len], sizeof(buf) - 1);
      if (ret == -1) {
        perror("read() failed");
        exit(EXIT_FAILURE);
      }
      recv_len += ret;
    }
    buf[recv_len] = '\0';
    printf("[recv %d bytes] %s\n", recv_len, buf);
  }
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     126d <main+0x4d>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xda6(%rip),%rsi
call   10e0 <fprintf@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
mov    0x2d4b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0xa4(%rbp)
cmp    $0xffffffff,%eax
jne    12af <main+0x8f>
lea    0xd7b(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2d1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,-0xac(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,-0xb0(%rbp)
mov    -0xa4(%rbp),%edi
lea    -0xb0(%rbp),%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
cmp    $0xffffffff,%eax
jne    135e <main+0x13e>
mov    0x2cab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc0(%rbp)
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0xc0(%rbp),%edi
mov    %rax,%rdx
lea    0xcdc(%rip),%rsi
call   10e0 <fprintf@plt>
mov    0x2c61(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
jmp    1363 <main+0x143>
mov    0x2c46(%rip),%rax
mov    (%rax),%esi
lea    0xcca(%rip),%rdi
call   1070 <fputs@plt>
lea    -0xa0(%rbp),%rdi
mov    0x2c5a(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   10b0 <fgets@plt>
lea    -0xa0(%rbp),%rdi
lea    0xcba(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%eax
je     13ca <main+0x1aa>
lea    -0xa0(%rbp),%rdi
lea    0xca1(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%eax
jne    13cf <main+0x1af>
jmp    14b4 <main+0x294>
mov    -0xa4(%rbp),%eax
mov    %eax,-0xcc(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xc8(%rbp)
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xcc(%rbp),%edi
mov    -0xc8(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0xb4(%rbp)
movl   $0x0,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
cmp    -0xb4(%rbp),%eax
jge    148d <main+0x26d>
mov    -0xa4(%rbp),%edi
movslq -0xb8(%rbp),%rax
lea    -0x1a(%rbp),%rsi
add    %rax,%rsi
mov    $0x9,%edx
call   10a0 <read@plt>
mov    %eax,-0xbc(%rbp)
cmpl   $0xffffffff,-0xbc(%rbp)
jne    1476 <main+0x256>
lea    0xbfd(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b49(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0xbc(%rbp),%eax
add    -0xb8(%rbp),%eax
mov    %eax,-0xb8(%rbp)
jmp    1419 <main+0x1f9>
movslq -0xb8(%rbp),%rax
movb   $0x0,-0x1a(%rbp,%rax,1)
mov    -0xb8(%rbp),%esi
lea    -0x1a(%rbp),%rdx
lea    0xbc4(%rip),%rdi
call   1060 <printf@plt>
jmp    1363 <main+0x143>
mov    -0xa4(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
jne    13ee <main+0x1de>
mov    0x2db4(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
cmp    $0xffffffff,%eax
je     1403 <main+0x1f3>
mov    %eax,%ebx
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x10(%rsp)
mov    0x8(%r14),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,0xc(%rsp)
mov    0x10(%r14),%rdi
call   10f0 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,0x8(%rsp)
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   1110 <connect@plt>
cmp    $0xffffffff,%eax
je     140c <main+0x1fc>
mov    0x2d03(%rip),%rax
mov    (%rax),%esi
lea    0xd87(%rip),%rdi
call   1070 <fputs@plt>
mov    0x2d1e(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%rdi
mov    $0x80,%esi
call   10b0 <fgets@plt>
mov    $0xa71,%ecx
mov    0x20(%rsp),%eax
xor    %ecx,%eax
movzbl 0x22(%rsp),%ecx
or     %ax,%cx
je     13b9 <main+0x1a9>
lea    0x20(%rsp),%r14
lea    0x16(%rsp),%r12
lea    0xd40(%rip),%r13
jmp    1356 <main+0x146>
nop
xor    %r15d,%r15d
movslq %r15d,%rsi
movb   $0x0,0x16(%rsp,%rsi,1)
lea    0xd5c(%rip),%rdi
mov    %r12,%rdx
call   1060 <printf@plt>
mov    0x2c8f(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   1070 <fputs@plt>
mov    0x2cae(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x80,%esi
call   10b0 <fgets@plt>
mov    0x20(%rsp),%eax
mov    $0xa71,%ecx
xor    %ecx,%eax
movzbl 0x22(%rsp),%ecx
or     %ax,%cx
je     13b9 <main+0x1a9>
mov    0x20(%rsp),%eax
mov    $0xa51,%ecx
xor    %ecx,%eax
movzbl 0x22(%rsp),%ecx
or     %ax,%cx
je     13b9 <main+0x1a9>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %eax,%eax
jle    1300 <main+0xf0>
mov    %eax,%ebp
xor    %r15d,%r15d
nopl   0x0(%rax)
movslq %r15d,%rax
lea    (%rsp,%rax,1),%rsi
add    $0x16,%rsi
mov    %ebx,%edi
mov    $0x9,%edx
call   10a0 <read@plt>
cmp    $0xffffffff,%eax
je     13d4 <main+0x1c4>
add    %eax,%r15d
cmp    %ebp,%r15d
jl     1390 <main+0x180>
jmp    1303 <main+0xf3>
mov    %ebx,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc85(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2bd1(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    0x2bdb(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xbff(%rip),%rsi
jmp    142f <main+0x21f>
lea    0xc0d(%rip),%rdi
jmp    13db <main+0x1cb>
mov    0x2bbd(%rip),%rax
mov    (%rax),%ebx
mov    0x2ba4(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xbfd(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10d0 <fprintf@plt>
jmp    13e0 <main+0x1d0>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"Usage: %s <ip> <port>\0A\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [16 x i8] c"socket() failed\00"
@.str.2 = [22 x i8] c"connect() failed: %s\0A\00"
@errno = global i32 0
@.str.3 = [29 x i8] c"Input message(Q/q to quit): \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.4 = [3 x i8] c"q\0A\00"
@.str.5 = [3 x i8] c"Q\0A\00"
@.str.6 = [14 x i8] c"read() failed\00"
@.str.7 = [20 x i8] c"[recv %d bytes] %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i8]
%7 = alloca [128 x i8]
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %23
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 @fprintf(i32 %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i32, i32* @AF_INET
%25 = load i32, i32* @SOCK_STREAM
%26 = call i32 @socket(i32 %24, i32 %25, i32 0)
store i32 %26, i32* %8
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %23
%33 = call i32 @memset(%struct.sockaddr_in* %9, i32 0, i32 12)
%34 = load i32, i32* @AF_INET
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %34, i32* %35
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @inet_addr(i8* %38)
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%41 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %40, i32 0, i32 0
store i32 %39, i32* %41
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 @atoi(i8* %44)
%46 = call i32 @htons(i32 %45)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %46, i32* %47
%48 = load i32, i32* %8
%49 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%50 = call i32 @connect(i32 %48, %struct.sockaddr* %49, i32 12)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %59
52: ; preds = %32
%53 = load i32, i32* @stderr
%54 = load i32, i32* @errno
%55 = call i8* @strerror(i32 %54)
%56 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %55)
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %32
br label %60
60: ; preds = %59, %100
%61 = load i32, i32* @stdout
%62 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %61)
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%64 = load i32, i32* @stdin
%65 = call i32 @fgets(i8* %63, i32 128, i32 %64)
%66 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%67 = call i32 @strcmp(i8* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %60
%70 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%71 = call i32 @strcmp(i8* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%72 = icmp ne i32 %71, 0
br i1 %72, label %74, label %73
73: ; preds = %69, %60
br label %107
74: ; preds = %69
%75 = load i32, i32* %8
%76 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%77 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%78 = call i32 @strlen(i8* %77)
%79 = call i32 @write(i32 %75, i8* %76, i32 %78)
store i32 %79, i32* %10
store i32 0, i32* %11
br label %80
80: ; preds = %96, %74
%81 = load i32, i32* %11
%82 = load i32, i32* %10
%83 = icmp slt i32 %81, %82
br i1 %83, label %84, label %100
84: ; preds = %80
%85 = load i32, i32* %8
%86 = load i32, i32* %11
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %87
%89 = call i32 @read(i32 %85, i8* %88, i32 9)
store i32 %89, i32* %12
%90 = load i32, i32* %12
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %96
92: ; preds = %84
%93 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%94 = load i32, i32* @EXIT_FAILURE
%95 = call i32 @exit(i32 %94)
unreachable
96: ; preds = %84
%97 = load i32, i32* %12
%98 = load i32, i32* %11
%99 = add nsw i32 %98, %97
store i32 %99, i32* %11
br label %80
100: ; preds = %80
%101 = load i32, i32* %11
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %102
store i8 0, i8* %103
%104 = load i32, i32* %11
%105 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%106 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %104, i8* %105)
br label %60
107: ; preds = %73
%108 = load i32, i32* %8
%109 = call i32 @close(i32 %108)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"Usage: %s <ip> <port>\0A\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [16 x i8] c"socket() failed\00"
@.str.2 = [22 x i8] c"connect() failed: %s\0A\00"
@errno = global i32 0
@.str.3 = [29 x i8] c"Input message(Q/q to quit): \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.4 = [3 x i8] c"q\0A\00"
@.str.5 = [3 x i8] c"Q\0A\00"
@.str.6 = [14 x i8] c"read() failed\00"
@.str.7 = [20 x i8] c"[recv %d bytes] %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = alloca [128 x i8]
%5 = alloca %struct.sockaddr_in
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = bitcast %struct.sockaddr_in* %5 to i8*
%9 = icmp eq i32 %0, 3
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = load i32, i32* @AF_INET
%18 = load i32, i32* @SOCK_STREAM
%19 = tail call i32 @socket(i32 %17, i32 %18, i32 0)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %16
%26 = call i32 @memset(%struct.sockaddr_in* %5, i32 0, i32 12)
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %27, i32* %28
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @inet_addr(i8* %30)
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
store i32 %31, i32* %32
%33 = getelementptr inbounds i8*, i8** %1, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
%36 = call i32 @htons(i32 %35)
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i32 %36, i32* %37
%38 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%39 = call i32 @connect(i32 %19, %struct.sockaddr* %38, i32 12)
%40 = icmp eq i32 %39, -1
br i1 %40, label %48, label %41
41: ; preds = %25
%42 = load i32, i32* @stdout
%43 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%44 = load i32, i32* @stdin
%45 = call i32 @fgets(i8* %7, i32 128, i32 %44)
%46 = call i32 @bcmp(i8* dereferenceable(3) %7, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 3)
%47 = icmp eq i32 %46, 0
br i1 %47, label %86, label %55
48: ; preds = %25
%49 = load i32, i32* @stderr
%50 = load i32, i32* @errno
%51 = call i8* @strerror(i32 %50)
%52 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %51)
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %41, %75
%56 = call i32 @bcmp(i8* dereferenceable(3) %7, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 3)
%57 = icmp eq i32 %56, 0
br i1 %57, label %86, label %58
58: ; preds = %55
%59 = call i32 @strlen(i8* %7)
%60 = call i32 @write(i32 %19, i8* %7, i32 %59)
%61 = icmp sgt i32 %60, 0
br i1 %61, label %64, label %75
62: ; preds = %64
%63 = icmp slt i32 %70, %60
br i1 %63, label %64, label %75
64: ; preds = %58, %62
%65 = phi i32 [ %70, %62 ], [ 0, %58 ]
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %66
%68 = call i32 @read(i32 %19, i8* %67, i32 9)
%69 = icmp eq i32 %68, -1
%70 = add nsw i32 %68, %65
br i1 %69, label %71, label %62
71: ; preds = %64
%72 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%73 = load i32, i32* @EXIT_FAILURE
%74 = call i32 @exit(i32 %73)
unreachable
75: ; preds = %62, %58
%76 = phi i32 [ 0, %58 ], [ %70, %62 ]
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %77
store i8 0, i8* %78
%79 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %76, i8* %6)
%80 = load i32, i32* @stdout
%81 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %80)
%82 = load i32, i32* @stdin
%83 = call i32 @fgets(i8* %7, i32 128, i32 %82)
%84 = call i32 @bcmp(i8* dereferenceable(3) %7, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 3)
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %55
86: ; preds = %55, %75, %41
%87 = call i32 @close(i32 %19)
ret i32 0
}