#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*/ servaddr;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int bytesToInt(unsigned char *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int listen(int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int recv(int, unsigned char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int sockfd, connfd;
  FILE *fp;
  if (argc != 2) {
    printf("Wrong parameter!\n");
    return -1;
  }
  char *path = argv[1];
  char *filename = argv[1];
  long count = 0;
  int len;
  struct sockaddr_in servaddr;
  sockfd = socket(PF_INET, SOCK_STREAM, 0);
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
  servaddr.sin_port = htons(8000);
  bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
  if (listen(sockfd, 10) == -1) {
    printf("listen socket error\n");
    exit(0);
  }
  int n;
  unsigned char *recvbuf = NULL;
  unsigned char *block = NULL;
  unsigned char *next_temp_block = NULL;
  recvbuf = (unsigned char *)malloc(4096 * 10 * sizeof(char));
  block = (unsigned char *)malloc(4096 * 10 * sizeof(char));
  next_temp_block = (unsigned char *)malloc(4096 * 10 * sizeof(char));
  memset(recvbuf, 0, 4096 * 10);
  memset(block, 0, 4096 * 10);
  memset(next_temp_block, 0, 4096 * 10);
  if ((connfd = accept(sockfd, (struct sockaddr *)NULL, NULL)) == -1) {
    printf("accept socket error\n");
    exit(0);
  } else {
    printf("accept!\n");
  }
  int offset_next_block = 0;
  int offset_block = 0;
  int offset_recv = 0;
  int recv_remain = 0;
  int block_remain = 0;
  int block_done_flag = 1;
  int blocklen;
  while (1) {
    if (offset_recv >= 4096 * 10) {
      printf("offset_recv >= Size!!\n");
      goto out;
    }
    len = recv(connfd, recvbuf + recv_remain, 4096 * 10 - recv_remain, 0);
    if (len <= 0)
      goto out;
    if (block_remain == 0) {
      blocklen = bytesToInt(recvbuf, 4);
      offset_recv += 4;
      block_remain = blocklen;
    }
    while (offset_block < blocklen && offset_recv < (recv_remain + len)) {
      block[offset_block++] = recvbuf[offset_recv++];
      block_remain--;
    }
    assert(block_remain >= 0);
    if (block_remain == 0) {
      block_done_flag = 1;
      offset_block = 0;
      fp = fopen(filename, "ab");
      fwrite(block, sizeof(unsigned char), blocklen, fp);
      fclose(fp);
      count++;
      recv_remain = recv_remain + len - offset_recv;
      if (recv_remain > 0) {
        memcpy(next_temp_block, recvbuf + offset_recv, recv_remain);
        offset_next_block = recv_remain;
        memcpy(recvbuf, next_temp_block, recv_remain);
        offset_recv = 0;
      } else {
        assert(recv_remain == 0);
        offset_next_block = 0;
        offset_recv = 0;
      }
    } else {
      assert(offset_recv == recv_remain + len);
      offset_recv = 0;
      recv_remain = 0;
      continue;
    }
  }
