// File: /workspace/github_cpp_makefile_star2_O2/LiGaCu[P]Distributed_System_to_Compute_the_Shortest_Path/aws.cpp
// Function: main
int main(void)
{
    int TCPfath_fd,TCPchld_fd, UDP_fd;
    struct addrinfo hints, *servinfo, *servinfoA, *servinfoB, *servinfoC;
    struct sigaction sa;

    int rv;

    char buf[MAXDATASIZE];int numbytes;
    std::string mapbuff, mapinfo;
    char mapid; int srcVtxid,dstVtxid,filesize;
    float Tt,Tp;
    int path[11]; float mindistan;

    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    if ((rv = getaddrinfo("127.0.0.1", TCPPORT, &hints, &servinfo)) != 0) 
    {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
        return 1;
    }
    TCPfath_fd = getTCPsockandbind(servinfo);
    freeaddrinfo(servinfo);

    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_UNSPEC; // set to AF_INET to force IPv4
    hints.ai_socktype = SOCK_DGRAM;
    if ((rv = getaddrinfo("127.0.0.1", UDPPORT, &hints, &servinfo)) != 0) 
    {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
        return 1;
    }
    UDP_fd = getUDPsockandbind(servinfo);
    freeaddrinfo(servinfo);

    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_UNSPEC; // set to AF_INET to force IPv4
    hints.ai_socktype = SOCK_DGRAM;
    if ((rv = getaddrinfo("127.0.0.1", AUDPPORT, &hints, &servinfoA)) != 0) 
    {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
        return 1;
    }

    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_UNSPEC; // set to AF_INET to force IPv4
    hints.ai_socktype = SOCK_DGRAM;
    if ((rv = getaddrinfo("127.0.0.1", BUDPPORT, &hints, &servinfoB)) != 0) 
    {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
        return 1;
    }

    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_UNSPEC; // set to AF_INET to force IPv4
    hints.ai_socktype = SOCK_DGRAM;
    if ((rv = getaddrinfo("127.0.0.1", CUDPPORT, &hints, &servinfoC)) != 0) 
    {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
        return 1;
    }

    if (listen(TCPfath_fd, BACKLOG) == -1) 
    {
        perror("listen");
        exit(1);
    }

    // The following lines of sigaction() thing is from Beej's Tutorial
    sa.sa_handler = sigchld_handler; // reap all dead processes
    sigemptyset(&sa.sa_mask);
    sa.sa_flags = SA_RESTART;
    if (sigaction(SIGCHLD, &sa, NULL) == -1) 
    {
        perror("sigaction");
        exit(1);
    }

    std::cout << "The AWS is up and ranning" << "\n" << std::endl;
    
    while(1)
    {
        TCPchld_fd = accept(TCPfath_fd,(struct sockaddr *)NULL,NULL);
        if (TCPchld_fd == -1) 
        {
            perror("accept");
            continue;
        }

        if (!fork()) 
        { // this is the child process
            close(TCPfath_fd);
            if ((numbytes = recv(TCPchld_fd, buf, MAXDATASIZE-1, 0)) == -1) 
            {
                perror("recvTCP");
                exit(1);
            }

            //decode the massage received from the client
            mapid = buf[0];
            memcpy(&srcVtxid,buf+1,sizeof(int));
            memcpy(&dstVtxid,buf+1+sizeof(int),sizeof(int));
            memcpy(&filesize,buf+1+2*sizeof(int),sizeof(int));

            std::cout << "The AWS has recieved map ID " << mapid << ", start vertex " << srcVtxid << ", destination vertex " << dstVtxid
             << " and file size " << filesize << " from the client using TCP over port " << TCPPORT << "\n" << std::endl;

            if ((numbytes = sendto(UDP_fd, buf, numbytes, 0, servinfoA->ai_addr, servinfoA->ai_addrlen)) == -1) 
            {
                perror("talker: sendtoA");
                exit(1);
            }
            std::cout << "The AWS has sent map ID to server A using UDP over port " << UDPPORT << "\n" << std::endl;

            if ((numbytes = sendto(UDP_fd, buf, numbytes, 0, servinfoB->ai_addr, servinfoB->ai_addrlen)) == -1) 
            {
                perror("talker: sendtoB");
                exit(1);
            }
            std::cout << "The AWS has sent map ID to server B using UDP over port " << UDPPORT << "\n" << std::endl;

            if ((numbytes = recvfrom(UDP_fd, buf, MAXDATASIZE-1 , 0, (struct sockaddr *) NULL, NULL)) == -1) 
            {
                perror("recvfromA/B");
                exit(1);
            }
            mapbuff.assign(buf, numbytes);
            
            int receivedA = 0, receivedB = 0;
            char msgA = '\0', msgB = '\0';

            interpUDPmsg(mapbuff, mapinfo, &receivedA, &receivedB, &msgA, &msgB);
            if(!receivedA || !receivedB)
            {
                if ((numbytes = recvfrom(UDP_fd, buf, MAXDATASIZE-1 , 0, (struct sockaddr *) NULL, NULL)) == -1) 
                {
                    perror("recvfromA/B");
                    exit(1);
                }
                mapbuff.assign(buf, numbytes);
                interpUDPmsg(mapbuff, mapinfo, &receivedA, &receivedB, &msgA, &msgB);
            }

            char matchstate = mapsearchresult(msgA, msgB, mapid, srcVtxid, dstVtxid);

            if (matchstate == 'y') // all map id, source vertex index and destination vertex index are found
            {
                memcpy(buf, &srcVtxid, sizeof(int));
                memcpy(buf+sizeof(int), &dstVtxid, sizeof(int));
                memcpy(buf+2*sizeof(int), &filesize, sizeof(int));
                memcpy(buf+3*sizeof(int), &mapid, sizeof(char));
                mapinfo.insert(0, buf, 3*sizeof(int)+sizeof(char));

                //send required information to serverC
                if ((numbytes = sendto(UDP_fd, mapinfo.data(), mapinfo.length(), 0, servinfoC->ai_addr, servinfoC->ai_addrlen)) == -1) 
                {
                    perror("talker: sendtoC");
                    exit(1);
                }
                std::cout << "The AWS has sent map, source ID, destination ID, propagation speed and transmission speed to" <<
                 "server C using UDP over port " << UDPPORT << "\n" << std::endl;
                //receive calculated results from serverC
                if ((numbytes = recvfrom(UDP_fd, buf, MAXDATASIZE-1 , 0, (struct sockaddr *) NULL, NULL)) == -1) 
                {
                    perror("recvfromC");
                    exit(1);
                }
                memcpy(&mindistan, buf                  , sizeof(float));
                memcpy(&Tt       , buf + sizeof(float)  , sizeof(float));
                memcpy(&Tp       , buf + sizeof(float)*2, sizeof(float));
                memcpy(path      , buf + sizeof(float)*3, sizeof(path));
                //show the result
                std::cout << "The AWS has received results from serverC:\n" <<  "Shortest path: ";
                for (int i =0 ; i< 11; i++)
                {
                    if(path[i] == 2333)
                        break;
                    
                    if (i==0)
                        std::cout << path[i];
                    else
                        std::cout << " -- " << path[i];

                }
                std::cout << "\nShortest Distance: " << mindistan << " km\nTransmission Delay: " << Tt << " s\nPropagation Delay: " << Tp << " s\n" << std::endl;
                //send calculated results to client
                std::string tempstr("y");
                tempstr.append(buf,numbytes);
                if (send(TCPchld_fd, tempstr.data(), tempstr.length(), 0) == -1)
                    perror("sendTCP");
                std::cout << "The AWS has sent calculated results to client using TCP over port " << TCPPORT << "\n" << std::endl;
            }
            else if(matchstate == 'e') // abnormal map1 and map2 state
            {
                perror("storedmapswrong");
            }
            else // map id, source vertex index or destination vertex index is not found
            {
                std::string tempstr("!");
                tempstr.append(1,matchstate);
                if (send(TCPchld_fd, tempstr.data(), 2, 0) == -1)
                    perror("sendTCP");
            }

            close(TCPchld_fd);
            exit(0);
        }

        //close(TCPchld_fd);
    }

    close(TCPfath_fd);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x588, %rsp            # imm = 0x588
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
leaq 0x58(%rsp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb %cl, (%rdx)
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, 0x20(%rdx)
movl $0x1, 0x8(%rdx)
leaq 0x1bae(%rip), %rdi      # 0x4004
leaq 0x1bb1(%rip), %rsi      # 0x400e
leaq 0x18(%rsp), %rcx
callq 0x21f0
testl %eax, %eax
jne 0x263e
movq 0x18(%rsp), %rdi
callq 0x2cdd
movl %eax, %r14d
leaq 0x18(%rsp), %rbx
movq (%rbx), %rdi
callq 0x2200
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movl $0x2, 0x8(%rdx)
leaq 0x1b57(%rip), %rdi      # 0x4004
leaq 0x1b71(%rip), %rsi      # 0x4025
movq %rbx, %rcx
callq 0x21f0
testl %eax, %eax
jne 0x263e
movq 0x18(%rsp), %rdi
callq 0x2dae
movl %eax, %ebp
movq 0x18(%rsp), %rdi
callq 0x2200
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movl $0x2, 0x8(%rdx)
leaq 0x1b06(%rip), %rdi      # 0x4004
leaq 0x1b26(%rip), %rsi      # 0x402b
leaq 0x78(%rsp), %rcx
callq 0x21f0
testl %eax, %eax
jne 0x263e
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movl $0x2, 0x8(%rdx)
leaq 0x1ac9(%rip), %rdi      # 0x4004
leaq 0x1aef(%rip), %rsi      # 0x4031
leaq 0x70(%rsp), %rcx
callq 0x21f0
testl %eax, %eax
jne 0x263e
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movl $0x2, 0x8(%rdx)
leaq 0x1a8c(%rip), %rdi      # 0x4004
leaq 0x1ab8(%rip), %rsi      # 0x4037
leaq 0x68(%rsp), %rcx
callq 0x21f0
testl %eax, %eax
jne 0x263e
pushq $0xa
popq %rsi
movl %r14d, %edi
callq 0x2190
cmpl $-0x1, %eax
je 0x29e1
leaq 0x8d5(%rip), %rax       # 0x2e81
leaq 0x4f8(%rsp), %rbx
movq %rax, -0x8(%rbx)
movq %rbx, %rdi
callq 0x21d0
movl $0x10000000, 0x80(%rbx) # imm = 0x10000000
pushq $0x11
popq %rdi
leaq 0x4f0(%rsp), %rsi
xorl %edx, %edx
callq 0x21e0
cmpl $-0x1, %eax
je 0x29ea
movq 0x39e4(%rip), %rdi      # 0x5fd0
leaq 0x1a5b(%rip), %rsi      # 0x404e
callq 0x2160
leaq 0x1c4e(%rip), %rsi      # 0x424d
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20d0
leaq 0x1a52(%rip), %r15      # 0x4068
movl %r14d, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2090
movl %eax, %ebx
cmpl $-0x1, %eax
je 0x2634
callq 0x2080
testl %eax, %eax
jne 0x2616
jmp 0x268f
movq %r15, %rdi
callq 0x2140
jmp 0x2616
movq 0x3993(%rip), %rcx      # 0x5fd8
movq (%rcx), %rbx
movl %eax, %edi
callq 0x2220
leaq 0x19be(%rip), %rsi      # 0x4014
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2230
leaq 0x48(%rsp), %rdi
callq 0x20c0
leaq 0x80(%rsp), %rdi
callq 0x20c0
pushq $0x1
popq %rax
addq $0x588, %rsp            # imm = 0x588
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r14d, %edi
callq 0x22b0
leaq 0x100(%rsp), %rsi
movl $0x3e7, %edx            # imm = 0x3E7
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
movq %rax, %r12
cmpl $-0x1, %r12d
je 0x29f3
movb 0x100(%rsp), %al
movb %al, 0xc(%rsp)
movl 0x101(%rsp), %r14d
movl 0x105(%rsp), %r15d
movl 0x109(%rsp), %eax
movl %eax, 0x8(%rsp)
movq 0x38e9(%rip), %rdi      # 0x5fd0
leaq 0x1989(%rip), %rsi      # 0x4077
callq 0x2160
movsbl 0xc(%rsp), %r13d
movq %rax, %rdi
movl %r13d, %esi
callq 0x21a0
leaq 0x1989(%rip), %rsi      # 0x4094
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
movl %r14d, %esi
callq 0x2250
leaq 0x197f(%rip), %rsi      # 0x40a4
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
movl %r15d, %esi
callq 0x2250
leaq 0x197b(%rip), %rsi      # 0x40ba
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x2250
leaq 0x1970(%rip), %rsi      # 0x40ca
movq %rax, %rdi
callq 0x2160
leaq 0x18a5(%rip), %rsi      # 0x400e
movq %rax, %rdi
callq 0x2160
leaq 0x1ad5(%rip), %rsi      # 0x424d
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20d0
movslq %r12d, %rdx
movq 0x78(%rsp), %rax
movq 0x18(%rax), %r8
movl 0x10(%rax), %r9d
leaq 0x100(%rsp), %rsi
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x2040
movq %rax, %r12
cmpl $-0x1, %r12d
je 0x29fc
movq 0x3813(%rip), %rdi      # 0x5fd0
leaq 0x193c(%rip), %rsi      # 0x4100
callq 0x2160
leaq 0x1855(%rip), %rsi      # 0x4025
movq %rax, %rdi
callq 0x2160
leaq 0x1a6e(%rip), %rsi      # 0x424d
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20d0
movslq %r12d, %rdx
movq 0x70(%rsp), %rax
movq 0x18(%rax), %r8
movl 0x10(%rax), %r9d
leaq 0x100(%rsp), %rsi
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x2040
cmpl $-0x1, %eax
je 0x2a05
movq 0x37b0(%rip), %rdi      # 0x5fd0
leaq 0x1922(%rip), %rsi      # 0x4149
callq 0x2160
leaq 0x17f2(%rip), %rsi      # 0x4025
movq %rax, %rdi
callq 0x2160
leaq 0x1a0b(%rip), %rsi      # 0x424d
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20d0
leaq 0x100(%rsp), %rsi
movl $0x3e7, %edx            # imm = 0x3E7
movl %ebp, %edi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2110
cmpl $-0x1, %eax
je 0x29d8
movslq %eax, %rdx
leaq 0x80(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x2210
leaq 0x14(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x10(%rsp), %rcx
andl $0x0, (%rcx)
xorl %eax, %eax
leaq 0x6(%rsp), %r8
movb %al, (%r8)
leaq 0x5(%rsp), %r9
movb %al, (%r9)
leaq 0x80(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x2eb8
cmpl $0x0, 0x14(%rsp)
je 0x28d1
cmpl $0x0, 0x10(%rsp)
jne 0x2934
leaq 0x100(%rsp), %rsi
movl $0x3e7, %edx            # imm = 0x3E7
movl %ebp, %edi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2110
cmpl $-0x1, %eax
je 0x29d8
movslq %eax, %rdx
leaq 0x80(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x2210
leaq 0x80(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x14(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x6(%rsp), %r8
leaq 0x5(%rsp), %r9
callq 0x2eb8
movsbl 0x6(%rsp), %edi
movsbl 0x5(%rsp), %esi
movl %r13d, %edx
movl %r14d, %ecx
movl %r15d, %r8d
callq 0x3047
movl %eax, %r12d
cmpb $0x65, %al
jne 0x296d
leaq 0x19a0(%rip), %rdi      # 0x42fa
callq 0x2140
movl %ebx, %edi
callq 0x22b0
xorl %edi, %edi
callq 0x21b0
movzbl %r12b, %eax
cmpl $0x79, %eax
jne 0x2a19
leaq 0x100(%rsp), %rdx
movl %r14d, (%rdx)
movl %r15d, 0x4(%rdx)
movl 0x8(%rsp), %eax
movl %eax, 0x8(%rdx)
movb 0xc(%rsp), %al
movb %al, 0xc(%rdx)
leaq 0x48(%rsp), %rdi
pushq $0xd
popq %rcx
xorl %esi, %esi
callq 0x2280
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x68(%rsp), %rax
movq 0x18(%rax), %r8
movl 0x10(%rax), %r9d
movl %ebp, %edi
xorl %ecx, %ecx
callq 0x2040
cmpl $-0x1, %eax
jne 0x2a72
leaq 0x17b8(%rip), %rdi      # 0x418e
jmp 0x2a0c
leaq 0x17a3(%rip), %rdi      # 0x4182
jmp 0x2a0c
leaq 0x1655(%rip), %rdi      # 0x403d
jmp 0x2a0c
leaq 0x1653(%rip), %rdi      # 0x4044
jmp 0x2a0c
leaq 0x1675(%rip), %rdi      # 0x406f
jmp 0x2a0c
leaq 0x16ed(%rip), %rdi      # 0x40f0
jmp 0x2a0c
leaq 0x172d(%rip), %rdi      # 0x4139
callq 0x2140
pushq $0x1
popq %rdi
callq 0x21b0
leaq 0x18ea(%rip), %rsi      # 0x430a
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x335a
movsbl %r12b, %edx
leaq 0x28(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x2180
movq 0x28(%rsp), %rsi
pushq $0x2
popq %rdx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20e0
cmpq $-0x1, %rax
jne 0x2a63
leaq 0x1851(%rip), %rdi      # 0x42af
callq 0x2140
leaq 0x28(%rsp), %rdi
callq 0x20c0
jmp 0x295f
movq 0x3557(%rip), %rdi      # 0x5fd0
leaq 0x171e(%rip), %rsi      # 0x419e
callq 0x2160
leaq 0x176f(%rip), %rsi      # 0x41fb
movq %rax, %rdi
callq 0x2160
leaq 0x158a(%rip), %rsi      # 0x4025
movq %rax, %rdi
callq 0x2160
leaq 0x17a3(%rip), %rsi      # 0x424d
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20d0
leaq 0x100(%rsp), %rsi
movl $0x3e7, %edx            # imm = 0x3E7
movl %ebp, %edi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2110
movq %rax, %r14
cmpl $-0x1, %r14d
jne 0x2aeb
leaq 0x1733(%rip), %rdi      # 0x4219
jmp 0x2a0c
leaq 0x10c(%rsp), %rax
movss -0xc(%rax), %xmm0
movss %xmm0, 0xc(%rsp)
movss -0x8(%rax), %xmm0
movss %xmm0, 0x8(%rsp)
movss -0x4(%rax), %xmm0
movss %xmm0, 0x24(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x1c(%rax), %xmm2
movaps %xmm0, 0xd0(%rsp)
movaps %xmm1, 0xe0(%rsp)
movups %xmm2, 0xec(%rsp)
movq 0x3492(%rip), %r15      # 0x5fd0
leaq 0x16de(%rip), %rsi      # 0x4223
movq %r15, %rdi
callq 0x2160
leaq 0x16fb(%rip), %rsi      # 0x424f
movq %rax, %rdi
callq 0x2160
xorl %r13d, %r13d
leaq 0x16f9(%rip), %r12      # 0x425f
cmpq $0xb, %r13
je 0x2b9e
movl 0xd0(%rsp,%r13,4), %ebp
cmpl $0x91d, %ebp            # imm = 0x91D
je 0x2b9e
movq %r15, %rax
testq %r13, %r13
je 0x2b8f
movq %r15, %rdi
movq %r12, %rsi
callq 0x2160
movq %rax, %rdi
movl %ebp, %esi
callq 0x2250
incq %r13
jmp 0x2b66
movq 0x342b(%rip), %rdi      # 0x5fd0
leaq 0x16b8(%rip), %rsi      # 0x4264
callq 0x2160
movq %rax, %rdi
movss 0xc(%rsp), %xmm0
callq 0x2100
leaq 0x16b3(%rip), %rsi      # 0x4279
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
movss 0x8(%rsp), %xmm0
callq 0x2100
leaq 0x16af(%rip), %rsi      # 0x4292
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
movss 0x24(%rsp), %xmm0
callq 0x2100
leaq 0x16a9(%rip), %rsi      # 0x42a9
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20d0
leaq 0x1696(%rip), %rsi      # 0x42ad
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x335a
movslq %r14d, %rdx
leaq 0x28(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x2050
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20e0
cmpq $-0x1, %rax
jne 0x2c60
leaq 0x1654(%rip), %rdi      # 0x42af
callq 0x2140
movq 0x3369(%rip), %rdi      # 0x5fd0
leaq 0x1649(%rip), %rsi      # 0x42b7
callq 0x2160
leaq 0x1394(%rip), %rsi      # 0x400e
movq %rax, %rdi
callq 0x2160
leaq 0x15c4(%rip), %rsi      # 0x424d
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20d0
jmp 0x2a63
jmp 0x2ca4
jmp 0x2cbb
jmp 0x2cbb
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x20c0
jmp 0x2cbe
jmp 0x2cbb
jmp 0x2cbb
jmp 0x2cbb
jmp 0x2cbb
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x20c0
leaq 0x80(%rsp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2260