// File: yckwong[P]tinywebserver/http/http_conn.cpp
// Function: http_conn::do_request()
http_conn::HTTP_CODE http_conn::do_request()
{
    strcpy(m_real_file, doc_root);
    int len = strlen(doc_root);
    //printf("m_url:%s\n", m_url);
    const char *p = strrchr(m_url, '/');

    //处理cgi
    if (cgi == 1 && (*(p + 1) == '2' || *(p + 1) == '3'))
    {

        //根据标志判断是登录检测还是注册检测
        char flag = m_url[1];

        char *m_url_real = (char *)malloc(sizeof(char) * 200);
        strcpy(m_url_real, "/");
        strcat(m_url_real, m_url + 2);
        strncpy(m_real_file + len, m_url_real, FILENAME_LEN - len - 1);
        free(m_url_real);

        //将用户名和密码提取出来
        //user=123&passwd=123
        char name[100], password[100];
        int i;
        for (i = 5; m_string[i] != '&'; ++i)
            name[i - 5] = m_string[i];
        name[i - 5] = '\0';

        int j = 0;
        for (i = i + 10; m_string[i] != '\0'; ++i, ++j)
            password[j] = m_string[i];
        password[j] = '\0';

        if (0 == m_SQLVerify)
        {
            if (*(p + 1) == '3')
            {
                //如果是注册，先检测数据库中是否有重名的
                //没有重名的，进行增加数据
                char *sql_insert = (char *)malloc(sizeof(char) * 200);
                strcpy(sql_insert, "INSERT INTO user(username, passwd) VALUES(");
                strcat(sql_insert, "'");
                strcat(sql_insert, name);
                strcat(sql_insert, "', '");
                strcat(sql_insert, password);
                strcat(sql_insert, "')");

                if (users.find(name) == users.end())
                {
                    m_lock.lock();
                    int res = mysql_query(mysql, sql_insert);
                    users.insert(pair<string, string>(name, password));
                    m_lock.unlock();

                    if (!res)
                        strcpy(m_url, "/log.html");
                    else
                        strcpy(m_url, "/registerError.html");
                }
                else
                    strcpy(m_url, "/registerError.html");
            }
            //如果是登录，直接判断
            //若浏览器端输入的用户名和密码在表中可以查找到，返回1，否则返回0
            else if (*(p + 1) == '2')
            {
                if (users.find(name) != users.end() && users[name] == password)
                    strcpy(m_url, "/welcome.html");
                else
                    strcpy(m_url, "/logError.html");
            }
        }
        else if (1 == m_SQLVerify)
        {
            //注册
            if (*(p + 1) == '3')
            {
                //如果是注册，先检测数据库中是否有重名的
                //没有重名的，进行增加数据
                char *sql_insert = (char *)malloc(sizeof(char) * 200);
                strcpy(sql_insert, "INSERT INTO user(username, passwd) VALUES(");
                strcat(sql_insert, "'");
                strcat(sql_insert, name);
                strcat(sql_insert, "', '");
                strcat(sql_insert, password);
                strcat(sql_insert, "')");

                if (users.find(name) == users.end())
                {
                    m_lock.lock();
                    int res = mysql_query(mysql, sql_insert);
                    users.insert(pair<string, string>(name, password));
                    m_lock.unlock();

                    if (!res)
                    {
                        strcpy(m_url, "/log.html");
                        m_lock.lock();
                        //每次都需要重新更新id_passwd.txt
                        ofstream out("./CGImysql/id_passwd.txt", ios::app);
                        out << name << " " << password << endl;
                        out.close();
                        m_lock.unlock();
                    }
                    else
                        strcpy(m_url, "/registerError.html");
                }
                else
                    strcpy(m_url, "/registerError.html");
            }
            //登录
            else if (*(p + 1) == '2')
            {
                pid_t pid;
                int pipefd[2];
                if (pipe(pipefd) < 0)
                {
                    LOG_ERROR("pipe() error:%d", 4);
                    return BAD_REQUEST;
                }
                if ((pid = fork()) < 0)
                {
                    LOG_ERROR("fork() error:%d", 3);
                    return BAD_REQUEST;
                }

                if (pid == 0)
                {
                    //标准输出，文件描述符是1，然后将输出重定向到管道写端
                    dup2(pipefd[1], 1);
                    //关闭管道的读端
                    close(pipefd[0]);
                    //父进程去执行cgi程序，m_real_file,name,password为输入
                    execl(m_real_file, name, password, "./CGImysql/id_passwd.txt", "1", NULL);
                }
                else
                {
                    //子进程关闭写端，打开读端，读取父进程的输出
                    close(pipefd[1]);
                    char result;
                    int ret = read(pipefd[0], &result, 1);

                    if (ret != 1)
                    {
                        LOG_ERROR("管道read error:ret=%d", ret);
                        return BAD_REQUEST;
                    }

                    LOG_INFO("%s", "登录检测");

                    //当用户名和密码正确，则显示welcome界面，否则显示错误界面
                    if (result == '1')
                        strcpy(m_url, "/welcome.html");
                    else
                        strcpy(m_url, "/logError.html");

                    //回收进程资源
                    waitpid(pid, NULL, 0);
                }
            }
        }

        //CGI多进程登录校验,不用数据库连接池
        //子进程完成注册和登录
        else
        {
            //fd[0]:读管道，fd[1]:写管道
            pid_t pid;
            int pipefd[2];
            if (pipe(pipefd) < 0)
            {
                LOG_ERROR("pipe() error:%d", 4);
                return BAD_REQUEST;
            }
            if ((pid = fork()) < 0)
            {
                LOG_ERROR("fork() error:%d", 3);
                return BAD_REQUEST;
            }

            if (pid == 0)
            {
                //标准输出，文件描述符是1，然后将输出重定向到管道写端
                dup2(pipefd[1], 1);

                //关闭管道的读端
                close(pipefd[0]);

                //父进程去执行cgi程序
                execl(m_real_file, &flag, name, password, "2", sql_user, sql_passwd, sql_name, NULL);
            }
            else
            {
                //子进程关闭写端，打开读端，读取父进程的输出
                close(pipefd[1]);
                char result;
                int ret = read(pipefd[0], &result, 1);

                if (ret != 1)
                {
                    LOG_ERROR("管道read error:ret=%d", ret);
                    return BAD_REQUEST;
                }
                if (flag == '2')
                {
                    LOG_INFO("%s", "登录检测");


                    //当用户名和密码正确，则显示welcome界面，否则显示错误界面
                    if (result == '1')
                        strcpy(m_url, "/welcome.html");
                    else
                        strcpy(m_url, "/logError.html");
                }
                else if (flag == '3')
                {
                    LOG_INFO("%s", "注册检测");

                    //当成功注册后，则显示登陆界面，否则显示错误界面
                    if (result == '1')
                        strcpy(m_url, "/log.html");
                    else
                        strcpy(m_url, "/registerError.html");
                }
                //回收进程资源
                waitpid(pid, NULL, 0);
            }
        }
    }

    if (*(p + 1) == '0')
    {
        char *m_url_real = (char *)malloc(sizeof(char) * 200);
        strcpy(m_url_real, "/register.html");
        strncpy(m_real_file + len, m_url_real, strlen(m_url_real));

        free(m_url_real);
    }
    else if (*(p + 1) == '1')
    {
        char *m_url_real = (char *)malloc(sizeof(char) * 200);
        strcpy(m_url_real, "/log.html");
        strncpy(m_real_file + len, m_url_real, strlen(m_url_real));

        free(m_url_real);
    }
    else if (*(p + 1) == '5')
    {
        char *m_url_real = (char *)malloc(sizeof(char) * 200);
        strcpy(m_url_real, "/picture.html");
        strncpy(m_real_file + len, m_url_real, strlen(m_url_real));

        free(m_url_real);
    }
    else if (*(p + 1) == '6')
    {
        char *m_url_real = (char *)malloc(sizeof(char) * 200);
        strcpy(m_url_real, "/video.html");
        strncpy(m_real_file + len, m_url_real, strlen(m_url_real));

        free(m_url_real);
    }
    else if (*(p + 1) == '7')
    {
        char *m_url_real = (char *)malloc(sizeof(char) * 200);
        strcpy(m_url_real, "/fans.html");
        strncpy(m_real_file + len, m_url_real, strlen(m_url_real));

        free(m_url_real);
    }
    else
        strncpy(m_real_file + len, m_url, FILENAME_LEN - len - 1);

    if (stat(m_real_file, &m_file_stat) < 0)
        return NO_RESOURCE;

    if (!(m_file_stat.st_mode & S_IROTH))
        return FORBIDDEN_REQUEST;

    if (S_ISDIR(m_file_stat.st_mode))
        return BAD_REQUEST;

    int fd = open(m_real_file, O_RDONLY);
    m_file_address = (char *)mmap(0, m_file_stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
    close(fd);
    return FILE_REQUEST;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x640, %rsp            # imm = 0x640
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x518(%rbp)
movq %rax, %rdi
addq $0xc40, %rdi            # imm = 0xC40
movq 0xdf8(%rax), %rsi
callq 0x4470
movq -0x518(%rbp), %rax
movq 0xdf8(%rax), %rdi
callq 0x41c0
movq %rax, %rcx
movq -0x518(%rbp), %rax
movl %ecx, -0x14(%rbp)
movq 0xd08(%rax), %rdi
movl $0x2f, %esi
callq 0x4560
movq %rax, %rcx
movq -0x518(%rbp), %rax
movq %rcx, -0x20(%rbp)
cmpl $0x1, 0xde4(%rax)
jne 0x7de5
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x32, %eax
je 0x6e4a
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x33, %eax
jne 0x7de5
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rax
movb 0x1(%rax), %al
movb %al, -0x21(%rbp)
movl $0xc8, %edi
callq 0x4650
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x93e4(%rip), %rsi      # 0x1025b
callq 0x4470
movq -0x518(%rbp), %rax
movq -0x30(%rbp), %rdi
movq 0xd08(%rax), %rsi
addq $0x2, %rsi
callq 0x47f0
movq -0x518(%rbp), %rdi
addq $0xc40, %rdi            # imm = 0xC40
movslq -0x14(%rbp), %rax
addq %rax, %rdi
movq -0x30(%rbp), %rsi
movl $0xc8, %eax
subl -0x14(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rdx
callq 0x4250
movq -0x30(%rbp), %rdi
callq 0x45c0
movl $0x5, -0x114(%rbp)
movq -0x518(%rbp), %rax
movq 0xde8(%rax), %rax
movslq -0x114(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x26, %eax
je 0x6f2f
movq -0x518(%rbp), %rax
movq 0xde8(%rax), %rax
movslq -0x114(%rbp), %rcx
movb (%rax,%rcx), %cl
movl -0x114(%rbp), %eax
subl $0x5, %eax
cltq
movb %cl, -0xa0(%rbp,%rax)
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x6ed6
movl -0x114(%rbp), %eax
subl $0x5, %eax
cltq
movb $0x0, -0xa0(%rbp,%rax)
movl $0x0, -0x118(%rbp)
movl -0x114(%rbp), %eax
addl $0xa, %eax
movl %eax, -0x114(%rbp)
movq -0x518(%rbp), %rax
movq 0xde8(%rax), %rax
movslq -0x114(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x6fbf
movq -0x518(%rbp), %rax
movq 0xde8(%rax), %rax
movslq -0x114(%rbp), %rcx
movb (%rax,%rcx), %cl
movslq -0x118(%rbp), %rax
movb %cl, -0x110(%rbp,%rax)
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
movl -0x118(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x118(%rbp)
jmp 0x6f5b
movq -0x518(%rbp), %rcx
movslq -0x118(%rbp), %rax
movb $0x0, -0x110(%rbp,%rax)
xorl %eax, %eax
cmpl 0xe30(%rcx), %eax
jne 0x7509
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x33, %eax
jne 0x7295
movl $0xc8, %edi
callq 0x4650
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rdi
leaq 0x92a1(%rip), %rsi      # 0x102b4
callq 0x4470
movq -0x120(%rbp), %rdi
leaq 0x92bc(%rip), %rsi      # 0x102e2
callq 0x47f0
movq -0x120(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movq %rsi, -0x528(%rbp)
callq 0x47f0
movq -0x120(%rbp), %rdi
leaq 0x928c(%rip), %rsi      # 0x102df
callq 0x47f0
movq -0x120(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x47f0
movq -0x120(%rbp), %rdi
leaq 0x926b(%rip), %rsi      # 0x102e4
callq 0x47f0
leaq -0x149(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0x47e0
movq -0x528(%rbp), %rsi
movq -0x520(%rbp), %rdx
leaq -0x148(%rbp), %rdi
callq 0x4f60
jmp 0x70ad
leaq 0xf464(%rip), %rdi      # 0x16518
leaq -0x148(%rbp), %rsi
callq 0x8c90
movq %rax, -0x530(%rbp)
jmp 0x70c9
movq -0x530(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq 0xf43a(%rip), %rdi      # 0x16518
callq 0x8cc0
movq %rax, -0x168(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x8c60
movb %al, -0x531(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x42d0
leaq -0x149(%rbp), %rdi
callq 0x4500
movb -0x531(%rbp), %al
testb $0x1, %al
jne 0x712a
jmp 0x7276
leaq 0xf3bf(%rip), %rdi      # 0x164f0
callq 0x8cf0
movq -0x518(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x120(%rbp), %rsi
callq 0x4320
movl %eax, -0x16c(%rbp)
leaq -0x1b0(%rbp), %rdi
movq %rdi, -0x550(%rbp)
leaq -0xa0(%rbp), %rsi
leaq -0x110(%rbp), %rdx
callq 0x8d60
movq -0x550(%rbp), %rsi
leaq 0xf396(%rip), %rdi      # 0x16518
callq 0x8d20
movb %dl, -0x541(%rbp)
movq %rax, -0x540(%rbp)
jmp 0x7196
movb -0x541(%rbp), %al
movq -0x540(%rbp), %rcx
movq %rcx, -0x1c0(%rbp)
movb %al, -0x1b8(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x8e40
leaq 0xf32d(%rip), %rdi      # 0x164f0
callq 0x8e70
cmpl $0x0, -0x16c(%rbp)
jne 0x725a
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x90fd(%rip), %rsi      # 0x102e7
callq 0x4470
jmp 0x7274
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0x7226
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x42d0
leaq -0x149(%rbp), %rdi
callq 0x4500
jmp 0x81d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x8e40
jmp 0x81d8
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x9082(%rip), %rsi      # 0x102f1
callq 0x4470
jmp 0x7290
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x9066(%rip), %rsi      # 0x102f1
callq 0x4470
jmp 0x7504
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x32, %eax
jne 0x7502
leaq -0x1e9(%rbp), %rdi
movq %rdi, -0x558(%rbp)
callq 0x47e0
movq -0x558(%rbp), %rdx
movb $0x0, -0x21a(%rbp)
movb $0x0, -0x21b(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4f60
jmp 0x72e3
leaq 0xf22e(%rip), %rdi      # 0x16518
leaq -0x1e8(%rbp), %rsi
callq 0x8c90
movq %rax, -0x560(%rbp)
jmp 0x72ff
movq -0x560(%rbp), %rax
movq %rax, -0x1c8(%rbp)
leaq 0xf204(%rip), %rdi      # 0x16518
callq 0x8cc0
movq %rax, -0x1f8(%rbp)
leaq -0x1c8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x8ea0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x561(%rbp)
jne 0x7347
jmp 0x73c9
leaq -0x219(%rbp), %rdi
movq %rdi, -0x570(%rbp)
callq 0x47e0
movq -0x570(%rbp), %rdx
movb $0x1, -0x21a(%rbp)
leaq -0x218(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4f60
jmp 0x737d
movb $0x1, -0x21b(%rbp)
leaq 0xf18d(%rip), %rdi      # 0x16518
leaq -0x218(%rbp), %rsi
callq 0x8f00
movq %rax, -0x578(%rbp)
jmp 0x73a0
movq -0x578(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x8ed0
movb %al, -0x579(%rbp)
jmp 0x73bb
movb -0x579(%rbp), %al
movb %al, -0x561(%rbp)
jmp 0x73c9
movb -0x561(%rbp), %al
movb %al, -0x57a(%rbp)
testb $0x1, -0x21b(%rbp)
jne 0x73e0
jmp 0x73ec
leaq -0x218(%rbp), %rdi
callq 0x42d0
testb $0x1, -0x21a(%rbp)
jne 0x73f7
jmp 0x7403
leaq -0x219(%rbp), %rdi
callq 0x4500
leaq -0x1e8(%rbp), %rdi
callq 0x42d0
leaq -0x1e9(%rbp), %rdi
callq 0x4500
movb -0x57a(%rbp), %al
testb $0x1, %al
jne 0x742a
jmp 0x74e6
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x8ec6(%rip), %rsi      # 0x10305
callq 0x4470
jmp 0x7500
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0x74d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0x74c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0x74b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
testb $0x1, -0x21b(%rbp)
jne 0x74a2
jmp 0x74ae
leaq -0x218(%rbp), %rdi
callq 0x42d0
jmp 0x74b0
testb $0x1, -0x21a(%rbp)
jne 0x74bb
jmp 0x74c7
leaq -0x219(%rbp), %rdi
callq 0x4500
jmp 0x74c9
leaq -0x1e8(%rbp), %rdi
callq 0x42d0
leaq -0x1e9(%rbp), %rdi
callq 0x4500
jmp 0x81d8
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x8e18(%rip), %rsi      # 0x10313
callq 0x4470
jmp 0x7502
jmp 0x7504
jmp 0x7de3
movq -0x518(%rbp), %rcx
movl $0x1, %eax
cmpl 0xe30(%rcx), %eax
jne 0x7aec
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x33, %eax
jne 0x78b2
movl $0xc8, %edi
callq 0x4650
movq %rax, -0x228(%rbp)
movq -0x228(%rbp), %rdi
leaq 0x8d63(%rip), %rsi      # 0x102b4
callq 0x4470
movq -0x228(%rbp), %rdi
leaq 0x8d7e(%rip), %rsi      # 0x102e2
callq 0x47f0
movq -0x228(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movq %rsi, -0x590(%rbp)
callq 0x47f0
movq -0x228(%rbp), %rdi
leaq 0x8d4e(%rip), %rsi      # 0x102df
callq 0x47f0
movq -0x228(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x47f0
movq -0x228(%rbp), %rdi
leaq 0x8d2d(%rip), %rsi      # 0x102e4
callq 0x47f0
leaq -0x251(%rbp), %rdi
movq %rdi, -0x588(%rbp)
callq 0x47e0
movq -0x590(%rbp), %rsi
movq -0x588(%rbp), %rdx
leaq -0x250(%rbp), %rdi
callq 0x4f60
jmp 0x75eb
leaq 0xef26(%rip), %rdi      # 0x16518
leaq -0x250(%rbp), %rsi
callq 0x8c90
movq %rax, -0x598(%rbp)
jmp 0x7607
movq -0x598(%rbp), %rax
movq %rax, -0x230(%rbp)
leaq 0xeefc(%rip), %rdi      # 0x16518
callq 0x8cc0
movq %rax, -0x260(%rbp)
leaq -0x230(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x8c60
movb %al, -0x599(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x42d0
leaq -0x251(%rbp), %rdi
callq 0x4500
movb -0x599(%rbp), %al
testb $0x1, %al
jne 0x7668
jmp 0x7893
leaq 0xee81(%rip), %rdi      # 0x164f0
callq 0x8cf0
movq -0x518(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x228(%rbp), %rsi
callq 0x4320
movl %eax, -0x264(%rbp)
leaq -0x2a8(%rbp), %rdi
movq %rdi, -0x5b8(%rbp)
leaq -0xa0(%rbp), %rsi
leaq -0x110(%rbp), %rdx
callq 0x8d60
movq -0x5b8(%rbp), %rsi
leaq 0xee58(%rip), %rdi      # 0x16518
callq 0x8d20
movb %dl, -0x5a9(%rbp)
movq %rax, -0x5a8(%rbp)
jmp 0x76d4
movb -0x5a9(%rbp), %al
movq -0x5a8(%rbp), %rcx
movq %rcx, -0x2b8(%rbp)
movb %al, -0x2b0(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x8e40
leaq 0xedef(%rip), %rdi      # 0x164f0
callq 0x8e70
cmpl $0x0, -0x264(%rbp)
jne 0x7877
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x8bbf(%rip), %rsi      # 0x102e7
callq 0x4470
leaq 0xedbc(%rip), %rdi      # 0x164f0
callq 0x8cf0
leaq 0x8add(%rip), %rsi      # 0x1021d
leaq -0x4b8(%rbp), %rdi
movq %rdi, -0x5c8(%rbp)
movl $0x1, %edx
callq 0x4510
movq -0x5c8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4480
movq %rax, -0x5c0(%rbp)
jmp 0x7774
movq -0x5c0(%rbp), %rdi
leaq 0x8d2f(%rip), %rsi      # 0x104b1
callq 0x4480
movq %rax, -0x5d0(%rbp)
jmp 0x7790
movq -0x5d0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x4480
movq %rax, -0x5d8(%rbp)
jmp 0x77ac
movq -0x5d8(%rbp), %rdi
movq 0xe7f6(%rip), %rsi      # 0x15fb0
callq 0x44e0
jmp 0x77c1
leaq -0x4b8(%rbp), %rdi
callq 0x46b0
jmp 0x77cf
leaq 0xed1a(%rip), %rdi      # 0x164f0
callq 0x8e70
jmp 0x77dd
leaq -0x4b8(%rbp), %rdi
callq 0x46f0
jmp 0x7891
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0x7820
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x42d0
leaq -0x251(%rbp), %rdi
callq 0x4500
jmp 0x81d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x8e40
jmp 0x81d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x4b8(%rbp), %rdi
callq 0x46f0
jmp 0x81d8
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x8a65(%rip), %rsi      # 0x102f1
callq 0x4470
jmp 0x78ad
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x8a49(%rip), %rsi      # 0x102f1
callq 0x4470
jmp 0x7ae7
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x32, %eax
jne 0x7ae5
leaq -0x4c4(%rbp), %rdi
callq 0x4680
cmpl $0x0, %eax
jge 0x791e
movq -0x518(%rbp), %rcx
xorl %eax, %eax
cmpl 0xe38(%rcx), %eax
jne 0x7912
callq 0x8ad0
movq %rax, %rdi
movl $0x3, %esi
leaq 0x8a29(%rip), %rdx      # 0x10322
movl $0x4, %ecx
movb $0x0, %al
callq 0xafe0
callq 0x8ad0
movq %rax, %rdi
callq 0xb550
movl $0x2, -0x4(%rbp)
jmp 0x81cc
callq 0x40f0
movl %eax, -0x4bc(%rbp)
cmpl $0x0, %eax
jge 0x7975
movq -0x518(%rbp), %rcx
xorl %eax, %eax
cmpl 0xe38(%rcx), %eax
jne 0x7969
callq 0x8ad0
movq %rax, %rdi
movl $0x3, %ecx
leaq 0x89df(%rip), %rdx      # 0x10332
movl %ecx, %esi
movb $0x0, %al
callq 0xafe0
callq 0x8ad0
movq %rax, %rdi
callq 0xb550
movl $0x2, -0x4(%rbp)
jmp 0x81cc
cmpl $0x0, -0x4bc(%rbp)
jne 0x79d4
movl -0x4c0(%rbp), %edi
movl $0x1, %esi
callq 0x4460
movl -0x4c4(%rbp), %edi
callq 0x48a0
movq -0x518(%rbp), %rdi
addq $0xc40, %rdi            # imm = 0xC40
leaq -0xa0(%rbp), %rsi
leaq -0x110(%rbp), %rdx
leaq 0x8861(%rip), %rcx      # 0x1021d
leaq 0x8690(%rip), %r8       # 0x10053
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x4610
jmp 0x7ae3
movl -0x4c0(%rbp), %edi
callq 0x48a0
movl -0x4c4(%rbp), %edi
leaq -0x4c5(%rbp), %rsi
movl $0x1, %edx
callq 0x46c0
movl %eax, -0x4cc(%rbp)
cmpl $0x1, -0x4cc(%rbp)
je 0x7a50
movq -0x518(%rbp), %rcx
xorl %eax, %eax
cmpl 0xe38(%rcx), %eax
jne 0x7a44
callq 0x8ad0
movq %rax, %rdi
movl -0x4cc(%rbp), %ecx
movl $0x3, %esi
leaq 0x8912(%rip), %rdx      # 0x10342
movb $0x0, %al
callq 0xafe0
callq 0x8ad0
movq %rax, %rdi
callq 0xb550
movl $0x2, -0x4(%rbp)
jmp 0x81cc
movq -0x518(%rbp), %rcx
xorl %eax, %eax
cmpl 0xe38(%rcx), %eax
jne 0x7a90
callq 0x8ad0
movq %rax, %rdi
movl $0x1, %esi
leaq 0x883c(%rip), %rdx      # 0x102b1
leaq 0x88de(%rip), %rcx      # 0x1035a
movb $0x0, %al
callq 0xafe0
callq 0x8ad0
movq %rax, %rdi
callq 0xb550
movsbl -0x4c5(%rbp), %eax
cmpl $0x31, %eax
jne 0x7ab8
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x8854(%rip), %rsi      # 0x10305
callq 0x4470
jmp 0x7ad2
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x8846(%rip), %rsi      # 0x10313
callq 0x4470
movl -0x4bc(%rbp), %edi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x43c0
jmp 0x7ae5
jmp 0x7ae7
jmp 0x7de1
leaq -0x4d8(%rbp), %rdi
callq 0x4680
cmpl $0x0, %eax
jge 0x7b47
movq -0x518(%rbp), %rcx
xorl %eax, %eax
cmpl 0xe38(%rcx), %eax
jne 0x7b3b
callq 0x8ad0
movq %rax, %rdi
movl $0x3, %esi
leaq 0x8800(%rip), %rdx      # 0x10322
movl $0x4, %ecx
movb $0x0, %al
callq 0xafe0
callq 0x8ad0
movq %rax, %rdi
callq 0xb550
movl $0x2, -0x4(%rbp)
jmp 0x81cc
callq 0x40f0
movl %eax, -0x4d0(%rbp)
cmpl $0x0, %eax
jge 0x7b9e
movq -0x518(%rbp), %rcx
xorl %eax, %eax
cmpl 0xe38(%rcx), %eax
jne 0x7b92
callq 0x8ad0
movq %rax, %rdi
movl $0x3, %ecx
leaq 0x87b6(%rip), %rdx      # 0x10332
movl %ecx, %esi
movb $0x0, %al
callq 0xafe0
callq 0x8ad0
movq %rax, %rdi
callq 0xb550
movl $0x2, -0x4(%rbp)
jmp 0x81cc
cmpl $0x0, -0x4d0(%rbp)
jne 0x7c2b
movl -0x4d4(%rbp), %edi
movl $0x1, %esi
callq 0x4460
movl -0x4d8(%rbp), %edi
callq 0x48a0
movq -0x518(%rbp), %rax
movq %rax, %rdi
addq $0xc40, %rdi            # imm = 0xC40
leaq -0xa0(%rbp), %rdx
leaq -0x110(%rbp), %rcx
movq %rax, %r9
addq $0xe3c, %r9             # imm = 0xE3C
movq %rax, %r10
addq $0xea0, %r10            # imm = 0xEA0
addq $0xf04, %rax            # imm = 0xF04
leaq -0x21(%rbp), %rsi
leaq 0x875d(%rip), %r8       # 0x10367
xorl %r11d, %r11d
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, %al
callq 0x4610
jmp 0x7ddf
movl -0x4d4(%rbp), %edi
callq 0x48a0
movl -0x4d8(%rbp), %edi
leaq -0x4d9(%rbp), %rsi
movl $0x1, %edx
callq 0x46c0
movl %eax, -0x4e0(%rbp)
cmpl $0x1, -0x4e0(%rbp)
je 0x7ca7
movq -0x518(%rbp), %rcx
xorl %eax, %eax
cmpl 0xe38(%rcx), %eax
jne 0x7c9b
callq 0x8ad0
movq %rax, %rdi
movl -0x4e0(%rbp), %ecx
movl $0x3, %esi
leaq 0x86bb(%rip), %rdx      # 0x10342
movb $0x0, %al
callq 0xafe0
callq 0x8ad0
movq %rax, %rdi
callq 0xb550
movl $0x2, -0x4(%rbp)
jmp 0x81cc
movsbl -0x21(%rbp), %eax
cmpl $0x32, %eax
jne 0x7d3b
movq -0x518(%rbp), %rcx
xorl %eax, %eax
cmpl 0xe38(%rcx), %eax
jne 0x7cf4
callq 0x8ad0
movq %rax, %rdi
movl $0x1, %esi
leaq 0x85d8(%rip), %rdx      # 0x102b1
leaq 0x867a(%rip), %rcx      # 0x1035a
movb $0x0, %al
callq 0xafe0
callq 0x8ad0
movq %rax, %rdi
callq 0xb550
movsbl -0x4d9(%rbp), %eax
cmpl $0x31, %eax
jne 0x7d1c
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x85f0(%rip), %rsi      # 0x10305
callq 0x4470
jmp 0x7d36
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x85e2(%rip), %rsi      # 0x10313
callq 0x4470
jmp 0x7dce
movsbl -0x21(%rbp), %eax
cmpl $0x33, %eax
jne 0x7dcc
movq -0x518(%rbp), %rcx
xorl %eax, %eax
cmpl 0xe38(%rcx), %eax
jne 0x7d88
callq 0x8ad0
movq %rax, %rdi
movl $0x1, %esi
leaq 0x8544(%rip), %rdx      # 0x102b1
leaq 0x85f5(%rip), %rcx      # 0x10369
movb $0x0, %al
callq 0xafe0
callq 0x8ad0
movq %rax, %rdi
callq 0xb550
movsbl -0x4d9(%rbp), %eax
cmpl $0x31, %eax
jne 0x7db0
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x853e(%rip), %rsi      # 0x102e7
callq 0x4470
jmp 0x7dca
movq -0x518(%rbp), %rax
movq 0xd08(%rax), %rdi
leaq 0x852c(%rip), %rsi      # 0x102f1
callq 0x4470
jmp 0x7dcc
jmp 0x7dce
movl -0x4d0(%rbp), %edi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x43c0
jmp 0x7de1
jmp 0x7de3
jmp 0x7de5
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x30, %eax
jne 0x7e76
movl $0xc8, %edi
callq 0x4650
movq %rax, -0x4e8(%rbp)
movq -0x4e8(%rbp), %rdi
leaq 0x8561(%rip), %rsi      # 0x10376
callq 0x4470
movq -0x518(%rbp), %rax
addq $0xc40, %rax            # imm = 0xC40
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x5e8(%rbp)
movq -0x4e8(%rbp), %rax
movq %rax, -0x5e0(%rbp)
movq -0x4e8(%rbp), %rdi
callq 0x41c0
movq -0x5e8(%rbp), %rdi
movq -0x5e0(%rbp), %rsi
movq %rax, %rdx
callq 0x4250
movq -0x4e8(%rbp), %rdi
callq 0x45c0
jmp 0x80ed
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x31, %eax
jne 0x7f07
movl $0xc8, %edi
callq 0x4650
movq %rax, -0x4f0(%rbp)
movq -0x4f0(%rbp), %rdi
leaq 0x8441(%rip), %rsi      # 0x102e7
callq 0x4470
movq -0x518(%rbp), %rax
addq $0xc40, %rax            # imm = 0xC40
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x5f8(%rbp)
movq -0x4f0(%rbp), %rax
movq %rax, -0x5f0(%rbp)
movq -0x4f0(%rbp), %rdi
callq 0x41c0
movq -0x5f8(%rbp), %rdi
movq -0x5f0(%rbp), %rsi
movq %rax, %rdx
callq 0x4250
movq -0x4f0(%rbp), %rdi
callq 0x45c0
jmp 0x80eb
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x35, %eax
jne 0x7f98
movl $0xc8, %edi
callq 0x4650
movq %rax, -0x4f8(%rbp)
movq -0x4f8(%rbp), %rdi
leaq 0x844e(%rip), %rsi      # 0x10385
callq 0x4470
movq -0x518(%rbp), %rax
addq $0xc40, %rax            # imm = 0xC40
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x608(%rbp)
movq -0x4f8(%rbp), %rax
movq %rax, -0x600(%rbp)
movq -0x4f8(%rbp), %rdi
callq 0x41c0
movq -0x608(%rbp), %rdi
movq -0x600(%rbp), %rsi
movq %rax, %rdx
callq 0x4250
movq -0x4f8(%rbp), %rdi
callq 0x45c0
jmp 0x80e9
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x36, %eax
jne 0x8029
movl $0xc8, %edi
callq 0x4650
movq %rax, -0x500(%rbp)
movq -0x500(%rbp), %rdi
leaq 0x83cb(%rip), %rsi      # 0x10393
callq 0x4470
movq -0x518(%rbp), %rax
addq $0xc40, %rax            # imm = 0xC40
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x618(%rbp)
movq -0x500(%rbp), %rax
movq %rax, -0x610(%rbp)
movq -0x500(%rbp), %rdi
callq 0x41c0
movq -0x618(%rbp), %rdi
movq -0x610(%rbp), %rsi
movq %rax, %rdx
callq 0x4250
movq -0x500(%rbp), %rdi
callq 0x45c0
jmp 0x80e7
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x37, %eax
jne 0x80b3
movl $0xc8, %edi
callq 0x4650
movq %rax, -0x508(%rbp)
movq -0x508(%rbp), %rdi
leaq 0x834a(%rip), %rsi      # 0x1039f
callq 0x4470
movq -0x518(%rbp), %rax
addq $0xc40, %rax            # imm = 0xC40
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x628(%rbp)
movq -0x508(%rbp), %rax
movq %rax, -0x620(%rbp)
movq -0x508(%rbp), %rdi
callq 0x41c0
movq -0x628(%rbp), %rdi
movq -0x620(%rbp), %rsi
movq %rax, %rdx
callq 0x4250
movq -0x508(%rbp), %rdi
callq 0x45c0
jmp 0x80e5
movq -0x518(%rbp), %rax
movq %rax, %rdi
addq $0xc40, %rdi            # imm = 0xC40
movslq -0x14(%rbp), %rcx
addq %rcx, %rdi
movq 0xd08(%rax), %rsi
movl $0xc8, %eax
subl -0x14(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rdx
callq 0x4250
jmp 0x80e7
jmp 0x80e9
jmp 0x80eb
jmp 0x80ed
movq -0x518(%rbp), %rsi
movq %rsi, %rdi
addq $0xc40, %rdi            # imm = 0xC40
addq $0xd30, %rsi            # imm = 0xD30
callq 0x4440
cmpl $0x0, %eax
jge 0x811b
movl $0x3, -0x4(%rbp)
jmp 0x81cc
movq -0x518(%rbp), %rax
movl 0xd48(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x813c
movl $0x4, -0x4(%rbp)
jmp 0x81cc
movq -0x518(%rbp), %rax
movl 0xd48(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x815e
movl $0x2, -0x4(%rbp)
jmp 0x81cc
movq -0x518(%rbp), %rdi
addq $0xc40, %rdi            # imm = 0xC40
xorl %esi, %esi
movb $0x0, %al
callq 0x4370
movl %eax, %ecx
movq -0x518(%rbp), %rax
movl %ecx, -0x50c(%rbp)
movq 0xd60(%rax), %rsi
movl -0x50c(%rbp), %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, %edx
movl $0x2, %ecx
movq %r9, %rdi
callq 0x4800
movq %rax, %rcx
movq -0x518(%rbp), %rax
movq %rcx, 0xd28(%rax)
movl -0x50c(%rbp), %edi
callq 0x48a0
movl $0x5, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x640, %rsp            # imm = 0x640
popq %rbp
retq
movq -0x158(%rbp), %rdi
callq 0x47d0
nopw %cs:(%rax,%rax)