// File: /workspace/github_cpp_makefile_star2_O1/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 $0x598, %rsp            # imm = 0x598
leaq 0x88(%rsp), %rbp
movq %rbp, -0x10(%rbp)
xorl %eax, %eax
movq %rax, -0x8(%rbp)
movb %al, (%rbp)
leaq 0x68(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, 0x20(%rdx)
movl $0x1, 0x8(%rdx)
leaq 0x1a6d(%rip), %rdi      # 0x4004
leaq 0x1a70(%rip), %rsi      # 0x400e
leaq 0x30(%rsp), %rcx
callq 0x21f0
testl %eax, %eax
jne 0x27c2
movq 0x30(%rsp), %rdi
callq 0x3027
movl %eax, %r14d
leaq 0x30(%rsp), %rbx
movq (%rbx), %rdi
callq 0x2200
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movl $0x2, 0x8(%rdx)
leaq 0x1a16(%rip), %rdi      # 0x4004
leaq 0x1a30(%rip), %rsi      # 0x4025
movq %rbx, %rcx
callq 0x21f0
testl %eax, %eax
jne 0x27c2
movq 0x30(%rsp), %rdi
callq 0x30e2
movl %eax, 0x18(%rsp)
movq 0x30(%rsp), %rdi
callq 0x2200
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movl $0x2, 0x8(%rdx)
leaq 0x19c3(%rip), %rdi      # 0x4004
leaq 0x19e3(%rip), %rsi      # 0x402b
leaq 0xa8(%rsp), %rcx
callq 0x21f0
testl %eax, %eax
jne 0x27c2
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movl $0x2, 0x8(%rdx)
leaq 0x1983(%rip), %rdi      # 0x4004
leaq 0x19a9(%rip), %rsi      # 0x4031
leaq 0xa0(%rsp), %rcx
callq 0x21f0
testl %eax, %eax
jne 0x27c2
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movl $0x2, 0x8(%rdx)
leaq 0x1943(%rip), %rdi      # 0x4004
leaq 0x196f(%rip), %rsi      # 0x4037
leaq 0x98(%rsp), %rcx
callq 0x21f0
testl %eax, %eax
jne 0x27c2
movl %r14d, %edi
movl $0xa, %esi
callq 0x2180
cmpl $-0x1, %eax
je 0x2c6e
leaq 0xaa3(%rip), %rax       # 0x319d
leaq 0x508(%rsp), %rbx
movq %rax, -0x8(%rbx)
movq %rbx, %rdi
callq 0x21d0
movl $0x10000000, 0x80(%rbx) # imm = 0x10000000
leaq 0x500(%rsp), %rsi
movl $0x11, %edi
xorl %edx, %edx
callq 0x21e0
cmpl $-0x1, %eax
je 0x2c73
movq 0x3894(%rip), %rdi      # 0x5fd0
leaq 0x190b(%rip), %rsi      # 0x404e
movl $0x19, %edx
callq 0x21a0
movq 0x387c(%rip), %rbx      # 0x5fd0
leaq 0x1af2(%rip), %rsi      # 0x424d
movl $0x1, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x384a(%rip), %rdi      # 0x5fd0
callq 0x2030
movq %rax, %rdi
callq 0x20e0
leaq 0x18ce(%rip), %r15      # 0x4068
movl %r14d, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x20a0
movl %eax, %ebx
cmpl $-0x1, %eax
je 0x27b8
callq 0x2090
testl %eax, %eax
jne 0x279a
jmp 0x282f
movq %r15, %rdi
callq 0x2130
jmp 0x279a
movq 0x380f(%rip), %rcx      # 0x5fd8
movq (%rcx), %rbx
movl %eax, %edi
callq 0x2210
leaq 0x183a(%rip), %rsi      # 0x4014
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2220
movq 0x58(%rsp), %rdi
cmpq %r13, %rdi
je 0x27fe
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2160
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2818
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2160
movl $0x1, %eax
addq $0x598, %rsp            # imm = 0x598
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r14d, %edi
callq 0x22d0
leaq 0x110(%rsp), %rsi
movl $0x3e7, %edx            # imm = 0x3E7
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20b0
movq %rax, %r15
cmpl $-0x1, %r15d
je 0x2c78
movb 0x110(%rsp), %al
movb %al, 0x14(%rsp)
movl 0x111(%rsp), %r14d
movl 0x115(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0x119(%rsp), %eax
movl %eax, 0x24(%rsp)
movq 0x3746(%rip), %rdi      # 0x5fd0
leaq 0x17e6(%rip), %rsi      # 0x4077
movl $0x1c, %edx
callq 0x21a0
leaq 0x38(%rsp), %rsi
movb 0x14(%rsp), %al
movb %al, (%rsi)
movq 0x3723(%rip), %rdi      # 0x5fd0
movl $0x1, %edx
callq 0x21a0
movq %rax, %r12
leaq 0x17d3(%rip), %rsi      # 0x4094
movl $0xf, %edx
movq %rax, %rdi
callq 0x21a0
movq %r12, %rdi
movl %r14d, %esi
callq 0x2260
movq %rax, %r12
leaq 0x17c1(%rip), %rsi      # 0x40a4
movl $0x15, %edx
movq %rax, %rdi
callq 0x21a0
movq %r12, %rdi
movl 0x10(%rsp), %esi
callq 0x2260
movq %rax, %r12
leaq 0x17b4(%rip), %rsi      # 0x40ba
movl $0xf, %edx
movq %rax, %rdi
callq 0x21a0
movq %r12, %rdi
movl 0x24(%rsp), %esi
callq 0x2260
movq %rax, %r12
leaq 0x17a1(%rip), %rsi      # 0x40ca
movl $0x25, %edx
movq %rax, %rdi
callq 0x21a0
leaq 0x16d1(%rip), %rsi      # 0x400e
movl $0x5, %edx
movq %r12, %rdi
callq 0x21a0
leaq 0x18fc(%rip), %rsi      # 0x424d
movl $0x1, %edx
movq %r12, %rdi
callq 0x21a0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movslq %r15d, %rdx
movq 0xa8(%rsp), %rax
movq 0x18(%rax), %r8
movl 0x10(%rax), %r9d
leaq 0x110(%rsp), %rsi
movl 0x18(%rsp), %edi
xorl %ecx, %ecx
callq 0x2050
movq %rax, %r15
cmpl $-0x1, %r15d
je 0x2c7d
movq 0x3610(%rip), %rdi      # 0x5fd0
leaq 0x1739(%rip), %rsi      # 0x4100
movl $0x38, %edx
callq 0x21a0
movq 0x35f8(%rip), %rdi      # 0x5fd0
leaq 0x1646(%rip), %rsi      # 0x4025
movl $0x5, %edx
callq 0x21a0
movq 0x35e0(%rip), %r12      # 0x5fd0
leaq 0x1856(%rip), %rsi      # 0x424d
movl $0x1, %edx
movq %r12, %rdi
callq 0x21a0
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x35ad(%rip), %rdi      # 0x5fd0
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movslq %r15d, %rdx
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %r8
movl 0x10(%rax), %r9d
leaq 0x110(%rsp), %rsi
movl 0x18(%rsp), %edi
xorl %ecx, %ecx
callq 0x2050
cmpl $-0x1, %eax
je 0x2c82
movq 0x356a(%rip), %rdi      # 0x5fd0
leaq 0x16dc(%rip), %rsi      # 0x4149
movl $0x38, %edx
callq 0x21a0
movq 0x3552(%rip), %rdi      # 0x5fd0
leaq 0x15a0(%rip), %rsi      # 0x4025
movl $0x5, %edx
callq 0x21a0
movq 0x353a(%rip), %r12      # 0x5fd0
leaq 0x17b0(%rip), %rsi      # 0x424d
movl $0x1, %edx
movq %r12, %rdi
callq 0x21a0
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x3507(%rip), %rdi      # 0x5fd0
callq 0x2030
movq %rax, %rdi
callq 0x20e0
leaq 0x110(%rsp), %rsi
movl $0x3e7, %edx            # imm = 0x3E7
movl 0x18(%rsp), %edi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2100
cmpl $-0x1, %eax
je 0x2c87
movslq %eax, %r8
leaq 0x78(%rsp), %rdi
movq 0x8(%rdi), %rdx
xorl %r15d, %r15d
leaq 0x110(%rsp), %rcx
xorl %esi, %esi
callq 0x2240
leaq 0x2c(%rsp), %rdx
movl %r15d, (%rdx)
leaq 0x28(%rsp), %rcx
movl %r15d, (%rcx)
leaq 0xf(%rsp), %r8
movb %r15b, (%r8)
leaq 0xe(%rsp), %r9
movb %r15b, (%r9)
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x31c8
cmpl $0x0, 0x2c(%rsp)
je 0x2b58
cmpl $0x0, 0x28(%rsp)
jne 0x2bbd
leaq 0x110(%rsp), %rsi
movl $0x3e7, %edx            # imm = 0x3E7
movl 0x18(%rsp), %edi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2100
cmpl $-0x1, %eax
je 0x2d0b
movslq %eax, %r8
leaq 0x78(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x110(%rsp), %rcx
xorl %esi, %esi
callq 0x2240
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x2c(%rsp), %rdx
leaq 0x28(%rsp), %rcx
leaq 0xf(%rsp), %r8
leaq 0xe(%rsp), %r9
callq 0x31c8
movsbl 0xf(%rsp), %edi
movsbl 0xe(%rsp), %esi
movsbl 0x14(%rsp), %edx
movl %r14d, %ecx
movl 0x10(%rsp), %r8d
callq 0x33f2
movl %eax, %r12d
cmpb $0x65, %al
jne 0x2bfa
leaq 0x1713(%rip), %rdi      # 0x42fa
callq 0x2130
movl %ebx, %edi
callq 0x22d0
xorl %edi, %edi
callq 0x21b0
movzbl %r12b, %eax
cmpl $0x79, %eax
jne 0x2c8c
leaq 0x110(%rsp), %rcx
movl %r14d, (%rcx)
movl 0x10(%rsp), %eax
movl %eax, 0x4(%rcx)
movl 0x24(%rsp), %eax
movl %eax, 0x8(%rcx)
movb 0x14(%rsp), %al
movb %al, 0xc(%rcx)
leaq 0x58(%rsp), %rdi
movl $0xd, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x2190
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x98(%rsp), %rax
movq 0x18(%rax), %r8
movl 0x10(%rax), %r9d
movl 0x18(%rsp), %edi
xorl %ecx, %ecx
callq 0x2050
cmpl $-0x1, %eax
jne 0x2d10
callq 0x231a
callq 0x2398
callq 0x2383
callq 0x236e
callq 0x2359
callq 0x2344
callq 0x232f
leaq 0x48(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x166e(%rip), %rsi      # 0x430a
leaq 0x1668(%rip), %rdx      # 0x430b
leaq 0x38(%rsp), %rdi
callq 0x38c2
leaq 0x38(%rsp), %rdi
movq 0x8(%rdi), %rsi
movsbl %r12b, %r8d
movl $0x1, %ecx
xorl %edx, %edx
callq 0x22b0
movq 0x38(%rsp), %rsi
movl $0x2, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20d0
cmpq $-0x1, %rax
jne 0x2ceb
leaq 0x15c9(%rip), %rdi      # 0x42af
callq 0x2130
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x2bec
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2160
jmp 0x2bec
callq 0x22f0
movq 0x32b9(%rip), %rdi      # 0x5fd0
leaq 0x1480(%rip), %rsi      # 0x419e
movl $0x5c, %edx
callq 0x21a0
movq 0x32a1(%rip), %rdi      # 0x5fd0
leaq 0x14c5(%rip), %rsi      # 0x41fb
movl $0x1d, %edx
callq 0x21a0
movq 0x3289(%rip), %rdi      # 0x5fd0
leaq 0x12d7(%rip), %rsi      # 0x4025
movl $0x5, %edx
callq 0x21a0
movq 0x3271(%rip), %rdi      # 0x5fd0
leaq 0x14e7(%rip), %rsi      # 0x424d
movl $0x1, %edx
callq 0x21a0
movq 0x3259(%rip), %rdi      # 0x5fd0
callq 0x20c0
leaq 0x110(%rsp), %rsi
movl $0x3e7, %edx            # imm = 0x3E7
movl 0x18(%rsp), %edi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2100
movq %rax, 0x18(%rsp)
cmpl $-0x1, 0x18(%rsp)
jne 0x2dab
callq 0x2305
leaq 0x11c(%rsp), %rax
movss -0xc(%rax), %xmm0
movss %xmm0, 0x14(%rsp)
movss -0x8(%rax), %xmm0
movss %xmm0, 0x10(%rsp)
movss -0x4(%rax), %xmm0
movss %xmm0, 0x24(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x1c(%rax), %xmm2
movaps %xmm0, 0xe0(%rsp)
movaps %xmm1, 0xf0(%rsp)
movups %xmm2, 0xfc(%rsp)
movq 0x31d2(%rip), %rdi      # 0x5fd0
leaq 0x141e(%rip), %rsi      # 0x4223
movl $0x2b, %edx
callq 0x21a0
movq 0x31ba(%rip), %rdi      # 0x5fd0
leaq 0x1432(%rip), %rsi      # 0x424f
movl $0xf, %edx
callq 0x21a0
xorl %r12d, %r12d
movq 0x319f(%rip), %r15      # 0x5fd0
movl 0xe0(%rsp,%r12,4), %r14d
cmpl $0x91d, %r14d           # imm = 0x91D
je 0x2e6f
testq %r12, %r12
je 0x2e5b
movl $0x4, %edx
movq %r15, %rdi
leaq 0x1409(%rip), %rsi      # 0x425f
callq 0x21a0
movq %r15, %rdi
movl %r14d, %esi
callq 0x2260
incq %r12
cmpq $0xb, %r12
jne 0x2e31
movq 0x315a(%rip), %rdi      # 0x5fd0
leaq 0x13e7(%rip), %rsi      # 0x4264
movl $0x14, %edx
callq 0x21a0
xorps %xmm0, %xmm0
cvtss2sd 0x14(%rsp), %xmm0
movq 0x3139(%rip), %rdi      # 0x5fd0
callq 0x2250
movq %rax, %r15
leaq 0x13d3(%rip), %rsi      # 0x4279
movl $0x18, %edx
movq %rax, %rdi
callq 0x21a0
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rsp), %xmm0
movq %r15, %rdi
callq 0x2250
movq %rax, %r15
leaq 0x13c4(%rip), %rsi      # 0x4292
movl $0x16, %edx
movq %rax, %rdi
callq 0x21a0
xorps %xmm0, %xmm0
cvtss2sd 0x24(%rsp), %xmm0
movq %r15, %rdi
callq 0x2250
movq %rax, %r15
leaq 0x13b3(%rip), %rsi      # 0x42a9
movl $0x3, %edx
movq %rax, %rdi
callq 0x21a0
movq %r15, %rdi
callq 0x20c0
leaq 0x48(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1392(%rip), %rsi      # 0x42ad
leaq 0x138c(%rip), %rdx      # 0x42ae
leaq 0x38(%rsp), %rdi
callq 0x38c2
movslq 0x18(%rsp), %rdx
leaq 0x38(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x2060
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20d0
cmpq $-0x1, %rax
jne 0x2f68
leaq 0x134c(%rip), %rdi      # 0x42af
callq 0x2130
movq 0x3061(%rip), %rdi      # 0x5fd0
leaq 0x1341(%rip), %rsi      # 0x42b7
movl $0x42, %edx
callq 0x21a0
movq 0x3049(%rip), %rdi      # 0x5fd0
leaq 0x1080(%rip), %rsi      # 0x400e
movl $0x5, %edx
callq 0x21a0
movq 0x3031(%rip), %rdi      # 0x5fd0
leaq 0x12a7(%rip), %rsi      # 0x424d
movl $0x1, %edx
callq 0x21a0
movq 0x3019(%rip), %rdi      # 0x5fd0
callq 0x20c0
jmp 0x2ceb
jmp 0x2fc7
jmp 0x2feb
jmp 0x2feb
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x2fee
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2160
jmp 0x2fee
jmp 0x2feb
jmp 0x2feb
jmp 0x2feb
jmp 0x2feb
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r13, %rdi
je 0x3005
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2160
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
je 0x301f
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2280