// File: /workspace/github_cpp_makefile_star2_O3/yayuntian[P]user_agent/browser.cpp
// Function: detectBrowser(UserAgent&, std::vector<Section, std::allocator<Section>>&, int)
void detectBrowser(UserAgent& p, vector<Section>& sections, int slen) {

    if (sections[0].name == "Opera") {
        p.browser.Name = "Opera";
        p.browser.Version = sections[0].version;
        p.browser.Engine = "Presto";
        if (slen > 1) {
            p.browser.EngineVersion = sections[1].version;
        }
    } else if (sections[0].name == "Dalvik") {
        p.mozilla = "5.0";
    } else if (slen > 1) {
        Section engine = sections[1];
        p.browser.Engine = engine.name;
        p.browser.EngineVersion = engine.version;
        if (slen > 2) {
            int sectionIndex = 2;
            if (sections[2].version == "" && slen > 3) {
                sectionIndex = 3;
            }
            p.browser.Version = sections[sectionIndex].version;
            if (engine.name == "AppleWebKit") {
                string name = sections[slen - 1].name;
                if (name == "Edge") {
                    p.browser.Name = "Edge";
                    p.browser.Version = sections[slen - 1].version;
                    p.browser.Engine = "EdgeHTML";
                    p.browser.EngineVersion = "";
                } else if (name == "OPR") {
                    p.browser.Name = "Opera";
                    p.browser.Version = sections[slen - 1].version;
                } else if (name == "QQBrowser") {
                    p.browser.Name = name;
                    p.browser.Version = sections[slen - 1].version;
                } else if (name == "360SE") {
                    p.browser.Name = name;
//                    p.browser.Version = sections[slen - 1].version;
                } else if (name == "LBBROWSER") {
                    p.browser.Name = name;
//                    p.browser.Version = sections[slen - 1].version;
                } else {
                    if (sections[sectionIndex].name == "Chrome") {
                        p.browser.Name = "Chrome";
                    } else if (sections[sectionIndex].name == "Chromium") {
                        p.browser.Name = "Chromium";
                    } else {
                        p.browser.Name = "Safari";
                    }
                }
            } else if (engine.name == "Gecko") {
                string name = sections[2].name;
                if (name == "MRA" && slen > 4) {
                    name = sections[4].name;
                    p.browser.Version = sections[4].version;
                }
                p.browser.Name = name;
            } else if (engine.name == "like" && sections[2].name == "Gecko") {
                p.browser.Engine = "Trident";
                p.browser.Name = "Internet Explorer";
                for (auto s : sections[0].comment) {
                    boost::smatch what;
                    if (boost::regex_search(s, what, ie11Regexp)) {
                        p.browser.Version = what[1];
                        return;
                    }
                }
                p.browser.Version = "";
            }
        }
    } else if (slen == 1 && sections[0].comment.size() > 1) {
        vector<string> comment = sections[0].comment;
        if (comment[0] == "compatible" && starts_with(comment[1], "MSIE")) {
            p.browser.Name = "Internet Explorer";
            p.browser.Engine = "Trident";

            if (starts_with(comment[comment.size() - 1], "360SE")) {
                p.browser.Name = "360SE";
            }

            size_t len = comment.size();
            for (size_t i = 0; i < len; i++) {
                if (starts_with(comment[i], "Trident")) {
                    switch (my_atoi(comment[i].c_str())) {
                        case 4:
                            p.browser.Version = "8.0";
                            break;
                        case 5:
                            p.browser.Version = "9.0";
                            break;
                        case 6:
                            p.browser.Version = "10.0";
                            break;
                        default:
                            break;
                    }
                    break;
                }
            }
            if (p.browser.Version == "") {
                string ver;
                ver.assign(comment[1], 4, string::npos);
                p.browser.Version = trim_copy(ver);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %rbx
movq (%rsi), %rdi
leaq 0x9cd3(%rip), %rsi      # 0x3526b
callq 0x60d0
testl %eax, %eax
je 0x2b81c
movq (%r15), %rdi
leaq 0x9cc2(%rip), %rsi      # 0x35271
callq 0x60d0
testl %eax, %eax
je 0x2b8a7
cmpl $0x2, %r13d
jl 0x2b8d7
movq (%r15), %r14
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x58(%r14), %rsi
movq 0x60(%r14), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0xc5fa
leaq 0xa8(%rsp), %r12
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x78(%r14), %rsi
movq 0x80(%r14), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xc5fa
leaq 0xc8(%rsp), %rdi
addq $0x98, %r14
movq %r14, %rsi
callq 0x21c06
leaq 0xa0(%rbx), %rbp
leaq 0x88(%rsp), %rsi
movq %rbp, %rdi
callq 0x61f0
leaq 0xc0(%rbx), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x61f0
cmpl $0x2, %r13d
je 0x2bdaf
movl $0xd0, %edi
addq (%r15), %rdi
leaq 0x5d54(%rip), %r12      # 0x313c4
movq %r12, %rsi
callq 0x60d0
testl %eax, %eax
sete %al
cmpl $0x4, %r13d
setae %cl
andb %al, %cl
movzbl %cl, %eax
orq $0x2, %rax
movq (%r15), %rcx
imulq $0x58, %rax, %rax
movq %rax, 0x100(%rsp)
leaq (%rcx,%rax), %rsi
addq $0x20, %rsi
leaq 0x100(%rbx), %rdi
movq %rdi, 0x8(%rsp)
callq 0x61f0
leaq 0x9b9b(%rip), %rsi      # 0x35257
leaq 0x88(%rsp), %rdi
callq 0x60d0
testl %eax, %eax
je 0x2badc
leaq 0x270e(%rip), %rsi      # 0x2dde6
leaq 0x88(%rsp), %rdi
callq 0x60d0
testl %eax, %eax
je 0x2bbdb
leaq 0xb985(%rip), %rsi      # 0x37079
leaq 0x88(%rsp), %rdi
callq 0x60d0
testl %eax, %eax
jne 0x2bdaf
movl $0xb0, %edi
addq (%r15), %rdi
leaq 0x26ce(%rip), %rsi      # 0x2dde6
callq 0x60d0
testl %eax, %eax
jne 0x2bdaf
leaq 0x9b37(%rip), %rsi      # 0x35263
movq %rbp, %rdi
callq 0x6490
addq $0xe0, %rbx
leaq 0xb93c(%rip), %rsi      # 0x3707e
movq %rbx, %rdi
callq 0x6490
movq (%r15), %rax
movq 0x40(%rax), %r13
movq 0x48(%rax), %rbp
cmpq %rbp, %r13
je 0x2b806
leaq 0x20(%rsp), %r12
leaq 0x68(%rsp), %rbx
leaq 0x18d69(%rip), %r14     # 0x444d8
leaq 0x30(%rsp), %r15
movq %r12, 0x10(%rsp)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0xc5fa
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movb $0x0, 0x60(%rsp)
movups %xmm0, (%rbx)
movl $0x0, 0x10(%rbx)
movb $0x1, 0x7c(%rsp)
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %r15, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
movq %rdi, %r9
callq 0x2644a
testb %al, %al
jne 0x2bcfc
movq %r15, %rdi
callq 0x26426
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x2b7f9
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6340
addq $0x20, %r13
cmpq %rbp, %r13
jne 0x2b774
leaq 0x5bb7(%rip), %rsi      # 0x313c4
movq 0x8(%rsp), %rdi
callq 0x6490
jmp 0x2bdaf
leaq 0xa0(%rbx), %r14
leaq 0xe0(%rbx), %rdi
movq 0xe8(%rbx), %rdx
leaq 0x9a33(%rip), %rcx      # 0x3526b
movl $0x5, %r8d
xorl %esi, %esi
callq 0x6550
movq (%r15), %rsi
addq $0x20, %rsi
leaq 0x100(%rbx), %rdi
callq 0x61f0
movq 0xa8(%rbx), %rdx
leaq 0xb7d0(%rip), %rcx      # 0x37036
movl $0x6, %r8d
movq %r14, %rdi
xorl %esi, %esi
callq 0x6550
cmpl $0x2, %r13d
jl 0x2be06
movq (%r15), %rsi
addq $0x78, %rsi
addq $0xc0, %rbx
movq %rbx, %rdi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x61f0
movq 0x28(%rbx), %rdx
addq $0x20, %rbx
leaq 0x3d6d(%rip), %rcx      # 0x2f623
movl $0x3, %r8d
movq %rbx, %rdi
xorl %esi, %esi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6550
cmpl $0x1, %r13d
jne 0x2be06
movq (%r15), %rsi
movq 0x48(%rsi), %rax
subq 0x40(%rsi), %rax
cmpq $0x21, %rax
jb 0x2be06
addq $0x40, %rsi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x21c06
movq (%r14), %rdi
leaq 0x984b(%rip), %rsi      # 0x3515c
callq 0x60d0
testl %eax, %eax
jne 0x2bacd
movq 0x10(%rsp), %rdi
addq $0x20, %rdi
leaq 0xb762(%rip), %rsi      # 0x37090
callq 0x2bfa2
testb %al, %al
je 0x2bacd
leaq 0xe0(%rbx), %r15
leaq 0xb735(%rip), %rsi      # 0x3707e
movq %r15, %rdi
callq 0x6490
leaq 0xa0(%rbx), %rdi
leaq 0x9904(%rip), %r14      # 0x35263
movq %r14, %rsi
callq 0x6490
movq 0x18(%rsp), %rdi
addq $-0x20, %rdi
leaq 0xb6e2(%rip), %rsi      # 0x37059
callq 0x2c005
testb %al, %al
je 0x2b98f
leaq 0xb6d2(%rip), %rsi      # 0x37059
movq %r15, %rdi
callq 0x6490
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
je 0x2b9fc
sarq $0x5, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
movq %rdx, %rdi
shlq $0x5, %rdi
movq 0x8(%rax,%rdi), %rsi
testq %rsi, %rsi
je 0x2b9f4
movq (%rax,%rdi), %rdi
decq %rsi
cmpq $0x6, %rsi
movl $0x6, %r8d
cmovbq %rsi, %r8
incq %r8
xorl %r9d, %r9d
movb (%rdi,%r9), %r10b
cmpb (%r9,%r14), %r10b
jne 0x2b9f4
incq %r9
cmpq %r9, %r8
jne 0x2b9d8
cmpq $0x6, %rsi
jae 0x2bd3a
incq %rdx
cmpq %rcx, %rdx
jne 0x2b9ac
addq $0x100, %rbx            # imm = 0x100
leaq 0x59ba(%rip), %rsi      # 0x313c4
movq %rbx, %rdi
callq 0x60d0
testl %eax, %eax
jne 0x2bacd
leaq 0x98(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
leaq 0x88(%rsp), %rdi
movl $0x4, %edx
movq $-0x1, %rcx
callq 0x61c0
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
callq 0x66d0
leaq 0x30(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movq %r14, %rdx
callq 0x2c068
leaq 0x30(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6410
movq (%r14), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2baa3
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6340
leaq 0xe0(%rsp), %rdi
callq 0x64b0
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bacd
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x6340
leaq 0x10(%rsp), %rdi
callq 0xd4b2
jmp 0x2be06
decl %r13d
movq (%r15), %rax
imulq $0x58, %r13, %r13
leaq 0x40(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0xc5fa
leaq 0xb531(%rip), %rsi      # 0x3703d
leaq 0x30(%rsp), %rdi
callq 0x60d0
testl %eax, %eax
je 0x2bc68
leaq 0xb526(%rip), %rsi      # 0x3704b
leaq 0x30(%rsp), %rdi
callq 0x60d0
testl %eax, %eax
je 0x2bca7
leaq 0xb511(%rip), %rsi      # 0x3704f
leaq 0x30(%rsp), %rdi
callq 0x60d0
testl %eax, %eax
je 0x2bccb
leaq 0xb502(%rip), %rsi      # 0x37059
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x60d0
testl %eax, %eax
je 0x2bcbf
leaq 0xb4ec(%rip), %rsi      # 0x3705f
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x60d0
testl %eax, %eax
je 0x2bcbf
movq (%r15), %rdi
movq 0x100(%rsp), %r13
addq %r13, %rdi
leaq 0xb4cc(%rip), %r12      # 0x37069
movq %r12, %rsi
callq 0x60d0
testl %eax, %eax
je 0x2bd7e
addq (%r15), %r13
leaq 0xb4b9(%rip), %r14      # 0x37070
movq %r13, %rdi
movq %r14, %rsi
callq 0x60d0
addq $0xe0, %rbx
testl %eax, %eax
leaq 0x962d(%rip), %r12      # 0x351ff
cmoveq %r14, %r12
jmp 0x2bd85
movq (%r15), %rax
leaq 0x40(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xb0(%rax), %rsi
movq 0xb8(%rax), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0xc5fa
leaq 0x38c2(%rip), %rsi      # 0x2f4cb
leaq 0x30(%rsp), %rdi
callq 0x60d0
cmpl $0x5, %r13d
jb 0x2bc41
testl %eax, %eax
jne 0x2bc41
movl $0x160, %esi            # imm = 0x160
addq (%r15), %rsi
leaq 0x30(%rsp), %rdi
callq 0x61f0
movl $0x180, %esi            # imm = 0x180
addq (%r15), %rsi
movq 0x8(%rsp), %rdi
callq 0x61f0
addq $0xe0, %rbx
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x61f0
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
jne 0x2bda2
jmp 0x2bdaf
addq $0xe0, %rbx
leaq 0xb3c7(%rip), %rsi      # 0x3703d
movq %rbx, %rdi
callq 0x6490
movq (%r15), %rax
leaq (%rax,%r13), %rsi
addq $0x20, %rsi
movq 0x8(%rsp), %rdi
callq 0x61f0
leaq 0xb3a8(%rip), %rsi      # 0x37042
movq %rbp, %rdi
callq 0x6490
jmp 0x2bd88
addq $0xe0, %rbx
leaq 0x95b6(%rip), %rsi      # 0x3526b
movq %rbx, %rdi
callq 0x6490
jmp 0x2bcdf
addq $0xe0, %rbx
movq %rbx, %rdi
jmp 0x2bcef
addq $0xe0, %rbx
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x61f0
movq (%r15), %rax
leaq (%rax,%r13), %r14
addq $0x20, %r14
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x61f0
jmp 0x2bd93
leaq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0x263ce
cmpb $0x1, 0x10(%rax)
jne 0x2be18
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xe0(%rsp), %rdi
callq 0x25824
jmp 0x2be2f
decq %rdi
movsbl 0x1(%rdi), %eax
incq %rdi
addl $-0x3a, %eax
cmpl $-0xa, %eax
jb 0x2bd3d
callq 0x6560
addl $-0x4, %eax
cmpl $0x3, %eax
jae 0x2b9fc
movl %eax, %eax
leaq 0xb33a(%rip), %rcx      # 0x370a0
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
leaq 0x100(%rbx), %rdi
callq 0x6490
jmp 0x2b9fc
addq $0xe0, %rbx
movq %rbx, %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x6490
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2bdaf
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6340
leaq 0xc8(%rsp), %rdi
callq 0xd4b2
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x2bde1
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x6340
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x2be06
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x6340
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xe0(%rsp), %rbx
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x6410
movq (%rbx), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x2be64
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x6340
leaq 0x30(%rsp), %rdi
callq 0x26426
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x2bdaf
movq 0x20(%rsp), %rsi
jmp 0x2bda7
jmp 0x2beda
jmp 0x2bef1
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x64b0
jmp 0x2be9f
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bedd
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x6340
jmp 0x2bedd
jmp 0x2bf8a
jmp 0x2bf8a
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
jne 0x2bf25
jmp 0x2bf8d
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xd4b2
jmp 0x2bf9a
jmp 0x2bf8a
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x26426
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x2bf8d
movq 0x20(%rsp), %rsi
jmp 0x2bf2a
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2bf8d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6340
jmp 0x2bf8d
jmp 0x2bf8a
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x2bf63
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x6340
jmp 0x2bf63
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x2bf9a
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x6340
jmp 0x2bf9a
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0xd3da
movq %rbx, %rdi
callq 0x6630