// File: /workspace/github_cpp_makefile_star2_O1/Computer-Kids-Club[P]screenshare-pro-backend/server.cpp
// Function: main
int main(int argc, char *argv[]) {
    int opt = TRUE;
    int master_socket, addrlen, new_socket,
        max_clients = 30, activity, i, valread, sd;
    int max_sd;
    struct sockaddr_in address;

    bool doPrintSocketFrame = false;
    bool doPrintSocketFrameStats = false;

    // yes
    for (int i = 0; i < argc; i++) {
        if (argv[i][0] == '-') {
            if (strcmp(argv[i], "-pf") == 0) {
                doPrintSocketFrame = true;
            } else if (strcmp(argv[i], "-pfs") == 0) {
                doPrintSocketFrameStats = true;
            }
        }
    }

    unsigned long long totalFramesRecieved = 1;
    unsigned long long totalFramesSent = 1;
    unsigned long long lastFrameLength = 0;
    unsigned long long totalFrameLength = 0;

    std::unordered_map<std::string, int> urlToSocketDesc;
    std::unordered_map<int, std::vector<Client>> socketDescToClients;
    std::unordered_map<int, int> clientSocketDescToStreamerSocketDesc;
    std::unordered_map<int, Client> clients;

    char buffer[BUFFER_SIZE + 1];       //data buffer of 1K
    char send_buffer[BUFFER_SIZE + 1];  //data buffer of 1K

    //set of socket descriptors
    fd_set readfds;

    //create a master socket
    if ((master_socket = socket(AF_INET, SOCK_STREAM, 0)) == 0) {
        perror("socket failed");
        exit(EXIT_FAILURE);
    }

    //set master socket to allow multiple connections ,
    //this is just a good habit, it will work without this
    if (setsockopt(master_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&opt,
                   sizeof(opt)) < 0) {
        perror("setsockopt");
        exit(EXIT_FAILURE);
    }

    //type of socket created
    address.sin_family = AF_INET;
    address.sin_addr.s_addr = INADDR_ANY;
    address.sin_port = htons(PORT);

    //bind the socket to localhost port 4004
    if (0 > bind(master_socket, (struct sockaddr *)&address, sizeof(address))) {
        perror("bind failed");
        exit(EXIT_FAILURE);
    }
    printf(COLOR_RESET "Listener on port %d \n", PORT);

    //try to specify maximum of 3 pending connections for the master socket
    if (listen(master_socket, 3) < 0) {
        perror("listen");
        exit(EXIT_FAILURE);
    }

    //accept the incoming connection
    addrlen = sizeof(address);
    puts("Waiting for connections ...");

    while (TRUE) {
        //clear the socket set
        FD_ZERO(&readfds);

        //add master socket to set
        FD_SET(master_socket, &readfds);
        max_sd = master_socket;

        //add child sockets to set
        for (auto &clientFromClients : clients) {
            Client client = clientFromClients.second;
            //socket descriptor
            sd = client.socket_descriptor;

            //if valid socket descriptor then add to read list
            if (sd > 0)
                FD_SET(sd, &readfds);

            //highest file descriptor number, need it for the select function
            if (sd > max_sd)
                max_sd = sd;

            if (client.last_ping != -1) {
                if (client.last_ping != -1) {
                }
            }
        }

        //wait for an activity on one of the sockets , timeout is NULL ,
        //so wait indefinitely
        activity = select(max_sd + 1, &readfds, NULL, NULL, NULL);

        if ((activity < 0) && (errno != EINTR)) {
            printf("select error");
        }

        //If something happened on the master socket ,
        //then its an incoming connection
        if (FD_ISSET(master_socket, &readfds)) {
            if (0 > (new_socket = accept(master_socket, (struct sockaddr *)&address, (socklen_t *)&addrlen))) {
                perror("accept");
                exit(EXIT_FAILURE);
            }

            //inform user of socket number - used in send and receive commands
            printf(GREEN("New connection , socket fd is %d , ip is : %s , port : %d  \n"), new_socket, inet_ntoa(address.sin_addr), ntohs(address.sin_port));

            //puts("Welcome message sent successfully");

            clients[new_socket] = {new_socket, 0, "", -1};
            // clients.push_back({new_socket, 0});
            //printf("Adding to list of sockets as %d\n", i);
        }

        //else its some IO operation on some other socket
        // for (auto socketClientPair = clients.begin(); socketClientPair != clients.end(); ++socketClientPair) { //&socketClientPair : clients)
        auto it = clients.begin();
        while (it != clients.end()) {
            if (doPrintSocketFrameStats) {
                printf(COLOR_RESET "Total frames recieved: %llu\n", totalFramesRecieved);
                printf(COLOR_RESET "Total frames sent: %llu\n", totalFramesSent);
                printf(COLOR_RESET "Last frame length: %llu\n", lastFrameLength);
                printf(COLOR_RESET "Average frame length: %llu\n\n", totalFrameLength / totalFramesRecieved);
            }

            Client client = it->second;
            auto previous_it = it;
            ++it;
            //socket descriptor
            sd = client.socket_descriptor;
            if (FD_ISSET(sd, &readfds)) {
                //Check if it was for closing , and also read the
                //incoming message
                memset(buffer, 0, sizeof(buffer));

                int read_size = BUFFER_SIZE;

                if (client.startedWS == 1) {
                    read_size = 10;
                }
                if ((valread = read(sd, buffer, read_size)) == 0) {
                    //Somebody disconnected , get his details and print
                    getpeername(sd, (struct sockaddr *)&address, (socklen_t *)&addrlen);
                    printf(MAGENTA("Host disconnected , ip %s , port %d \n"), inet_ntoa(address.sin_addr), ntohs(address.sin_port));

                    //Close the socket and mark as 0 in list for reuse
                    close(sd);
                    //socketDescToClients[sd].erase(std::remove(socketDescToClients[sd].begin(), socketDescToClients[sd].end(), clients[sd]), socketDescToClients[sd].end());
                    it = clients.erase(previous_it);
                    continue;
                } else {
                    //set the string terminating NULL byte on the end
                    //of the data read
                    buffer[valread] = '\0';

                    if (client.startedWS == 1) {
                        unsigned int fin = (unsigned int)(buffer[0] & 0b10000000) == 0b10000000;
                        unsigned int opcode = (unsigned int)(buffer[0] & 0b00001111);
                        if (opcode > 2) {
                            //printf(BACK_YELLOW(RED("Something is very wrong: 1.") "\n=============================================================\n"));
                            //continue;
                        } else if (fin == 0 || opcode == 0) {
                            //printf(BACK_YELLOW(RED("Something is very wrong: 2.") "\n=============================================================\n"));
                            continue;
                        }
                        unsigned long payload_length = (unsigned int)(buffer[1] & 0b01111111);
                        unsigned int bit_offset = 2;
                        if (payload_length == 126) {
                            bit_offset += 2;
                            payload_length = (unsigned int)(buffer[2] & 0b11111111);
                            payload_length = payload_length << 8;
                            payload_length += (unsigned int)(buffer[3] & 0b11111111);
                        } else if (payload_length == 127) {
                            bit_offset += 8;
                            payload_length = (unsigned int)(buffer[2] & 0b11111111);
                            for (int shift_i = 0; shift_i < 7; shift_i++) {
                                payload_length = payload_length << 8;
                                payload_length += (unsigned int)(buffer[3 + shift_i] & 0b11111111);
                            }
                        }
                        if (doPrintSocketFrame) {
                            printf(BACK_YELLOW("================= Recieved websocket Frame ==================") ".");
                            printf("\n" BACK_YELLOW(" ") " Fin: %x ", fin);
                            printf(("Opcode: %x "), opcode);
                            printf(("Is masked: %d "), (unsigned int)((buffer[1] & 0b10000000) == 0b10000000));
                            printf(("Payload length: %lu"), payload_length);
                            printf(("\n" BACK_YELLOW(" ") " Mask: %x %x %x %x "),
                                   (unsigned int)(buffer[bit_offset + 0] & 0b11111111),
                                   (unsigned int)(buffer[bit_offset + 1] & 0b11111111),
                                   (unsigned int)(buffer[bit_offset + 2] & 0b11111111),
                                   (unsigned int)(buffer[bit_offset + 3] & 0b11111111));
                        }

                        bit_offset += 4;

                        totalFramesRecieved++;

                        int totalread = valread;
                        if (payload_length + bit_offset + 1 > BUFFER_SIZE) {
                            while (totalread < payload_length + bit_offset && (valread = read(sd, buffer, payload_length + bit_offset - totalread)) != 0) {
                                totalread += valread;
                            }
                            lastFrameLength = totalread;
                            totalFrameLength += totalread;
                            printf(BACK_YELLOW(RED("Dropped frame.")) " (Frame size is greater than %d bytes)\n", BUFFER_SIZE);
                            continue;
                        };
                        while (totalread < payload_length + bit_offset) {
                            valread = read(sd, buffer + totalread, payload_length + bit_offset - totalread);
                            totalread += valread;
                        }
                        lastFrameLength = totalread;
                        totalFrameLength += totalread;
                        buffer[totalread] = '\0';
                        if (doPrintSocketFrame) {
                            printf(("Total read length: %d\n"), totalread);
                            printf(BACK_YELLOW("=============================================================\n"));
                        }

                        //printf("Unmasked payload: \n>");
                        for (int payload_i = 0; payload_i < payload_length; payload_i++) {
                            buffer[bit_offset + payload_i] = buffer[bit_offset + payload_i] ^ buffer[bit_offset - 4 + payload_i % 4];
                            //printf("%c", buffer[bit_offset + payload_i]);
                        }

                        if (payload_length > 7 && buffer[bit_offset + 2] == 'h' && buffer[bit_offset + 3] == 'r' && buffer[bit_offset + 4] == 'e' && buffer[bit_offset + 5] == 'f') {
                            std::string url = std::string(buffer + bit_offset + 9, buffer + bit_offset - 2 + payload_length);
                            printf("%s\n", url.c_str());
                            if (url.compare(baseUrl) == 0) {
                                std::string stream_url = url + std::to_string(sd);
                                urlToSocketDesc[stream_url] = sd;
                                socketDescToClients[sd] = std::vector<Client>();

                                int send_len = generate_ws_frame(send_buffer, "{\"url\":\"" + stream_url + "\",\"streamer\":" + std::to_string(sd) + "}");

                                if (send(sd, send_buffer, send_len, 0) != send_len) {
                                    perror("send");
                                }

                                continue;
                            } else {
                                previous_it->second.url = url;
                                clientSocketDescToStreamerSocketDesc[sd] = urlToSocketDesc[url];
                                socketDescToClients[urlToSocketDesc[url]].push_back(previous_it->second);

                                int send_len = generate_ws_frame(send_buffer, "{\"watcher\":" + std::to_string(sd) + ",\"streamer\":" + std::to_string(urlToSocketDesc[url]) + "}");

                                if (send(sd, send_buffer, send_len, 0) != send_len) {
                                    perror("send");
                                }
                            }
                            continue;
                        }

                        if (opcode != 1 && opcode != 2) {
                            continue;
                        }

                        //printf("Bit offset: %d\n", bit_offset);

                        for (int payload_i = 0; payload_i < payload_length; payload_i++) {
                            buffer[bit_offset - 4 + payload_i] = buffer[bit_offset + payload_i];
                        }

                        buffer[0] = buffer[0] & 0b10001111;
                        buffer[1] = buffer[1] & 0b01111111;

                        opcode = (unsigned int)(buffer[0] & 0b00001111);

                        buffer[bit_offset - 4 + payload_length] = '\0';
                        buffer[bit_offset - 3 + payload_length] = '\0';
                        buffer[bit_offset - 2 + payload_length] = '\0';
                        buffer[bit_offset - 1 + payload_length] = '\0';

                        int target_sd_bit_offset = bit_offset - 4;
                        if (buffer[target_sd_bit_offset] == 't' && buffer[target_sd_bit_offset + 1] == 'o') {
                            int target_sd = 0;
                            target_sd_bit_offset += 2;
                            while (buffer[target_sd_bit_offset] != '{') {
                                target_sd = target_sd * 10 + buffer[target_sd_bit_offset++] - '0';
                            }
                            if (send(target_sd, buffer, bit_offset - 4 + payload_length, 0) != bit_offset - 4 + payload_length) {
                                perror("send");
                            } else {
                                totalFramesSent++;
                            }
                        } else if (clientSocketDescToStreamerSocketDesc[sd] && clientSocketDescToStreamerSocketDesc[sd] != sd) {
                            if (send(clientSocketDescToStreamerSocketDesc[sd], buffer, bit_offset - 4 + payload_length, 0) != bit_offset - 4 + payload_length) {
                                perror("send");
                            } else {
                                totalFramesSent++;
                            }
                        } else {
                            for (auto clientForSocket = socketDescToClients[sd].begin(); clientForSocket != socketDescToClients[sd].end();) {
                                if (send(clientForSocket->socket_descriptor, buffer, bit_offset - 4 + payload_length, 0) != bit_offset - 4 + payload_length) {
                                    perror("send");
                                    clientForSocket = socketDescToClients[sd].erase(clientForSocket);
                                } else {
                                    totalFramesSent++;
                                    clientForSocket++;
                                }
                            }
                        }

                        continue;
                    }

                    std::unordered_map<std::string, std::string> headerMap = parse_header(buffer, buffer + valread);

                    if (headerMap.count("Sec-WebSocket-Key") == 1) {
                        printf(GREEN("Recieved ws request\n"));
                        printf(CYAN("%s\n"), buffer);

                        char sha1_handshake[40];
                        size_t handshake_sz;

                        memset(sha1_handshake, 0, sizeof(sha1_handshake));
                        if (ws_compute_handshake(headerMap["Sec-WebSocket-Key"].c_str(), sha1_handshake, &handshake_sz) != 0) {
                            /* failed to compute handshake. */
                            printf("failed to compute handshake\n");
                            continue;
                        }

                        //printf("%s\n", sha1_handshake);

                        std::string strWSResponse = "HTTP/1.1 101 Switching Protocols\r\nUpgrade: WebSocket\r\nConnection: Upgrade\r\n";
                        strWSResponse += "Sec-WebSocket-Accept: ";
                        strWSResponse += sha1_handshake;
                        strWSResponse += "\r\n";
                        const char *strWSResponseMsg = strWSResponse.c_str();

                        //send websocket response
                        if (send(sd, strWSResponseMsg, strlen(strWSResponseMsg), 0) != strlen(strWSResponseMsg)) {
                            perror("send");
                        }

                        previous_it->second.startedWS = 1;

                    } else {
                        printf(GREEN("Recieved http request\n"));
                        printf(RED("%s\n"), buffer);
                    }

                    /*for (auto x : headerMap)
                    {
                        //cout << x.first << " " << x.second << endl;
                        printf(">%s< -> >%s<\n", x.first.c_str(), x.second.c_str());
                    }*/
                    //send(sd, buffer, strlen(buffer), 0);
                }
            }
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20338, %rsp          # imm = 0x20338
movl $0x1, -0x15c(%rbp)
testl %edi, %edi
jle 0x262a
movq %rsi, %rbx
movl %edi, %r13d
xorl %r15d, %r15d
leaq 0x4a62(%rip), %r14      # 0x7020
movq $0x0, -0x130(%rbp)
movl $0x0, -0x84(%rbp)
movq (%rbx,%r15,8), %r12
cmpb $0x2d, (%r12)
jne 0x2620
movq %r12, %rdi
movq %r14, %rsi
callq 0x22a0
testl %eax, %eax
je 0x2617
movq %r12, %rdi
leaq 0x4a2d(%rip), %rsi      # 0x7024
callq 0x22a0
testl %eax, %eax
movl -0x84(%rbp), %eax
movzbl %al, %eax
movl $0x1, %ecx
cmovel %ecx, %eax
movl %eax, -0x84(%rbp)
jmp 0x2620
movb $0x1, %al
movq %rax, -0x130(%rbp)
incq %r15
cmpq %r15, %r13
jne 0x25d3
jmp 0x263f
movl $0x0, -0x84(%rbp)
movq $0x0, -0x130(%rbp)
leaq -0x2b0(%rbp), %rax
movq %rax, -0x30(%rax)
movl $0x1, %ecx
movq %rcx, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, %edx       # imm = 0x3F800000
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq -0x208(%rbp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq -0x278(%rbp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq -0x240(%rbp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2080
testl %eax, %eax
je 0x3c54
movl %eax, %r12d
leaq -0x15c(%rbp), %rcx
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x2330
testl %eax, %eax
js 0x3c5d
movl $0xa40f0002, %eax       # imm = 0xA40F0002
leaq -0x16c(%rbp), %rsi
movq %rax, (%rsi)
movl %r12d, %edi
movl $0x10, %edx
callq 0x2060
testl %eax, %eax
js 0x3c66
leaq 0x492d(%rip), %rdi      # 0x704e
movl $0xfa4, %esi            # imm = 0xFA4
xorl %eax, %eax
callq 0x2040
movl %r12d, %edi
movl $0x3, %esi
callq 0x2230
testl %eax, %eax
js 0x3c6f
leaq -0x124(%rbp), %rax
movl $0x10, (%rax)
leaq 0x4919(%rip), %rdi      # 0x706f
callq 0x22e0
leal 0x3f(%r12), %eax
testl %r12d, %r12d
cmovnsl %r12d, %eax
movl %eax, %edx
andl $-0x40, %edx
movl %r12d, %ecx
subl %edx, %ecx
movl $0x1, %edx
movq %rdx, -0x138(%rbp)
shlq %cl, %rdx
movq %rdx, -0x200(%rbp)
sarl $0x6, %eax
cltq
movq %rax, -0x188(%rbp)
movq $0x0, -0x180(%rbp)
xorl %r14d, %r14d
movl $0x1, %eax
movq %rax, -0x178(%rbp)
movq %r12, -0x58(%rbp)
movq %r14, %r15
xorps %xmm0, %xmm0
movaps %xmm0, -0x2f0(%rbp)
movaps %xmm0, -0x300(%rbp)
movaps %xmm0, -0x310(%rbp)
movaps %xmm0, -0x320(%rbp)
movaps %xmm0, -0x330(%rbp)
movaps %xmm0, -0x340(%rbp)
movaps %xmm0, -0x350(%rbp)
movaps %xmm0, -0x360(%rbp)
movq -0x200(%rbp), %r13
movq -0x188(%rbp), %rax
orq %r13, -0x360(%rbp,%rax,8)
movq -0x260(%rbp), %r14
movl %r12d, %ebx
testq %r14, %r14
je 0x28a3
movq 0x10(%r14), %rax
movq %rax, -0x118(%rbp)
leaq -0x100(%rbp), %rax
movq %rax, -0x110(%rbp)
movq 0x18(%r14), %rsi
movq 0x20(%r14), %rdx
addq %rsi, %rdx
leaq -0x110(%rbp), %rdi
callq 0x40ee
movl 0x38(%r14), %eax
movl %eax, -0xf0(%rbp)
movl -0x118(%rbp), %ecx
movl %ecx, -0x2c(%rbp)
testl %ecx, %ecx
jle 0x2874
movl $0x1, %eax
shlq %cl, %rax
movl %ecx, %edx
shrl $0x6, %edx
orq %rax, -0x360(%rbp,%rdx,8)
cmpl %ebx, %ecx
cmovgl %ecx, %ebx
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x289b
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x2200
movq (%r14), %r14
jmp 0x280f
incl %ebx
movl %ebx, %edi
leaq -0x360(%rbp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x21e0
movq %r15, %r14
testl %eax, %eax
jns 0x28d9
callq 0x2030
cmpl $0x4, (%rax)
je 0x28d9
leaq 0x47b9(%rip), %rdi      # 0x708b
xorl %eax, %eax
callq 0x2040
movq -0x188(%rbp), %rax
testq %r13, -0x360(%rbp,%rax,8)
je 0x29e2
movl %r12d, %edi
leaq -0x16c(%rbp), %rsi
leaq -0x124(%rbp), %rdx
callq 0x20d0
movl %eax, %ebx
movl %eax, -0x120(%rbp)
testl %eax, %eax
js 0x3c3e
movl -0x168(%rbp), %edi
callq 0x2110
movzwl -0x16a(%rbp), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
leaq 0x476b(%rip), %rdi      # 0x709f
movl %ebx, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2040
movl -0x120(%rbp), %eax
movl %eax, -0x118(%rbp)
movl $0x0, -0x114(%rbp)
leaq -0x100(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x110(%rbp), %rdi
leaq 0x47ee(%rip), %rdx      # 0x7160
movq %rdx, %rsi
callq 0x48f0
movl $0xffffffff, -0xf0(%rbp) # imm = 0xFFFFFFFF
leaq -0x270(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x45a0
movq %rax, %rbx
movq -0x118(%rbp), %rax
movq %rax, (%rbx)
movq %rbx, %rdi
addq $0x8, %rdi
leaq -0x110(%rbp), %rsi
callq 0x2280
movl -0xf0(%rbp), %eax
movl %eax, 0x28(%rbx)
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x29e2
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x260(%rbp), %r13
testq %r13, %r13
je 0x27b1
jmp 0x32e5
leaq 0x4943(%rip), %rdi      # 0x7341
callq 0x21c0
jmp 0x3acb
leaq 0x4932(%rip), %rdi      # 0x7341
callq 0x21c0
jmp 0x3bf9
movl -0x2c(%rbp), %ebx
movl %ebx, %r14d
negl %r14d
cmovsl %ebx, %r14d
movl $0x1, %r12d
cmpl $0xa, %r14d
jb 0x2e54
movl $0x4, %r12d
movl %r14d, %eax
cmpl $0x63, %eax
jbe 0x2e4b
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x2e51
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x2e54
movl %eax, %ecx
movl $0xd1b71759, %edx       # imm = 0xD1B71759
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r12d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x2a3f
addl $-0x3, %r12d
jmp 0x2e54
addl $-0x2, %r12d
jmp 0x2a8c
decl %r12d
shrl $0x1f, %ebx
leal (%r12,%rbx), %esi
leaq -0x148(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0x158(%rbp), %r13
movq %r13, %rdi
movl $0x2d, %edx
callq 0x2250
addq -0x158(%rbp), %rbx
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x4195
movl $0xb, %r8d
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x4868(%rip), %rcx      # 0x7346
callq 0x2240
leaq -0x70(%rbp), %r12
movq %r12, -0x80(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2b07
movq %rdx, -0x80(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x70(%rbp)
jmp 0x2b0f
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, -0x78(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x80(%rbp), %rdi
leaq 0x4801(%rip), %rsi      # 0x7332
callq 0x2360
leaq -0x40(%rbp), %rsi
movq %rsi, -0x50(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2b5a
movq %rdx, -0x50(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x40(%rbp)
jmp 0x2b60
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
leaq -0x118(%rbp), %rsi
movq 0x8(%rax), %rdx
movq %rdx, -0x48(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x2e0(%rbp), %rdi
callq 0x4a4e
movl (%rax), %ebx
movl %ebx, %r14d
negl %r14d
cmovsl %ebx, %r14d
movl $0x1, %r12d
cmpl $0xa, %r14d
jb 0x2be9
movl $0x4, %r12d
movl %r14d, %eax
cmpl $0x63, %eax
jbe 0x2be0
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x2be6
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x2be9
movl %eax, %ecx
movl $0xd1b71759, %edx       # imm = 0xD1B71759
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r12d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x2bab
addl $-0x3, %r12d
jmp 0x2be9
addl $-0x2, %r12d
jmp 0x2be9
decl %r12d
shrl $0x1f, %ebx
leal (%r12,%rbx), %esi
leaq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0xd0(%rbp), %rdi
movl $0x2d, %edx
callq 0x2250
addq -0xd0(%rbp), %rbx
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x4195
movq -0x50(%rbp), %rcx
movl $0xf, %esi
leaq -0x40(%rbp), %rax
cmpq %rax, %rcx
je 0x2c3a
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %r8
movq -0xc8(%rbp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
leaq -0xa0(%rbp), %r14
leaq -0x70(%rbp), %r12
jbe 0x2c7a
movl $0xf, %esi
leaq -0xc0(%rbp), %rdi
cmpq %rdi, -0xd0(%rbp)
je 0x2c75
movq -0xc0(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x2c8c
movq -0xd0(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x20c0
jmp 0x2c9c
leaq -0xd0(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2240
movq %r14, -0xb0(%rbp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x2cc2
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0x2cc9
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0xa8(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq -0xb0(%rbp), %rdi
leaq 0x4649(%rip), %rsi      # 0x733f
callq 0x2360
leaq -0x198(%rbp), %rsi
movq %rsi, -0x1a8(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2d2b
movq %rdx, -0x1a8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x198(%rbp)
jmp 0x2d31
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x1a0(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x20360(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x6b0b
movl %eax, %ebx
movq -0x1a8(%rbp), %rdi
leaq -0x198(%rbp), %rax
cmpq %rax, %rdi
je 0x2d82
movq -0x198(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2d9d
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
movq -0xd8(%rbp), %r14
je 0x2dc6
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x2ddf
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x80(%rbp), %rdi
cmpq %r12, %rdi
je 0x2df4
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x158(%rbp), %rdi
leaq -0x148(%rbp), %rax
cmpq %rax, %rdi
movq -0x58(%rbp), %r12
je 0x2e1a
movq -0x148(%rbp), %rsi
incq %rsi
callq 0x2200
movl -0x2c(%rbp), %edi
movslq %ebx, %rbx
leaq -0x20360(%rbp), %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x2130
cmpq %rbx, %rax
je 0x32ac
leaq 0x4500(%rip), %rdi      # 0x7341
callq 0x21c0
jmp 0x32ac
addl $-0x2, %r12d
jmp 0x2e54
decl %r12d
shrl $0x1f, %ebx
leal (%r12,%rbx), %esi
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %r13
movq %r13, %rdi
movl $0x2d, %edx
callq 0x2250
addq -0x50(%rbp), %rbx
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x4195
movq -0x118(%rbp), %rcx
movq -0x110(%rbp), %r8
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2240
leaq -0xa0(%rbp), %r14
movq %r14, -0xb0(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
leaq -0x70(%rbp), %r12
je 0x2ed4
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0x2edb
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0xa8(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x2f0e
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2200
movl -0x2c(%rbp), %ebx
leaq -0x2e0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4a4e
movl %ebx, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
leaq -0x238(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x4e88
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq (%rax), %rcx
movups 0x8(%rax), %xmm0
movq -0x80(%rbp), %rdx
movq %rdx, (%rax)
movq -0x78(%rbp), %rdx
movq %rdx, 0x8(%rax)
movq -0x70(%rbp), %rdx
movq %rdx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rsi
movq %rcx, -0x50(%rbp)
movups %xmm0, -0x48(%rbp)
movq %rax, -0x80(%rbp)
movq %rdx, -0x78(%rbp)
movq %rsi, -0x70(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3f86
leaq -0x80(%rbp), %rdi
callq 0x3f86
leaq -0x158(%rbp), %rbx
movq %rbx, %rdi
leaq 0x4373(%rip), %rsi      # 0x7328
leaq -0xb0(%rbp), %rdx
callq 0x3ff0
movq %rbx, %rdi
leaq 0x4366(%rip), %rsi      # 0x7331
callq 0x2360
movq %r12, -0x80(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2ff0
movq %rdx, -0x80(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x70(%rbp)
jmp 0x2ff8
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, -0x78(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl -0x2c(%rbp), %ebx
movl %ebx, %r14d
negl %r14d
cmovsl %ebx, %r14d
movl $0x1, %r12d
cmpl $0xa, %r14d
jb 0x306f
movl $0x4, %r12d
movl %r14d, %eax
cmpl $0x63, %eax
jbe 0x3066
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x306c
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x306f
movl %eax, %ecx
movl $0xd1b71759, %edx       # imm = 0xD1B71759
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r12d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x3031
addl $-0x3, %r12d
jmp 0x306f
addl $-0x2, %r12d
jmp 0x306f
decl %r12d
shrl $0x1f, %ebx
leal (%r12,%rbx), %esi
leaq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0xd0(%rbp), %rdi
movl $0x2d, %edx
callq 0x2250
addq -0xd0(%rbp), %rbx
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x4195
movq -0x80(%rbp), %rcx
movl $0xf, %esi
leaq -0x70(%rbp), %r12
cmpq %r12, %rcx
je 0x30c0
movq -0x70(%rbp), %rsi
movq -0x78(%rbp), %r8
movq -0xc8(%rbp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
leaq -0xa0(%rbp), %r14
jbe 0x30fc
movl $0xf, %esi
leaq -0xc0(%rbp), %rdi
cmpq %rdi, -0xd0(%rbp)
je 0x30f7
movq -0xc0(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x310e
movq -0xd0(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x20c0
jmp 0x311e
leaq -0xd0(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2240
leaq -0x40(%rbp), %rsi
movq %rsi, -0x50(%rbp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x313f
movq %rdx, -0x50(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x40(%rbp)
jmp 0x3145
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x48(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq -0x50(%rbp), %rdi
leaq 0x41d3(%rip), %rsi      # 0x733f
callq 0x2360
leaq -0x1b8(%rbp), %rsi
movq %rsi, -0x1c8(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x31a1
movq %rdx, -0x1c8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x1b8(%rbp)
jmp 0x31a7
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x1c0(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x20360(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x6b0b
movl %eax, %ebx
movq -0x1c8(%rbp), %rdi
leaq -0x1b8(%rbp), %rax
cmpq %rax, %rdi
je 0x31f8
movq -0x1b8(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3211
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x3233
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x80(%rbp), %rdi
cmpq %r12, %rdi
je 0x3248
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x158(%rbp), %rdi
leaq -0x148(%rbp), %rax
cmpq %rax, %rdi
movq -0x58(%rbp), %r12
je 0x326e
movq -0x148(%rbp), %rsi
incq %rsi
callq 0x2200
movl -0x2c(%rbp), %edi
movslq %ebx, %rbx
leaq -0x20360(%rbp), %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x2130
cmpq %rbx, %rax
jne 0x32d7
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x32a5
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0xd8(%rbp), %r14
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x3bfd
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x3bfd
leaq 0x4063(%rip), %rdi      # 0x7341
callq 0x21c0
jmp 0x328a
testb $0x1, -0x84(%rbp)
je 0x3349
leaq 0x3df0(%rip), %rdi      # 0x70e5
movq -0x178(%rbp), %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x3df9(%rip), %rdi      # 0x7106
movq -0x138(%rbp), %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x3e01(%rip), %rdi      # 0x7123
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
movq -0x180(%rbp), %rax
xorl %edx, %edx
divq %rbx
leaq 0x3e01(%rip), %rdi      # 0x7140
movq %rax, %rsi
xorl %eax, %eax
callq 0x2040
movq 0x10(%r13), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x1e0(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq 0x18(%r13), %rsi
movq 0x20(%r13), %rdx
addq %rsi, %rdx
leaq -0x1f0(%rbp), %rdi
callq 0x40ee
movl 0x38(%r13), %eax
movl %eax, -0x1d0(%rbp)
movq (%r13), %r15
movl -0x1f8(%rbp), %ebx
movl %ebx, -0x2c(%rbp)
leal 0x3f(%rbx), %eax
testl %ebx, %ebx
cmovnsl %ebx, %eax
sarl $0x6, %eax
cltq
movq -0x360(%rbp,%rax,8), %rax
btq %rbx, %rax
jae 0x3c0b
movq %r15, -0xe0(%rbp)
movq %r14, %r15
movl $0x10000, %edx          # imm = 0x10000
leaq -0x10360(%rbp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x2160
cmpl $0x1, -0x1f4(%rbp)
movl $0xffff, %edx           # imm = 0xFFFF
movl $0xa, %eax
cmoveq %rax, %rdx
movl %ebx, %edi
movq %r14, %rsi
callq 0x22b0
movq %rax, %r12
testl %r12d, %r12d
je 0x3449
movslq %r12d, %rax
movb $0x0, -0x10360(%rbp,%rax)
cmpl $0x1, -0x1f4(%rbp)
jne 0x34af
movzbl -0x10360(%rbp), %esi
movl %esi, %edx
andl $0xf, %edx
cmpl $0x2, %edx
ja 0x35e0
testb %sil, %sil
setns %al
testl %edx, %edx
sete %cl
orb %al, %cl
je 0x35e0
movq -0x58(%rbp), %r12
movq %r15, %r14
movq -0xe0(%rbp), %r15
jmp 0x3c0b
movl -0x2c(%rbp), %edi
leaq -0x16c(%rbp), %rsi
leaq -0x124(%rbp), %rdx
callq 0x2190
movl -0x168(%rbp), %edi
callq 0x2110
movzwl -0x16a(%rbp), %ecx
rolw $0x8, %cx
movzwl %cx, %edx
leaq 0x3ce2(%rip), %rdi      # 0x7161
movq %rax, %rsi
xorl %eax, %eax
callq 0x2040
movl -0x2c(%rbp), %edi
callq 0x2370
leaq -0x270(%rbp), %rdi
movq %r13, %rsi
callq 0x498a
movq -0x58(%rbp), %r12
movq %r15, %r14
movq %rax, %r15
jmp 0x3c0b
leaq (%rax,%rbp), %rdx
addq $-0x10360, %rdx         # imm = 0xFFFEFCA0
leaq -0x118(%rbp), %rbx
movq %rbx, %rdi
leaq -0x10360(%rbp), %rsi
callq 0x5dfc
leaq -0xa0(%rbp), %r14
movq %r14, -0xb0(%rbp)
leaq -0xb0(%rbp), %r12
movq %r12, %rdi
leaq 0x3e63(%rip), %rsi      # 0x7352
leaq 0x3e6d(%rip), %rdx      # 0x7363
callq 0x48f0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x57c4
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3524
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2200
testq %rbx, %rbx
leaq -0x40(%rbp), %r12
leaq -0x50(%rbp), %r14
je 0x3770
leaq 0x3e28(%rip), %rdi      # 0x7364
xorl %eax, %eax
callq 0x2040
leaq 0x3e38(%rip), %rdi      # 0x7382
leaq -0x10360(%rbp), %rsi
xorl %eax, %eax
callq 0x2040
xorps %xmm0, %xmm0
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0xa0(%rbp)
movq $0x0, -0x90(%rbp)
movq %r12, -0x50(%rbp)
movq %r14, %rdi
leaq 0x3dd0(%rip), %rsi      # 0x7352
leaq 0x3dda(%rip), %rdx      # 0x7363
callq 0x48f0
leaq -0x118(%rbp), %rdi
movq %r14, %rsi
callq 0x58d0
movq (%rax), %rdi
leaq -0xb0(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x69d8
movl %eax, %ebx
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x35c7
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2200
testl %ebx, %ebx
je 0x3a50
leaq 0x3e8d(%rip), %rdi      # 0x7463
callq 0x22e0
jmp 0x3793
movzbl -0x1035f(%rbp), %r14d
andl $0x7f, %r14d
cmpq $0x7e, %r14
jne 0x3608
movzwl -0x1035e(%rbp), %eax
rolw $0x8, %ax
movzwl %ax, %r14d
movl $0x4, %eax
jmp 0x363e
movl $0x2, %eax
cmpb $0x7f, %r14b
jne 0x363e
movzbl -0x1035e(%rbp), %r14d
xorl %eax, %eax
movq %r14, %rcx
shlq $0x8, %rcx
movzbl -0x1035d(%rbp,%rax), %r14d
orq %rcx, %r14
incq %rax
cmpq $0x7, %rax
jne 0x361d
movl $0xa, %eax
movl %edx, -0x11c(%rbp)
movl %eax, %ebx
testb $0x1, -0x130(%rbp)
je 0x36de
shrl $0x7, %esi
leaq 0x3b33(%rip), %rdi      # 0x7190
xorl %eax, %eax
movl %esi, %r15d
callq 0x2040
leaq 0x3b73(%rip), %rdi      # 0x71e1
movl %r15d, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x3b80(%rip), %rdi      # 0x71ff
movl -0x11c(%rbp), %esi
xorl %eax, %eax
callq 0x2040
movzbl -0x1035f(%rbp), %esi
shrl $0x7, %esi
leaq 0x3b6e(%rip), %rdi      # 0x720b
xorl %eax, %eax
callq 0x2040
leaq 0x3b6f(%rip), %rdi      # 0x721a
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
leaq -0x10360(%rbp), %rax
movzbl (%rbx,%rax), %esi
movzbl 0x1(%rbx,%rax), %edx
movzbl 0x2(%rbx,%rax), %ecx
movzbl 0x3(%rbx,%rax), %r8d
leaq 0x3b57(%rip), %rdi      # 0x722e
xorl %eax, %eax
callq 0x2040
leaq (%r14,%rbx), %r15
addq $0x4, %r15
leaq (%r14,%rbx), %rax
addq $-0xfffb, %rax          # imm = 0xFFFF0005
movslq %r12d, %rcx
cmpq $-0x10000, %rax         # imm = 0xFFFF0000
jae 0x374a
cmpq %rcx, %r15
movq %rcx, %r14
jbe 0x3727
movl -0x2c(%rbp), %edi
movq %r15, %rdx
subq %r14, %rdx
leaq -0x10360(%rbp), %rsi
callq 0x22b0
testl %eax, %eax
je 0x3727
addl %eax, %r12d
movslq %r12d, %r14
cmpq %r14, %r15
ja 0x3703
leaq 0x3b28(%rip), %rdi      # 0x7256
movl $0xffff, %esi           # imm = 0xFFFF
xorl %eax, %eax
callq 0x2040
movq -0x58(%rbp), %r12
movq -0xe0(%rbp), %r15
jmp 0x3bfd
cmpq %rcx, %r15
jbe 0x379f
movl -0x2c(%rbp), %edi
leaq (%rcx,%rbp), %rsi
addq $-0x10360, %rsi         # imm = 0xFFFEFCA0
movq %r15, %rdx
subq %rcx, %rdx
callq 0x22b0
addl %eax, %r12d
movslq %r12d, %rcx
jmp 0x374a
leaq 0x3c7b(%rip), %rdi      # 0x73f2
xorl %eax, %eax
callq 0x2040
leaq 0x3c8d(%rip), %rdi      # 0x7412
leaq -0x10360(%rbp), %rsi
xorl %eax, %eax
callq 0x2040
movq -0x58(%rbp), %r12
movq %r15, %r14
jmp 0x3aef
movq %rcx, -0xd8(%rbp)
movb $0x0, -0x10360(%rbp,%rcx)
testb $0x1, -0x130(%rbp)
je 0x37d6
leaq 0x3ae9(%rip), %rdi      # 0x72a7
movl %r12d, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x3aef(%rip), %rdi      # 0x72be
xorl %eax, %eax
callq 0x2040
testq %r14, %r14
movq -0xe0(%rbp), %r15
je 0x3808
leaq -0x1035c(%rbp), %rax
addq %rbx, %rax
xorl %ecx, %ecx
movl %ecx, %edx
andl $0x3, %edx
addq %rbx, %rdx
movb -0x10360(%rbp,%rdx), %dl
xorb %dl, (%rax,%rcx)
incq %rcx
cmpq %rcx, %r14
jne 0x37ee
cmpq $0x7, %r14
movq -0x58(%rbp), %r12
jbe 0x396b
leaq -0x10360(%rbp), %rax
cmpb $0x68, 0x6(%rbx,%rax)
jne 0x396b
cmpb $0x72, 0x7(%rbx,%rax)
jne 0x396b
cmpb $0x65, 0x8(%rbx,%rax)
jne 0x396b
cmpb $0x66, 0x9(%rbx,%rax)
jne 0x396b
leaq 0x4(%rbx), %rax
leaq (%rax,%rbp), %rcx
addq $-0x10360, %rcx         # imm = 0xFFFEFCA0
leaq -0x10357(%rbp,%rax), %rsi
leaq -0x2(%r14,%rcx), %rdx
leaq -0x108(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x118(%rbp), %r14
movq %r14, %rdi
callq 0x40ee
movq -0x118(%rbp), %rdi
callq 0x22e0
movq %r14, %rdi
leaq 0x3a77(%rip), %rsi      # 0x730f
callq 0x20b0
testl %eax, %eax
je 0x2a19
leaq 0x18(%r13), %rdi
movq %r14, %rsi
callq 0x2150
leaq -0x2e0(%rbp), %rdi
movq %r14, %rsi
callq 0x4a4e
movl (%rax), %ebx
leaq -0x2a8(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x51b8
movl %ebx, (%rax)
leaq -0x2e0(%rbp), %rdi
movq %r14, %rsi
callq 0x4a4e
leaq -0x238(%rbp), %rdi
movq %rax, %rsi
callq 0x4e88
addq $0x10, %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x4082
movl -0x2c(%rbp), %ebx
movl %ebx, %r14d
negl %r14d
cmovsl %ebx, %r14d
movl $0x1, %r12d
cmpl $0xa, %r14d
jb 0x2a8c
movl $0x4, %r12d
movl %r14d, %eax
cmpl $0x63, %eax
jbe 0x2a83
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x2a89
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x2a8c
movl %eax, %ecx
movl $0xd1b71759, %edx       # imm = 0xD1B71759
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r12d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x3927
addl $-0x3, %r12d
jmp 0x2a8c
movl -0x11c(%rbp), %eax
addl $-0x3, %eax
cmpl $-0x2, %eax
jb 0x3bbd
testq %r14, %r14
je 0x399d
leaq -0x1035c(%rbp), %rax
addq %rbx, %rax
xorl %ecx, %ecx
movb (%rax,%rcx), %dl
movb %dl, -0x4(%rax,%rcx)
incq %rcx
cmpq %rcx, %r14
jne 0x398e
andb $-0x71, -0x10360(%rbp)
andb $0x7f, -0x1035f(%rbp)
leaq (%r14,%rbx), %r12
xorl %ecx, %ecx
movb %cl, -0x10360(%rbp,%r12)
leaq (%r14,%rbx), %rax
incq %rax
movb %cl, -0x10360(%rbp,%rax)
leaq (%r14,%rbx), %rax
addq $0x2, %rax
movb %cl, -0x10360(%rbp,%rax)
movb %cl, -0x1035d(%rbp,%r12)
cmpb $0x74, -0x10360(%rbp,%rbx)
jne 0x3b07
movq %rbx, %rax
orq $0x1, %rax
cmpb $0x6f, -0x10360(%rbp,%rax)
jne 0x3b07
leaq 0x2(%rbx), %rax
movb -0x10360(%rbp,%rax), %al
xorl %edi, %edi
cmpb $0x7b, %al
movq -0xd8(%rbp), %r14
je 0x3a3a
leaq -0x1035d(%rbp), %rcx
addq %rcx, %rbx
xorl %edi, %edi
movsbl %al, %eax
leal (%rdi,%rdi,4), %ecx
leal (%rax,%rcx,2), %edi
addl $-0x30, %edi
movb (%rbx), %al
incq %rbx
cmpb $0x7b, %al
jne 0x3a25
leaq -0x10360(%rbp), %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x2130
jmp 0x3be9
movq %r12, -0x50(%rbp)
movq %r14, %rdi
leaq 0x3931(%rip), %rsi      # 0x738f
leaq 0x3975(%rip), %rdx      # 0x73da
callq 0x48f0
movq %r14, %rdi
leaq 0x3967(%rip), %rsi      # 0x73db
callq 0x2360
movq %r14, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x2360
movq %r14, %rdi
leaq 0x3946(%rip), %rsi      # 0x73d8
callq 0x2360
movq -0x50(%rbp), %rbx
movl -0x2c(%rbp), %r14d
movq %rbx, %rdi
callq 0x2100
movl %r14d, %edi
movq %rbx, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x2130
movq %rax, %r14
movq %rbx, %rdi
callq 0x2100
cmpq %rax, %r14
jne 0x29f7
movl $0x1, 0x14(%r13)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
movq %r15, %r14
je 0x3aeb
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x58(%rbp), %r12
movq -0xe0(%rbp), %r15
leaq -0x118(%rbp), %rdi
callq 0x4208
jmp 0x3c0b
leaq -0x2a8(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x51b8
movq -0xd8(%rbp), %r14
cmpl $0x0, (%rax)
je 0x3b3e
leaq -0x2a8(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x51b8
movl (%rax), %eax
cmpl -0x2c(%rbp), %eax
jne 0x3bc6
leaq -0x238(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x4e88
movq (%rax), %r14
leaq -0x238(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x4e88
cmpq 0x8(%rax), %r14
je 0x3bb9
movl (%r14), %edi
leaq -0x10360(%rbp), %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x2130
cmpq %r12, %rax
je 0x3bac
leaq 0x37ba(%rip), %rdi      # 0x7341
callq 0x21c0
leaq -0x238(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x4e88
movq %rax, %rdi
movq %r14, %rsi
callq 0x570a
movq %rax, %r14
jmp 0x3b51
incq -0x138(%rbp)
addq $0x30, %r14
jmp 0x3b51
movq -0x58(%rbp), %r12
movq -0xd8(%rbp), %r14
jmp 0x3bfd
leaq -0x2a8(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x51b8
movl (%rax), %edi
leaq -0x10360(%rbp), %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x2130
cmpq %r12, %rax
jne 0x2a08
incq -0x138(%rbp)
movq -0x58(%rbp), %r12
incq -0x178(%rbp)
addq %r14, -0x180(%rbp)
movq -0x1f0(%rbp), %rdi
leaq -0x1e0(%rbp), %rax
cmpq %rax, %rdi
je 0x3c2d
movq -0x1e0(%rbp), %rsi
incq %rsi
callq 0x2200
movq %r15, %r13
testq %r15, %r15
jne 0x32e5
jmp 0x27b1
leaq 0x3453(%rip), %rdi      # 0x7098
callq 0x21c0
movl $0x1, %edi
callq 0x2270
leaq 0x33ce(%rip), %rdi      # 0x7029
jmp 0x3c45
leaq 0x33d3(%rip), %rdi      # 0x7037
jmp 0x3c45
leaq 0x33d5(%rip), %rdi      # 0x7042
jmp 0x3c45
leaq 0x33f2(%rip), %rdi      # 0x7068
jmp 0x3c45
jmp 0x3d45
movq %rax, %rbx
movq -0x1c8(%rbp), %rdi
leaq -0x1b8(%rbp), %rax
cmpq %rax, %rdi
je 0x3ca7
movq -0x1b8(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x3ca7
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3cc5
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x3cc5
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x3cec
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x3cec
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x3d05
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
leaq -0xa0(%rbp), %r14
movq -0x158(%rbp), %rdi
leaq -0x148(%rbp), %rax
cmpq %rax, %rdi
je 0x3d48
movq -0x148(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x3d48
movq %rax, %rbx
jmp 0x3d0c
jmp 0x3d45
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x3f86
jmp 0x3d48
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3e71
movq -0xa0(%rbp), %rsi
jmp 0x3e64
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3e71
movq -0x40(%rbp), %rsi
jmp 0x3e64
jmp 0x3e6e
movq %rax, %rbx
jmp 0x3dbc
jmp 0x3e6e
movq %rax, %rbx
movq -0x1a8(%rbp), %rdi
leaq -0x198(%rbp), %rax
cmpq %rax, %rdi
je 0x3db5
movq -0x198(%rbp), %rsi
incq %rsi
callq 0x2200
leaq -0xa0(%rbp), %r14
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3dd7
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2200
leaq -0x70(%rbp), %r12
jmp 0x3de0
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x3e1c
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x3e1c
movq %rax, %rbx
jmp 0x3e35
movq %rax, %rbx
jmp 0x3e4a
jmp 0x3e6e
jmp 0x3f21
movq %rax, %rbx
leaq -0x70(%rbp), %r12
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3e35
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x80(%rbp), %rdi
cmpq %r12, %rdi
je 0x3e4a
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x158(%rbp), %rdi
leaq -0x148(%rbp), %rax
cmpq %rax, %rdi
je 0x3e71
movq -0x148(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x3e71
movq %rax, %rbx
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x3f24
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x3f24
jmp 0x3f21
jmp 0x3f21
jmp 0x3ece
jmp 0x3ec5
jmp 0x3f21
jmp 0x3ec5
jmp 0x3ece
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3ee6
movq -0xa0(%rbp), %rsi
jmp 0x3ede
movq %rax, %rbx
jmp 0x3ee6
jmp 0x3f21
jmp 0x3f21
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x3ee6
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2200
leaq -0x118(%rbp), %rdi
callq 0x4208
jmp 0x3f24
jmp 0x3f21
jmp 0x3f21
jmp 0x3f21
movq %rax, %rbx
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x3f4d
movq -0x100(%rbp), %rsi
jmp 0x3f3e
jmp 0x3f4a
jmp 0x3f21
jmp 0x3f21
jmp 0x3f4a
movq %rax, %rbx
movq -0x1f0(%rbp), %rdi
leaq -0x1e0(%rbp), %rax
cmpq %rax, %rdi
je 0x3f4d
movq -0x1e0(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x3f4d
jmp 0x3f4a
movq %rax, %rbx
leaq -0x270(%rbp), %rdi
callq 0x4304
leaq -0x2a8(%rbp), %rdi
callq 0x43ba
leaq -0x238(%rbp), %rdi
callq 0x4442
leaq -0x2e0(%rbp), %rdi
callq 0x44ea
movq %rbx, %rdi
callq 0x2320
nop