// File: yayuntian[P]user_agent/operatingSystem.cpp
// Function: getOSInfo(UserAgent&)
OSInfo getOSInfo(UserAgent& p) {

    string os = replace_first_copy(p.os, "like Mac OS X", "");
    os = replace_first_copy(os, "CPU", "");
    os = trim_copy_if(os, is_any_of(" "));

    vector<string> osSplit;
    split(osSplit, os, is_any_of(" "));

    if (os == "Windows XP x64 Edition") {
        osSplit = split_v(osSplit, 0, 1);
    }

    string name, version;
    osName(osSplit, name, version);

    if (contains(name, "/")) {
        int s = name.size();
        char buf[64] = {0,};
        if (s < 64) {
            strncpy(buf, name.c_str(), name.size());
            char *ver = NULL;
            char *ptr = strtok_r(buf, "/", &ver);
            remove_rchar(buf);
            name = buf;
            if (ptr) {
                version = ver;
            }
        }
    }
    version = replace_all_copy(version, "_", ".");

    return OSInfo {
        .FUllName = p.os,
        .Name = name,
        .Version = version
    };
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x1c0(%rbp)
movq %rdi, %rax
movq %rax, -0x1b8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rsi
addq $0x60, %rsi
leaq 0x1f61c(%rip), %rdx     # 0x6e67f
leaq 0x1b3a2(%rip), %rcx     # 0x6a40c
movq %rcx, -0x1a8(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x4fec0
movq -0x1b0(%rbp), %rsi
movq -0x1a8(%rbp), %rcx
leaq 0x1f5f7(%rip), %rdx     # 0x6e68d
leaq -0x50(%rbp), %rdi
callq 0x4ff50
jmp 0x4f0a1
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rsi, -0x1c8(%rbp)
callq 0x85b0
movq -0x1c8(%rbp), %rdi
callq 0x89e8
leaq 0x1c111(%rip), %rsi     # 0x6b1d9
leaq -0x98(%rbp), %rdi
callq 0x4f8f0
jmp 0x4f0d6
leaq -0x80(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x98(%rbp), %rdx
callq 0x4ffe0
jmp 0x4f0ec
leaq -0x30(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq %rsi, -0x1d0(%rbp)
callq 0x85b0
movq -0x1d0(%rbp), %rdi
callq 0x89e8
leaq -0x98(%rbp), %rdi
callq 0x4f940
leaq -0xb0(%rbp), %rdi
callq 0x15710
leaq 0x1c0ae(%rip), %rsi     # 0x6b1d9
leaq -0xc8(%rbp), %rdi
callq 0x4f8f0
jmp 0x4f139
leaq -0xb0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0xc8(%rbp), %rdx
movl $0x1, %ecx
callq 0x4f820
jmp 0x4f157
leaq -0xc8(%rbp), %rdi
callq 0x4f940
leaq 0x1f47c(%rip), %rsi     # 0x6e5e6
leaq -0x30(%rbp), %rdi
callq 0x155a0
movb %al, -0x1d1(%rbp)
jmp 0x4f17b
movb -0x1d1(%rbp), %al
testb $0x1, %al
jne 0x4f18a
jmp 0x4f223
leaq -0xe0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x4eb90
jmp 0x4f1a6
leaq -0xb0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x4fb80
leaq -0xe0(%rbp), %rdi
callq 0x15790
jmp 0x4f223
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4f4be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x4f940
jmp 0x4f4be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4f4b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x4f940
jmp 0x4f4b2
leaq -0x100(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x8680
leaq -0x120(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x8680
movq -0x1e8(%rbp), %rsi
movq -0x1e0(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x4ecc0
jmp 0x4f265
leaq 0x1bbe0(%rip), %rsi     # 0x6ae4c
leaq -0x100(%rbp), %rdi
callq 0x50180
movb %al, -0x1e9(%rbp)
jmp 0x4f280
movb -0x1e9(%rbp), %al
testb $0x1, %al
jne 0x4f28f
jmp 0x4f389
leaq -0x100(%rbp), %rdi
callq 0x8350
movl %eax, -0x124(%rbp)
leaq -0x170(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x8260
cmpl $0x40, -0x124(%rbp)
jge 0x4f387
leaq -0x100(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x81a0
movq -0x208(%rbp), %rdi
movq %rax, -0x200(%rbp)
callq 0x8350
movq -0x200(%rbp), %rsi
movq %rax, %rdx
leaq -0x170(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x8240
movq -0x1f8(%rbp), %rdi
movq $0x0, -0x178(%rbp)
leaq 0x1bb2f(%rip), %rsi     # 0x6ae4c
leaq -0x178(%rbp), %rdx
callq 0x88f0
movq -0x1f8(%rbp), %rdi
movq %rax, -0x180(%rbp)
callq 0x4f4d0
jmp 0x4f33e
leaq -0x100(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x8670
jmp 0x4f353
cmpq $0x0, -0x180(%rbp)
je 0x4f385
movq -0x178(%rbp), %rsi
leaq -0x120(%rbp), %rdi
callq 0x8670
jmp 0x4f372
jmp 0x4f385
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4f49a
jmp 0x4f387
jmp 0x4f389
leaq 0x1f301(%rip), %rdx     # 0x6e691
leaq 0x1d060(%rip), %rcx     # 0x6c3f7
leaq -0x1a0(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x501b0
jmp 0x4f3ac
leaq -0x120(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
movq %rsi, -0x218(%rbp)
callq 0x85b0
movq -0x218(%rbp), %rdi
callq 0x89e8
movq -0x1c0(%rbp), %rdi
movq %rdi, %rax
movq %rax, -0x210(%rbp)
movq -0x10(%rbp), %rsi
addq $0x60, %rsi
callq 0x81c0
jmp 0x4f3f2
movq -0x1c0(%rbp), %rdi
addq $0x20, %rdi
movq %rdi, -0x220(%rbp)
leaq -0x100(%rbp), %rsi
callq 0x81c0
jmp 0x4f412
movq -0x1c0(%rbp), %rdi
addq $0x40, %rdi
leaq -0x120(%rbp), %rsi
callq 0x81c0
jmp 0x4f42b
leaq -0x120(%rbp), %rdi
callq 0x89e8
leaq -0x100(%rbp), %rdi
callq 0x89e8
leaq -0xb0(%rbp), %rdi
callq 0x15790
leaq -0x30(%rbp), %rdi
callq 0x89e8
movq -0x1b8(%rbp), %rax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4f48e
movq -0x220(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x89e8
movq -0x210(%rbp), %rdi
callq 0x89e8
leaq -0x120(%rbp), %rdi
callq 0x89e8
leaq -0x100(%rbp), %rdi
callq 0x89e8
leaq -0xb0(%rbp), %rdi
callq 0x15790
leaq -0x30(%rbp), %rdi
callq 0x89e8
movq -0x58(%rbp), %rdi
callq 0x88a0