#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;
};
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ err_sys(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(unsigned short);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read_some(int);
int send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  int ret = 0;
  unsigned short port = 10028;
  struct sockaddr_in addr;
  addr.sin_family = AF_INET;
  addr.sin_port = htons(port);
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  int connfd = socket(PF_INET, SOCK_STREAM, 0);
  if (connfd < 0)
    err_sys("create socket");
  socklen_t addrlen = sizeof(struct sockaddr_in);
  ret = connect(connfd, (struct sockaddr *)&addr, addrlen);
  if (ret < 0)
    err_sys("connect");
  read_some(connfd);
  int n = 0, quit = 0;
  char buf[512 + 1] = {0};
  while (!quit) {
    if (fgets(buf, 512, stdin) == NULL) {
      printf("getting user input failed\n");
      break;
    }
    if (strncmp(buf, "exit", 4) == 0) {
      quit = 1;
    } else if (strncmp(buf, "ctlc", 4) == 0) {
      buf[0] = 03;
      buf[1] = 0;
    } else if (strncmp(buf, "ctld", 4) == 0) {
      buf[0] = 04;
      buf[1] = 0;
    } else if (strncmp(buf, "ctlz", 4) == 0) {
      buf[0] = 032;
      buf[1] = 0;
    } else if (strncmp(buf, "ctlq", 4) == 0) {
      buf[0] = 0134 - 0100;
      buf[1] = 0;
    }
    while ((n = strlen(buf)) > 0 && buf[n - 1] == '\n')
      buf[n - 1] = 0;
    ret = send(connfd, buf, n, 0);
    if (ret < n) {
      printf("send failed, %d != %d\n", ret, n);
      break;
    }
    read_some(connfd);
  }
  printf("connection break...\n");
  close(connfd);
  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)
