// File: /workspace/github_cpp_makefile_star2_O2/Infinidat[P]slimfastq/recs.cpp
// Function: RecLoad::load_pre5(unsigned char*, unsigned char const*)
size_t RecLoad::load_pre5(UCHAR* buf, const UCHAR* prev) {

    UINT64 map = get_num(0);

    UCHAR* b = buf;
    for (int i = 0; i < smap[0].len; i++) {
        // if (IS_SET(last_map, i)) {
         if (IS_SET(map, i)) {

             UCHAR type = get_type(i+1);
             switch (type) {

             case ST_DGT:
             case ST_DLT: {
                      // compatibility - let it open old fi
                 long long pval;
                 bool expect_num = is_number(prev + smap[0].off[i], smap[0].wln[i], pval);
                 assert(expect_num);
                 long long gap = get_num(i+1);
                 long long val = type == ST_DGT ? pval + gap : pval - gap ;
                 // if (UINT64(val) > 0xffffffff00000000) {
                 //     fprintf(stderr, "big val: 0x%llx gap=0x%llx %s pval=0x%llx\n",
                 //             val, gap, (type == ST_DGT ? "GAP" : "PAG"), pval);
                 //     // debug point
                 // }

                 b += sprintf((char*)b, "%lld", val);
             } break;

             case ST_STR: {
                 b = get_str(i+1, b);
             } break;

             default:
                 croak("REC: bad type value %d", type);
             }
         }
         else {
            // b = (UCHAR*)mempcpy(b, prev + smap[0].off[i], smap[0].wln[i]);
            // mempcpy is not compatible with Mac OS, must do it the hard way ..
            UINT32 count = smap[0].wln[i] ;
            memcpy(b, prev + smap[0].off[i], count );
            b += count;
        }
        *b ++ = smap[0].str[i];
    }
    return b-buf-1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, (%rsp)
movq %rsi, %r13
movq %rdi, %r15
addq $0x60e, %rdi            # imm = 0x60E
leaq 0xc7ce0(%r15), %rsi
callq 0x6d04
movq %rax, %r14
xorl %r12d, %r12d
movq %r13, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movzbl 0xc7f79(%r15), %eax
cmpq %rax, %r12
jae 0x6b8e
btq %r12, %r14
jae 0x6b3a
leal 0x1(%r12), %eax
movzbl %al, %ebx
movq %r15, %rdi
movl %ebx, %esi
callq 0x5fec
movl %eax, %ebp
cmpb $0x2, %al
jae 0x6b5e
movslq 0xc7d30(%r15,%r12,4), %rax
movq (%rsp), %rcx
cmpb $0x30, (%rcx,%rax)
je 0x6bab
addq (%rsp), %rax
movl 0xc7e34(%r15,%r12,4), %ecx
testl %ecx, %ecx
movl $0x0, %edx
cmovlel %edx, %ecx
xorl %r14d, %r14d
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x6b03
movzbl (%rax,%rdx), %esi
leal -0x30(%rsi), %edi
cmpl $0x9, %edi
ja 0x6bab
imulq $0xa, %r14, %rdi
leaq (%rdi,%rsi), %r14
addq $-0x30, %r14
incq %rdx
jmp 0x6add
movq %r15, %rdi
movl %ebx, %esi
callq 0x600a
movq %rax, %rdx
negq %rdx
testb %bpl, %bpl
cmoveq %rax, %rdx
addq %r14, %rdx
movq %r13, %rdi
leaq 0x2fb2(%rip), %rsi      # 0x9ad9
xorl %eax, %eax
callq 0x20a0
cltq
addq %rax, %r13
movq 0x10(%rsp), %r14
jmp 0x6b77
movl 0xc7e34(%r15,%r12,4), %ebx
movslq 0xc7d30(%r15,%r12,4), %rsi
addq (%rsp), %rsi
movq %r13, %rdi
movq %rbx, %rdx
callq 0x21a0
addq %rbx, %r13
jmp 0x6b77
movzbl %bpl, %esi
cmpl $0x2, %esi
jne 0x6bca
movq %r15, %rdi
movl %ebx, %esi
movq %r13, %rdx
callq 0x602c
movq %rax, %r13
movb 0xc7f38(%r15,%r12), %al
movb %al, (%r13)
incq %r13
incq %r12
jmp 0x6a75
movq 0x8(%rsp), %rax
notq %rax
addq %rax, %r13
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3445(%rip), %rdi      # 0x9ff7
leaq 0x33ab(%rip), %rsi      # 0x9f64
leaq 0x3442(%rip), %rcx      # 0xa002
movl $0x1e0, %edx            # imm = 0x1E0
callq 0x2150
leaq 0x340f(%rip), %rdi      # 0x9fe0
xorl %eax, %eax
callq 0x2350