// File: yayuntian[P]user_agent/userAgent.cpp
// Function: Parse(UserAgent&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
void Parse(UserAgent& p, string ua, const int ua_len) {

#ifdef LRU_CACHE
    if (cacheUA.exists(ua) == true) {
        p = cacheUA.get(ua);
        return;
    }
#endif
    vector<Section> sections;
    initialize(p);
    p.ua = ua;

    int index = 0;

    while (index < ua_len) {
        Section s = parseSection(ua, ua_len, index);
        if (!p.mobile && s.name == "Mobile") {
            p.mobile = true;
        }
        sections.push_back(s);
    }

    int slen = sections.size();
    if (slen > 0) {
        if (sections[0].name == "Mozilla") {
            p.mozilla = sections[0].version;
        }

        detectBrowser(p, sections, slen);
        detectOS(p, sections[0], sections[0].comment.size());

        if (p.undecided) {
            checkBot(p, sections, slen);
        }
#ifdef LRU_CACHE
        cacheUA.put(ua, p);
#endif
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rsi, -0xa8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x15580
movq -0x8(%rbp), %rdi
callq 0x14ad0
jmp 0x14c01
movq -0xa8(%rbp), %rsi
movq -0x8(%rbp), %rdi
callq 0x8060
jmp 0x14c13
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x14cd4
movq -0xa8(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x98(%rbp), %rdi
leaq -0x40(%rbp), %rcx
callq 0x148d0
jmp 0x14c42
movq -0x8(%rbp), %rax
testb $0x1, 0x121(%rax)
jne 0x14cb1
leaq 0x59a0c(%rip), %rsi     # 0x6e662
leaq -0x98(%rbp), %rdi
callq 0x155a0
movb %al, -0xa9(%rbp)
jmp 0x14c6a
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x14c76
jmp 0x14cb1
movq -0x8(%rbp), %rax
movb $0x1, 0x121(%rax)
jmp 0x14cb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x14df5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x15540
jmp 0x14df5
leaq -0x30(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x155d0
jmp 0x14cc3
leaq -0x98(%rbp), %rdi
callq 0x15540
jmp 0x14c1a
leaq -0x30(%rbp), %rdi
callq 0x15640
movl %eax, -0x9c(%rbp)
cmpl $0x0, -0x9c(%rbp)
jle 0x14de3
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x15670
movq %rax, %rdi
leaq 0x53954(%rip), %rsi     # 0x6865b
callq 0x155a0
movb %al, -0xaa(%rbp)
jmp 0x14d14
movb -0xaa(%rbp), %al
testb $0x1, %al
jne 0x14d20
jmp 0x14d45
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x15670
movq %rax, %rsi
addq $0x20, %rsi
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
callq 0x8060
jmp 0x14d43
jmp 0x14d45
movq -0x8(%rbp), %rdi
movl -0x9c(%rbp), %edx
leaq -0x30(%rbp), %rsi
callq 0x64a40
jmp 0x14d5a
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0xc8(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x15670
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq %rax, -0xb8(%rbp)
callq 0x15670
movq %rax, %rdi
addq $0x40, %rdi
callq 0x15690
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movl %eax, %edx
callq 0x4f520
jmp 0x14dbd
movq -0x8(%rbp), %rax
testb $0x1, 0x122(%rax)
je 0x14de1
movq -0x8(%rbp), %rdi
movl -0x9c(%rbp), %edx
leaq -0x30(%rbp), %rsi
callq 0x56830
jmp 0x14ddf
jmp 0x14de1
jmp 0x14de3
leaq -0x30(%rbp), %rdi
callq 0x156b0
addq $0xd0, %rsp
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x156b0
movq -0x38(%rbp), %rdi
callq 0x88a0
nopw (%rax,%rax)