// File: zeeev[P]DASVC/bamtools/src/api/internal/sam/SamHeaderValidator_p.cpp
// Function: BamTools::Internal::SamHeaderValidator::ValidateVersion()
bool SamHeaderValidator::ValidateVersion(void) {

    const string& version = m_header.Version;

    // warn if version not present
    if ( version.empty() ) {
        AddWarning("Version (VN) missing. Not required, but strongly recommended");
        return true;
    }

    // invalid if version does not contain a period
    const size_t periodFound = version.find(Constants::SAM_PERIOD);
    if ( periodFound == string::npos ) {
        AddError("Invalid version (VN) format: " + version);
        return false;
    }

    // invalid if major version is empty or contains non-digits
    const string majorVersion = version.substr(0, periodFound);
    if ( majorVersion.empty() || !ContainsOnlyDigits(majorVersion) ) {
        AddError("Invalid version (VN) format: " + version);
        return false;
    }

    // invalid if major version is empty or contains non-digits
    const string minorVersion = version.substr(periodFound + 1);
    if ( minorVersion.empty() || !ContainsOnlyDigits(minorVersion) ) {
        AddError("Invalid version (VN) format: " + version);
        return false;
    }

    // TODO: check if version is not just syntactically OK,
    // but is also a valid SAM version ( 1.0 .. CURRENT )

    // all checked out this far, then version is OK
    return true;
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x128(%rsp)
movq 0x128(%rsp), %rax
movq %rax, 0x30(%rsp)
movq (%rax), %rax
movq %rax, 0x120(%rsp)
movq 0x120(%rsp), %rdi
callq 0x7aba0
testb $0x1, %al
jne 0xe67ed
jmp 0xe68a4
leaq 0xff(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x7b5f0
movq 0x28(%rsp), %rdx
leaq 0x5f33(%rip), %rsi      # 0xec73e
leaq 0x100(%rsp), %rdi
callq 0x78e70
jmp 0xe681a
movq 0x30(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x73580
jmp 0xe682e
leaq 0x100(%rsp), %rdi
callq 0x7cce8
jmp 0xe683d
leaq 0xff(%rsp), %rdi
callq 0x76f80
movb $0x1, 0x137(%rsp)
jmp 0xe6b6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0xe6892
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x7cce8
jmp 0xe6890
jmp 0xe6892
leaq 0xff(%rsp), %rdi
callq 0x76f80
jmp 0xe6b80
movq 0x120(%rsp), %rdi
movl $0x2e, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x787f0
movq %rax, 0xe0(%rsp)
cmpq $-0x1, 0xe0(%rsp)
jne 0xe6941
movq 0x120(%rsp), %rdx
leaq 0x5e9f(%rip), %rsi      # 0xec77b
leaq 0xc0(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x75e70
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x763a0
jmp 0xe68ff
leaq 0xc0(%rsp), %rdi
callq 0x7cce8
movb $0x0, 0x137(%rsp)
jmp 0xe6b6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x7cce8
jmp 0xe693c
jmp 0xe6b80
movq 0x120(%rsp), %rsi
movq 0xe0(%rsp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x76c50
movq 0x10(%rsp), %rdi
callq 0x7aba0
movb %al, 0x1f(%rsp)
jmp 0xe6977
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0xe69a7
jmp 0xe6981
movq 0x30(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x73be0
movb %al, 0xf(%rsp)
jmp 0xe6999
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0xe6a3e
jmp 0xe69a7
movq 0x120(%rsp), %rdx
leaq 0x5dc5(%rip), %rsi      # 0xec77b
leaq 0x80(%rsp), %rdi
callq 0x75e70
jmp 0xe69c5
movq 0x30(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x763a0
jmp 0xe69d9
leaq 0x80(%rsp), %rdi
callq 0x7cce8
jmp 0xe69e8
movb $0x0, 0x137(%rsp)
movl $0x1, 0x7c(%rsp)
jmp 0xe6b4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0xe6b5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x7cce8
jmp 0xe6a39
jmp 0xe6b5e
movq 0x120(%rsp), %rsi
movq 0xe0(%rsp), %rdx
incq %rdx
leaq 0x58(%rsp), %rdi
movq $-0x1, %rcx
callq 0x76c50
jmp 0xe6a64
leaq 0x58(%rsp), %rdi
callq 0x7aba0
movb %al, 0xe(%rsp)
jmp 0xe6a74
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0xe6aa1
jmp 0xe6a7e
movq 0x30(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x73be0
movb %al, 0xd(%rsp)
jmp 0xe6a93
movb 0xd(%rsp), %al
testb $0x1, %al
jne 0xe6b23
jmp 0xe6aa1
movq 0x120(%rsp), %rdx
leaq 0x5ccb(%rip), %rsi      # 0xec77b
leaq 0x38(%rsp), %rdi
callq 0x75e70
jmp 0xe6abc
movq 0x30(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x763a0
jmp 0xe6acd
leaq 0x38(%rsp), %rdi
callq 0x7cce8
jmp 0xe6ad9
movb $0x0, 0x137(%rsp)
movl $0x1, 0x7c(%rsp)
jmp 0xe6b33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0xe6b41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x7cce8
jmp 0xe6b21
jmp 0xe6b41
movb $0x1, 0x137(%rsp)
movl $0x1, 0x7c(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x7cce8
jmp 0xe6b3f
jmp 0xe6b4f
leaq 0x58(%rsp), %rdi
callq 0x7cce8
jmp 0xe6b4d
jmp 0xe6b5e
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
jmp 0xe6b6f
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
jmp 0xe6b6d
jmp 0xe6b80
movb 0x137(%rsp), %al
andb $0x1, %al
addq $0x138, %rsp            # imm = 0x138
retq
movq 0xf0(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw %cs:(%rax,%rax)