// File: /workspace/github_cpp_makefile_star2_O3/yuryu[P]tfoecho/client.cpp
// Function: send_recv(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, std::atomic<int>&)
void send_recv(const std::string &server_addr, const int msg_size, std::atomic_int &count)
{
    std::vector<char> msg_buf(msg_size), recv_buf(msg_size);
    
    std::mt19937 rand_engine;
    std::uniform_int_distribution<char> distribution(
        std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
    auto generator = std::bind(distribution, rand_engine);
    while( count-- > 0 )
    {
        std::generate(msg_buf.begin(), msg_buf.end(), generator);
        FD sock(getsock(server_addr, msg_buf));
        shutdown(sock, SHUT_WR);
        ssize_t read_bytes = 0;
        while( read_bytes != msg_size )
        {
            ssize_t r;
            do
            {
                r = recv(sock, &recv_buf[read_bytes], recv_buf.size() - read_bytes, 0);
            } while( r == -1 && errno == EINTR );
            if( r == 0 ) break;
            if( r == -1 )
            {
                cerror("recv");
                std::exit(EXIT_FAILURE);
            }
            read_bytes += r;
        }
        if( msg_buf != recv_buf )
            std::cerr << "Receive mismatch." << std::endl;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3af8, %rsp           # imm = 0x3AF8
movq %rdx, 0x20(%rsp)
movl %esi, %ebp
movq %rdi, 0x48(%rsp)
movslq %esi, %rbx
leaq 0x8(%rsp), %rdi
leaq 0x52(%rsp), %rdx
movq %rbx, %rsi
callq 0x2a4e
leaq 0x28(%rsp), %rdi
leaq 0x52(%rsp), %rdx
movq %rbx, 0x40(%rsp)
movq %rbx, %rsi
callq 0x2a4e
movq $0x1571, 0x2770(%rsp) # imm = 0x1571
movl $0x1, %eax
movl $0x1571, %ecx           # imm = 0x1571
movq %rcx, %rdx
shrq $0x1e, %rdx
xorl %ecx, %edx
imull $0x6c078965, %edx, %ecx # imm = 0x6C078965
addl %eax, %ecx
movq %rcx, 0x2770(%rsp,%rax,8)
incq %rax
cmpq $0x270, %rax            # imm = 0x270
jne 0x2663
leaq 0x2770(%rsp), %rsi
movq $0x270, 0x1380(%rsi) # imm = 0x270
leaq 0x58(%rsp), %rdi
movl $0x1388, %edx           # imm = 0x1388
callq 0x2150
movq 0x20(%rsp), %rax
lock
decl (%rax)
jl 0x2805
leaq 0x13e8(%rsp), %r13
movq 0x392a(%rip), %r12      # 0x5ff0
leaq 0x13e0(%rsp), %r15
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %rbx
movw $0x7f80, 0x13e0(%rsp)   # imm = 0x7F80
movl $0x138e, %edx           # imm = 0x138E
leaq 0x13e2(%rsp), %rdi
leaq 0x52(%rsp), %rsi
callq 0x2150
cmpq %rbx, %r14
je 0x2714
movq %r15, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2d68
movb %al, (%r14)
incq %r14
jmp 0x26f9
movq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x23dc
movl %eax, 0x4(%rsp)
movl %eax, %edi
movl $0x1, %esi
callq 0x2220
testl %ebp, %ebp
je 0x2779
xorl %r14d, %r14d
movl 0x4(%rsp), %edi
movq 0x28(%rsp), %rsi
addq %r14, %rsi
movq 0x30(%rsp), %rdx
subq %rsi, %rdx
xorl %ecx, %ecx
callq 0x2080
cmpq $-0x1, %rax
jne 0x276a
callq 0x2040
cmpl $0x4, (%rax)
je 0x273a
jmp 0x2845
testq %rax, %rax
je 0x2779
addq %rax, %r14
cmpq 0x40(%rsp), %r14
jne 0x273a
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rax
movq %rax, %rdx
subq %rdi, %rdx
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rcx
subq %rsi, %rcx
cmpq %rcx, %rdx
jne 0x27a9
cmpq %rdi, %rax
je 0x27e5
callq 0x21d0
testl %eax, %eax
je 0x27e5
movl $0x11, %edx
movq %r12, %rdi
leaq 0x18b6(%rip), %rsi      # 0x406e
callq 0x21e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x4(%rsp), %rdi
callq 0x2aae
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x20(%rsp), %rcx
lock
xaddl %eax, (%rcx)
testl %eax, %eax
jg 0x26ce
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x281c
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x2833
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
addq $0x3af8, %rsp           # imm = 0x3AF8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x181d(%rip), %rdi      # 0x4069
callq 0x2531
movl $0x1, %edi
callq 0x21f0
movq %rax, %rbx
jmp 0x288f
jmp 0x2875
jmp 0x2866
jmp 0x2866
movq %rax, %rbx
leaq 0x4(%rsp), %rdi
callq 0x2aae
jmp 0x2878
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x288f
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x28a6
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x2270