#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*/ socklen_t;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
scalar_t__ send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  struct sockaddr_in addr;
  socklen_t addrlen;
  int sk;
  char buf[512];
  int len;
  if (argc != 2) {
    printf("Usage: echoc <ip>\nEx.:   echoc 10.30.0.2\n");
    exit(0);
  }
  if ((sk = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("socket");
    exit(1);
  }
  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_addr.s_addr = inet_addr(argv[1]);
  addr.sin_port = htons(1996);
  if (connect(sk, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
    perror("connect");
    exit(1);
  }
  printf("Connected to Echo server. Type /q to quit.\n");
  while (1) {
    printf("> ");
    fgets(buf, 512, stdin);
    len = strlen(buf);
    if (len == 0)
      continue;
    buf[len - 1] = '\0';
    if (strcmp(buf, "/q") == 0)
      break;
    if (send(sk, buf, len, 0) < 0) {
      perror("send");
      exit(1);
    }
    len = recv(sk, buf, 512, 0);
    if (len < 0) {
      perror("recv");
      exit(1);
    } else if (len == 0) {
      printf("Remote host has closed the connection\n");
      exit(1);
    }
    buf[len] = '\0';
    printf("<< %s\n", buf);
  }
  sprintf(buf, "/q");
  if (send(sk, buf, strlen(buf), 0) < 0) {
    perror("send");
    exit(1);
  }
  close(sk);
  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)
je     1228 <main+0x38>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    0x2d98(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    1263 <main+0x73>
lea    0xdd6(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x7cc,%edi
call   1050 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   1100 <connect@plt>
cmp    $0x0,%rax
jge    12cd <main+0xdd>
lea    0xd73(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x230(%rbp),%rdi
mov    0x2ce9(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   10a0 <fgets@plt>
lea    -0x230(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x234(%rbp)
cmpl   $0x0,-0x234(%rbp)
jne    1327 <main+0x137>
jmp    12db <main+0xeb>
mov    -0x234(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x230(%rbp,%rax,1)
lea    -0x230(%rbp),%rdi
lea    0xd20(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    135c <main+0x16c>
jmp    1425 <main+0x235>
mov    -0x28(%rbp),%edi
lea    -0x230(%rbp),%rsi
mov    -0x234(%rbp),%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0x0,%rax
jge    1393 <main+0x1a3>
lea    0xce7(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x28(%rbp),%edi
lea    -0x230(%rbp),%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x234(%rbp)
cmpl   $0x0,-0x234(%rbp)
jge    13d2 <main+0x1e2>
lea    0xcad(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
cmpl   $0x0,-0x234(%rbp)
jne    13f7 <main+0x207>
lea    0xc8f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    13fc <main+0x20c>
movslq -0x234(%rbp),%rax
movb   $0x0,-0x230(%rbp,%rax,1)
lea    -0x230(%rbp),%rsi
lea    0xc83(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12db <main+0xeb>
lea    -0x230(%rbp),%rdi
lea    0xc35(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x244(%rbp)
lea    -0x230(%rbp),%rax
mov    %rax,-0x240(%rbp)
lea    -0x230(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x244(%rbp),%edi
mov    -0x240(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0x0,%rax
jge    1491 <main+0x2a1>
lea    0xbe9(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x28(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
cmp    $0x2,%edi
jne    13bf <main+0x1cf>
mov    %rsi,%rbx
mov    0x2dd4(%rip),%r14
mov    (%r14),%edi
mov    0x2db2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
test   %eax,%eax
js     13d2 <main+0x1e2>
mov    %eax,%r13d
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    (%r14),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%rbx),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,0x4(%rsp)
mov    $0x7cc,%edi
call   1060 <htons@plt>
mov    %eax,(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0xc,%edx
call   1100 <connect@plt>
test   %rax,%rax
js     13db <main+0x1eb>
lea    0xda1(%rip),%rdi
call   1040 <puts@plt>
lea    0xd7e(%rip),%r14
mov    0x2d48(%rip),%r12
lea    0x10(%rsp),%rbx
lea    0xd6e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x200,%esi
call   10b0 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
je     12b0 <main+0xc0>
mov    %eax,%ebp
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1341 <main+0x151>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
test   %rax,%rax
js     138a <main+0x19a>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
js     1393 <main+0x1a3>
je     13a9 <main+0x1b9>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xced(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    12b0 <main+0xc0>
movb   $0x0,0x12(%rsp)
movw   $0x712f,0x10(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
test   %rax,%rax
js     138a <main+0x19a>
mov    %r13d,%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc84(%rip),%rdi
jmp    139a <main+0x1aa>
lea    0xc80(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xca1(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xcb1(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
lea    0xc27(%rip),%rdi
jmp    139a <main+0x1aa>
lea    0xc25(%rip),%rdi
jmp    139a <main+0x1aa>

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