// File: yuryu[P]tfoecho/client.cpp
// Function: main
int main(int argc, char *argv[])
{
    if( argc <= 4 )
    {
        std::cerr << "Usage: client [server addr] [msg size] [count] [thread]" << std::endl;
        return EXIT_FAILURE;
    }
    
    std::string server_addr(argv[1]);
    int msg_size = std::atoi(argv[2]);
    std::atomic_int count(std::atoi(argv[3]));
    int nthreads = std::atoi(argv[4]);

    std::vector<std::thread> threads;
    threads.reserve(nthreads);
    for( int i = 0; i < nthreads; ++i )
        threads.push_back(std::thread(send_recv, server_addr, msg_size, std::ref(count)));
    std::for_each(threads.begin(), threads.end(), std::mem_fn(&std::thread::join));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x4, -0x8(%rbp)
jg 0x2b4d
movq 0x84ca(%rip), %rdi      # 0xaff0
leaq 0x452b(%rip), %rsi      # 0x7058
callq 0x21f0
movq %rax, %rdi
movq 0x847c(%rip), %rsi      # 0xafb8
callq 0x2220
movl $0x1, -0x4(%rbp)
jmp 0x2d51
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xd0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x2320
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x3160
jmp 0x2b85
leaq -0x31(%rbp), %rdi
callq 0x2240
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x22f0
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x22f0
movl %eax, %esi
leaq -0x4c(%rbp), %rdi
callq 0x3210
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x22f0
movl %eax, -0x50(%rbp)
leaq -0x68(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x3240
movq -0xd8(%rbp), %rdi
movslq -0x50(%rbp), %rsi
callq 0x3260
jmp 0x2be8
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x2c8e
leaq -0x4c(%rbp), %rdi
callq 0x3390
movq %rax, -0x80(%rbp)
leaq -0x4cf(%rip), %rsi      # 0x2740
leaq -0x78(%rbp), %rdi
leaq -0x30(%rbp), %rdx
leaq -0x48(%rbp), %rcx
leaq -0x80(%rbp), %r8
callq 0x33c0
jmp 0x2c26
leaq -0x68(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3360
jmp 0x2c35
leaq -0x78(%rbp), %rdi
callq 0x3490
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x2bef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x2240
jmp 0x2d6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2d5d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3490
jmp 0x2d5d
leaq -0x68(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x3530
movq -0xf0(%rbp), %rdi
movq %rax, -0x88(%rbp)
callq 0x3560
movq %rax, -0x90(%rbp)
movq 0x8311(%rip), %rax      # 0xafd0
movq %rax, -0xb0(%rbp)
movq $0x0, -0xa8(%rbp)
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x3590
movq %rax, -0xa0(%rbp)
movq %rdx, -0x98(%rbp)
movq -0x88(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movq -0x98(%rbp), %rcx
callq 0x34c0
movq %rdx, -0xe8(%rbp)
movq %rax, -0xe0(%rbp)
jmp 0x2d23
movq -0xe8(%rbp), %rax
movq -0xe0(%rbp), %rcx
movq %rcx, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x35e0
leaq -0x30(%rbp), %rdi
callq 0x2150
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x35e0
leaq -0x30(%rbp), %rdi
callq 0x2150
movq -0x40(%rbp), %rdi
callq 0x2310
nopl (%rax,%rax)