#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 /*<<< orphan*/ sprintf(char *, char *, char *, long);
int main(int argc, char **argv) {
  int sockfd, connfd;
  FILE *fp;
  char *path = "/dev/shm/test/";
  char filename[25];
  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");
      exit(0);
    }
    len = recv(connfd, recvbuf + recv_remain, 4096 * 10 - recv_remain, 0);
    printf("rev Len = %d, recv buf at %d\n", len, len + recv_remain);
    if (block_remain == 0) {
      blocklen = bytesToInt(recvbuf, 4);
      offset_recv += 4;
      printf("block Len = %d\n", blocklen);
      block_remain = blocklen;
    }
    while (offset_block < blocklen && offset_recv < (recv_remain + len)) {
      block[offset_block++] = recvbuf[offset_recv++];
      block_remain--;
    }
    printf("offset_block: %d, offset_recv: %d, block_remain: %d\n",
           offset_block, offset_recv, block_remain);
    assert(block_remain >= 0);
    if (block_remain == 0) {
      block_done_flag = 1;
      offset_block = 0;
      sprintf(filename, "%s%ld", path, count);
      printf("%s\n", filename);
      fp = fopen(filename, "w+");
      fwrite(block, sizeof(unsigned char), blocklen, fp);
      fclose(fp);
      count++;
      recv_remain = recv_remain + len - offset_recv;
      printf("recv_reamin : %d\n", recv_remain);
      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;
    }
  }
  close(sockfd);
  printf("CLOSE!!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdb0(%rip),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x58(%rbp)
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x68(%rbp),%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2d47(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x64(%rbp)
mov    $0x1f40,%edi
call   1050 <htons@plt>
mov    %eax,-0x68(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x68(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
mov    -0x14(%rbp),%edi
mov    $0xa,%esi
call   10d0 <listen@plt>
cmp    $0xffffffff,%eax
jne    12ec <main+0xbc>
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   1130 <exit@plt>
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x80(%rbp)
movq   $0x0,-0x88(%rbp)
mov    $0xa000,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    $0xa000,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x80(%rbp)
mov    $0xa000,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x88(%rbp)
mov    -0x78(%rbp),%rdi
xor    %esi,%esi
mov    $0xa000,%edx
call   1090 <memset@plt>
mov    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0xa000,%edx
call   1090 <memset@plt>
mov    -0x88(%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   1110 <accept@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1397 <main+0x167>
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   1130 <exit@plt>
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x8c(%rbp)
movl   $0x0,-0x90(%rbp)
movl   $0x0,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
movl   $0x0,-0x9c(%rbp)
movl   $0x1,-0xa0(%rbp)
cmpl   $0xa000,-0x94(%rbp)
jl     1406 <main+0x1d6>
lea    0xc4a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   1130 <exit@plt>
mov    -0x18(%rbp),%edi
mov    -0x78(%rbp),%rsi
movslq -0x98(%rbp),%rax
add    %rax,%rsi
mov    $0xa000,%edx
sub    -0x98(%rbp),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%esi
mov    -0x5c(%rbp),%edx
add    -0x98(%rbp),%edx
lea    0xc1a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x9c(%rbp)
jne    1496 <main+0x266>
mov    -0x78(%rbp),%rdi
mov    $0x4,%esi
call   1070 <bytesToInt@plt>
mov    %eax,-0xa4(%rbp)
mov    -0x94(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x94(%rbp)
mov    -0xa4(%rbp),%esi
lea    0xbf4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xa4(%rbp),%eax
mov    %eax,-0x9c(%rbp)
jmp    149b <main+0x26b>
mov    -0x90(%rbp),%ecx
xor    %eax,%eax
cmp    -0xa4(%rbp),%ecx
mov    %al,-0xa5(%rbp)
jge    14cf <main+0x29f>
mov    -0x94(%rbp),%eax
mov    -0x98(%rbp),%ecx
add    -0x5c(%rbp),%ecx
cmp    %ecx,%eax
setl   %al
mov    %al,-0xa5(%rbp)
mov    -0xa5(%rbp),%al
test   $0x1,%al
jne    14e2 <main+0x2b2>
jmp    152c <main+0x2fc>
mov    -0x78(%rbp),%rax
mov    -0x94(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x94(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x80(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x90(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x9c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x9c(%rbp)
jmp    149b <main+0x26b>
mov    -0x90(%rbp),%esi
mov    -0x94(%rbp),%edx
mov    -0x9c(%rbp),%ecx
lea    0xb42(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x9c(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
cmpl   $0x0,-0x9c(%rbp)
jne    16a0 <main+0x470>
movl   $0x1,-0xa0(%rbp)
movl   $0x0,-0x90(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x58(%rbp),%rcx
lea    0xb28(%rip),%rsi
call   1120 <sprintf@plt>
lea    -0x50(%rbp),%rsi
lea    0xb1e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    0xb10(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x80(%rbp),%rdi
mov    -0xa4(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1140 <fwrite@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
mov    -0x98(%rbp),%eax
add    -0x5c(%rbp),%eax
sub    -0x94(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%esi
lea    0xabb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x98(%rbp)
jle    1673 <main+0x443>
mov    -0x88(%rbp),%rdi
mov    -0x78(%rbp),%rsi
movslq -0x94(%rbp),%rax
add    %rax,%rsi
mov    -0x98(%rbp),%edx
call   10b0 <memcpy@plt>
mov    -0x98(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x98(%rbp),%edx
call   10b0 <memcpy@plt>
movl   $0x0,-0x94(%rbp)
jmp    169b <main+0x46b>
cmpl   $0x0,-0x98(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
movl   $0x0,-0x8c(%rbp)
movl   $0x0,-0x94(%rbp)
jmp    16d7 <main+0x4a7>
mov    -0x94(%rbp),%eax
mov    -0x98(%rbp),%ecx
add    -0x5c(%rbp),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
movl   $0x0,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
jmp    13e1 <main+0x1b1>
jmp    13e1 <main+0x1b1>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
mov    0x2d72(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,%r15d
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xc,%esi
call   1110 <bzero@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %eax,0xc(%rsp)
mov    $0x1f40,%edi
call   1060 <htons@plt>
mov    %eax,0x8(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   10f0 <bind@plt>
mov    %r15d,%edi
mov    $0xa,%esi
call   10e0 <listen@plt>
cmp    $0xffffffff,%eax
je     1670 <main+0x430>
mov    $0xa000,%edi
call   10d0 <malloc@plt>
mov    %rax,%rbx
mov    $0xa000,%edi
call   10d0 <malloc@plt>
mov    %rax,%r14
mov    $0xa000,%edi
call   10d0 <malloc@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa000,%edx
call   10a0 <memset@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xa000,%edx
call   10a0 <memset@plt>
mov    %rbp,0x18(%rsp)
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xa000,%edx
call   10a0 <memset@plt>
mov    %r15d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1120 <accept@plt>
mov    %eax,0x4(%rsp)
cmp    $0xffffffff,%eax
je     1679 <main+0x439>
lea    0xd55(%rip),%rdi
call   1040 <puts@plt>
lea    0x1(%r14),%rax
mov    %rax,0x30(%rsp)
lea    0x1(%rbx),%rax
mov    %rax,0x38(%rsp)
lea    0xc(%r14),%rax
mov    %rax,0x28(%rsp)
xor    %r12d,%r12d
xor    %r13d,%r13d
jmp    137b <main+0x13b>
sete   %al
movzbl %al,%edi
call   10b0 <assert@plt>
mov    %r12,0x20(%rsp)
xor    %r15d,%r15d
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
movslq %r13d,%r13
lea    (%rbx,%r13,1),%rsi
mov    $0xa000,%edx
sub    %r13d,%edx
mov    0x4(%rsp),%edi
xor    %ecx,%ecx
call   1030 <recv@plt>
add    %eax,%r13d
lea    0xc6b(%rip),%rdi
mov    %eax,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x0,%ebp
test   %r12d,%r12d
jne    13f3 <main+0x1b3>
mov    $0x4,%ebp
mov    %rbx,%rdi
mov    $0x4,%esi
call   1080 <bytesToInt@plt>
mov    %eax,%r12d
lea    0xc57(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12d,(%rsp)
cmp    (%rsp),%r15d
jge    1570 <main+0x330>
cmp    %ebp,%r13d
jle    1570 <main+0x330>
mov    %ebp,%eax
movslq %r15d,%r15
movslq (%rsp),%rcx
mov    %r15,%rsi
not    %rsi
add    %rcx,%rsi
not    %ebp
add    %r13d,%ebp
cmp    %rsi,%rbp
mov    %rsi,%r10
cmovb  %rbp,%r10
add    $0x1,%r10
test   %rsi,%rsi
mov    $0x1,%edx
cmove  %rdx,%r10
cmp    $0x8,%r10
jb     1550 <main+0x310>
cmp    %rsi,%rbp
cmovae %rsi,%rbp
test   %rsi,%rsi
cmove  %rsi,%rbp
lea    (%r14,%r15,1),%rsi
lea    (%rax,%rbp,1),%rdi
add    0x38(%rsp),%rdi
cmp    %rdi,%rsi
movdqa 0xb99(%rip),%xmm2
jae    147e <main+0x23e>
add    %r15,%rbp
add    0x30(%rsp),%rbp
lea    (%rbx,%rax,1),%rsi
cmp    %rbp,%rsi
jb     1550 <main+0x310>
mov    %r10,%r8
movabs $0x1fffffff8,%rdx
and    %rdx,%r8
movd   %r12d,%xmm0
lea    -0x8(%r8),%rsi
mov    %rsi,%r9
shr    $0x3,%r9
add    $0x1,%r9
test   %rsi,%rsi
je     15ae <main+0x36e>
mov    %r9,%rdi
and    $0xfffffffffffffffe,%rdi
mov    0x28(%rsp),%rdx
lea    (%rdx,%r15,1),%rsi
pxor   %xmm1,%xmm1
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rdx,%rbp
or     %rax,%rbp
mov    (%rbx,%rbp,1),%rbp
mov    %rbp,-0xc(%rsi,%rdx,1)
lea    0x8(%rdx),%rbp
or     %rax,%rbp
mov    (%rbx,%rbp,1),%rbp
mov    %rbp,-0x4(%rsi,%rdx,1)
paddd  %xmm2,%xmm0
paddd  %xmm2,%xmm1
add    $0x10,%rdx
add    $0xfffffffffffffffe,%rdi
jne    14d0 <main+0x290>
test   $0x1,%r9b
je     1522 <main+0x2e2>
lea    (%rdx,%r15,1),%rsi
or     %rax,%rdx
mov    (%rbx,%rdx,1),%rdx
mov    %rdx,(%r14,%rsi,1)
pcmpeqd %xmm2,%xmm2
paddd  %xmm2,%xmm0
paddd  %xmm2,%xmm1
paddd  %xmm1,%xmm0
add    %r8,%r15
or     %r8,%rax
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%r12d
cmp    %r8,%r10
je     156e <main+0x32e>
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%rax,1),%edx
add    $0x1,%rax
mov    %dl,(%r14,%r15,1)
add    $0x1,%r15
add    $0xffffffff,%r12d
cmp    %rcx,%r15
jge    156e <main+0x32e>
cmp    %eax,%r13d
jg     1550 <main+0x310>
mov    %eax,%ebp
lea    0xad6(%rip),%rdi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12d,%edi
not    %edi
shr    $0x1f,%edi
call   10b0 <assert@plt>
test   %r12d,%r12d
je     15d0 <main+0x390>
xor    %edi,%edi
cmp    %ebp,%r13d
sete   %dil
call   10b0 <assert@plt>
xor    %r13d,%r13d
jmp    1390 <main+0x150>
pxor   %xmm1,%xmm1
xor    %edx,%edx
test   $0x1,%r9b
jne    1507 <main+0x2c7>
jmp    1522 <main+0x2e2>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x40(%rsp),%r15
mov    %r15,%rdi
lea    0xaa3(%rip),%rsi
lea    0xa2a(%rip),%rdx
mov    0x20(%rsp),%r12
mov    %r12,%rcx
call   1130 <sprintf@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
lea    0xa83(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    $0x1,%esi
mov    (%rsp),%edx
mov    %rax,%rcx
call   1150 <fwrite@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
add    $0x1,%r12
mov    %r13d,%esi
sub    %ebp,%esi
lea    0xa53(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
sub    %ebp,%r13d
jle    1370 <main+0x130>
mov    %ebp,%esi
add    %rbx,%rsi
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13d,%edx
call   10c0 <memcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
call   10c0 <memcpy@plt>
jmp    137b <main+0x13b>
lea    0xa42(%rip),%rdi
jmp    1680 <main+0x440>
lea    0xa25(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1140 <exit@plt>

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

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