// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movq %rdi, %rbx
leaq 0xc40(%rdi), %r14
movq 0xdf8(%rdi), %rsi
movq %r14, %rdi
callq 0x33f0
movq 0xdf8(%rbx), %rdi
callq 0x3180
movq %rax, %r15
movq 0xd08(%rbx), %r13
movq %r13, %rdi
movl $0x2f, %esi
callq 0x3490
movq %rax, %r12
cmpl $0x1, 0xde4(%rbx)
jne 0x5997
movb 0x1(%r12), %al
andb $-0x2, %al
cmpb $0x32, %al
jne 0x5997
movq %r12, 0x18(%rsp)
movzbl 0x1(%r13), %r12d
movb %r12b, 0xf(%rsp)
movl $0xc8, %edi
callq 0x3580
movq %rax, %rbp
movw $0x2f, (%rax)
addq $0x2, %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x36f0
movq %r15, 0x10(%rsp)
movslq %r15d, %rax
leaq (%r14,%rax), %rdi
movl $0xc7, %ecx
subl %eax, %ecx
movslq %ecx, %rdx
movq %rbp, %rsi
callq 0x3220
movq %rbp, %rdi
callq 0x3500
movq 0xde8(%rbx), %rax
movb 0x5(%rax), %dl
movl $0x5, %ecx
cmpb $0x26, %dl
je 0x5033
xorl %ecx, %ecx
movb %dl, 0x40(%rsp,%rcx)
movb 0x6(%rax,%rcx), %dl
incq %rcx
cmpb $0x26, %dl
jne 0x5020
addl $0x5, %ecx
movslq %ecx, %rdx
leaq 0x40(%rsp), %rsi
movb $0x0, -0x5(%rdx,%rsi)
movb 0xa(%rax,%rdx), %dl
testb %dl, %dl
je 0x5068
movl %ecx, %ecx
addq %rax, %rcx
addq $0xb, %rcx
xorl %eax, %eax
movb %dl, 0xb0(%rsp,%rax)
movb (%rcx,%rax), %dl
incq %rax
testb %dl, %dl
jne 0x5053
movl %eax, %eax
jmp 0x506a
xorl %eax, %eax
movb $0x0, 0xb0(%rsp,%rax)
movl 0xe30(%rbx), %eax
cmpl $0x1, %eax
je 0x5231
testl %eax, %eax
jne 0x5370
movq 0x18(%rsp), %r12
movzbl 0x1(%r12), %eax
cmpl $0x32, %eax
je 0x5460
cmpl $0x33, %eax
movq 0x10(%rsp), %r15
jne 0x5997
movl $0xc8, %edi
callq 0x3580
movq %rax, %r13
movups 0x51f1(%rip), %xmm0     # 0xa2b0
movups %xmm0, (%rax)
movups 0x51f7(%rip), %xmm0     # 0xa2c0
movups %xmm0, 0x10(%rax)
movups 0x51f7(%rip), %xmm0     # 0xa2cb
movups %xmm0, 0x1b(%rax)
movq %rax, %rdi
callq 0x3180
movw $0x27, (%r13,%rax)
leaq 0x40(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x36f0
movq %r13, %rdi
callq 0x3180
xorl %r15d, %r15d
movb %r15b, 0x4(%r13,%rax)
movl $0x27202c27, (%r13,%rax) # imm = 0x27202C27
leaq 0xb0(%rsp), %rsi
movq %r13, %rdi
callq 0x36f0
movq %r13, %rdi
callq 0x3180
movb %r15b, 0x2(%r13,%rax)
movw $0x2927, (%r13,%rax)    # imm = 0x2927
leaq 0x128(%rsp), %r15
movq %r15, -0x10(%r15)
movq %rbp, %rdi
callq 0x3180
leaq (%rsp,%rax), %rdx
addq $0x40, %rdx
leaq 0x118(%rsp), %rdi
movq %rbp, %rsi
callq 0x3e86
leaq 0x932f(%rip), %rdi      # 0xe498
leaq 0x118(%rsp), %rsi
callq 0x694e
movq %rax, %rbp
movq 0x118(%rsp), %rdi
cmpq %r15, %rdi
je 0x5196
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3430
leaq 0x9303(%rip), %rax      # 0xe4a0
cmpq %rax, %rbp
movq 0x10(%rsp), %r15
jne 0x5353
leaq 0x92be(%rip), %rdi      # 0xe470
callq 0x35f0
movq 0x8(%rbx), %rdi
movq %r13, %rsi
callq 0x32e0
movl %eax, %ebp
leaq 0x118(%rsp), %r13
leaq 0x40(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
movq %r13, %rdi
callq 0x6402
leaq 0x92af(%rip), %rdi      # 0xe498
movq %r13, %rsi
callq 0x6994
leaq 0x118(%rsp), %rdi
callq 0x6480
leaq 0x926b(%rip), %rdi      # 0xe470
callq 0x3350
movq 0xd08(%rbx), %rax
testl %ebp, %ebp
jne 0x535a
movabsq $0x6d74682e676f6c2f, %rcx # imm = 0x6D74682E676F6C2F
movq %rcx, (%rax)
movw $0x6c, 0x8(%rax)
jmp 0x5997
movq 0x18(%rsp), %r12
movzbl 0x1(%r12), %eax
cmpl $0x32, %eax
je 0x5527
cmpl $0x33, %eax
movq 0x10(%rsp), %r15
jne 0x5997
movl $0xc8, %edi
callq 0x3580
movq %rax, %r13
movups 0x5049(%rip), %xmm0     # 0xa2b0
movups %xmm0, (%rax)
movups 0x504f(%rip), %xmm0     # 0xa2c0
movups %xmm0, 0x10(%rax)
movups 0x504f(%rip), %xmm0     # 0xa2cb
movups %xmm0, 0x1b(%rax)
movq %rax, %rdi
callq 0x3180
movw $0x27, (%r13,%rax)
leaq 0x40(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x36f0
movq %r13, %rdi
callq 0x3180
xorl %r15d, %r15d
movb %r15b, 0x4(%r13,%rax)
movl $0x27202c27, (%r13,%rax) # imm = 0x27202C27
leaq 0xb0(%rsp), %rsi
movq %r13, %rdi
callq 0x36f0
movq %r13, %rdi
callq 0x3180
movb %r15b, 0x2(%r13,%rax)
movw $0x2927, (%r13,%rax)    # imm = 0x2927
leaq 0x128(%rsp), %r15
movq %r15, -0x10(%r15)
movq %rbp, %rdi
callq 0x3180
leaq (%rsp,%rax), %rdx
addq $0x40, %rdx
leaq 0x118(%rsp), %rdi
movq %rbp, %rsi
callq 0x3e86
leaq 0x9187(%rip), %rdi      # 0xe498
leaq 0x118(%rsp), %rsi
callq 0x694e
movq %rax, %rbp
movq 0x118(%rsp), %rdi
cmpq %r15, %rdi
je 0x533e
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3430
leaq 0x915b(%rip), %rax      # 0xe4a0
cmpq %rax, %rbp
movq 0x10(%rsp), %r15
je 0x5695
movq 0xd08(%rbx), %rax
movups 0x4f8c(%rip), %xmm0     # 0xa2ed
movups %xmm0, (%rax)
movl $0x6c6d74, 0x10(%rax)   # imm = 0x6C6D74
jmp 0x5997
leaq 0x118(%rsp), %rdi
callq 0x35a0
testl %eax, %eax
js 0x544e
callq 0x30d0
testl %eax, %eax
js 0x55ed
movl 0x11c(%rsp), %edi
je 0x55ff
movl %eax, %ebp
callq 0x37b0
movl 0x118(%rsp), %edi
leaq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x35d0
movq %rax, %r13
cmpl $0x1, %r13d
jne 0x5838
cmpl $0x33, %r12d
je 0x58eb
cmpl $0x32, %r12d
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
jne 0x598c
cmpl $0x0, 0xe38(%rbx)
jne 0x541f
callq 0x62d8
leaq 0x4eb1(%rip), %rdx      # 0xa2ad
leaq 0x4f53(%rip), %rcx      # 0xa356
movq %rax, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x6e2c
callq 0x62d8
movq %rax, %rdi
callq 0x726e
cmpb $0x31, 0x20(%rsp)
movq 0xd08(%rbx), %rax
jne 0x5971
movabsq $0x6c6d74682e656d, %rcx # imm = 0x6C6D74682E656D
movq %rcx, 0x6(%rax)
movabsq $0x656d6f636c65772f, %rcx # imm = 0x656D6F636C65772F
jmp 0x5989
cmpl $0x0, 0xe38(%rbx)
jne 0x58e1
jmp 0x5677
leaq 0x128(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x40(%rsp), %r13
movq %r13, %rdi
callq 0x3180
leaq (%rsp,%rax), %rdx
addq $0x40, %rdx
leaq 0x118(%rsp), %rdi
movq %r13, %rsi
callq 0x3e86
leaq 0x9000(%rip), %rdi      # 0xe498
leaq 0x118(%rsp), %rsi
callq 0x694e
leaq 0x8ff4(%rip), %rcx      # 0xe4a0
cmpq %rcx, %rax
je 0x57cd
leaq 0x30(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x40(%rsp), %r13
movq %r13, %rdi
callq 0x3180
leaq (%rsp,%rax), %rdx
addq $0x40, %rdx
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x3e86
leaq 0x8fb1(%rip), %rdi      # 0xe498
leaq 0x20(%rsp), %rsi
callq 0x64b6
leaq 0xb0(%rsp), %rsi
movq %rax, %rdi
callq 0x30f0
testl %eax, %eax
sete %r13b
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x57d0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3430
jmp 0x57d0
leaq 0x118(%rsp), %rdi
callq 0x35a0
testl %eax, %eax
movq 0x10(%rsp), %r15
js 0x566a
callq 0x30d0
testl %eax, %eax
js 0x5847
movl 0x11c(%rsp), %edi
je 0x586f
movl %eax, %ebp
callq 0x37b0
movl 0x118(%rsp), %edi
leaq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x35d0
movq %rax, %r13
movl 0xe38(%rbx), %eax
cmpl $0x1, %r13d
jne 0x58b2
testl %eax, %eax
jne 0x55be
callq 0x62d8
leaq 0x4d12(%rip), %rdx      # 0xa2ad
leaq 0x4db4(%rip), %rcx      # 0xa356
movq %rax, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x6e2c
callq 0x62d8
movq %rax, %rdi
callq 0x726e
cmpb $0x31, 0x20(%rsp)
movq 0xd08(%rbx), %rax
jne 0x5954
movabsq $0x6c6d74682e656d, %rcx # imm = 0x6C6D74682E656D
movq %rcx, 0x6(%rax)
movabsq $0x656d6f636c65772f, %rcx # imm = 0x656D6F636C65772F
jmp 0x596c
cmpl $0x0, 0xe38(%rbx)
jne 0x58e1
jmp 0x5854
movl $0x1, %esi
callq 0x33e0
movl 0x118(%rsp), %edi
callq 0x37b0
leaq 0xe3c(%rbx), %r9
leaq 0xea0(%rbx), %r10
leaq 0xf04(%rbx), %r11
subq $0x8, %rsp
leaq 0x4d2e(%rip), %r8       # 0xa363
leaq 0x17(%rsp), %rsi
leaq 0x48(%rsp), %rdx
leaq 0xb8(%rsp), %rcx
movq %r14, %rdi
xorl %eax, %eax
pushq $0x0
pushq %r11
pushq %r10
callq 0x3540
addq $0x20, %rsp
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
jmp 0x5997
cmpl $0x0, 0xe38(%rbx)
jne 0x58e1
callq 0x62d8
leaq 0x4c9b(%rip), %rdx      # 0xa31e
movq %rax, %rdi
movl $0x3, %esi
movl $0x4, %ecx
jmp 0x58cd
leaq 0x8dd4(%rip), %rdi      # 0xe470
callq 0x35f0
movq 0x8(%rbx), %rdi
movq %r13, %rsi
callq 0x32e0
movl %eax, %ebp
leaq 0x118(%rsp), %r13
leaq 0x40(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
movq %r13, %rdi
callq 0x6402
leaq 0x8dc5(%rip), %rdi      # 0xe498
movq %r13, %rsi
callq 0x6994
leaq 0x118(%rsp), %rdi
callq 0x6480
leaq 0x8d81(%rip), %rdi      # 0xe470
callq 0x3350
movq 0xd08(%rbx), %rax
testl %ebp, %ebp
jne 0x535a
movabsq $0x6d74682e676f6c2f, %rcx # imm = 0x6D74682E676F6C2F
movq %rcx, (%rax)
movw $0x6c, 0x8(%rax)
leaq 0x8d53(%rip), %rdi      # 0xe470
callq 0x35f0
leaq 0x4af0(%rip), %rsi      # 0xa219
leaq 0x118(%rsp), %r13
movq %r13, %rdi
movl $0x1, %edx
callq 0x3460
leaq 0x40(%rsp), %rbp
movq %rbp, %rdi
callq 0x3180
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x34c0
leaq 0x4d47(%rip), %rsi      # 0xa4a7
leaq 0x118(%rsp), %rdi
movl $0x1, %edx
callq 0x34c0
leaq 0xb0(%rsp), %r13
movq %r13, %rdi
callq 0x3180
leaq 0x118(%rsp), %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x34c0
leaq 0x118(%rsp), %rdi
callq 0x31d0
leaq 0x118(%rsp), %rdi
callq 0x35c0
leaq 0x8cba(%rip), %rdi      # 0xe470
callq 0x3350
leaq 0x118(%rsp), %rdi
callq 0x3600
jmp 0x5997
xorl %r13d, %r13d
movq 0x118(%rsp), %rdi
cmpq %r15, %rdi
je 0x57ed
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3430
movq 0xd08(%rbx), %rax
testb %r13b, %r13b
movq 0x10(%rsp), %r15
je 0x5818
movabsq $0x6c6d74682e656d, %rcx # imm = 0x6C6D74682E656D
movq %rcx, 0x6(%rax)
movabsq $0x656d6f636c65772f, %rcx # imm = 0x656D6F636C65772F
jmp 0x5830
movabsq $0x6c6d74682e726f, %rcx # imm = 0x6C6D74682E726F
movq %rcx, 0x7(%rax)
movabsq $0x6f727245676f6c2f, %rcx # imm = 0x6F727245676F6C2F
movq %rcx, (%rax)
jmp 0x5997
cmpl $0x0, 0xe38(%rbx)
jne 0x58e1
jmp 0x58b6
cmpl $0x0, 0xe38(%rbx)
jne 0x58e1
callq 0x62d8
leaq 0x4ace(%rip), %rdx      # 0xa32e
movq %rax, %rdi
movl $0x3, %esi
movl $0x3, %ecx
jmp 0x58cd
movl $0x1, %esi
callq 0x33e0
movl 0x118(%rsp), %edi
callq 0x37b0
leaq 0x498d(%rip), %rcx      # 0xa219
leaq 0x47c0(%rip), %r8       # 0xa053
leaq 0x40(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
movq %r14, %rdi
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x3540
jmp 0x5997
testl %eax, %eax
jne 0x58e1
callq 0x62d8
leaq 0x4a7c(%rip), %rdx      # 0xa33e
movq %rax, %rdi
movl $0x3, %esi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x6e2c
callq 0x62d8
movq %rax, %rdi
callq 0x726e
movl $0x2, %eax
jmp 0x5b41
cmpl $0x0, 0xe38(%rbx)
jne 0x5923
callq 0x62d8
leaq 0x49ad(%rip), %rdx      # 0xa2ad
leaq 0x4a5e(%rip), %rcx      # 0xa365
movq %rax, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x6e2c
callq 0x62d8
movq %rax, %rdi
callq 0x726e
cmpb $0x31, 0x20(%rsp)
movq 0xd08(%rbx), %rax
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
jne 0x5b53
movabsq $0x6d74682e676f6c2f, %rcx # imm = 0x6D74682E676F6C2F
movq %rcx, (%rax)
movw $0x6c, 0x8(%rax)
jmp 0x598c
movabsq $0x6c6d74682e726f, %rcx # imm = 0x6C6D74682E726F
movq %rcx, 0x7(%rax)
movabsq $0x6f727245676f6c2f, %rcx # imm = 0x6F727245676F6C2F
movq %rcx, (%rax)
jmp 0x598c
movabsq $0x6c6d74682e726f, %rcx # imm = 0x6C6D74682E726F
movq %rcx, 0x7(%rax)
movabsq $0x6f727245676f6c2f, %rcx # imm = 0x6F727245676F6C2F
movq %rcx, (%rax)
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3360
movzbl 0x1(%r12), %eax
addl $-0x30, %eax
cmpl $0x7, %eax
ja 0x59e4
leaq 0x46ec(%rip), %rcx      # 0xa098
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xc8, %edi
callq 0x3580
movq %rax, %r12
movabsq $0x657473696765722f, %rax # imm = 0x657473696765722F
movq %rax, (%r12)
movabsq $0x6c6d74682e7265, %rax # imm = 0x6C6D74682E7265
movq %rax, 0x7(%r12)
jmp 0x5aa1
movslq %r15d, %rax
leaq (%r14,%rax), %rdi
movq 0xd08(%rbx), %rsi
movl $0xc7, %ecx
subl %eax, %ecx
movslq %ecx, %rdx
callq 0x3220
jmp 0x5ac5
movl $0xc8, %edi
callq 0x3580
movq %rax, %r12
movabsq $0x657275746369702f, %rax # imm = 0x657275746369702F
movq %rax, (%r12)
movabsq $0x6c6d74682e6572, %rax # imm = 0x6C6D74682E6572
movq %rax, 0x6(%r12)
jmp 0x5aa1
movl $0xc8, %edi
callq 0x3580
movq %rax, %r12
movabsq $0x6d74682e676f6c2f, %rax # imm = 0x6D74682E676F6C2F
movq %rax, (%r12)
movw $0x6c, 0x8(%r12)
jmp 0x5aa1
movl $0xc8, %edi
callq 0x3580
movq %rax, %r12
movabsq $0x682e6f656469762f, %rax # imm = 0x682E6F656469762F
movq %rax, (%r12)
movl $0x6c6d74, 0x8(%r12)    # imm = 0x6C6D74
jmp 0x5aa1
movl $0xc8, %edi
callq 0x3580
movq %rax, %r12
movabsq $0x74682e736e61662f, %rax # imm = 0x74682E736E61662F
movq %rax, (%r12)
movl $0x6c6d74, 0x7(%r12)    # imm = 0x6C6D74
movslq %r15d, %r15
addq %r14, %r15
movq %r12, %rdi
callq 0x3180
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x3220
movq %r12, %rdi
callq 0x3500
leaq 0xd30(%rbx), %rsi
movq %r14, %rdi
callq 0x33c0
testl %eax, %eax
js 0x5b3c
movl 0xd48(%rbx), %ecx
movl $0x4, %eax
testb $0x4, %cl
je 0x5b41
andl $0xf000, %ecx           # imm = 0xF000
movl $0x2, %eax
cmpl $0x4000, %ecx           # imm = 0x4000
je 0x5b41
movq %r14, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x3330
movl %eax, %ebp
movq 0xd60(%rbx), %rsi
xorl %edi, %edi
movl $0x1, %edx
movl $0x2, %ecx
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x3700
movq %rax, 0xd28(%rbx)
movl %ebp, %edi
callq 0x37b0
movl $0x5, %eax
jmp 0x5b41
movl $0x3, %eax
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movups 0x4793(%rip), %xmm0     # 0xa2ed
movups %xmm0, (%rax)
movl $0x6c6d74, 0x10(%rax)   # imm = 0x6C6D74
jmp 0x598c
jmp 0x5b6b
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x6480
jmp 0x5bda
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5bb4
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3430
jmp 0x5bb4
jmp 0x5bb1
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x3600
jmp 0x5bda
jmp 0x5bb1
jmp 0x5bb1
movq %rax, %rbx
movq 0x118(%rsp), %rdi
cmpq %r15, %rdi
je 0x5bda
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3430
jmp 0x5bda
jmp 0x5bd7
jmp 0x5bd7
movq %rax, %rbx
movq %rbx, %rdi
callq 0x36e0