// File: /workspace/github_cpp_makefile_star2_O1/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, 0x28(%rsp)
movq %rdi, 0x48(%rsp)
movslq %esi, %r15
leaq 0x10(%rsp), %rdi
leaq 0x52(%rsp), %rdx
movq %r15, %rsi
callq 0x2a72
leaq 0x30(%rsp), %rdi
leaq 0x52(%rsp), %rdx
movq %r15, %rsi
callq 0x2a72
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 0x2682
leaq 0x2770(%rsp), %rsi
movq $0x270, 0x1380(%rsi) # imm = 0x270
leaq 0x58(%rsp), %rdi
movl $0x1388, %edx           # imm = 0x1388
callq 0x2150
movq 0x28(%rsp), %rax
lock
decl (%rax)
jl 0x2829
leaq 0x13e8(%rsp), %r13
movq 0x390b(%rip), %r12      # 0x5ff0
leaq 0x13e0(%rsp), %rbp
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
movw $0x7f80, 0x13e0(%rsp)   # imm = 0x7F80
movl $0x138e, %edx           # imm = 0x138E
leaq 0x13e2(%rsp), %rdi
leaq 0x52(%rsp), %rsi
callq 0x2150
cmpq %r14, %rbx
je 0x2732
movq %rbp, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2d96
movb %al, (%rbx)
incq %rbx
jmp 0x2718
movq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x23dc
movl %eax, 0xc(%rsp)
movl %eax, %edi
movl $0x1, %esi
callq 0x2220
xorl %ebx, %ebx
cmpq %r15, %rbx
je 0x279d
movl 0xc(%rsp), %edi
movq 0x30(%rsp), %rsi
addq %rbx, %rsi
movq 0x38(%rsp), %rdx
subq %rsi, %rdx
xorl %ecx, %ecx
callq 0x2080
movq %rax, %r14
cmpq $-0x1, %rax
jne 0x2786
callq 0x2040
cmpl $0x4, (%rax)
je 0x2758
testq %r14, %r14
je 0x2798
cmpq $-0x1, %r14
je 0x2869
addq %r14, %rbx
testq %r14, %r14
jne 0x2753
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, %rdx
subq %rdi, %rdx
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rcx
subq %rsi, %rcx
cmpq %rcx, %rdx
jne 0x27cd
cmpq %rdi, %rax
je 0x2809
callq 0x21d0
testl %eax, %eax
je 0x2809
movl $0x11, %edx
movq %r12, %rdi
leaq 0x1856(%rip), %rsi      # 0x4032
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 0xc(%rsp), %rdi
callq 0x2ad2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x28(%rsp), %rcx
lock
xaddl %eax, (%rcx)
testl %eax, %eax
jg 0x26ed
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2840
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2857
movq 0x20(%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 0x17bd(%rip), %rdi      # 0x402d
callq 0x2557
movl $0x1, %edi
callq 0x21f0
movq %rax, %rbx
jmp 0x28b3
jmp 0x288a
jmp 0x288f
jmp 0x288f
movq %rax, %rbx
jmp 0x289c
movq %rax, %rbx
leaq 0xc(%rsp), %rdi
callq 0x2ad2
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x28b3
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x28ca
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x2270