movl   $0x0,-0x14(%rbp)
movw   $0x272c,-0x16(%rbp)
mov    0x2deb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
movzwl -0x16(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x24(%rbp)
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %eax,-0x28(%rbp)
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    0x2d99(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1251 <main+0x81>
lea    0xdb4(%rip),%rdi
call   1040 <err_sys@plt>
movl   $0xc,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%edx
call   10e0 <connect@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1280 <main+0xb0>
lea    0xd93(%rip),%rdi
call   1040 <err_sys@plt>
mov    -0x2c(%rbp),%edi
call   10d0 <read_some@plt>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
lea    -0x240(%rbp),%rdi
xor    %esi,%esi
mov    $0x201,%edx
call   10a0 <memset@plt>
cmpl   $0x0,-0x38(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12bf <main+0xef>
jmp    14bb <main+0x2eb>
lea    -0x240(%rbp),%rdi
mov    0x2d13(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   10c0 <fgets@plt>
cmp    $0x0,%rax
jne    12f6 <main+0x126>
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    14bb <main+0x2eb>
lea    -0x240(%rbp),%rdi
lea    0xd2d(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1324 <main+0x154>
movl   $0x1,-0x38(%rbp)
jmp    1407 <main+0x237>
lea    -0x240(%rbp),%rdi
lea    0xd04(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1359 <main+0x189>
movb   $0x3,-0x240(%rbp)
movb   $0x0,-0x23f(%rbp)
jmp    1402 <main+0x232>
lea    -0x240(%rbp),%rdi
lea    0xcd4(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    138e <main+0x1be>
movb   $0x4,-0x240(%rbp)
movb   $0x0,-0x23f(%rbp)
jmp    13fd <main+0x22d>
lea    -0x240(%rbp),%rdi
lea    0xca4(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    13c3 <main+0x1f3>
movb   $0x1a,-0x240(%rbp)
movb   $0x0,-0x23f(%rbp)
jmp    13f8 <main+0x228>
lea    -0x240(%rbp),%rdi
lea    0xc74(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    13f3 <main+0x223>
movb   $0x1c,-0x240(%rbp)
movb   $0x0,-0x23f(%rbp)
jmp    13f8 <main+0x228>
jmp    13fd <main+0x22d>
jmp    1402 <main+0x232>
jmp    1407 <main+0x237>
jmp    140c <main+0x23c>
lea    -0x240(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    %ecx,-0x34(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x241(%rbp)
jle    144a <main+0x27a>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x240(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
sete   %al
mov    %al,-0x241(%rbp)
mov    -0x241(%rbp),%al
test   $0x1,%al
jne    145d <main+0x28d>
jmp    1472 <main+0x2a2>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x240(%rbp,%rax,1)
jmp    140c <main+0x23c>
mov    -0x2c(%rbp),%edi
lea    -0x240(%rbp),%rsi
mov    -0x34(%rbp),%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    14ae <main+0x2de>
mov    -0x14(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xba8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    14bb <main+0x2eb>
mov    -0x2c(%rbp),%edi
call   10d0 <read_some@plt>
jmp    12a9 <main+0xd9>
lea    0xb9f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <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
mov    0x2df0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    $0x272c,%edi
call   1070 <htons@plt>
mov    %eax,0x4(%rsp)
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   10a0 <htonl@plt>
mov    %eax,(%rsp)
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
mov    0x2d9b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1248 <main+0x68>
lea    0xdbd(%rip),%rdi
call   1050 <err_sys@plt>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0xc,%edx
call   10f0 <connect@plt>
test   %eax,%eax
jns    1267 <main+0x87>
lea    0xdac(%rip),%rdi
call   1050 <err_sys@plt>
mov    %ebp,%edi
call   10e0 <read_some@plt>
lea    0x10(%rsp),%rbx
mov    $0x201,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <memset@plt>
mov    0x2d57(%rip),%r12
lea    0xd86(%rip),%r14
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x200,%esi
call   10d0 <fgets@plt>
test   %rax,%rax
je     13c6 <main+0x1e6>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1330 <main+0x150>
mov    %rbx,%rdi
lea    0xd52(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1340 <main+0x160>
mov    %rbx,%rdi
lea    0xd3e(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1347 <main+0x167>
mov    %rbx,%rdi
lea    0xd2a(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     134e <main+0x16e>
mov    %rbx,%rdi
lea    0xd16(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    $0x1,%r15b
test   %rax,%rax
jne    1370 <main+0x190>
movb   $0x1c,0x10(%rsp)
jmp    1360 <main+0x180>
nopl   (%rax)
xor    %r15d,%r15d
jmp    1370 <main+0x190>
cs nopw 0x0(%rax,%rax,1)
nop
movb   $0x3,0x10(%rsp)
jmp    1360 <main+0x180>
movb   $0x4,0x10(%rsp)
jmp    1360 <main+0x180>
movb   $0x1a,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x0,0x11(%rsp)
mov    $0x1,%r15b
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%r13d
test   %eax,%eax
jle    13a0 <main+0x1c0>
lea    -0x1(%r13),%eax
cmpb   $0xa,0x10(%rsp,%rax,1)
jne    13a0 <main+0x1c0>
movb   $0x0,0x10(%rsp,%rax,1)
jmp    1370 <main+0x190>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13d,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    %r13d,%eax
jl     13d4 <main+0x1f4>
mov    %ebp,%edi
call   10e0 <read_some@plt>
test   %r15b,%r15b
jne    1290 <main+0xb0>
jmp    13e7 <main+0x207>
lea    0xc8d(%rip),%rdi
call   1040 <puts@plt>
jmp    13e7 <main+0x207>
lea    0xc54(%rip),%rdi
mov    %eax,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xc58(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%edi
call   10c0 <close@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [14 x i8] c"create socket\00"
@.str.1 = [8 x i8] c"connect\00"
@stdin = global i32 0
@.str.2 = [27 x i8] c"getting user input failed\0A\00"
@.str.3 = [5 x i8] c"exit\00"
@.str.4 = [5 x i8] c"ctlc\00"
@.str.5 = [5 x i8] c"ctld\00"
@.str.6 = [5 x i8] c"ctlz\00"
@.str.7 = [5 x i8] c"ctlq\00"
@.str.8 = [23 x i8] c"send failed, %d != %d\0A\00"
@.str.9 = [21 x i8] c"connection break...\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i16
%8 = alloca %struct.sockaddr_in
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [513 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i16 10028, i16* %7
%14 = load i32, i32* @AF_INET
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %14, i32* %15
%16 = load i16, i16* %7
%17 = call i32 @htons(i16 zeroext %16)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
store i32 %17, i32* %18
%19 = load i32, i32* @INADDR_ANY
%20 = call i32 @htonl(i32 %19)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
store i32 %20, i32* %22
%23 = load i32, i32* @PF_INET
%24 = load i32, i32* @SOCK_STREAM
%25 = call i32 @socket(i32 %23, i32 %24, i32 0)
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %2
%29 = call i32 @err_sys(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %2
store i32 12, i32* %10
%31 = load i32, i32* %9
%32 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%33 = load i32, i32* %10
%34 = call i32 @connect(i32 %31, %struct.sockaddr* %32, i32 %33)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %30
%38 = call i32 @err_sys(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %30
%40 = load i32, i32* %9
%41 = call i32 @read_some(i32 %40)
store i32 0, i32* %11
store i32 0, i32* %12
%42 = bitcast [513 x i8]* %13 to i8*
br label %43
43: ; preds = %123, %39
%44 = load i32, i32* %12
%45 = icmp ne i32 %44, 0
%46 = xor i1 %45, true
br i1 %46, label %47, label %126
47: ; preds = %43
%48 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
%49 = load i32, i32* @stdin
%50 = call i32* @fgets(i8* %48, i32 512, i32 %49)
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %126
54: ; preds = %47
%55 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
%56 = call i64 @strncmp(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %54
store i32 1, i32* %12
br label %91
59: ; preds = %54
%60 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
%61 = call i64 @strncmp(i8* %60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
store i8 3, i8* %64
%65 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 1
store i8 0, i8* %65
br label %90
66: ; preds = %59
%67 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
%68 = call i64 @strncmp(i8* %67, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %66
%71 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
store i8 4, i8* %71
%72 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 1
store i8 0, i8* %72
br label %89
73: ; preds = %66
%74 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
%75 = call i64 @strncmp(i8* %74, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %73
%78 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
store i8 26, i8* %78
%79 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 1
store i8 0, i8* %79
br label %88
80: ; preds = %73
%81 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
%82 = call i64 @strncmp(i8* %81, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4)
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %80
%85 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
store i8 28, i8* %85
%86 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 1
store i8 0, i8* %86
br label %87
87: ; preds = %84, %80
br label %88
88: ; preds = %87, %77
br label %89
89: ; preds = %88, %70
br label %90
90: ; preds = %89, %63
br label %91
91: ; preds = %90, %58
br label %92
92: ; preds = %106, %91
%93 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
%94 = call i32 @strlen(i8* %93)
store i32 %94, i32* %11
%95 = icmp sgt i32 %94, 0
br i1 %95, label %96, label %104
96: ; preds = %92
%97 = load i32, i32* %11
%98 = sub nsw i32 %97, 1
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 %99
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
%103 = icmp eq i32 %102, 10
br label %104
104: ; preds = %96, %92
%105 = phi i1 [ false, %92 ], [ %103, %96 ]
br i1 %105, label %106, label %111
106: ; preds = %104
%107 = load i32, i32* %11
%108 = sub nsw i32 %107, 1
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 %109
store i8 0, i8* %110
br label %92
111: ; preds = %104
%112 = load i32, i32* %9
%113 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
%114 = load i32, i32* %11
%115 = call i32 @send(i32 %112, i8* %113, i32 %114, i32 0)
store i32 %115, i32* %6
%116 = load i32, i32* %6
%117 = load i32, i32* %11
%118 = icmp slt i32 %116, %117
br i1 %118, label %119, label %123
119: ; preds = %111
%120 = load i32, i32* %6
%121 = load i32, i32* %11
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %120, i32 %121)
br label %126
123: ; preds = %111
%124 = load i32, i32* %9
%125 = call i32 @read_some(i32 %124)
br label %43
126: ; preds = %119, %52, %43
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%128 = load i32, i32* %9
%129 = call i32 @close(i32 %128)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [14 x i8] c"create socket\00"
@.str.1 = [8 x i8] c"connect\00"
@stdin = global i32 0
@.str.3 = [5 x i8] c"exit\00"
@.str.4 = [5 x i8] c"ctlc\00"
@.str.5 = [5 x i8] c"ctld\00"
@.str.6 = [5 x i8] c"ctlz\00"
@.str.7 = [5 x i8] c"ctlq\00"
@.str.8 = [23 x i8] c"send failed, %d != %d\0A\00"
@str = [20 x i8] c"connection break...\00"
@str.10 = [26 x i8] c"getting user input failed\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [513 x i8]
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %6, i32* %7
%8 = tail call i32 @htons(i16 zeroext 10028)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %8, i32* %9
%10 = load i32, i32* @INADDR_ANY
%11 = tail call i32 @htonl(i32 %10)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %11, i32* %12
%13 = load i32, i32* @PF_INET
%14 = load i32, i32* @SOCK_STREAM
%15 = tail call i32 @socket(i32 %13, i32 %14, i32 0)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = tail call i32 @err_sys(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %2
%20 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%21 = call i32 @connect(i32 %15, %struct.sockaddr* %20, i32 12)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @err_sys(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
%26 = call i32 @read_some(i32 %15)
%27 = getelementptr inbounds [513 x i8], [513 x i8]* %4, i64 0, i64 0
%28 = getelementptr inbounds [513 x i8], [513 x i8]* %4, i64 0, i64 1
br label %29
29: ; preds = %25, %75
%30 = load i32, i32* @stdin
%31 = call i32* @fgets(i8* %27, i32 512, i32 %30)
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.10, i64 0, i64 0))
br label %77
35: ; preds = %29
%36 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%37 = icmp eq i64 %36, 0
br i1 %37, label %55, label %38
38: ; preds = %35
%39 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %38
store i8 3, i8* %27
br label %54
42: ; preds = %38
%43 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %42
store i8 4, i8* %27
br label %54
46: ; preds = %42
%47 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %46
store i8 26, i8* %27
br label %54
50: ; preds = %46
%51 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %50
store i8 28, i8* %27
br label %54
54: ; preds = %45, %53, %49, %41
store i8 0, i8* %28
br label %55
55: ; preds = %54, %35, %50
%56 = phi i1 [ false, %35 ], [ true, %50 ], [ true, %54 ]
%57 = call i32 @strlen(i8* %27)
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %69
59: ; preds = %55, %66
%60 = phi i32 [ %67, %66 ], [ %57, %55 ]
%61 = add nsw i32 %60, -1
%62 = zext i32 %61 to i64
%63 = getelementptr inbounds [513 x i8], [513 x i8]* %4, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = icmp eq i8 %64, 10
br i1 %65, label %66, label %69
66: ; preds = %59
store i8 0, i8* %63
%67 = call i32 @strlen(i8* %27)
%68 = icmp sgt i32 %67, 0
br i1 %68, label %59, label %69
69: ; preds = %59, %66, %55
%70 = phi i32 [ %57, %55 ], [ %67, %66 ], [ %60, %59 ]
%71 = call i32 @send(i32 %15, i8* %27, i32 %70, i32 0)
%72 = icmp slt i32 %71, %70
br i1 %72, label %73, label %75
73: ; preds = %69
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %71, i32 %70)
br label %77
75: ; preds = %69
%76 = call i32 @read_some(i32 %15)
br i1 %56, label %29, label %77
77: ; preds = %75, %73, %33
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%79 = call i32 @close(i32 %15)
ret i32 0
}