// File: /workspace/github_cpp_makefile_star2_O3/yckwong[P]tinywebserver/http/http_conn.cpp
// Function: http_conn::parse_request_line(char*)
http_conn::HTTP_CODE http_conn::parse_request_line(char *text)
{
    m_url = strpbrk(text, " \t");
    if (!m_url)
    {
        return BAD_REQUEST;
    }
    *m_url++ = '\0';
    char *method = text;
    if (strcasecmp(method, "GET") == 0)
        m_method = GET;
    else if (strcasecmp(method, "POST") == 0)
    {
        m_method = POST;
        cgi = 1;
    }
    else
        return BAD_REQUEST;
    m_url += strspn(m_url, " \t");
    m_version = strpbrk(m_url, " \t");
    if (!m_version)
        return BAD_REQUEST;
    *m_version++ = '\0';
    m_version += strspn(m_version, " \t");
    if (strcasecmp(m_version, "HTTP/1.1") != 0)
        return BAD_REQUEST;
    if (strncasecmp(m_url, "http://", 7) == 0)
    {
        m_url += 7;
        m_url = strchr(m_url, '/');
    }

    if (strncasecmp(m_url, "https://", 8) == 0)
    {
        m_url += 8;
        m_url = strchr(m_url, '/');
    }

    if (!m_url || m_url[0] != '/')
        return BAD_REQUEST;
    //当url为/时，显示判断界面
    if (strlen(m_url) == 1)
        strcat(m_url, "judge.html");
    m_check_state = CHECK_STATE_HEADER;
    return NO_REQUEST;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x5748(%rip), %rsi      # 0xa23c
movq %r14, %rdi
callq 0x36d0
movq %rax, 0xd08(%rbx)
movl $0x2, %ebp
testq %rax, %rax
je 0x4be8
movq %rax, %rcx
incq %rcx
movq %rcx, 0xd08(%rbx)
movb $0x0, (%rax)
leaq 0x5717(%rip), %rsi      # 0xa23f
movq %r14, %rdi
callq 0x3470
testl %eax, %eax
je 0x4b61
leaq 0x5708(%rip), %rsi      # 0xa243
movq %r14, %rdi
callq 0x3470
testl %eax, %eax
jne 0x4be8
movl $0x1, 0xc3c(%rbx)
movl $0x1, %eax
movl $0xde4, %ecx            # imm = 0xDE4
jmp 0x4b68
xorl %eax, %eax
movl $0xc3c, %ecx            # imm = 0xC3C
movl %eax, (%rbx,%rcx)
movq 0xd08(%rbx), %r14
leaq 0x56c3(%rip), %r15      # 0xa23c
movq %r14, %rdi
movq %r15, %rsi
callq 0x3170
addq %rax, %r14
movq %r14, 0xd08(%rbx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x36d0
movq %rax, 0xd10(%rbx)
testq %rax, %rax
je 0x4be8
movq %rax, %rcx
incq %rcx
movq %rcx, 0xd10(%rbx)
movb $0x0, (%rax)
movq 0xd10(%rbx), %r14
leaq 0x5679(%rip), %rsi      # 0xa23c
movq %r14, %rdi
callq 0x3170
addq %rax, %r14
movq %r14, 0xd10(%rbx)
leaq 0x566c(%rip), %rsi      # 0xa248
movq %r14, %rdi
callq 0x3470
testl %eax, %eax
je 0x4bf5
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xd08(%rbx), %r14
leaq 0x564e(%rip), %rsi      # 0xa251
movl $0x7, %edx
movq %r14, %rdi
callq 0x3560
testl %eax, %eax
jne 0x4c36
addq $0x7, %r14
movq %r14, 0xd08(%rbx)
movq %r14, %rdi
movl $0x2f, %esi
callq 0x3150
movq %rax, %r14
movq %rax, 0xd08(%rbx)
leaq 0x561c(%rip), %rsi      # 0xa259
movl $0x8, %edx
movq %r14, %rdi
callq 0x3560
testl %eax, %eax
jne 0x4c70
addq $0x8, %r14
movq %r14, 0xd08(%rbx)
movq %r14, %rdi
movl $0x2f, %esi
callq 0x3150
movq %rax, %r14
movq %rax, 0xd08(%rbx)
testq %r14, %r14
je 0x4be8
cmpb $0x2f, (%r14)
jne 0x4be8
movq %r14, %rdi
callq 0x3180
cmpq $0x1, %rax
jne 0x4cb0
movq %r14, %rdi
callq 0x3180
movabsq $0x74682e656764756a, %rcx # imm = 0x74682E656764756A
movq %rcx, (%r14,%rax)
movl $0x6c6d74, 0x7(%r14,%rax) # imm = 0x6C6D74
movl $0x1, 0xc38(%rbx)
xorl %ebp, %ebp
jmp 0x4be8
nop