// File: /workspace/github_cpp_makefile_star2_O2/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, %r12d
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rdi
leaq 0x94b3(%rip), %rsi      # 0x2f24b
callq 0xb1d5
testb %al, %al
je 0x25e0e
leaq 0xa0(%rbx), %r15
leaq 0xe0(%rbx), %rdi
leaq 0x9495(%rip), %rsi      # 0x2f24b
callq 0x7700
movq (%r14), %rsi
addq $0x20, %rsi
leaq 0x100(%rbx), %rdi
callq 0x71f0
leaq 0xb241(%rip), %rsi      # 0x31016
movq %r15, %rdi
callq 0x7700
cmpl $0x2, %r12d
jl 0x262a0
movq (%r14), %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 0x71f0
movq (%r14), %rdi
leaq 0x9439(%rip), %rsi      # 0x2f251
callq 0xb1d5
testb %al, %al
je 0x25e45
addq $0x20, %rbx
leaq 0x37f7(%rip), %rsi      # 0x29623
movq %rbx, %rdi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7700
cmpl $0x2, %r12d
jl 0x25f7e
movq (%r14), %rsi
addq $0x58, %rsi
leaq 0xb0(%rsp), %r15
movq %r15, %rdi
callq 0x1d77a
leaq 0xa0(%rbx), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x71f0
leaq 0xd0(%rsp), %rsi
leaq 0xc0(%rbx), %rbp
movq %rbp, %rdi
callq 0x71f0
cmpl $0x2, %r12d
je 0x26293
movl $0xd0, %edi
addq (%r14), %rdi
leaq 0x551c(%rip), %r15      # 0x2b3c4
movq %r15, %rsi
callq 0xb1d5
cmpl $0x4, %r12d
setae %cl
andb %al, %cl
movzbl %cl, %eax
orq $0x2, %rax
movq (%r14), %rcx
imulq $0x58, %rax, %rax
movq %rax, 0x88(%rsp)
leaq (%rcx,%rax), %rsi
addq $0x20, %rsi
leaq 0x100(%rbx), %rdi
movq %rdi, 0x8(%rsp)
callq 0x71f0
leaq 0x9348(%rip), %rsi      # 0x2f237
leaq 0xb0(%rsp), %rdi
callq 0xb1d5
testb %al, %al
je 0x26073
decl %r12d
imulq $0x58, %r12, %r12
movq (%r14), %rsi
addq %r12, %rsi
leaq 0x30(%rsp), %rdi
callq 0x7490
leaq 0xb0fb(%rip), %rsi      # 0x3101d
leaq 0x30(%rsp), %rdi
callq 0xb1d5
testb %al, %al
je 0x261d9
addq $0xe0, %rbx
leaq 0xb0db(%rip), %rsi      # 0x3101d
movq %rbx, %rdi
callq 0x7700
movq (%r14), %rax
leaq (%rax,%r12), %rsi
addq $0x20, %rsi
movq 0x8(%rsp), %rdi
callq 0x71f0
leaq 0xb0bc(%rip), %rsi      # 0x31022
movq %r13, %rdi
callq 0x7700
movq %rbp, %rdi
movq %r15, %rsi
callq 0x7700
jmp 0x26289
cmpl $0x1, %r12d
jne 0x262a0
movq (%r14), %rsi
movq 0x48(%rsi), %rax
subq 0x40(%rsi), %rax
cmpq $0x21, %rax
jb 0x262a0
addq $0x40, %rsi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x1d7d0
movq (%r14), %rdi
leaq 0x9184(%rip), %rsi      # 0x2f13c
callq 0xb1d5
testb %al, %al
je 0x2639b
movq 0x10(%rsp), %rdi
addq $0x20, %rdi
leaq 0xb09b(%rip), %rsi      # 0x31070
callq 0x26502
testb %al, %al
je 0x2639b
leaq 0xe0(%rbx), %r14
leaq 0xb06e(%rip), %rsi      # 0x3105e
movq %r14, %rdi
callq 0x7700
leaq 0xa0(%rbx), %rdi
leaq 0x923d(%rip), %rsi      # 0x2f243
callq 0x7700
movq 0x18(%rsp), %rdi
addq $-0x20, %rdi
leaq 0xb01e(%rip), %rsi      # 0x31039
callq 0x1f125
testb %al, %al
je 0x26033
leaq 0xb00e(%rip), %rsi      # 0x31039
movq %r14, %rdi
callq 0x7700
movq 0x18(%rsp), %r15
subq 0x10(%rsp), %r15
sarq $0x5, %r15
xorl %r12d, %r12d
leaq 0x91f8(%rip), %r14      # 0x2f243
subq $0x1, %r15
jb 0x262f6
movq 0x10(%rsp), %rdi
addq %r12, %rdi
movq %r14, %rsi
callq 0x1f0da
testb %al, %al
jne 0x262b2
addq $0x20, %r12
jmp 0x2604b
leaq 0x1d6c(%rip), %rsi      # 0x27de6
leaq 0xb0(%rsp), %rdi
callq 0xb1d5
testb %al, %al
je 0x260f5
movl $0xb0, %esi
addq (%r14), %rsi
leaq 0x30(%rsp), %rdi
callq 0x7490
leaq 0x3427(%rip), %rsi      # 0x294cb
leaq 0x30(%rsp), %rdi
callq 0xb1d5
cmpl $0x5, %r12d
jb 0x260dc
testb %al, %al
je 0x260dc
movl $0x160, %esi            # imm = 0x160
addq (%r14), %rsi
leaq 0x30(%rsp), %rdi
callq 0x71f0
movl $0x180, %esi            # imm = 0x180
addq (%r14), %rsi
movq 0x8(%rsp), %rdi
callq 0x71f0
addq $0xe0, %rbx
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x71f0
jmp 0x26289
leaq 0xaf5d(%rip), %rsi      # 0x31059
leaq 0xb0(%rsp), %rdi
callq 0xb1d5
testb %al, %al
je 0x26293
movl $0xb0, %edi
addq (%r14), %rdi
leaq 0x1cc6(%rip), %rsi      # 0x27de6
callq 0xb1d5
testb %al, %al
je 0x26293
leaq 0x910f(%rip), %rsi      # 0x2f243
movq %r13, %rdi
callq 0x7700
addq $0xe0, %rbx
leaq 0xaf14(%rip), %rsi      # 0x3105e
movq %rbx, %rdi
callq 0x7700
movq (%r14), %rax
movq 0x40(%rax), %rbx
movq 0x48(%rax), %r13
leaq 0x68(%rsp), %rbp
leaq 0x10(%rsp), %r14
leaq 0x1b39a(%rip), %r15     # 0x41508
leaq 0x30(%rsp), %r12
cmpq %r13, %rbx
je 0x263aa
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7490
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movb $0x0, 0x60(%rsp)
movups %xmm0, (%rbp)
andl $0x0, 0x10(%rbp)
movb $0x1, 0x7c(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x264e7
testb %al, %al
jne 0x263c0
movq %r12, %rdi
callq 0x21160
movq %r14, %rdi
callq 0x7748
addq $0x20, %rbx
jmp 0x26173
leaq 0xae4b(%rip), %rsi      # 0x3102b
leaq 0x30(%rsp), %rdi
callq 0xb1d5
testb %al, %al
je 0x26206
addq $0xe0, %rbx
leaq 0x904f(%rip), %rsi      # 0x2f24b
movq %rbx, %rdi
callq 0x7700
jmp 0x2622f
leaq 0xae22(%rip), %rsi      # 0x3102f
leaq 0x30(%rsp), %rdi
callq 0xb1d5
testb %al, %al
je 0x2623c
addq $0xe0, %rbx
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x71f0
movq (%r14), %rax
leaq (%rax,%r12), %r15
addq $0x20, %r15
jmp 0x2627c
leaq 0xadf6(%rip), %rsi      # 0x31039
leaq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0xb1d5
testb %al, %al
jne 0x26270
leaq 0xade4(%rip), %rsi      # 0x3103f
leaq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0xb1d5
testb %al, %al
je 0x2640e
addq $0xe0, %rbx
movq %rbx, 0x8(%rsp)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x71f0
leaq 0x30(%rsp), %rdi
callq 0x7748
leaq 0xb0(%rsp), %rdi
callq 0xb1b6
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rax
movq (%rax,%r12), %rdi
decq %rdi
movsbl 0x1(%rdi), %eax
incq %rdi
addl $-0x3a, %eax
cmpl $-0xa, %eax
jb 0x262be
callq 0x7550
addl $-0x4, %eax
cmpl $0x3, %eax
jae 0x262f6
movl %eax, %eax
leaq 0xad9d(%rip), %rcx      # 0x31080
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
leaq 0x100(%rbx), %rdi
callq 0x7700
addq $0x100, %rbx            # imm = 0x100
leaq 0x50c0(%rip), %rsi      # 0x2b3c4
movq %rbx, %rdi
callq 0xb1d5
testb %al, %al
je 0x2639b
leaq 0xc0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
leaq 0xb0(%rsp), %rdi
pushq $0x4
popq %rdx
pushq $-0x1
popq %rcx
callq 0x71c0
leaq 0x90(%rsp), %r14
movq %r14, %rdi
callq 0x7720
leaq 0x30(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
movq %r14, %rdx
callq 0x21108
leaq 0x30(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7400
movq %r14, %rdi
callq 0x7748
leaq 0x90(%rsp), %rdi
callq 0x74b0
leaq 0xb0(%rsp), %rdi
callq 0x7748
leaq 0x10(%rsp), %rdi
callq 0xb230
jmp 0x262a0
leaq 0x5013(%rip), %rsi      # 0x2b3c4
movq 0x8(%rsp), %rdi
callq 0x7700
jmp 0x26293
leaq 0x30(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x21076
leaq 0x90(%rsp), %rdi
movq %rax, %rsi
callq 0x210ce
leaq 0x90(%rsp), %rbx
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x7400
movq %rbx, %rdi
callq 0x7748
leaq 0x30(%rsp), %rdi
callq 0x21160
leaq 0x10(%rsp), %rdi
jmp 0x2628e
movq (%r14), %rdi
movq 0x88(%rsp), %r12
addq %r12, %rdi
leaq 0xac26(%rip), %r15      # 0x31049
movq %r15, %rsi
callq 0xb1d5
testb %al, %al
je 0x26438
addq $0xe0, %rbx
jmp 0x26461
addq (%r14), %r12
leaq 0xac0e(%rip), %r14      # 0x31050
movq %r12, %rdi
movq %r14, %rsi
callq 0xb1d5
addq $0xe0, %rbx
leaq 0x8d84(%rip), %r15      # 0x2f1df
testb %al, %al
cmovneq %r14, %r15
movq %rbx, %rbp
jmp 0x25f6e
jmp 0x264c0
jmp 0x26499
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x74b0
jmp 0x26482
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x7748
jmp 0x264c3
jmp 0x264cf
jmp 0x264b1
jmp 0x264cf
jmp 0x264c0
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x21160
leaq 0x10(%rsp), %rdi
jmp 0x264b9
jmp 0x264cf
jmp 0x264cf
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x7748
jmp 0x264d2
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xb230
jmp 0x264df
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xb1b6
movq %rbx, %rdi
callq 0x7640