// File: 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
movq %rsp, %rbp
subq $0x3bb0, %rsp           # imm = 0x3BB0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movslq -0xc(%rbp), %rax
movq %rax, -0x3b50(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x3b48(%rbp)
callq 0x2320
movq -0x3b50(%rbp), %rsi
movq -0x3b48(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x2dc0
jmp 0x278a
leaq -0x31(%rbp), %rdi
callq 0x2240
movslq -0xc(%rbp), %rax
movq %rax, -0x3b60(%rbp)
leaq -0x61(%rbp), %rdi
movq %rdi, -0x3b58(%rbp)
callq 0x2320
movq -0x3b60(%rbp), %rsi
movq -0x3b58(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x2dc0
jmp 0x27c7
leaq -0x61(%rbp), %rdi
callq 0x2240
leaq -0x13f0(%rbp), %rdi
callq 0x2e30
jmp 0x27de
callq 0x2e50
movb %al, -0x3b61(%rbp)
callq 0x2e60
movb -0x3b61(%rbp), %cl
movsbl %cl, %esi
movsbl %al, %edx
leaq -0x13f2(%rbp), %rdi
callq 0x2e70
jmp 0x2808
leaq -0x2788(%rbp), %rdi
leaq -0x13f2(%rbp), %rsi
leaq -0x13f0(%rbp), %rdx
callq 0x2ea0
jmp 0x2824
jmp 0x2826
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x2ee0
cmpl $0x0, %eax
jle 0x2ac6
leaq -0x30(%rbp), %rdi
movq %rdi, -0x3b78(%rbp)
callq 0x2ff0
movq -0x3b78(%rbp), %rdi
movq %rax, -0x2790(%rbp)
callq 0x3020
movq %rax, -0x2798(%rbp)
leaq -0x3b28(%rbp), %rdi
movq %rdi, -0x3b70(%rbp)
leaq -0x2788(%rbp), %rsi
movl $0x1390, %edx           # imm = 0x1390
callq 0x21a0
movq -0x3b70(%rbp), %rdx
movq -0x2790(%rbp), %rdi
movq -0x2798(%rbp), %rsi
callq 0x2f90
jmp 0x289f
movq -0x8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x24a0
movl %eax, -0x3b7c(%rbp)
jmp 0x28b4
movl -0x3b7c(%rbp), %esi
leaq -0x3b2c(%rbp), %rdi
callq 0x3050
jmp 0x28c8
leaq -0x3b2c(%rbp), %rdi
callq 0x3070
movl %eax, -0x3b80(%rbp)
jmp 0x28dc
movl -0x3b80(%rbp), %edi
movl $0x1, %esi
callq 0x22b0
movq $0x0, -0x3b38(%rbp)
movq -0x3b38(%rbp), %rax
movslq -0xc(%rbp), %rcx
cmpq %rcx, %rax
je 0x2a61
jmp 0x290d
leaq -0x3b2c(%rbp), %rdi
callq 0x3070
movl %eax, -0x3b84(%rbp)
jmp 0x2921
movq -0x3b38(%rbp), %rsi
leaq -0x60(%rbp), %rdi
movq %rdi, -0x3ba0(%rbp)
callq 0x3080
movq -0x3ba0(%rbp), %rdi
movq %rax, -0x3b98(%rbp)
callq 0x2da0
movl -0x3b84(%rbp), %edi
movq -0x3b98(%rbp), %rsi
movq %rax, %rdx
movq -0x3b38(%rbp), %rax
subq %rax, %rdx
xorl %ecx, %ecx
callq 0x2080
movq %rax, -0x3b90(%rbp)
jmp 0x2975
movq -0x3b90(%rbp), %rax
movq %rax, -0x3b40(%rbp)
xorl %eax, %eax
cmpq $-0x1, -0x3b40(%rbp)
movb %al, -0x3ba1(%rbp)
jne 0x29a6
callq 0x2030
cmpl $0x4, (%rax)
sete %al
movb %al, -0x3ba1(%rbp)
movb -0x3ba1(%rbp), %al
testb $0x1, %al
jne 0x290d
cmpq $0x0, -0x3b40(%rbp)
jne 0x2a25
jmp 0x2a61
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x2240
jmp 0x2af3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x2240
jmp 0x2aea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2ae1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x3b2c(%rbp), %rdi
callq 0x30d0
jmp 0x2ae1
cmpq $-0x1, -0x3b40(%rbp)
jne 0x2a47
leaq 0x460b(%rip), %rdi      # 0x7041
callq 0x26e0
jmp 0x2a3d
movl $0x1, %edi
callq 0x2270
movq -0x3b40(%rbp), %rax
addq -0x3b38(%rbp), %rax
movq %rax, -0x3b38(%rbp)
jmp 0x28f7
leaq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x30a0
movb %al, -0x3ba2(%rbp)
jmp 0x2a76
movb -0x3ba2(%rbp), %al
testb $0x1, %al
jne 0x2a82
jmp 0x2ab5
movq 0x8567(%rip), %rdi      # 0xaff0
leaq 0x45b6(%rip), %rsi      # 0x7046
callq 0x21f0
movq %rax, -0x3bb0(%rbp)
jmp 0x2a9e
movq -0x3bb0(%rbp), %rdi
movq 0x850c(%rip), %rsi      # 0xafb8
callq 0x2220
jmp 0x2ab3
jmp 0x2ab5
leaq -0x3b2c(%rbp), %rdi
callq 0x30d0
jmp 0x2826
leaq -0x60(%rbp), %rdi
callq 0x3100
leaq -0x30(%rbp), %rdi
callq 0x3100
addq $0x3bb0, %rsp           # imm = 0x3BB0
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0x3100
leaq -0x30(%rbp), %rdi
callq 0x3100
movq -0x40(%rbp), %rdi
callq 0x2310
nopl (%rax)