// File: Infinidat[P]slimfastq/usrs.cpp
// Function: UsrSave::determine_record()
void UsrSave::determine_record() {

    int q = m_cur;

    rarely_if(m_cur >= m_end) {
        if (not conf.quiet) {
            if (x_lrec->tell())
                fprintf(stderr, "::: HEY all records were oversized\n");
            else
                fprintf(stderr, "::: HEY no records were found");
        }
        return;
    }

    rarely_if(m_buff[q++] != '@')
        croak("first record: Missing prefix '@', is it really a fastq format?");

    int sanity = MAX_ID_LLEN;
    while (--  sanity and m_buff[q] != '\n')
        q ++ ;
    rarely_if( not sanity) {
        // croak("first record: REC is too long");
        g_record_count++;
        get_oversized_record(m_cur, false);
        return determine_record();
    }

    if (m_buff[q++] != '\n')
        croak("first record: Expected newline, got '%c'", m_buff[q-1]);

    int qg = q;
    // LLEN
    for (int i = 1;
         i < MAX_GN_LLEN and not m_llen;
         i++)
        if (m_buff[q + i] == '\n')
            m_llen = i;

    if (not m_llen) {
        // croak("first record: GEN is too long");
        g_record_count++;
        get_oversized_record(m_cur, false);
        return determine_record();
    }

    q += m_llen + 1;
    if (m_buff[q] != '+')
        croak("first record: Missing 2nd prefix '+', is it really a fastq format?");

    // 2ND ID
    bool has_2nd_id = false;
    while (m_buff[++ q ] != '\n')
        if (m_buff[ q ] != ' ' )
            has_2nd_id = true;

    // SOLID
    bool d_solid = false;
    for (int i = 1;
         i < m_llen and not d_solid and not m_solid;
         i ++ )
        switch (m_buff[qg + i] | 0x20) {
        case '0': case '1': case '2': case '3':
            m_solid = true;
            break;

        case 'a': case 'c' : case 'g' : case 't':
            d_solid = true;
            break;

        default:
            // TODO: what if first record is all Ns ?
            // - seek in other records
            break;
        }

    if (m_solid) {
        conf.set_info("usr.solid", m_solid);
        m_llen --;
    }
    conf.set_info("llen", m_llen);
    conf.set_info("usr.2id", has_2nd_id); // TODO
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq 0x30(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movl 0x124048(%rcx), %eax
movl %eax, 0x2c(%rsp)
movl 0x124048(%rcx), %eax
cmpl 0x12404c(%rcx), %eax
jl 0xce38
leaq 0xb5fe(%rip), %rax      # 0x183e0
testb $0x1, 0xe(%rax)
jne 0xce33
movq 0x10(%rsp), %rax
movq 0x124098(%rax), %rdi
callq 0xfcc0
cmpq $0x0, %rax
je 0xce19
movq 0x91ca(%rip), %rax      # 0x15fd0
movq (%rax), %rdi
leaq 0x459e(%rip), %rsi      # 0x113ae
movb $0x0, %al
callq 0x2380
jmp 0xce31
movq 0x91b0(%rip), %rax      # 0x15fd0
movq (%rax), %rdi
leaq 0x45a8(%rip), %rsi      # 0x113d2
movb $0x0, %al
callq 0x2380
jmp 0xce33
jmp 0xd1a0
movq 0x10(%rsp), %rax
movl 0x2c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x2c(%rsp)
movslq %ecx, %rcx
movzbl 0x31(%rax,%rcx), %eax
cmpl $0x40, %eax
je 0xce65
leaq 0x4592(%rip), %rdi      # 0x113f0
movb $0x0, %al
callq 0x3450
movl $0x2000, 0x28(%rsp)     # imm = 0x2000
movl 0x28(%rsp), %ecx
addl $-0x1, %ecx
movl %ecx, 0x28(%rsp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0xf(%rsp)
je 0xce9c
movq 0x10(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movzbl 0x31(%rax,%rcx), %eax
cmpl $0xa, %eax
setne %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0xcea6
jmp 0xceb3
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0xce6d
cmpl $0x0, 0x28(%rsp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xcec3
jmp 0xcefc
movq 0x10(%rsp), %rdi
leaq 0x9391(%rip), %rax      # 0x16260
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x9383(%rip), %rax      # 0x16260
movq %rcx, (%rax)
movl 0x124048(%rdi), %esi
xorl %edx, %edx
callq 0xd8c0
movq 0x10(%rsp), %rdi
callq 0xcdb0
jmp 0xd1a0
movq 0x10(%rsp), %rax
movl 0x2c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x2c(%rsp)
movslq %ecx, %rcx
movzbl 0x31(%rax,%rcx), %eax
cmpl $0xa, %eax
je 0xcf3d
movq 0x10(%rsp), %rax
movl 0x2c(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl 0x31(%rax,%rcx), %esi
leaq 0x44f9(%rip), %rdi      # 0x1142f
movb $0x0, %al
callq 0x3450
movl 0x2c(%rsp), %eax
movl %eax, 0x24(%rsp)
movl $0x1, 0x20(%rsp)
xorl %eax, %eax
cmpl $0x10000, 0x20(%rsp)    # imm = 0x10000
movb %al, 0xe(%rsp)
jge 0xcf72
movq 0x10(%rsp), %rax
cmpl $0x0, 0x12405c(%rax)
setne %al
xorb $-0x1, %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0xcf7c
jmp 0xcfb4
movq 0x10(%rsp), %rax
movl 0x2c(%rsp), %ecx
addl 0x20(%rsp), %ecx
movslq %ecx, %rcx
movzbl 0x31(%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0xcfa5
movq 0x10(%rsp), %rax
movl 0x20(%rsp), %ecx
movl %ecx, 0x12405c(%rax)
jmp 0xcfa7
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0xcf4d
movq 0x10(%rsp), %rax
cmpl $0x0, 0x12405c(%rax)
jne 0xcffb
movq 0x10(%rsp), %rdi
leaq 0x9292(%rip), %rax      # 0x16260
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x9284(%rip), %rax      # 0x16260
movq %rcx, (%rax)
movl 0x124048(%rdi), %esi
xorl %edx, %edx
callq 0xd8c0
movq 0x10(%rsp), %rdi
callq 0xcdb0
jmp 0xd1a0
movq 0x10(%rsp), %rax
movl 0x12405c(%rax), %ecx
addl $0x1, %ecx
addl 0x2c(%rsp), %ecx
movl %ecx, 0x2c(%rsp)
movslq 0x2c(%rsp), %rcx
movzbl 0x31(%rax,%rcx), %eax
cmpl $0x2b, %eax
je 0xd02e
leaq 0x4431(%rip), %rdi      # 0x11458
movb $0x0, %al
callq 0x3450
movb $0x0, 0x1f(%rsp)
movq 0x10(%rsp), %rax
movl 0x2c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rsp)
movslq %ecx, %rcx
movzbl 0x31(%rax,%rcx), %eax
cmpl $0xa, %eax
je 0xd06b
movq 0x10(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movzbl 0x31(%rax,%rcx), %eax
cmpl $0x20, %eax
je 0xd069
movb $0x1, 0x1f(%rsp)
jmp 0xd033
movb $0x0, 0x1e(%rsp)
movl $0x1, 0x18(%rsp)
movq 0x10(%rsp), %rdx
movl 0x18(%rsp), %ecx
xorl %eax, %eax
cmpl 0x12405c(%rdx), %ecx
movb %al, 0xd(%rsp)
jge 0xd0ad
xorl %eax, %eax
testb $0x1, 0x1e(%rsp)
movb %al, 0xd(%rsp)
jne 0xd0ad
movq 0x10(%rsp), %rax
movb 0x124064(%rax), %al
xorb $-0x1, %al
movb %al, 0xd(%rsp)
movb 0xd(%rsp), %al
testb $0x1, %al
jne 0xd0b7
jmp 0xd11c
movq 0x10(%rsp), %rax
movl 0x24(%rsp), %ecx
movl 0x18(%rsp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movzbl 0x31(%rax,%rcx), %eax
orl $0x20, %eax
addl $-0x30, %eax
movl %eax, %ecx
movq %rcx, (%rsp)
subl $0x44, %eax
ja 0xd108
movq (%rsp), %rax
leaq 0x407e(%rip), %rcx      # 0x11168
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rsp), %rax
movb $0x1, 0x124064(%rax)
jmp 0xd10a
movb $0x1, 0x1e(%rsp)
jmp 0xd10a
jmp 0xd10a
jmp 0xd10c
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0xd078
movq 0x10(%rsp), %rax
testb $0x1, 0x124064(%rax)
je 0xd163
movq 0x10(%rsp), %rax
movb 0x124064(%rax), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, %edx
leaq 0xb29d(%rip), %rdi      # 0x183e0
leaq 0x3dff(%rip), %rsi      # 0x10f49
callq 0x3dd0
movq 0x10(%rsp), %rax
movl 0x12405c(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x12405c(%rax)
movq 0x10(%rsp), %rax
movslq 0x12405c(%rax), %rdx
leaq 0xb26a(%rip), %rdi      # 0x183e0
leaq 0x431e(%rip), %rsi      # 0x1149b
callq 0x3dd0
movb 0x1f(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, %edx
leaq 0xb24c(%rip), %rdi      # 0x183e0
leaq 0x4305(%rip), %rsi      # 0x114a0
callq 0x3dd0
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)