#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 utsname {
  int /*<<< orphan*/ nodename;
};
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 servent {
  int /*<<< orphan*/ s_port;
};
struct hostent {
  int h_length;
  scalar_t__ **h_addr_list;
};
typedef int /*<<< orphan*/ s_client;
typedef int /*<<< orphan*/ on;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_NONE;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ err_exit(int);
int getchar();
struct hostent *gethostbyname(int /*<<< orphan*/);
struct servent *getservbyname(char *, char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char *, int);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int);
int uname(struct utsname *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  int port;
  struct utsname u_s;
  int i, c[4], d, n;
  char serv_addr[15];
  struct servent *servent_ptr;
  struct hostent *h_s;
  struct sockaddr_in s_client;
  int slave_sock;
  int on = 1;
  int connected, connect_count;
  char stdin_buf[100];
  char sock_buf[1000];
  int sock_buf_len;
  if ((servent_ptr = (getservbyname("SSTL_d", "tcp")))) {
    port = (ntohs(servent_ptr->s_port));
  } else {
    err_exit(1);
  }
  if (uname(&u_s) == -1)
    err_exit(2);
  if ((h_s = gethostbyname(u_s.nodename)) == NULL)
    err_exit(3);
  serv_addr[0] = '\0';
  for (i = 0; i < h_s->h_length; i++) {
    c[i] = (int)(h_s->h_addr_list[0][i]);
    if (c[i] < 0)
      c[i] = c[i] + 256;
  }
  sprintf(serv_addr, "%d.%d.%d.%d", c[0], c[1], c[2], c[3]);
  if ((slave_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
    err_exit(4);
  }
  if ((setsockopt(slave_sock, SOL_SOCKET, SO_REUSEADDR, (char *)&on,
                  sizeof(on))) == -1)
    err_exit(5);
  memset((char *)&s_client, 0, sizeof(s_client));
  s_client.sin_family = AF_INET;
  s_client.sin_port = htons(port);
  if ((s_client.sin_addr.s_addr = inet_addr(serv_addr)) == INADDR_NONE)
    err_exit(6);
  connected = 0;
  connect_count = 0;
  while ((connect_count < 30) && (!connected)) {
    if (connect(slave_sock, (struct sockaddr *)&s_client, sizeof(s_client)) ==
        0) {
      connected = 1;
    } else {
      connect_count++;
      sleep(1);
    }
  }
  if (!connected)
    err_exit(7);
  printf("000=query 001=add\nstring args separated by ,\neg.\n  John "
         "Williams000\n  John Williams,27,male001\n");
  i = 2;
  d = getchar();
  while (d != '\n') {
    stdin_buf[i++] = (char)d;
    d = getchar();
  }
  n = (100 * (stdin_buf[i - 3] - '0')) + (10 * (stdin_buf[i - 2] - '0')) +
      ((stdin_buf[i - 1] - '0'));
  stdin_buf[i - 3] = (unsigned char)n / 256;
  stdin_buf[i - 2] = (unsigned char)n % 256;
  stdin_buf[0] = (unsigned char)(i - 3) / 256;
  stdin_buf[1] = (unsigned char)(i - 3) % 256;
  write(slave_sock, stdin_buf, i - 1);
  read(slave_sock, sock_buf, 2);
  sock_buf_len =
      ((unsigned char)sock_buf[0] * 256) + (unsigned char)sock_buf[0 + 1];
  read(slave_sock, sock_buf, sock_buf_len);
  close(slave_sock);
  sock_buf[sock_buf_len + 1] = '\0';
  printf("Received from SSTL server:\n%s\n", sock_buf);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x70(%rbp)
lea    0xdb9(%rip),%rdi
lea    0xdb9(%rip),%rsi
call   1080 <getservbyname@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     1274 <main+0x54>
mov    -0x50(%rbp),%rax
mov    (%rax),%edi
call   1100 <ntohs@plt>
mov    %eax,-0x14(%rbp)
jmp    127e <main+0x5e>
mov    $0x1,%edi
call   10f0 <err_exit@plt>
lea    -0x18(%rbp),%rdi
call   1070 <uname@plt>
cmp    $0xffffffff,%eax
jne    129a <main+0x7a>
mov    $0x2,%edi
call   10f0 <err_exit@plt>
mov    -0x18(%rbp),%edi
call   10e0 <gethostbyname@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    12ba <main+0x9a>
mov    $0x3,%edi
call   10f0 <err_exit@plt>
movb   $0x0,-0x47(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x58(%rbp),%rcx
cmp    (%rcx),%eax
jge    1329 <main+0x109>
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %eax,%ecx
movslq -0x1c(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
movslq -0x1c(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
jge    1316 <main+0xf6>
movslq -0x1c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x100,%ecx
movslq -0x1c(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    131b <main+0xfb>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12c5 <main+0xa5>
lea    -0x47(%rbp),%rdi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x24(%rbp),%r9d
lea    0xcc9(%rip),%rsi
call   1110 <sprintf@plt>
mov    0x2c92(%rip),%rax
mov    (%rax),%edi
mov    0x2c69(%rip),%rax
mov    (%rax),%esi
mov    0x2c70(%rip),%rax
mov    (%rax),%edx
call   1140 <socket@plt>
mov    %eax,-0x6c(%rbp)
cmp    $0xffffffff,%eax
jne    137d <main+0x15d>
mov    $0x4,%edi
call   10f0 <err_exit@plt>
mov    -0x6c(%rbp),%edi
mov    0x2c61(%rip),%rax
mov    (%rax),%esi
mov    0x2c28(%rip),%rax
mov    (%rax),%edx
lea    -0x70(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    13b4 <main+0x194>
mov    $0x5,%edi
call   10f0 <err_exit@plt>
lea    -0x68(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2c15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x64(%rbp)
lea    -0x47(%rbp),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,-0x68(%rbp)
mov    0x2bea(%rip),%rcx
cmp    (%rcx),%eax
jne    1400 <main+0x1e0>
mov    $0x6,%edi
call   10f0 <err_exit@plt>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
xor    %eax,%eax
cmpl   $0x1e,-0x78(%rbp)
mov    %al,-0x4d5(%rbp)
jge    142f <main+0x20f>
cmpl   $0x0,-0x74(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x4d5(%rbp)
mov    -0x4d5(%rbp),%al
test   $0x1,%al
jne    1442 <main+0x222>
jmp    1481 <main+0x261>
mov    -0x6c(%rbp),%edi
lea    -0x68(%rbp),%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
cmp    $0x0,%rax
jne    1469 <main+0x249>
movl   $0x1,-0x74(%rbp)
jmp    147c <main+0x25c>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
mov    $0x1,%edi
call   1130 <sleep@plt>
jmp    140e <main+0x1ee>
cmpl   $0x0,-0x74(%rbp)
jne    1495 <main+0x275>
mov    $0x7,%edi
call   10f0 <err_exit@plt>
lea    0xb7b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x2,-0x1c(%rbp)
mov    $0x0,%al
call   10d0 <getchar@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
je     14e6 <main+0x2c6>
mov    -0x34(%rbp),%eax
mov    %al,%cl
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %cl,-0xe0(%rbp,%rax,1)
mov    $0x0,%al
call   10d0 <getchar@plt>
mov    %eax,-0x34(%rbp)
jmp    14b4 <main+0x294>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
cltq
movsbl -0xe0(%rbp,%rax,1),%eax
ff
sub    $0x30,%eax
imul   $0x64,%eax,%eax
mov    -0x1c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl -0xe0(%rbp,%rcx,1),%ecx
ff
sub    $0x30,%ecx
imul   $0xa,%ecx,%ecx
add    %ecx,%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0xe0(%rbp,%rcx,1),%ecx
ff
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
movzbl %al,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %al,%cl
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
cltq
mov    %cl,-0xe0(%rbp,%rax,1)
mov    -0x38(%rbp),%eax
movzbl %al,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%cl
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
cltq
mov    %cl,-0xe0(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
movzbl %al,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %al,-0xe0(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
movzbl %al,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0xdf(%rbp)
mov    -0x6c(%rbp),%edi
lea    -0xe0(%rbp),%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
call   1040 <write@plt>
mov    -0x6c(%rbp),%edi
lea    -0x4d0(%rbp),%rsi
mov    $0x2,%edx
call   10b0 <read@plt>
movzbl -0x4d0(%rbp),%eax
shl    $0x8,%eax
movzbl -0x4cf(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x4d4(%rbp)
mov    -0x6c(%rbp),%edi
lea    -0x4d0(%rbp),%rsi
mov    -0x4d4(%rbp),%edx
call   10b0 <read@plt>
mov    -0x6c(%rbp),%edi
call   10a0 <close@plt>
mov    -0x4d4(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x4d0(%rbp,%rax,1)
lea    -0x4d0(%rbp),%rsi
lea    0xa5b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x4e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x498,%rsp
movl   $0x1,0x1c(%rsp)
lea    0xdc4(%rip),%rdi
lea    0xdc4(%rip),%rsi
call   1090 <getservbyname@plt>
test   %rax,%rax
je     1269 <main+0x39>
mov    (%rax),%edi
call   1110 <ntohs@plt>
mov    %eax,%r15d
jmp    1273 <main+0x43>
mov    $0x1,%edi
call   1100 <err_exit@plt>
lea    0x18(%rsp),%rdi
call   1080 <uname@plt>
cmp    $0xffffffff,%eax
jne    128c <main+0x5c>
mov    $0x2,%edi
call   1100 <err_exit@plt>
mov    0x18(%rsp),%edi
call   10f0 <gethostbyname@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    12a7 <main+0x77>
mov    $0x3,%edi
call   1100 <err_exit@plt>
movb   $0x0,0x31(%rsp)
mov    0x0(%rbp),%eax
mov    0x8(%rbp),%rcx
mov    (%rcx),%rcx
cmp    $0x4,%rax
jae    12c3 <main+0x93>
xor    %edx,%edx
jmp    1430 <main+0x200>
mov    %eax,%edx
and    $0x7ffffffc,%edx
lea    -0x4(%rdx),%rsi
mov    %rsi,%rbp
shr    $0x2,%rbp
add    $0x1,%rbp
test   %rsi,%rsi
je     164f <main+0x41f>
mov    %rbp,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
movdqa 0xd0c(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movdqu (%rcx,%rsi,8),%xmm1
movdqu 0x10(%rcx,%rsi,8),%xmm2
pshufd $0xe8,%xmm1,%xmm1
pshufd $0xe8,%xmm2,%xmm2
pxor   %xmm3,%xmm3
pcmpgtd %xmm1,%xmm3
pxor   %xmm4,%xmm4
pcmpgtd %xmm2,%xmm4
movdqa %xmm3,%xmm5
pandn  %xmm1,%xmm5
paddd  %xmm0,%xmm1
pand   %xmm3,%xmm1
por    %xmm5,%xmm1
movdqa %xmm4,%xmm3
pandn  %xmm2,%xmm3
paddd  %xmm0,%xmm2
pand   %xmm4,%xmm2
por    %xmm3,%xmm2
punpcklqdq %xmm2,%xmm1
movdqa %xmm1,(%rsp,%rsi,4)
movdqu 0x20(%rcx,%rsi,8),%xmm1
movdqu 0x30(%rcx,%rsi,8),%xmm2
pshufd $0xe8,%xmm1,%xmm1
pshufd $0xe8,%xmm2,%xmm2
pxor   %xmm3,%xmm3
pcmpgtd %xmm1,%xmm3
pxor   %xmm4,%xmm4
pcmpgtd %xmm2,%xmm4
movdqa %xmm3,%xmm5
pandn  %xmm1,%xmm5
paddd  %xmm0,%xmm1
pand   %xmm3,%xmm1
por    %xmm5,%xmm1
movdqa %xmm4,%xmm3
pandn  %xmm2,%xmm3
paddd  %xmm0,%xmm2
pand   %xmm4,%xmm2
por    %xmm3,%xmm2
punpcklqdq %xmm2,%xmm1
movdqa %xmm1,0x10(%rsp,%rsi,4)
add    $0x8,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1300 <main+0xd0>
test   $0x1,%bpl
je     141c <main+0x1ec>
movdqu (%rcx,%rsi,8),%xmm0
movdqu 0x10(%rcx,%rsi,8),%xmm1
pshufd $0xe8,%xmm0,%xmm0
pshufd $0xe8,%xmm1,%xmm1
pxor   %xmm2,%xmm2
pxor   %xmm3,%xmm3
pcmpgtd %xmm0,%xmm3
pcmpgtd %xmm1,%xmm2
movdqa 0xc11(%rip),%xmm4
movdqa %xmm3,%xmm5
pandn  %xmm0,%xmm5
paddd  %xmm4,%xmm0
paddd  %xmm1,%xmm4
pand   %xmm3,%xmm0
por    %xmm5,%xmm0
pand   %xmm2,%xmm4
pandn  %xmm1,%xmm2
por    %xmm4,%xmm2
punpcklqdq %xmm2,%xmm0
movdqa %xmm0,(%rsp,%rsi,4)
cmp    %rax,%rdx
je     144a <main+0x21a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rcx,%rdx,8),%esi
lea    0x100(%rsi),%edi
test   %esi,%esi
cmovns %esi,%edi
mov    %edi,(%rsp,%rdx,4)
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1430 <main+0x200>
mov    (%rsp),%edx
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%r8d
mov    0xc(%rsp),%r9d
lea    0xbb9(%rip),%rsi
lea    0x31(%rsp),%rdi
call   1120 <sprintf@plt>
mov    0x2b6d(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2b43(%rip),%rax
mov    (%rax),%esi
mov    0x2b4a(%rip),%rax
mov    (%rax),%edx
call   1150 <socket@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    149f <main+0x26f>
mov    $0x4,%edi
call   1100 <err_exit@plt>
mov    0x2b42(%rip),%rax
mov    (%rax),%esi
mov    0x2b09(%rip),%rax
mov    (%rax),%edx
lea    0x1c(%rsp),%rcx
mov    %r14d,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    14d3 <main+0x2a3>
mov    $0x5,%edi
call   1100 <err_exit@plt>
lea    0x20(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0xc,%edx
call   10a0 <memset@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x28(%rsp)
mov    %r15d,%edi
call   1060 <htons@plt>
mov    %eax,0x24(%rsp)
lea    0x31(%rsp),%rdi
call   10d0 <inet_addr@plt>
mov    %eax,0x20(%rsp)
mov    0x2aca(%rip),%rcx
cmp    (%rcx),%eax
jne    151c <main+0x2ec>
mov    $0x6,%edi
call   1100 <err_exit@plt>
lea    0x20(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   1130 <connect@plt>
test   %rax,%rax
je     156b <main+0x33b>
mov    %rax,%rbp
mov    $0x1,%edi
call   1140 <sleep@plt>
test   %rbp,%rbp
je     1561 <main+0x331>
lea    0x1(%rbx),%eax
cmp    $0x1d,%ebx
mov    %eax,%ebx
jb     1530 <main+0x300>
mov    $0x7,%edi
call   1100 <err_exit@plt>
lea    0xad4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   10e0 <getchar@plt>
mov    $0x2,%ebx
cmp    $0xa,%eax
je     15a4 <main+0x374>
mov    $0x2,%ebx
nopl   (%rax)
mov    %al,0x40(%rsp,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   10e0 <getchar@plt>
cmp    $0xa,%eax
jne    1590 <main+0x360>
movslq %ebx,%rax
lea    -0x3(%rax),%rcx
movzbl 0x3d(%rsp,%rax,1),%edx
imul   $0x64,%edx,%edi
lea    0x40(%rsp),%rsi
movzbl -0x2(%rax,%rsi,1),%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%ebp
lea    -0x1(%rax),%rdx
add    %dil,%bpl
add    0x3f(%rsp,%rax,1),%bpl
add    $0x30,%bpl
movb   $0x0,0x3d(%rsp,%rax,1)
mov    %bpl,-0x2(%rax,%rsi,1)
movb   $0x0,0x40(%rsp)
mov    %cl,0x41(%rsp)
mov    %r14d,%edi
call   1050 <write@plt>
lea    0xb0(%rsp),%rbx
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
call   10c0 <read@plt>
movzwl 0xb0(%rsp),%ebp
shl    $0x30,%rbp
bswap  %rbp
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   10c0 <read@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
movb   $0x0,0x1(%rbp,%rbx,1)
lea    0x9f2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x498,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %esi,%esi
test   $0x1,%bpl
jne    13c2 <main+0x192>
jmp    141c <main+0x1ec>

LLVM IR (-O0):
%struct.utsname = type { i32 }
%struct.servent = type { i32 }
%struct.hostent = type { i32, i64** }
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [7 x i8] c"SSTL_d\00"
@.str.1 = [4 x i8] c"tcp\00"
@.str.2 = [12 x i8] c"%d.%d.%d.%d\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@INADDR_NONE = global i32 0
@.str.3 = [96 x i8] c"000=query 001=add\0Astring args separated by ,\0Aeg.\0A John Williams000\0A John Williams,27,male001\0A\00"
@.str.4 = [31 x i8] c"Received from SSTL server:\0A%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.utsname
%8 = alloca i32
%9 = alloca [4 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca [15 x i8]
%13 = alloca %struct.servent*
%14 = alloca %struct.hostent*
%15 = alloca %struct.sockaddr_in
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca [100 x i8]
%21 = alloca [1000 x i8]
%22 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %17
%23 = call %struct.servent* @getservbyname(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store %struct.servent* %23, %struct.servent** %13
%24 = icmp ne %struct.servent* %23, null
br i1 %24, label %25, label %30
25: ; preds = %2
%26 = load %struct.servent*, %struct.servent** %13
%27 = getelementptr inbounds %struct.servent, %struct.servent* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = call i32 @ntohs(i32 %28)
store i32 %29, i32* %6
br label %32
30: ; preds = %2
%31 = call i32 @err_exit(i32 1)
br label %32
32: ; preds = %30, %25
%33 = call i32 @uname(%struct.utsname* %7)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 @err_exit(i32 2)
br label %37
37: ; preds = %35, %32
%38 = getelementptr inbounds %struct.utsname, %struct.utsname* %7, i32 0, i32 0
%39 = load i32, i32* %38
%40 = call %struct.hostent* @gethostbyname(i32 %39)
store %struct.hostent* %40, %struct.hostent** %14
%41 = icmp eq %struct.hostent* %40, null
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = call i32 @err_exit(i32 3)
br label %44
44: ; preds = %42, %37
%45 = getelementptr inbounds [15 x i8], [15 x i8]* %12, i64 0, i64 0
store i8 0, i8* %45
store i32 0, i32* %8
br label %46
46: ; preds = %81, %44
%47 = load i32, i32* %8
%48 = load %struct.hostent*, %struct.hostent** %14
%49 = getelementptr inbounds %struct.hostent, %struct.hostent* %48, i32 0, i32 0
%50 = load i32, i32* %49
%51 = icmp slt i32 %47, %50
br i1 %51, label %52, label %84
52: ; preds = %46
%53 = load %struct.hostent*, %struct.hostent** %14
%54 = getelementptr inbounds %struct.hostent, %struct.hostent* %53, i32 0, i32 1
%55 = load i64**, i64*** %54
%56 = getelementptr inbounds i64*, i64** %55, i64 0
%57 = load i64*, i64** %56
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i64, i64* %57, i64 %59
%61 = load i64, i64* %60
%62 = trunc i64 %61 to i32
%63 = load i32, i32* %8
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %64
store i32 %62, i32* %65
%66 = load i32, i32* %8
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %80
71: ; preds = %52
%72 = load i32, i32* %8
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %73
%75 = load i32, i32* %74
%76 = add nsw i32 %75, 256
%77 = load i32, i32* %8
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %78
store i32 %76, i32* %79
br label %80
80: ; preds = %71, %52
br label %81
81: ; preds = %80
%82 = load i32, i32* %8
%83 = add nsw i32 %82, 1
store i32 %83, i32* %8
br label %46
84: ; preds = %46
%85 = getelementptr inbounds [15 x i8], [15 x i8]* %12, i64 0, i64 0
%86 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 0
%87 = load i32, i32* %86
%88 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 1
%89 = load i32, i32* %88
%90 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 2
%91 = load i32, i32* %90
%92 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 3
%93 = load i32, i32* %92
%94 = call i32 @sprintf(i8* %85, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %87, i32 %89, i32 %91, i32 %93)
%95 = load i32, i32* @AF_INET
%96 = load i32, i32* @SOCK_STREAM
%97 = load i32, i32* @IPPROTO_TCP
%98 = call i32 @socket(i32 %95, i32 %96, i32 %97)
store i32 %98, i32* %16
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %102
100: ; preds = %84
%101 = call i32 @err_exit(i32 4)
br label %102
102: ; preds = %100, %84
%103 = load i32, i32* %16
%104 = load i32, i32* @SOL_SOCKET
%105 = load i32, i32* @SO_REUSEADDR
%106 = bitcast i32* %17 to i8*
%107 = call i32 @setsockopt(i32 %103, i32 %104, i32 %105, i8* %106, i32 4)
%108 = icmp eq i32 %107, -1
br i1 %108, label %109, label %111
109: ; preds = %102
%110 = call i32 @err_exit(i32 5)
br label %111
111: ; preds = %109, %102
%112 = bitcast %struct.sockaddr_in* %15 to i8*
%113 = call i32 @memset(i8* %112, i32 0, i32 12)
%114 = load i32, i32* @AF_INET
%115 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 2
store i32 %114, i32* %115
%116 = load i32, i32* %6
%117 = call i32 @htons(i32 %116)
%118 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
store i32 %117, i32* %118
%119 = getelementptr inbounds [15 x i8], [15 x i8]* %12, i64 0, i64 0
%120 = call i32 @inet_addr(i8* %119)
%121 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
%122 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %121, i32 0, i32 0
store i32 %120, i32* %122
%123 = load i32, i32* @INADDR_NONE
%124 = icmp eq i32 %120, %123
br i1 %124, label %125, label %127
125: ; preds = %111
%126 = call i32 @err_exit(i32 6)
br label %127
127: ; preds = %125, %111
store i32 0, i32* %18
store i32 0, i32* %19
br label %128
128: ; preds = %147, %127
%129 = load i32, i32* %19
%130 = icmp slt i32 %129, 30
br i1 %130, label %131, label %135
131: ; preds = %128
%132 = load i32, i32* %18
%133 = icmp ne i32 %132, 0
%134 = xor i1 %133, true
br label %135
135: ; preds = %131, %128
%136 = phi i1 [ false, %128 ], [ %134, %131 ]
br i1 %136, label %137, label %148
137: ; preds = %135
%138 = load i32, i32* %16
%139 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%140 = call i64 @connect(i32 %138, %struct.sockaddr* %139, i32 12)
%141 = icmp eq i64 %140, 0
br i1 %141, label %142, label %143
142: ; preds = %137
store i32 1, i32* %18
br label %147
143: ; preds = %137
%144 = load i32, i32* %19
%145 = add nsw i32 %144, 1
store i32 %145, i32* %19
%146 = call i32 @sleep(i32 1)
br label %147
147: ; preds = %143, %142
br label %128
148: ; preds = %135
%149 = load i32, i32* %18
%150 = icmp ne i32 %149, 0
br i1 %150, label %153, label %151
151: ; preds = %148
%152 = call i32 @err_exit(i32 7)
br label %153
153: ; preds = %151, %148
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %8
%155 = call i32 (...) @getchar()
store i32 %155, i32* %10
br label %156
156: ; preds = %159, %153
%157 = load i32, i32* %10
%158 = icmp ne i32 %157, 10
br i1 %158, label %159, label %167
159: ; preds = %156
%160 = load i32, i32* %10
%161 = trunc i32 %160 to i8
%162 = load i32, i32* %8
%163 = add nsw i32 %162, 1
store i32 %163, i32* %8
%164 = sext i32 %162 to i64
%165 = getelementptr inbounds [100 x i8], [100 x i8]* %20, i64 0, i64 %164
store i8 %161, i8* %165
%166 = call i32 (...) @getchar()
store i32 %166, i32* %10
br label %156
167: ; preds = %156
%168 = load i32, i32* %8
%169 = sub nsw i32 %168, 3
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [100 x i8], [100 x i8]* %20, i64 0, i64 %170
%172 = load i8, i8* %171
%173 = sext i8 %172 to i32
%174 = sub nsw i32 %173, 48
%175 = mul nsw i32 100, %174
%176 = load i32, i32* %8
%177 = sub nsw i32 %176, 2
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds [100 x i8], [100 x i8]* %20, i64 0, i64 %178
%180 = load i8, i8* %179
%181 = sext i8 %180 to i32
%182 = sub nsw i32 %181, 48
%183 = mul nsw i32 10, %182
%184 = add nsw i32 %175, %183
%185 = load i32, i32* %8
%186 = sub nsw i32 %185, 1
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds [100 x i8], [100 x i8]* %20, i64 0, i64 %187
%189 = load i8, i8* %188
%190 = sext i8 %189 to i32
%191 = sub nsw i32 %190, 48
%192 = add nsw i32 %184, %191
store i32 %192, i32* %11
%193 = load i32, i32* %11
%194 = trunc i32 %193 to i8
%195 = zext i8 %194 to i32
%196 = sdiv i32 %195, 256
%197 = trunc i32 %196 to i8
%198 = load i32, i32* %8
%199 = sub nsw i32 %198, 3
%200 = sext i32 %199 to i64
%201 = getelementptr inbounds [100 x i8], [100 x i8]* %20, i64 0, i64 %200
store i8 %197, i8* %201
%202 = load i32, i32* %11
%203 = trunc i32 %202 to i8
%204 = zext i8 %203 to i32
%205 = srem i32 %204, 256
%206 = trunc i32 %205 to i8
%207 = load i32, i32* %8
%208 = sub nsw i32 %207, 2
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds [100 x i8], [100 x i8]* %20, i64 0, i64 %209
store i8 %206, i8* %210
%211 = load i32, i32* %8
%212 = sub nsw i32 %211, 3
%213 = trunc i32 %212 to i8
%214 = zext i8 %213 to i32
%215 = sdiv i32 %214, 256
%216 = trunc i32 %215 to i8
%217 = getelementptr inbounds [100 x i8], [100 x i8]* %20, i64 0, i64 0
store i8 %216, i8* %217
%218 = load i32, i32* %8
%219 = sub nsw i32 %218, 3
%220 = trunc i32 %219 to i8
%221 = zext i8 %220 to i32
%222 = srem i32 %221, 256
%223 = trunc i32 %222 to i8
%224 = getelementptr inbounds [100 x i8], [100 x i8]* %20, i64 0, i64 1
store i8 %223, i8* %224
%225 = load i32, i32* %16
%226 = getelementptr inbounds [100 x i8], [100 x i8]* %20, i64 0, i64 0
%227 = load i32, i32* %8
%228 = sub nsw i32 %227, 1
%229 = call i32 @write(i32 %225, i8* %226, i32 %228)
%230 = load i32, i32* %16
%231 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 0
%232 = call i32 @read(i32 %230, i8* %231, i32 2)
%233 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 0
%234 = load i8, i8* %233
%235 = zext i8 %234 to i32
%236 = mul nsw i32 %235, 256
%237 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 1
%238 = load i8, i8* %237
%239 = zext i8 %238 to i32
%240 = add nsw i32 %236, %239
store i32 %240, i32* %22
%241 = load i32, i32* %16
%242 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 0
%243 = load i32, i32* %22
%244 = call i32 @read(i32 %241, i8* %242, i32 %243)
%245 = load i32, i32* %16
%246 = call i32 @close(i32 %245)
%247 = load i32, i32* %22
%248 = add nsw i32 %247, 1
%249 = sext i32 %248 to i64
%250 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 %249
store i8 0, i8* %250
%251 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 0
%252 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %251)
ret i32 0
}

LLVM IR (-O2):
%struct.utsname = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.servent = type { i32 }
%struct.hostent = type { i32, i64** }
%struct.sockaddr = type { i32 }
@.str = [7 x i8] c"SSTL_d\00"
@.str.1 = [4 x i8] c"tcp\00"
@.str.2 = [12 x i8] c"%d.%d.%d.%d\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@INADDR_NONE = global i32 0
@.str.4 = [31 x i8] c"Received from SSTL server:\0A%s\0A\00"
@str = [95 x i8] c"000=query 001=add\0Astring args separated by ,\0Aeg.\0A John Williams000\0A John Williams,27,male001\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.utsname
%4 = alloca [4 x i32]
%5 = alloca [15 x i8]
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = alloca [100 x i8]
%9 = alloca [1000 x i8]
%10 = bitcast %struct.utsname* %3 to i8*
%11 = bitcast [4 x i32]* %4 to i8*
%12 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%13 = bitcast %struct.sockaddr_in* %6 to i8*
%14 = bitcast i32* %7 to i8*
store i32 1, i32* %7
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%17 = tail call %struct.servent* @getservbyname(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq %struct.servent* %17, null
br i1 %18, label %23, label %19
19: ; preds = %2
%20 = getelementptr inbounds %struct.servent, %struct.servent* %17, i64 0, i32 0
%21 = load i32, i32* %20
%22 = tail call i32 @ntohs(i32 %21)
br label %25
23: ; preds = %2
%24 = tail call i32 @err_exit(i32 1)
br label %25
25: ; preds = %23, %19
%26 = phi i32 [ %22, %19 ], [ undef, %23 ]
%27 = call i32 @uname(%struct.utsname* %3)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = tail call i32 @err_exit(i32 2)
br label %31
31: ; preds = %29, %25
%32 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 0
%33 = load i32, i32* %32
%34 = tail call %struct.hostent* @gethostbyname(i32 %33)
%35 = icmp eq %struct.hostent* %34, null
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = tail call i32 @err_exit(i32 3)
br label %38
38: ; preds = %36, %31
store i8 0, i8* %12
%39 = getelementptr inbounds %struct.hostent, %struct.hostent* %34, i64 0, i32 0
%40 = load i32, i32* %39
%41 = icmp sgt i32 %40, 0
%42 = getelementptr inbounds %struct.hostent, %struct.hostent* %34, i64 0, i32 1
%43 = load i64**, i64*** %42
%44 = load i64*, i64** %43
%45 = zext i32 %40 to i64
%46 = icmp ult i32 %40, 4
br i1 %46, label %123, label %47
47: ; preds = %38
%48 = and i64 %45, 2147483644
%49 = add nsw i64 %48, -4
%50 = lshr exact i64 %49, 2
%51 = add nuw nsw i64 %50, 1
%52 = and i64 %51, 1
%53 = icmp eq i64 %49, 0
br i1 %53, label %99, label %54
54: ; preds = %47
%55 = and i64 %51, 9223372036854775806
br label %56
56: ; preds = %56, %54
%57 = phi i64 [ 0, %54 ], [ %96, %56 ]
%58 = phi i64 [ 0, %54 ], [ %97, %56 ]
%59 = getelementptr inbounds i64, i64* %44, i64 %57
%60 = bitcast i64* %59 to <2 x i64>*
%61 = load <2 x i64>, <2 x i64>* %60
%62 = getelementptr inbounds i64, i64* %59, i64 2
%63 = bitcast i64* %62 to <2 x i64>*
%64 = load <2 x i64>, <2 x i64>* %63
%65 = trunc <2 x i64> %61 to <2 x i32>
%66 = trunc <2 x i64> %64 to <2 x i32>
%67 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %57
%68 = icmp slt <2 x i32> %65, zeroinitializer
%69 = icmp slt <2 x i32> %66, zeroinitializer
%70 = add nsw <2 x i32> %65, <i32 256, i32 256>
%71 = add nsw <2 x i32> %66, <i32 256, i32 256>
%72 = select <2 x i1> %68, <2 x i32> %70, <2 x i32> %65
%73 = select <2 x i1> %69, <2 x i32> %71, <2 x i32> %66
%74 = bitcast i32* %67 to <2 x i32>*
store <2 x i32> %72, <2 x i32>* %74
%75 = getelementptr inbounds i32, i32* %67, i64 2
%76 = bitcast i32* %75 to <2 x i32>*
store <2 x i32> %73, <2 x i32>* %76
%77 = or i64 %57, 4
%78 = getelementptr inbounds i64, i64* %44, i64 %77
%79 = bitcast i64* %78 to <2 x i64>*
%80 = load <2 x i64>, <2 x i64>* %79
%81 = getelementptr inbounds i64, i64* %78, i64 2
%82 = bitcast i64* %81 to <2 x i64>*
%83 = load <2 x i64>, <2 x i64>* %82
%84 = trunc <2 x i64> %80 to <2 x i32>
%85 = trunc <2 x i64> %83 to <2 x i32>
%86 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %77
%87 = icmp slt <2 x i32> %84, zeroinitializer
%88 = icmp slt <2 x i32> %85, zeroinitializer
%89 = add nsw <2 x i32> %84, <i32 256, i32 256>
%90 = add nsw <2 x i32> %85, <i32 256, i32 256>
%91 = select <2 x i1> %87, <2 x i32> %89, <2 x i32> %84
%92 = select <2 x i1> %88, <2 x i32> %90, <2 x i32> %85
%93 = bitcast i32* %86 to <2 x i32>*
store <2 x i32> %91, <2 x i32>* %93
%94 = getelementptr inbounds i32, i32* %86, i64 2
%95 = bitcast i32* %94 to <2 x i32>*
store <2 x i32> %92, <2 x i32>* %95
%96 = add nuw i64 %57, 8
%97 = add i64 %58, 2
%98 = icmp eq i64 %97, %55
br i1 %98, label %99, label %56
99: ; preds = %56, %47
%100 = phi i64 [ 0, %47 ], [ %96, %56 ]
%101 = icmp eq i64 %52, 0
br i1 %101, label %121, label %102
102: ; preds = %99
%103 = getelementptr inbounds i64, i64* %44, i64 %100
%104 = bitcast i64* %103 to <2 x i64>*
%105 = load <2 x i64>, <2 x i64>* %104
%106 = getelementptr inbounds i64, i64* %103, i64 2
%107 = bitcast i64* %106 to <2 x i64>*
%108 = load <2 x i64>, <2 x i64>* %107
%109 = trunc <2 x i64> %105 to <2 x i32>
%110 = trunc <2 x i64> %108 to <2 x i32>
%111 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %100
%112 = icmp slt <2 x i32> %109, zeroinitializer
%113 = icmp slt <2 x i32> %110, zeroinitializer
%114 = add nsw <2 x i32> %109, <i32 256, i32 256>
%115 = add nsw <2 x i32> %110, <i32 256, i32 256>
%116 = select <2 x i1> %112, <2 x i32> %114, <2 x i32> %109
%117 = select <2 x i1> %113, <2 x i32> %115, <2 x i32> %110
%118 = bitcast i32* %111 to <2 x i32>*
store <2 x i32> %116, <2 x i32>* %118
%119 = getelementptr inbounds i32, i32* %111, i64 2
%120 = bitcast i32* %119 to <2 x i32>*
store <2 x i32> %117, <2 x i32>* %120
br label %121
121: ; preds = %99, %102
%122 = icmp eq i64 %48, %45
br i1 %122, label %136, label %123
123: ; preds = %38, %121
%124 = phi i64 [ 0, %38 ], [ %48, %121 ]
br label %125
125: ; preds = %123, %125
%126 = phi i64 [ %134, %125 ], [ %124, %123 ]
%127 = getelementptr inbounds i64, i64* %44, i64 %126
%128 = load i64, i64* %127
%129 = trunc i64 %128 to i32
%130 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %126
%131 = icmp slt i32 %129, 0
%132 = add nsw i32 %129, 256
%133 = select i1 %131, i32 %132, i32 %129
store i32 %133, i32* %130
%134 = add nuw nsw i64 %126, 1
%135 = icmp eq i64 %134, %45
br i1 %135, label %136, label %125
136: ; preds = %125, %121
%137 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%138 = load i32, i32* %137
%139 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 1
%140 = load i32, i32* %139
%141 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 2
%142 = load i32, i32* %141
%143 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 3
%144 = load i32, i32* %143
%145 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %138, i32 %140, i32 %142, i32 %144)
%146 = load i32, i32* @AF_INET
%147 = load i32, i32* @SOCK_STREAM
%148 = load i32, i32* @IPPROTO_TCP
%149 = tail call i32 @socket(i32 %146, i32 %147, i32 %148)
%150 = icmp eq i32 %149, -1
br i1 %150, label %151, label %153
151: ; preds = %136
%152 = tail call i32 @err_exit(i32 4)
br label %153
153: ; preds = %151, %136
%154 = load i32, i32* @SOL_SOCKET
%155 = load i32, i32* @SO_REUSEADDR
%156 = call i32 @setsockopt(i32 %149, i32 %154, i32 %155, i8* %14, i32 4)
%157 = icmp eq i32 %156, -1
br i1 %157, label %158, label %160
158: ; preds = %153
%159 = call i32 @err_exit(i32 5)
br label %160
160: ; preds = %158, %153
%161 = call i32 @memset(i8* %13, i32 0, i32 12)
%162 = load i32, i32* @AF_INET
%163 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i32 %162, i32* %163
%164 = call i32 @htons(i32 %26)
%165 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1
store i32 %164, i32* %165
%166 = call i32 @inet_addr(i8* %12)
%167 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0, i32 0
store i32 %166, i32* %167
%168 = load i32, i32* @INADDR_NONE
%169 = icmp eq i32 %166, %168
br i1 %169, label %170, label %172
170: ; preds = %160
%171 = call i32 @err_exit(i32 6)
br label %172
172: ; preds = %170, %160
%173 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
br label %174
174: ; preds = %172, %178
%175 = phi i32 [ 0, %172 ], [ %179, %178 ]
%176 = call i64 @connect(i32 %149, %struct.sockaddr* %173, i32 12)
%177 = icmp eq i64 %176, 0
br i1 %177, label %185, label %178
178: ; preds = %174
%179 = add nuw nsw i32 %175, 1
%180 = call i32 @sleep(i32 1)
%181 = icmp ugt i32 %175, 28
%182 = or i1 %177, %181
br i1 %182, label %183, label %174
183: ; preds = %178
%184 = call i32 @err_exit(i32 7)
br label %185
185: ; preds = %174, %183
%186 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([95 x i8], [95 x i8]* @str, i64 0, i64 0))
%187 = call i32 (...) @getchar()
%188 = icmp eq i32 %187, 10
br i1 %188, label %199, label %189
189: ; preds = %185, %189
%190 = phi i64 [ %193, %189 ], [ 2, %185 ]
%191 = phi i32 [ %195, %189 ], [ %187, %185 ]
%192 = trunc i32 %191 to i8
%193 = add nuw i64 %190, 1
%194 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %190
store i8 %192, i8* %194
%195 = call i32 (...) @getchar()
%196 = icmp eq i32 %195, 10
br i1 %196, label %197, label %189
197: ; preds = %189
%198 = trunc i64 %193 to i32
br label %199
199: ; preds = %197, %185
%200 = phi i32 [ 2, %185 ], [ %198, %197 ]
%201 = add nsw i32 %200, -3
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %202
%204 = load i8, i8* %203
%205 = mul i8 %204, 100
%206 = add nsw i32 %200, -2
%207 = sext i32 %206 to i64
%208 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %207
%209 = load i8, i8* %208
%210 = mul i8 %209, 10
%211 = add nsw i32 %200, -1
%212 = sext i32 %211 to i64
%213 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %212
%214 = load i8, i8* %213
%215 = add i8 %205, 48
%216 = add i8 %215, %210
%217 = add i8 %216, %214
store i8 0, i8* %203
store i8 %217, i8* %208
%218 = trunc i32 %201 to i8
store i8 0, i8* %15
%219 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 1
store i8 %218, i8* %219
%220 = call i32 @write(i32 %149, i8* %15, i32 %211)
%221 = call i32 @read(i32 %149, i8* %16, i32 2)
%222 = load i8, i8* %16
%223 = zext i8 %222 to i32
%224 = shl nuw nsw i32 %223, 8
%225 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 1
%226 = load i8, i8* %225
%227 = zext i8 %226 to i32
%228 = or i32 %224, %227
%229 = call i32 @read(i32 %149, i8* %16, i32 %228)
%230 = call i32 @close(i32 %149)
%231 = add nuw nsw i32 %228, 1
%232 = zext i32 %231 to i64
%233 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 %232
store i8 0, i8* %233
%234 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %16)
ret i32 0
}