// File: /workspace/github_cpp_makefile_star2_O1/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 0x9983(%rip), %rsi      # 0x372bb
callq 0x70d0
testl %eax, %eax
je 0x2dc7f
movq (%r15), %rdi
leaq 0x9972(%rip), %rsi      # 0x372c1
callq 0x70d0
testl %eax, %eax
je 0x2dd0a
cmpl $0x2, %r13d
jl 0x2dd3a
movq (%r15), %r14
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x58(%r14), %rsi
movq 0x60(%r14), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %rdi
callq 0xe87a
leaq 0xc8(%rsp), %r12
leaq 0xd8(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x78(%r14), %rsi
movq 0x80(%r14), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xe87a
leaq 0xe8(%rsp), %rdi
addq $0x98, %r14
movq %r14, %rsi
callq 0x2403a
leaq 0xa0(%rbx), %rbp
leaq 0xa8(%rsp), %rsi
movq %rbp, %rdi
callq 0x71f0
leaq 0xc0(%rbx), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x71f0
cmpl $0x2, %r13d
je 0x2e1d3
movl $0xd0, %edi
addq (%r15), %rdi
leaq 0x59b4(%rip), %r12      # 0x333c4
movq %r12, %rsi
callq 0x70d0
testl %eax, %eax
sete %al
cmpl $0x4, %r13d
setge %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 0x71f0
leaq 0x984b(%rip), %rsi      # 0x372a7
leaq 0xa8(%rsp), %rdi
callq 0x70d0
testl %eax, %eax
je 0x2df3f
leaq 0x236e(%rip), %rsi      # 0x2fde6
leaq 0xa8(%rsp), %rdi
callq 0x70d0
testl %eax, %eax
je 0x2e03e
leaq 0xb635(%rip), %rsi      # 0x390c9
leaq 0xa8(%rsp), %rdi
callq 0x70d0
testl %eax, %eax
jne 0x2e1d3
movl $0xb0, %edi
addq (%r15), %rdi
leaq 0x232e(%rip), %rsi      # 0x2fde6
callq 0x70d0
testl %eax, %eax
jne 0x2e1d3
leaq 0x97e7(%rip), %rsi      # 0x372b3
movq %rbp, %rdi
callq 0x7490
addq $0xe0, %rbx
leaq 0xb5ec(%rip), %rsi      # 0x390ce
movq %rbx, %rdi
callq 0x7490
movq (%r15), %rax
movq 0x40(%rax), %rbp
movq 0x48(%rax), %rbx
cmpq %rbx, %rbp
je 0x2dc69
leaq 0x20(%rsp), %r12
leaq 0x68(%rsp), %r15
leaq 0x30(%rsp), %r13
movq %r12, 0x10(%rsp)
movq (%rbp), %rsi
movq 0x8(%rbp), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0xe87a
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movb $0x0, 0x60(%rsp)
movups %xmm0, (%r15)
movl $0x0, 0x10(%r15)
movb $0x1, 0x7c(%rsp)
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %r13, %rdx
leaq 0x18972(%rip), %rcx     # 0x464d8
xorl %r8d, %r8d
movq %rdi, %r9
callq 0x288d2
movl %eax, %r14d
testb %al, %al
je 0x2dbb1
movq %r13, %rdi
movl $0x1, %esi
callq 0x28856
cmpb $0x1, 0x10(%rax)
jne 0x2dbd9
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x27c50
jmp 0x2dbfd
movq %r13, %rdi
callq 0x288ae
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x2dc5c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7340
jmp 0x2dc5c
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq $0x0, 0x90(%rsp)
movb $0x0, 0x98(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x7410
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x2dc34
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x7340
movq %r13, %rdi
callq 0x288ae
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x2dc53
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7340
testb %r14b, %r14b
jne 0x2e1d3
addq $0x20, %rbp
cmpq %rbx, %rbp
jne 0x2db0d
leaq 0x5754(%rip), %rsi      # 0x333c4
movq 0x8(%rsp), %rdi
callq 0x7490
jmp 0x2e1d3
leaq 0xa0(%rbx), %r14
leaq 0xe0(%rbx), %rdi
movq 0xe8(%rbx), %rdx
leaq 0x9620(%rip), %rcx      # 0x372bb
movl $0x5, %r8d
xorl %esi, %esi
callq 0x7550
movq (%r15), %rsi
addq $0x20, %rsi
leaq 0x100(%rbx), %rdi
callq 0x71f0
movq 0xa8(%rbx), %rdx
leaq 0xb3bd(%rip), %rcx      # 0x39086
movl $0x6, %r8d
movq %r14, %rdi
xorl %esi, %esi
callq 0x7550
cmpl $0x2, %r13d
jl 0x2e22a
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 0x71f0
movq 0x28(%rbx), %rdx
addq $0x20, %rbx
leaq 0x390a(%rip), %rcx      # 0x31623
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 0x7550
cmpl $0x1, %r13d
jne 0x2e22a
movq (%r15), %rsi
movq 0x48(%rsi), %rax
subq 0x40(%rsi), %rax
cmpq $0x21, %rax
jb 0x2e22a
addq $0x40, %rsi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x2403a
movq (%r14), %rdi
leaq 0x9438(%rip), %rsi      # 0x371ac
callq 0x70d0
testl %eax, %eax
jne 0x2df30
movq 0x10(%rsp), %rdi
addq $0x20, %rdi
leaq 0xb34f(%rip), %rsi      # 0x390e0
callq 0x2e358
testb %al, %al
je 0x2df30
leaq 0xe0(%rbx), %r15
leaq 0xb322(%rip), %rsi      # 0x390ce
movq %r15, %rdi
callq 0x7490
leaq 0xa0(%rbx), %rdi
leaq 0x94f1(%rip), %r14      # 0x372b3
movq %r14, %rsi
callq 0x7490
movq 0x18(%rsp), %rdi
addq $-0x20, %rdi
leaq 0xb2cf(%rip), %rsi      # 0x390a9
callq 0x2e3bb
testb %al, %al
je 0x2ddf2
leaq 0xb2bf(%rip), %rsi      # 0x390a9
movq %r15, %rdi
callq 0x7490
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
je 0x2de5f
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 0x2de57
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 0x2de57
incq %r9
cmpq %r9, %r8
jne 0x2de3b
cmpq $0x6, %rsi
jae 0x2e15e
incq %rdx
cmpq %rcx, %rdx
jne 0x2de0f
addq $0x100, %rbx            # imm = 0x100
leaq 0x5557(%rip), %rsi      # 0x333c4
movq %rbx, %rdi
callq 0x70d0
testl %eax, %eax
jne 0x2df30
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
leaq 0xa8(%rsp), %rdi
movl $0x4, %edx
movq $-0x1, %rcx
callq 0x71c0
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x76d0
leaq 0x30(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
movq %r14, %rdx
callq 0x2e41e
leaq 0x30(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7410
movq (%r14), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2df06
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x7340
leaq 0x88(%rsp), %rdi
callq 0x74b0
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2df30
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x7340
leaq 0x10(%rsp), %rdi
callq 0xf6ee
jmp 0x2e22a
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 0xe87a
leaq 0xb11e(%rip), %rsi      # 0x3908d
leaq 0x30(%rsp), %rdi
callq 0x70d0
testl %eax, %eax
je 0x2e0cb
leaq 0xb113(%rip), %rsi      # 0x3909b
leaq 0x30(%rsp), %rdi
callq 0x70d0
testl %eax, %eax
je 0x2e10a
leaq 0xb0fe(%rip), %rsi      # 0x3909f
leaq 0x30(%rsp), %rdi
callq 0x70d0
testl %eax, %eax
je 0x2e130
leaq 0xb0ef(%rip), %rsi      # 0x390a9
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x70d0
testl %eax, %eax
je 0x2e122
leaq 0xb0d9(%rip), %rsi      # 0x390af
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x70d0
testl %eax, %eax
je 0x2e122
movq (%r15), %rdi
movq 0x100(%rsp), %r13
addq %r13, %rdi
leaq 0xb0b9(%rip), %r12      # 0x390b9
movq %r12, %rsi
callq 0x70d0
testl %eax, %eax
je 0x2e1a2
addq (%r15), %r13
leaq 0xb0a6(%rip), %r14      # 0x390c0
movq %r13, %rdi
movq %r14, %rsi
callq 0x70d0
addq $0xe0, %rbx
testl %eax, %eax
leaq 0x921a(%rip), %r12      # 0x3724f
cmoveq %r14, %r12
jmp 0x2e1a9
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 0xe87a
leaq 0x345f(%rip), %rsi      # 0x314cb
leaq 0x30(%rsp), %rdi
callq 0x70d0
cmpl $0x5, %r13d
jl 0x2e0a4
testl %eax, %eax
jne 0x2e0a4
movl $0x160, %esi            # imm = 0x160
addq (%r15), %rsi
leaq 0x30(%rsp), %rdi
callq 0x71f0
movl $0x180, %esi            # imm = 0x180
addq (%r15), %rsi
movq 0x8(%rsp), %rdi
callq 0x71f0
addq $0xe0, %rbx
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x71f0
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
jne 0x2e1c6
jmp 0x2e1d3
addq $0xe0, %rbx
leaq 0xafb4(%rip), %rsi      # 0x3908d
movq %rbx, %rdi
callq 0x7490
movq (%r15), %rax
leaq (%rax,%r13), %rsi
addq $0x20, %rsi
movq 0x8(%rsp), %rdi
callq 0x71f0
leaq 0xaf95(%rip), %rsi      # 0x39092
movq %rbp, %rdi
callq 0x7490
jmp 0x2e1ac
addq $0xe0, %rbx
leaq 0x91a3(%rip), %rsi      # 0x372bb
movq %rbx, %rdi
callq 0x7490
jmp 0x2e144
addq $0xe0, %rbx
movq %rbx, 0x8(%rsp)
jmp 0x2e14f
addq $0xe0, %rbx
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x71f0
movq (%r15), %rax
leaq (%rax,%r13), %r14
addq $0x20, %r14
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x71f0
jmp 0x2e1b7
decq %rdi
movsbl 0x1(%rdi), %eax
incq %rdi
addl $-0x3a, %eax
cmpl $-0xa, %eax
jb 0x2e161
callq 0x7560
addl $-0x4, %eax
cmpl $0x3, %eax
jae 0x2de5f
movl %eax, %eax
leaq 0xaf66(%rip), %rcx      # 0x390f0
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
leaq 0x100(%rbx), %rdi
callq 0x7490
jmp 0x2de5f
addq $0xe0, %rbx
movq %rbx, %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x7490
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2e1d3
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x7340
leaq 0xe8(%rsp), %rdi
callq 0xf6ee
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x2e205
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x7340
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x2e22a
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x7340
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2e28e
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x74b0
jmp 0x2e253
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e291
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x7340
jmp 0x2e291
jmp 0x2e340
jmp 0x2e340
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
jne 0x2e2db
jmp 0x2e343
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xf6ee
jmp 0x2e350
jmp 0x2e2a7
jmp 0x2e340
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x288ae
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x2e343
movq 0x20(%rsp), %rsi
jmp 0x2e2e0
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2e343
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x7340
jmp 0x2e343
jmp 0x2e340
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x2e319
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x7340
jmp 0x2e319
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x2e350
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x7340
jmp 0x2e350
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0xf616
movq %rbx, %rdi
callq 0x7630