// File: /workspace/github_cpp_makefile_star2_O2/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 $0x498, %rsp            # imm = 0x498
movq %r9, 0x18(%rsp)
movl %r8d, %ebp
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r15
movl 0x4d8(%rsp), %eax
leaq 0x8(%rdi), %rcx
movq %rcx, 0x10(%rdi)
movq %rcx, 0x8(%rsp)
movq %rcx, 0x8(%rdi)
andl $0x0, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rdi)
movl %eax, 0x4(%rdi)
movq (%rsi), %rsi
leaq 0x70(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0x2120
leaq 0x70(%rsp), %rdi
movl %ebp, %esi
callq 0x373e
movq %rax, 0x28(%r15)
leaq 0x70(%rsp), %rdi
callq 0x2140
movq (%r13), %rsi
leaq 0x50(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0x2120
leaq 0x50(%rsp), %rdi
movl %ebp, %esi
callq 0x373e
movl 0x4d0(%rsp), %r14d
movq %rax, 0x30(%r15)
leaq 0x50(%rsp), %rdi
callq 0x2140
movl %r14d, 0x48(%r15)
movl %ebp, 0x4c(%r15)
andl $0x0, 0x3c(%r15)
andw $0x0, 0x40(%r15)
movq (%r12), %rsi
leaq 0x30(%rsp), %rdi
leaq 0xb0(%rsp), %rbp
movq %rbp, %rdx
callq 0x2120
leaq 0x3c(%r15), %rdx
leaq 0x38(%r15), %rsi
leaq 0x30(%rsp), %rdi
callq 0x4460
movl %eax, %r12d
leaq 0x30(%rsp), %rdi
callq 0x2140
testl %r12d, %r12d
js 0x3e1e
pushq $0x11
popq %rdi
pushq $0x3
popq %rsi
movl $0x300, %edx            # imm = 0x300
callq 0x20c0
movl %eax, 0x44(%r15)
testl %eax, %eax
js 0x3e3b
leaq 0x1b12(%rip), %rsi      # 0x5730
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2190
cmpq $-0x1, %rax
jne 0x3e58
leaq 0x18(%r15), %rax
movq %rax, 0x10(%rsp)
movq (%rbx), %rsi
movl $0x3e8, %edx            # imm = 0x3E8
movq %rbp, %rdi
callq 0x2170
leaq 0x28(%rsp), %rax
andq $0x0, (%rax)
leaq 0x90(%rsp), %r13
movq %rbp, %rdi
leaq 0x1af7(%rip), %rsi      # 0x575d
leaq 0x28(%rsp), %rdx
callq 0x23f0
testq %rax, %rax
je 0x3da1
movq %rax, %rbx
movq %rax, %rdi
pushq $0x2d
popq %rsi
callq 0x2110
testq %rax, %rax
je 0x3c97
movq %rax, %r12
movb $0x0, (%rax)
incq %r12
jmp 0x3c9a
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0x2380
movl %eax, %ebx
movl %eax, %ebp
testq %r12, %r12
je 0x3cb5
movq %r12, %rdi
callq 0x2380
movl %eax, %ebp
movl %ebx, %edi
callq 0x3aa0
movl %ebp, %edi
callq 0x3aa0
cmpl %ebp, %ebx
jg 0x3dbb
cmpl %ebp, %ebx
jg 0x3d62
callq 0x3490
movq %rax, %rdi
pushq $0x76
popq %rsi
callq 0x345e
testl %eax, %eax
je 0x3d0c
movq 0x42e2(%rip), %rdi      # 0x7fd0
leaq 0x1a6a(%rip), %rsi      # 0x575f
callq 0x22a0
movq %rax, %rdi
movl %ebx, %esi
callq 0x23b0
movq %rax, %rdi
callq 0x2150
movl $0x840, %edi            # imm = 0x840
callq 0x22b0
movq %rax, %r12
movq %r13, %rdi
movq 0x18(%rsp), %rsi
callq 0x2320
movb $0x1, %r14b
movq %r12, %rdi
movl %ebx, %esi
movq %r13, %rdx
movq %r15, %rcx
callq 0x3fb0
movq %r12, 0x20(%rsp)
xorl %r14d, %r14d
movq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x41ae
movq %r13, %rdi
callq 0x2140
incl (%r15)
incl %ebx
jmp 0x3ccb
movq 0x10(%rsp), %rax
movq (%rax), %rax
cmpq $0x1388, %rax           # imm = 0x1388
ja 0x3dfb
movl $0x0, %ebp
testq %rax, %rax
jne 0x3c5c
movq 0x4265(%rip), %rdi      # 0x7ff0
leaq 0x1a05(%rip), %rsi      # 0x5797
callq 0x22a0
movq %rax, %rdi
callq 0x2150
jmp 0x3e16
movq 0x8(%r15), %rax
movq %rax, 0x20(%r15)
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x422e(%rip), %rdi      # 0x7ff0
leaq 0x19a3(%rip), %rsi      # 0x576c
callq 0x22a0
movq %rax, %rdi
movl %ebx, %esi
callq 0x23b0
leaq 0x195c(%rip), %rsi      # 0x573b
movq %rax, %rdi
callq 0x22a0
movq %rax, %rdi
movl %ebp, %esi
callq 0x23b0
movq %rax, %rdi
callq 0x2150
jmp 0x3e16
movq 0x41ee(%rip), %rdi      # 0x7ff0
leaq 0x1977(%rip), %rsi      # 0x5780
callq 0x22a0
movq %rax, %rdi
callq 0x2150
pushq $-0x1
popq %rdi
callq 0x22e0
movq 0x41cb(%rip), %rdi      # 0x7ff0
leaq 0x18e3(%rip), %rsi      # 0x570f
callq 0x22a0
movq %rax, %rdi
callq 0x2150
jmp 0x3e16
movq 0x41ae(%rip), %rdi      # 0x7ff0
leaq 0x18d7(%rip), %rsi      # 0x5720
callq 0x22a0
movq %rax, %rdi
callq 0x2150
jmp 0x3e16
movq 0x4191(%rip), %rdi      # 0x7ff0
leaq 0x18d7(%rip), %rsi      # 0x573d
callq 0x22a0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2220
movq %rax, %rdi
callq 0x2150
jmp 0x3e16
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
jmp 0x3ea0
jmp 0x3ed5
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x3ea0
jmp 0x3ed5
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x2140
jmp 0x3ed8
jmp 0x3ed5
jmp 0x3ed5
jmp 0x3ed5
jmp 0x3ed5
jmp 0x3ed5
movq %rax, %rbx
jmp 0x3ecb
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2140
testb %r14b, %r14b
je 0x3ed8
movq %r12, %rdi
callq 0x2270
jmp 0x3ed8
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x41ba
movq %rbx, %rdi
callq 0x23d0