out:
  close(sockfd);
  printf("CLOSE!!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     126b <main+0x3b>
lea    0xda6(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1608 <main+0x3d8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
mov    0x2d35(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x48(%rbp),%rdi
mov    $0xc,%esi
call   1110 <bzero@plt>
mov    0x2d2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x44(%rbp)
mov    $0x1f40,%edi
call   1050 <htons@plt>
mov    %eax,-0x48(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0xc,%edx
call   10f0 <bind@plt>
mov    -0x14(%rbp),%edi
mov    $0xa,%esi
call   10e0 <listen@plt>
cmp    $0xffffffff,%eax
jne    1319 <main+0xe9>
lea    0xd05(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   1130 <exit@plt>
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
mov    $0xa000,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    $0xa000,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    $0xa000,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0xa000,%edx
call   1090 <memset@plt>
mov    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0xa000,%edx
call   1090 <memset@plt>
mov    -0x68(%rbp),%rdi
xor    %esi,%esi
mov    $0xa000,%edx
call   1090 <memset@plt>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1120 <accept@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    13b9 <main+0x189>
lea    0xc7a(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   1130 <exit@plt>
lea    0xc7c(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x6c(%rbp)
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
movl   $0x1,-0x80(%rbp)
cmpl   $0xa000,-0x74(%rbp)
jl     140d <main+0x1dd>
lea    0xc42(%rip),%rdi
call   1060 <printf@plt>
jmp    15f4 <main+0x3c4>
mov    -0x18(%rbp),%edi
mov    -0x58(%rbp),%rsi
movslq -0x78(%rbp),%rax
add    %rax,%rsi
mov    $0xa000,%edx
sub    -0x78(%rbp),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jg     143c <main+0x20c>
jmp    15f4 <main+0x3c4>
cmpl   $0x0,-0x7c(%rbp)
jne    146c <main+0x23c>
mov    -0x58(%rbp),%rdi
mov    $0x4,%esi
call   1070 <bytesToInt@plt>
mov    %eax,-0x84(%rbp)
mov    -0x74(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x74(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x7c(%rbp)
jmp    1471 <main+0x241>
mov    -0x70(%rbp),%ecx
xor    %eax,%eax
cmp    -0x84(%rbp),%ecx
mov    %al,-0x85(%rbp)
jge    149c <main+0x26c>
mov    -0x74(%rbp),%eax
mov    -0x78(%rbp),%ecx
add    -0x3c(%rbp),%ecx
cmp    %ecx,%eax
setl   %al
mov    %al,-0x85(%rbp)
mov    -0x85(%rbp),%al
test   $0x1,%al
jne    14af <main+0x27f>
jmp    14e7 <main+0x2b7>
mov    -0x58(%rbp),%rax
mov    -0x74(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x74(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x60(%rbp),%rax
mov    -0x70(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x70(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x7c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7c(%rbp)
jmp    1471 <main+0x241>
cmpl   $0x0,-0x7c(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   10b0 <assert@plt>
cmpl   $0x0,-0x7c(%rbp)
jne    15c4 <main+0x394>
movl   $0x1,-0x80(%rbp)
movl   $0x0,-0x70(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xb41(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x84(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1140 <fwrite@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x78(%rbp),%eax
add    -0x3c(%rbp),%eax
sub    -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
cmpl   $0x0,-0x78(%rbp)
jle    15a0 <main+0x370>
mov    -0x68(%rbp),%rdi
mov    -0x58(%rbp),%rsi
movslq -0x74(%rbp),%rax
add    %rax,%rsi
mov    -0x78(%rbp),%edx
call   10c0 <memcpy@plt>
mov    -0x78(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x78(%rbp),%edx
call   10c0 <memcpy@plt>
movl   $0x0,-0x74(%rbp)
jmp    15bf <main+0x38f>
cmpl   $0x0,-0x78(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10b0 <assert@plt>
movl   $0x0,-0x6c(%rbp)
movl   $0x0,-0x74(%rbp)
jmp    15ef <main+0x3bf>
mov    -0x74(%rbp),%eax
mov    -0x78(%rbp),%ecx
add    -0x3c(%rbp),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10b0 <assert@plt>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
jmp    13ef <main+0x1bf>
jmp    13ef <main+0x1bf>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
lea    0xa5c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
cmp    $0x2,%edi
jne    168f <main+0x45f>
mov    0x8(%rsi),%rax
mov    %rax,0x50(%rsp)
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
mov    0x2d70(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,%r15d
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   1110 <bzero@plt>
mov    0x2d63(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x24(%rsp)
mov    $0x1f40,%edi
call   1060 <htons@plt>
mov    %eax,0x20(%rsp)
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10f0 <bind@plt>
mov    %r15d,%edi
mov    $0xa,%esi
call   10e0 <listen@plt>
cmp    $0xffffffff,%eax
je     16c8 <main+0x498>
mov    $0xa000,%edi
call   10d0 <malloc@plt>
mov    %rax,%r14
mov    $0xa000,%edi
call   10d0 <malloc@plt>
mov    %rax,%rbx
mov    $0xa000,%edi
call   10d0 <malloc@plt>
mov    %rax,%rbp
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xa000,%edx
call   1090 <memset@plt>
mov    %rbx,(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa000,%edx
call   1090 <memset@plt>
mov    %rbp,0x48(%rsp)
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xa000,%edx
call   1090 <memset@plt>
mov    %r15d,0x18(%rsp)
mov    %r15d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1120 <accept@plt>
cmp    $0xffffffff,%eax
je     16d1 <main+0x4a1>
mov    %eax,%ebp
lea    0xcc2(%rip),%rdi
call   1040 <puts@plt>
xor    %r12d,%r12d
mov    %ebp,%edi
mov    %r14,0x10(%rsp)
mov    %r14,%rsi
mov    $0xa000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    16a2 <main+0x472>
mov    %eax,%r13d
mov    (%rsp),%rcx
lea    0x1(%rcx),%rax
mov    %rax,0x38(%rsp)
mov    0x10(%rsp),%rax
add    $0x1,%rax
mov    %rax,0x40(%rsp)
lea    0xc(%rcx),%rax
mov    %rax,0x30(%rsp)
movdqa 0xc5a(%rip),%xmm2
xor    %r14d,%r14d
xor    %ebx,%ebx
mov    %ebp,0xc(%rsp)
jmp    13f7 <main+0x1c7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
cmp    %r15d,%r14d
sete   %dil
call   10b0 <assert@plt>
xor    %r14d,%r14d
mov    0xc(%rsp),%edi
mov    %r13,%rsi
mov    $0xa000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%r13d
test   %eax,%eax
movdqa 0xc0f(%rip),%xmm2
jle    16a2 <main+0x472>
xor    %r15d,%r15d
test   %r12d,%r12d
mov    0x1c(%rsp),%ebp
jne    1425 <main+0x1f5>
mov    $0x4,%r15d
mov    0x10(%rsp),%rdi
mov    $0x4,%esi
call   1070 <bytesToInt@plt>
movdqa 0xbe0(%rip),%xmm2
mov    %eax,%r12d
mov    %eax,%ebp
add    %r13d,%r14d
cmp    %ebp,%ebx
jge    1480 <main+0x250>
cmp    %r15d,%r14d
mov    0x10(%rsp),%r13
jle    15d2 <main+0x3a2>
mov    %r15d,%eax
movslq %ebx,%rbx
movslq %ebp,%rcx
mov    %rbx,%rdx
not    %rdx
add    %rcx,%rdx
not    %r15d
add    %r14d,%r15d
cmp    %rdx,%r15
mov    %rdx,%r10
cmovb  %r15,%r10
add    $0x1,%r10
test   %rdx,%rdx
mov    $0x1,%esi
cmove  %rsi,%r10
cmp    $0x8,%r10
jae    1490 <main+0x260>
mov    (%rsp),%rsi
jmp    15b0 <main+0x380>
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%r13
jmp    15d2 <main+0x3a2>
nopw   0x0(%rax,%rax,1)
cmp    %rdx,%r15
cmovae %rdx,%r15
test   %rdx,%rdx
cmove  %rdx,%r15
mov    (%rsp),%rdx
add    %rbx,%rdx
lea    (%r15,%rax,1),%rsi
add    0x40(%rsp),%rsi
cmp    %rsi,%rdx
jae    14cd <main+0x29d>
add    %rbx,%r15
add    0x38(%rsp),%r15
lea    (%rax,%r13,1),%rdx
cmp    %r15,%rdx
jae    14cd <main+0x29d>
mov    (%rsp),%rsi
jmp    15b0 <main+0x380>
mov    %ebp,%r11d
mov    %r10,%r8
movabs $0x1fffffff8,%rdx
and    %rdx,%r8
movd   %r12d,%xmm0
lea    -0x8(%r8),%rdx
mov    %rdx,%r9
shr    $0x3,%r9
add    $0x1,%r9
test   %rdx,%rdx
je     167a <main+0x44a>
mov    %r9,%rdi
and    $0xfffffffffffffffe,%rdi
mov    0x30(%rsp),%rdx
add    %rbx,%rdx
pxor   %xmm1,%xmm1
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rsi
or     %rax,%rsi
mov    0x0(%r13,%rsi,1),%rsi
mov    %rsi,-0xc(%rdx,%rbp,1)
lea    0x8(%rbp),%rsi
or     %rax,%rsi
mov    0x0(%r13,%rsi,1),%rsi
mov    %rsi,-0x4(%rdx,%rbp,1)
paddd  %xmm2,%xmm0
paddd  %xmm2,%xmm1
add    $0x10,%rbp
add    $0xfffffffffffffffe,%rdi
jne    1520 <main+0x2f0>
test   $0x1,%r9b
je     1579 <main+0x349>
lea    (%rbx,%rbp,1),%rdx
or     %rax,%rbp
mov    0x0(%r13,%rbp,1),%rsi
mov    (%rsp),%rdi
mov    %rsi,(%rdi,%rdx,1)
pcmpeqd %xmm2,%xmm2
paddd  %xmm2,%xmm0
paddd  %xmm2,%xmm1
paddd  %xmm1,%xmm0
add    %r8,%rbx
or     %r8,%rax
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%r12d
cmp    %r8,%r10
mov    (%rsp),%rsi
mov    %r11d,%ebp
je     15cf <main+0x39f>
cs nopw 0x0(%rax,%rax,1)
movzbl 0x0(%r13,%rax,1),%edx
add    $0x1,%rax
mov    %dl,(%rsi,%rbx,1)
add    $0x1,%rbx
add    $0xffffffff,%r12d
cmp    %rcx,%rbx
jge    15cf <main+0x39f>
cmp    %eax,%r14d
jg     15b0 <main+0x380>
mov    %eax,%r15d
mov    %r12d,%edi
not    %edi
shr    $0x1f,%edi
call   10b0 <assert@plt>
test   %r12d,%r12d
mov    %ebp,0x1c(%rsp)
jne    13c0 <main+0x190>
mov    0x50(%rsp),%rdi
lea    0xa18(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,%rbx
mov    (%rsp),%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %rax,%rcx
call   1140 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
sub    %r15d,%r14d
jle    1646 <main+0x416>
mov    %r15d,%esi
add    %r13,%rsi
mov    0x48(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14d,%edx
call   10c0 <memcpy@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   10c0 <memcpy@plt>
jmp    1651 <main+0x421>
sete   %al
movzbl %al,%edi
call   10b0 <assert@plt>
movslq %r14d,%rsi
add    %r13,%rsi
mov    $0xa000,%edx
sub    %r14d,%edx
xor    %r12d,%r12d
mov    0xc(%rsp),%edi
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%r13d
mov    $0x0,%ebx
jmp    13e7 <main+0x1b7>
pxor   %xmm1,%xmm1
xor    %ebp,%ebp
test   $0x1,%r9b
jne    1559 <main+0x329>
jmp    1579 <main+0x349>
lea    0x9b5(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
jmp    16b9 <main+0x489>
mov    0x18(%rsp),%edi
call   10a0 <close@plt>
lea    0x969(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x968(%rip),%rdi
jmp    16d8 <main+0x4a8>
lea    0x94b(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [18 x i8] c"Wrong parameter!\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.1 = [21 x i8] c"listen socket error\0A\00"
@.str.2 = [21 x i8] c"accept socket error\0A\00"
@.str.3 = [9 x i8] c"accept!\0A\00"
@.str.4 = [23 x i8] c"offset_recv >= Size!!\0A\00"
@.str.5 = [3 x i8] c"ab\00"
@.str.6 = [9 x i8] c"CLOSE!!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca %struct.sockaddr_in
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 2
br i1 %26, label %27, label %29
27: ; preds = %2
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %189
29: ; preds = %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
store i8* %32, i8** %9
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
store i8* %35, i8** %10
store i64 0, i64* %11
%36 = load i32, i32* @PF_INET
%37 = load i32, i32* @SOCK_STREAM
%38 = call i32 @socket(i32 %36, i32 %37, i32 0)
store i32 %38, i32* %6
%39 = call i32 @bzero(%struct.sockaddr_in* %13, i32 12)
%40 = load i32, i32* @AF_INET
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 2
store i32 %40, i32* %41
%42 = load i32, i32* @INADDR_ANY
%43 = call i32 @htonl(i32 %42)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
%45 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %44, i32 0, i32 0
store i32 %43, i32* %45
%46 = call i32 @htons(i32 8000)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
store i32 %46, i32* %47
%48 = load i32, i32* %6
%49 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%50 = call i32 @bind(i32 %48, %struct.sockaddr* %49, i32 12)
%51 = load i32, i32* %6
%52 = call i32 @listen(i32 %51, i32 10)
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %57
54: ; preds = %29
%55 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%56 = call i32 @exit(i32 0)
unreachable
57: ; preds = %29
store i8* null, i8** %15
store i8* null, i8** %16
store i8* null, i8** %17
%58 = call i64 @malloc(i32 40960)
%59 = inttoptr i64 %58 to i8*
store i8* %59, i8** %15
%60 = call i64 @malloc(i32 40960)
%61 = inttoptr i64 %60 to i8*
store i8* %61, i8** %16
%62 = call i64 @malloc(i32 40960)
%63 = inttoptr i64 %62 to i8*
store i8* %63, i8** %17
%64 = load i8*, i8** %15
%65 = call i32 @memset(i8* %64, i32 0, i32 40960)
%66 = load i8*, i8** %16
%67 = call i32 @memset(i8* %66, i32 0, i32 40960)
%68 = load i8*, i8** %17
%69 = call i32 @memset(i8* %68, i32 0, i32 40960)
%70 = load i32, i32* %6
%71 = call i32 @accept(i32 %70, %struct.sockaddr* null, i32* null)
store i32 %71, i32* %7
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %76
73: ; preds = %57
%74 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%75 = call i32 @exit(i32 0)
unreachable
76: ; preds = %57
%77 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %78
78: ; preds = %76
store i32 0, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store i32 0, i32* %22
store i32 1, i32* %23
br label %79
79: ; preds = %78, %176, %184
%80 = load i32, i32* %20
%81 = icmp sge i32 %80, 40960
br i1 %81, label %82, label %84
82: ; preds = %79
%83 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %185
84: ; preds = %79
%85 = load i32, i32* %7
%86 = load i8*, i8** %15
%87 = load i32, i32* %21
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %86, i64 %88
%90 = load i32, i32* %21
%91 = sub nsw i32 40960, %90
%92 = call i32 @recv(i32 %85, i8* %89, i32 %91, i32 0)
store i32 %92, i32* %12
%93 = load i32, i32* %12
%94 = icmp sle i32 %93, 0
br i1 %94, label %95, label %96
95: ; preds = %84
br label %185
96: ; preds = %84
%97 = load i32, i32* %22
%98 = icmp eq i32 %97, 0
br i1 %98, label %99, label %105
99: ; preds = %96
%100 = load i8*, i8** %15
%101 = call i32 @bytesToInt(i8* %100, i32 4)
store i32 %101, i32* %24
%102 = load i32, i32* %20
%103 = add nsw i32 %102, 4
store i32 %103, i32* %20
%104 = load i32, i32* %24
store i32 %104, i32* %22
br label %105
105: ; preds = %99, %96
br label %106
106: ; preds = %118, %105
%107 = load i32, i32* %19
%108 = load i32, i32* %24
%109 = icmp slt i32 %107, %108
br i1 %109, label %110, label %116
110: ; preds = %106
%111 = load i32, i32* %20
%112 = load i32, i32* %21
%113 = load i32, i32* %12
%114 = add nsw i32 %112, %113
%115 = icmp slt i32 %111, %114
br label %116
116: ; preds = %110, %106
%117 = phi i1 [ false, %106 ], [ %115, %110 ]
br i1 %117, label %118, label %132
118: ; preds = %116
%119 = load i8*, i8** %15
%120 = load i32, i32* %20
%121 = add nsw i32 %120, 1
store i32 %121, i32* %20
%122 = sext i32 %120 to i64
%123 = getelementptr inbounds i8, i8* %119, i64 %122
%124 = load i8, i8* %123
%125 = load i8*, i8** %16
%126 = load i32, i32* %19
%127 = add nsw i32 %126, 1
store i32 %127, i32* %19
%128 = sext i32 %126 to i64
%129 = getelementptr inbounds i8, i8* %125, i64 %128
store i8 %124, i8* %129
%130 = load i32, i32* %22
%131 = add nsw i32 %130, -1
store i32 %131, i32* %22
br label %106
132: ; preds = %116
%133 = load i32, i32* %22
%134 = icmp sge i32 %133, 0
%135 = zext i1 %134 to i32
%136 = call i32 @assert(i32 %135)
%137 = load i32, i32* %22
%138 = icmp eq i32 %137, 0
br i1 %138, label %139, label %176
139: ; preds = %132
store i32 1, i32* %23
store i32 0, i32* %19
%140 = load i8*, i8** %10
%141 = call i32* @fopen(i8* %140, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %141, i32** %8
%142 = load i8*, i8** %16
%143 = load i32, i32* %24
%144 = load i32*, i32** %8
%145 = call i32 @fwrite(i8* %142, i32 1, i32 %143, i32* %144)
%146 = load i32*, i32** %8
%147 = call i32 @fclose(i32* %146)
%148 = load i64, i64* %11
%149 = add nsw i64 %148, 1
store i64 %149, i64* %11
%150 = load i32, i32* %21
%151 = load i32, i32* %12
%152 = add nsw i32 %150, %151
%153 = load i32, i32* %20
%154 = sub nsw i32 %152, %153
store i32 %154, i32* %21
%155 = load i32, i32* %21
%156 = icmp sgt i32 %155, 0
br i1 %156, label %157, label %170
157: ; preds = %139
%158 = load i8*, i8** %17
%159 = load i8*, i8** %15
%160 = load i32, i32* %20
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds i8, i8* %159, i64 %161
%163 = load i32, i32* %21
%164 = call i32 @memcpy(i8* %158, i8* %162, i32 %163)
%165 = load i32, i32* %21
store i32 %165, i32* %18
%166 = load i8*, i8** %15
%167 = load i8*, i8** %17
%168 = load i32, i32* %21
%169 = call i32 @memcpy(i8* %166, i8* %167, i32 %168)
store i32 0, i32* %20
br label %175
170: ; preds = %139
%171 = load i32, i32* %21
%172 = icmp eq i32 %171, 0
%173 = zext i1 %172 to i32
%174 = call i32 @assert(i32 %173)
store i32 0, i32* %18
store i32 0, i32* %20
br label %175
175: ; preds = %170, %157
br label %184
176: ; preds = %132
%177 = load i32, i32* %20
%178 = load i32, i32* %21
%179 = load i32, i32* %12
%180 = add nsw i32 %178, %179
%181 = icmp eq i32 %177, %180
%182 = zext i1 %181 to i32
%183 = call i32 @assert(i32 %182)
store i32 0, i32* %20
store i32 0, i32* %21
br label %79
184: ; preds = %175
br label %79
185: ; preds = %95, %82
%186 = load i32, i32* %6
%187 = call i32 @close(i32 %186)
%188 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %189
189: ; preds = %185, %27
%190 = load i32, i32* %3
ret i32 %190
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.5 = [3 x i8] c"ab\00"
@str = [8 x i8] c"accept!\00"
@str.7 = [8 x i8] c"CLOSE!!\00"
@str.8 = [20 x i8] c"accept socket error\00"
@str.9 = [20 x i8] c"listen socket error\00"
@str.10 = [17 x i8] c"Wrong parameter!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = icmp eq i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0))
br label %244
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = bitcast %struct.sockaddr_in* %3 to i8*
%11 = load i32, i32* @PF_INET
%12 = load i32, i32* @SOCK_STREAM
%13 = tail call i32 @socket(i32 %11, i32 %12, i32 0)
%14 = call i32 @bzero(%struct.sockaddr_in* %3, i32 12)
%15 = load i32, i32* @AF_INET
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %15, i32* %16
%17 = load i32, i32* @INADDR_ANY
%18 = tail call i32 @htonl(i32 %17)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %18, i32* %19
%20 = tail call i32 @htons(i32 8000)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %20, i32* %21
%22 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%23 = call i32 @bind(i32 %13, %struct.sockaddr* %22, i32 12)
%24 = call i32 @listen(i32 %13, i32 10)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %7
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.9, i64 0, i64 0))
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %7
%30 = call i64 @malloc(i32 40960)
%31 = inttoptr i64 %30 to i8*
%32 = call i64 @malloc(i32 40960)
%33 = inttoptr i64 %32 to i8*
%34 = call i64 @malloc(i32 40960)
%35 = inttoptr i64 %34 to i8*
%36 = call i32 @memset(i8* %31, i32 0, i32 40960)
%37 = call i32 @memset(i8* %33, i32 0, i32 40960)
%38 = call i32 @memset(i8* %35, i32 0, i32 40960)
%39 = call i32 @accept(i32 %13, %struct.sockaddr* null, i32* null)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %29
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.8, i64 0, i64 0))
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %29
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%46 = call i32 @recv(i32 %39, i8* %31, i32 40960, i32 0)
%47 = icmp slt i32 %46, 1
br i1 %47, label %241, label %48
48: ; preds = %44
%49 = getelementptr i8, i8* %33, i64 1
%50 = getelementptr i8, i8* %31, i64 1
br label %51
51: ; preds = %230, %48
%52 = phi i32 [ %46, %48 ], [ %231, %230 ]
%53 = phi i32 [ undef, %48 ], [ %63, %230 ]
%54 = phi i32 [ 0, %48 ], [ %232, %230 ]
%55 = phi i32 [ 0, %48 ], [ %233, %230 ]
%56 = phi i32 [ 0, %48 ], [ %234, %230 ]
%57 = icmp eq i32 %54, 0
br i1 %57, label %58, label %60
58: ; preds = %51
%59 = call i32 @bytesToInt(i8* %31, i32 4)
br label %60
60: ; preds = %58, %51
%61 = phi i32 [ 4, %58 ], [ 0, %51 ]
%62 = phi i32 [ %59, %58 ], [ %54, %51 ]
%63 = phi i32 [ %59, %58 ], [ %53, %51 ]
%64 = add nsw i32 %52, %55
%65 = icmp slt i32 %56, %63
%66 = icmp sgt i32 %64, %61
%67 = select i1 %65, i1 %66, i1 false
br i1 %67, label %68, label %201
68: ; preds = %60
%69 = zext i32 %61 to i64
%70 = sext i32 %56 to i64
%71 = sext i32 %63 to i64
%72 = xor i64 %70, -1
%73 = add nsw i64 %72, %71
%74 = add i32 %52, -1
%75 = add i32 %74, %55
%76 = sub i32 %75, %61
%77 = zext i32 %76 to i64
%78 = icmp eq i64 %73, 0
%79 = call i64 @llvm.umin.i64(i64 %77, i64 %73)
%80 = add nuw nsw i64 %79, 1
%81 = select i1 %78, i64 1, i64 %80
%82 = icmp ult i64 %81, 8
br i1 %82, label %177, label %83
83: ; preds = %68
%84 = getelementptr i8, i8* %33, i64 %70
%85 = xor i64 %70, -1
%86 = add nsw i64 %85, %71
%87 = add i32 %52, -1
%88 = add i32 %87, %55
%89 = sub i32 %88, %61
%90 = zext i32 %89 to i64
%91 = icmp eq i64 %86, 0
%92 = call i64 @llvm.umin.i64(i64 %90, i64 %86)
%93 = select i1 %91, i64 0, i64 %92
%94 = add nsw i64 %93, %70
%95 = getelementptr i8, i8* %49, i64 %94
%96 = getelementptr i8, i8* %31, i64 %69
%97 = add nuw nsw i64 %93, %69
%98 = getelementptr i8, i8* %50, i64 %97
%99 = icmp ult i8* %84, %98
%100 = icmp ult i8* %96, %95
%101 = and i1 %99, %100
br i1 %101, label %177, label %102
102: ; preds = %83
%103 = and i64 %81, 8589934584
%104 = add nsw i64 %103, %70
%105 = or i64 %103, %69
%106 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %62, i64 0
%107 = add nsw i64 %103, -8
%108 = lshr exact i64 %107, 3
%109 = add nuw nsw i64 %108, 1
%110 = and i64 %109, 1
%111 = icmp eq i64 %107, 0
br i1 %111, label %149, label %112
112: ; preds = %102
%113 = and i64 %109, 4611686018427387902
br label %114
114: ; preds = %114, %112
%115 = phi i64 [ 0, %112 ], [ %146, %114 ]
%116 = phi <4 x i32> [ %106, %112 ], [ %144, %114 ]
%117 = phi <4 x i32> [ zeroinitializer, %112 ], [ %145, %114 ]
%118 = phi i64 [ 0, %112 ], [ %147, %114 ]
%119 = add i64 %115, %70
%120 = or i64 %115, %69
%121 = getelementptr inbounds i8, i8* %31, i64 %120
%122 = bitcast i8* %121 to <4 x i8>*
%123 = load <4 x i8>, <4 x i8>* %122
%124 = getelementptr inbounds i8, i8* %121, i64 4
%125 = bitcast i8* %124 to <4 x i8>*
%126 = load <4 x i8>, <4 x i8>* %125
%127 = getelementptr inbounds i8, i8* %33, i64 %119
%128 = bitcast i8* %127 to <4 x i8>*
store <4 x i8> %123, <4 x i8>* %128
%129 = getelementptr inbounds i8, i8* %127, i64 4
%130 = bitcast i8* %129 to <4 x i8>*
store <4 x i8> %126, <4 x i8>* %130
%131 = or i64 %115, 8
%132 = add i64 %131, %70
%133 = or i64 %131, %69
%134 = getelementptr inbounds i8, i8* %31, i64 %133
%135 = bitcast i8* %134 to <4 x i8>*
%136 = load <4 x i8>, <4 x i8>* %135
%137 = getelementptr inbounds i8, i8* %134, i64 4
%138 = bitcast i8* %137 to <4 x i8>*
%139 = load <4 x i8>, <4 x i8>* %138
%140 = getelementptr inbounds i8, i8* %33, i64 %132
%141 = bitcast i8* %140 to <4 x i8>*
store <4 x i8> %136, <4 x i8>* %141
%142 = getelementptr inbounds i8, i8* %140, i64 4
%143 = bitcast i8* %142 to <4 x i8>*
store <4 x i8> %139, <4 x i8>* %143
%144 = add <4 x i32> %116, <i32 -2, i32 -2, i32 -2, i32 -2>
%145 = add <4 x i32> %117, <i32 -2, i32 -2, i32 -2, i32 -2>
%146 = add nuw i64 %115, 16
%147 = add i64 %118, 2
%148 = icmp eq i64 %147, %113
br i1 %148, label %149, label %114
149: ; preds = %114, %102
%150 = phi <4 x i32> [ undef, %102 ], [ %144, %114 ]
%151 = phi <4 x i32> [ undef, %102 ], [ %145, %114 ]
%152 = phi i64 [ 0, %102 ], [ %146, %114 ]
%153 = phi <4 x i32> [ %106, %102 ], [ %144, %114 ]
%154 = phi <4 x i32> [ zeroinitializer, %102 ], [ %145, %114 ]
%155 = icmp eq i64 %110, 0
br i1 %155, label %171, label %156
156: ; preds = %149
%157 = add i64 %152, %70
%158 = or i64 %152, %69
%159 = getelementptr inbounds i8, i8* %31, i64 %158
%160 = bitcast i8* %159 to <4 x i8>*
%161 = load <4 x i8>, <4 x i8>* %160
%162 = getelementptr inbounds i8, i8* %159, i64 4
%163 = bitcast i8* %162 to <4 x i8>*
%164 = load <4 x i8>, <4 x i8>* %163
%165 = getelementptr inbounds i8, i8* %33, i64 %157
%166 = bitcast i8* %165 to <4 x i8>*
store <4 x i8> %161, <4 x i8>* %166
%167 = getelementptr inbounds i8, i8* %165, i64 4
%168 = bitcast i8* %167 to <4 x i8>*
store <4 x i8> %164, <4 x i8>* %168
%169 = add <4 x i32> %153, <i32 -1, i32 -1, i32 -1, i32 -1>
%170 = add <4 x i32> %154, <i32 -1, i32 -1, i32 -1, i32 -1>
br label %171
171: ; preds = %149, %156
%172 = phi <4 x i32> [ %150, %149 ], [ %169, %156 ]
%173 = phi <4 x i32> [ %151, %149 ], [ %170, %156 ]
%174 = add <4 x i32> %173, %172
%175 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %174)
%176 = icmp eq i64 %81, %103
br i1 %176, label %195, label %177
177: ; preds = %83, %68, %171
%178 = phi i64 [ %70, %83 ], [ %70, %68 ], [ %104, %171 ]
%179 = phi i64 [ %69, %83 ], [ %69, %68 ], [ %105, %171 ]
%180 = phi i32 [ %62, %83 ], [ %62, %68 ], [ %175, %171 ]
br label %181
181: ; preds = %177, %181
%182 = phi i64 [ %188, %181 ], [ %178, %177 ]
%183 = phi i64 [ %185, %181 ], [ %179, %177 ]
%184 = phi i32 [ %190, %181 ], [ %180, %177 ]
%185 = add nuw nsw i64 %183, 1
%186 = getelementptr inbounds i8, i8* %31, i64 %183
%187 = load i8, i8* %186
%188 = add nsw i64 %182, 1
%189 = getelementptr inbounds i8, i8* %33, i64 %182
store i8 %187, i8* %189
%190 = add nsw i32 %184, -1
%191 = icmp slt i64 %188, %71
%192 = trunc i64 %185 to i32
%193 = icmp sgt i32 %64, %192
%194 = select i1 %191, i1 %193, i1 false
br i1 %194, label %181, label %195
195: ; preds = %181, %171
%196 = phi i64 [ %105, %171 ], [ %185, %181 ]
%197 = phi i64 [ %104, %171 ], [ %188, %181 ]
%198 = phi i32 [ %175, %171 ], [ %190, %181 ]
%199 = trunc i64 %196 to i32
%200 = trunc i64 %197 to i32
br label %201
201: ; preds = %195, %60
%202 = phi i32 [ %56, %60 ], [ %200, %195 ]
%203 = phi i32 [ %61, %60 ], [ %199, %195 ]
%204 = phi i32 [ %62, %60 ], [ %198, %195 ]
%205 = xor i32 %204, -1
%206 = lshr i32 %205, 31
%207 = call i32 @assert(i32 %206)
%208 = icmp eq i32 %204, 0
br i1 %208, label %209, label %224
209: ; preds = %201
%210 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%211 = call i32 @fwrite(i8* %33, i32 1, i32 %63, i32* %210)
%212 = call i32 @fclose(i32* %210)
%213 = sub nsw i32 %64, %203
%214 = icmp sgt i32 %213, 0
br i1 %214, label %215, label %220
215: ; preds = %209
%216 = zext i32 %203 to i64
%217 = getelementptr inbounds i8, i8* %31, i64 %216
%218 = call i32 @memcpy(i8* %35, i8* %217, i32 %213)
%219 = call i32 @memcpy(i8* %31, i8* %35, i32 %213)
br label %235
220: ; preds = %209
%221 = icmp eq i32 %213, 0
%222 = zext i1 %221 to i32
%223 = call i32 @assert(i32 %222)
br label %235
224: ; preds = %201
%225 = icmp eq i32 %64, %203
%226 = zext i1 %225 to i32
%227 = call i32 @assert(i32 %226)
%228 = call i32 @recv(i32 %39, i8* %31, i32 40960, i32 0)
%229 = icmp slt i32 %228, 1
br i1 %229, label %241, label %230
230: ; preds = %224, %235
%231 = phi i32 [ %228, %224 ], [ %239, %235 ]
%232 = phi i32 [ %204, %224 ], [ 0, %235 ]
%233 = phi i32 [ 0, %224 ], [ %213, %235 ]
%234 = phi i32 [ %202, %224 ], [ 0, %235 ]
br label %51
235: ; preds = %215, %220
%236 = sext i32 %213 to i64
%237 = getelementptr inbounds i8, i8* %31, i64 %236
%238 = sub nsw i32 40960, %213
%239 = call i32 @recv(i32 %39, i8* %237, i32 %238, i32 0)
%240 = icmp slt i32 %239, 1
br i1 %240, label %241, label %230
241: ; preds = %235, %224, %44
%242 = call i32 @close(i32 %13)
%243 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.7, i64 0, i64 0))
br label %244
244: ; preds = %241, %5
%245 = phi i32 [ -1, %5 ], [ 0, %241 ]
ret i32 %245
}