// File: /workspace/github_cpp_makefile_star2_O3/yahoo[P]UDPing/src/clientsession.cc
// Function: ClientSessionList::ClientSessionList(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int)
ClientSessionList::ClientSessionList (
                string srcHost, string srcPorts, string dstHost, int dstPort,
                string dstMacList, int interval, int maxPacketSize )
{
    this->numPorts = 0;
    this->maxPacketSize = maxPacketSize;
    this->srcAddr = getSockAddr(srcHost.c_str(), dstPort);
    this->dstAddr = getSockAddr(dstHost.c_str(), dstPort);
    this->interval = interval;
    this->dstPort = dstPort;
    memset (srcMac, 0, 6);
    if (getIfInfo(srcHost.c_str(), &ifIndex, srcMac) < 0) {
        cerr << "getIfInfo failed" << endl;
        exit (-1);
    }
    socketFD = socket (PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
    if (socketFD < 0) {
        cerr << "socket() failed" << endl;
        exit (-1);
    }
    if (string::npos != srcPorts.find_first_not_of("1234567890,-")) {
        cerr << "Invalid source port descriptor " << srcPorts << endl;
        exit (-1);
    }
    char ports [1000];
    strncpy(ports, srcPorts.c_str(), 1000);
    char* curRange;
    char* curRangePtr = 0 ;
    char* pports = ports;
    while (curRange = strtok_r(pports, ",", &curRangePtr)) {
        pports = 0;
        char* startString = curRange;
        char* endString = 0;
        if (endString = strchr(curRange, '-')) {
            *endString = 0;
            endString++;
        }
        int start = atoi(startString);
        int end = start;
        if (endString) {
            end = atoi(endString);
        }
        if (isValidPort(start) && isValidPort(end) && (start <= end)) {
            for (int ix = start; ix <= end; ix++) {
                if (getOptions()->getFlagOption('v')) {
                    cout << "Adding port " << ix << endl;
                }
                sessions.push_back(new ClientSession(ix, dstMacList, this));
                this->numPorts ++;
            }
        } else {
            cerr << "Invalid port range " << start << "-" << end << endl;
            exit(-1);
        }
        if (sessions.size() > MAX_SOCKETS) {
            cerr << "Too many ports defined"<< endl;
            exit (-1);
        }
        if (sessions.size() == 0) {
            cerr << "No ports defined"<< endl;
            exit (-1);
        }
    }
    this->curSession = this->sessions.begin();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x488, %rsp            # imm = 0x488
movq %r9, 0x10(%rsp)
movl %r8d, %ebp
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r15
movl 0x4c8(%rsp), %eax
leaq 0x8(%rdi), %rbx
movq %rbx, 0x10(%rdi)
movq %rbx, 0x8(%rdi)
movl $0x0, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rdi)
movl %eax, 0x4(%rdi)
movq (%rsi), %rsi
leaq 0x80(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
callq 0x2130
leaq 0x80(%rsp), %rdi
movl %ebp, %esi
callq 0x3cb9
movq %rax, 0x28(%r15)
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x412f
callq 0x2280
movq (%r12), %rsi
leaq 0x60(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
callq 0x2130
movq %r14, %r12
leaq 0x60(%rsp), %rdi
movl %ebp, %esi
callq 0x3cb9
movl 0x4c0(%rsp), %r14d
movq %rax, 0x30(%r15)
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4173
callq 0x2280
movl %r14d, 0x48(%r15)
movl %ebp, 0x4c(%r15)
movl $0x0, 0x3c(%r15)
movw $0x0, 0x40(%r15)
movq (%r13), %rsi
leaq 0x40(%rsp), %rdi
leaq 0xa0(%rsp), %r13
movq %r13, %rdx
callq 0x2130
leaq 0x3c(%r15), %rdx
leaq 0x38(%r15), %rsi
leaq 0x40(%rsp), %rdi
callq 0x4b28
movl %eax, %ebp
movq %r12, %r14
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x41cd
callq 0x2280
testl %ebp, %ebp
js 0x44a0
movl $0x11, %edi
movl $0x3, %esi
movl $0x300, %edx            # imm = 0x300
callq 0x20d0
movl %eax, 0x44(%r15)
testl %eax, %eax
js 0x44c6
leaq 0x1554(%rip), %rsi      # 0x5750
movl $0xc, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23d0
cmpq $-0x1, %rax
jne 0x44ec
leaq 0x18(%r15), %rax
movq %rax, 0x8(%rsp)
movq (%r14), %rsi
movl $0x3e8, %edx            # imm = 0x3E8
movq %r13, %rdi
callq 0x2180
leaq 0x18(%rsp), %rax
movq $0x0, (%rax)
leaq 0x30(%rsp), %r14
movq %r13, %rdi
leaq 0x1534(%rip), %rsi      # 0x577d
leaq 0x18(%rsp), %rdx
callq 0x2430
testq %rax, %rax
je 0x4404
movq %rax, %r12
movq %rax, %rdi
movl $0x2d, %esi
callq 0x2120
testq %rax, %rax
je 0x428f
movq %rax, %r13
movb $0x0, (%rax)
incq %r13
movq %r12, %rdi
callq 0x23a0
movl %eax, %r12d
movq %r13, %rdi
callq 0x23a0
jmp 0x429a
movq %r12, %rdi
callq 0x23a0
movl %eax, %r12d
movl %eax, 0x4(%rsp)
leaq 0x20(%rsp), %r13
movl %r12d, %edi
callq 0x404c
movl 0x4(%rsp), %ebp
movl %ebp, %edi
callq 0x404c
cmpl %ebp, %r12d
jg 0x441e
incl %ebp
movl %ebp, 0x4(%rsp)
callq 0x397c
movq %rax, %rdi
movl $0x76, %esi
callq 0x394a
testl %eax, %eax
je 0x432c
movl $0xc, %edx
movq 0x3ce9(%rip), %rdi      # 0x7fd0
leaq 0x1491(%rip), %rsi      # 0x577f
callq 0x22e0
movq 0x3cd6(%rip), %rdi      # 0x7fd0
movl %r12d, %esi
callq 0x23e0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x22a0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x21a0
movl $0x840, %edi            # imm = 0x840
callq 0x22d0
movq %rax, %rbp
movq %r14, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x36e6
movq %r15, %rcx
movq %r13, %rdx
movq %r14, %r13
movb $0x1, %r14b
movq %rbp, %rdi
movl %r12d, %esi
callq 0x468a
xorl %r14d, %r14d
movl $0x18, %edi
callq 0x22d0
movq %rbp, 0x10(%rax)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2080
movq 0x8(%rsp), %rax
incq (%rax)
movq 0x20(%rsp), %rdi
movq %r13, %r14
cmpq %r13, %rdi
je 0x43a2
callq 0x2280
incl (%r15)
incl %r12d
cmpl %r12d, 0x4(%rsp)
leaq 0x20(%rsp), %r13
jne 0x42c5
movq 0x8(%rsp), %rax
movq (%rax), %rax
cmpq $0x1388, %rax           # imm = 0x1388
ja 0x4472
movl $0x0, %r13d
testq %rax, %rax
jne 0x423f
movq 0x3c0e(%rip), %rdi      # 0x7ff0
leaq 0x13ce(%rip), %rsi      # 0x57b7
movl $0x10, %edx
callq 0x22e0
movq 0x3bf6(%rip), %rdi      # 0x7ff0
callq 0x2160
jmp 0x4496
movq 0x8(%r15), %rax
movq %rax, 0x20(%r15)
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3bcb(%rip), %rdi      # 0x7ff0
leaq 0x1360(%rip), %rsi      # 0x578c
movl $0x13, %edx
callq 0x22e0
movq 0x3bb3(%rip), %rdi      # 0x7ff0
movl %r12d, %esi
callq 0x23e0
movq %rax, %r14
leaq 0x130c(%rip), %rsi      # 0x575b
movl $0x1, %edx
movq %rax, %rdi
callq 0x22e0
movq %r14, %rdi
movl 0x4(%rsp), %esi
callq 0x23e0
movq %rax, %rdi
callq 0x2160
jmp 0x4496
movq 0x3b77(%rip), %rdi      # 0x7ff0
leaq 0x1320(%rip), %rsi      # 0x57a0
movl $0x16, %edx
callq 0x22e0
movq 0x3b5f(%rip), %rdi      # 0x7ff0
callq 0x2160
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2310
movq 0x3b49(%rip), %rdi      # 0x7ff0
leaq 0x1281(%rip), %rsi      # 0x572f
movl $0x10, %edx
callq 0x22e0
movq 0x3b31(%rip), %rdi      # 0x7ff0
callq 0x2160
jmp 0x4496
movq 0x3b23(%rip), %rdi      # 0x7ff0
leaq 0x126c(%rip), %rsi      # 0x5740
movl $0xf, %edx
callq 0x22e0
movq 0x3b0b(%rip), %rdi      # 0x7ff0
callq 0x2160
jmp 0x4496
movq 0x3afd(%rip), %rdi      # 0x7ff0
leaq 0x1263(%rip), %rsi      # 0x575d
movl $0x1f, %edx
callq 0x22e0
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq 0x3adc(%rip), %rdi      # 0x7ff0
callq 0x22e0
movq %rax, %rdi
callq 0x2160
jmp 0x4496
movq %rax, %r12
leaq 0x50(%rsp), %rax
jmp 0x4549
jmp 0x4584
movq %rax, %r12
leaq 0x70(%rsp), %rax
jmp 0x4549
jmp 0x4584
movq %rax, %r12
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x457d
jmp 0x4587
jmp 0x4584
jmp 0x4584
jmp 0x4584
jmp 0x4584
jmp 0x4584
movq %rax, %r12
jmp 0x457a
movq %rax, %r12
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x4575
callq 0x2280
testb %r14b, %r14b
je 0x4587
movq %rbp, %rdi
callq 0x2280
jmp 0x4587
movq %rax, %r12
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x459f
movq (%rdi), %r14
callq 0x2280
movq %r14, %rdi
cmpq %rbx, %r14
jne 0x458f
movq %r12, %rdi
callq 0x2400
nop