// File: /workspace/github_cpp_makefile_star2_O2/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 $0x3ae8, %rsp           # imm = 0x3AE8
movq %rdx, %rbx
movq %rdi, %r14
movslq %esi, %r15
leaq 0x28(%rsp), %rdi
leaq 0x42(%rsp), %rdx
movq %r15, %rsi
callq 0x2808
leaq 0x10(%rsp), %rdi
leaq 0x42(%rsp), %rdx
movq %r15, %rsi
callq 0x2808
leaq 0x2760(%rsp), %rdi
callq 0x285a
leaq 0x48(%rsp), %rdi
leaq 0x2760(%rsp), %rsi
movl $0x1388, %edx           # imm = 0x1388
callq 0x2140
leaq 0x28(%rsp), %r12
lock
decl (%rbx)
jl 0x263a
movq 0x28(%rsp), %rbp
movq 0x30(%rsp), %r13
movw $0x7f80, 0x13d0(%rsp)   # imm = 0x7F80
movl $0x138e, %edx           # imm = 0x138E
leaq 0x13d2(%rsp), %rdi
leaq 0x42(%rsp), %rsi
callq 0x2140
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x13d0(%rsp), %rdx
callq 0x2864
movq %r14, %rdi
movq %r12, %rsi
callq 0x238c
movl %eax, 0xc(%rsp)
movl %eax, %edi
pushq $0x1
popq %rsi
callq 0x21f0
xorl %r13d, %r13d
cmpq %r15, %r13
je 0x25ff
movl 0xc(%rsp), %edi
movq 0x10(%rsp), %rsi
addq %r13, %rsi
movq 0x18(%rsp), %rdx
subq %rsi, %rdx
xorl %ecx, %ecx
callq 0x2070
cmpq $-0x1, %rax
jne 0x25f5
callq 0x2030
cmpl $0x4, (%rax)
je 0x25c8
jmp 0x2660
testq %rax, %rax
je 0x25ff
addq %rax, %r13
jmp 0x25c3
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0x288d
testb %al, %al
je 0x262b
movq 0x39d9(%rip), %rdi      # 0x5ff0
leaq 0x1a14(%rip), %rsi      # 0x4032
callq 0x2180
movq %rax, %rdi
callq 0x20e0
leaq 0xc(%rsp), %rdi
callq 0x2898
jmp 0x2560
leaq 0x10(%rsp), %rdi
callq 0x2b8a
leaq 0x28(%rsp), %rdi
callq 0x2b8a
addq $0x3ae8, %rsp           # imm = 0x3AE8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19c6(%rip), %rdi      # 0x402d
callq 0x24b7
pushq $0x1
popq %rdi
callq 0x21c0
jmp 0x267d
movq %rax, %rbx
jmp 0x269d
jmp 0x267d
movq %rax, %rbx
jmp 0x2693
jmp 0x2686
jmp 0x2686
movq %rax, %rbx
leaq 0xc(%rsp), %rdi
callq 0x2898
leaq 0x10(%rsp), %rdi
callq 0x2b8a
leaq 0x28(%rsp), %rdi
callq 0x2b8a
movq %rbx, %rdi
callq 0x2230