// File: /workspace/github_cpp_makefile_star2_O3/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 $0x28, %rsp
movq %rdx, 0x8(%rsp)
movq %rsi, %rbp
movq %rdi, %r15
addq $0x60e, %rdi            # imm = 0x60E
leaq 0xc7ce0(%r15), %rsi
movq %rsi, 0x18(%rsp)
callq 0x8a62
movq %rax, 0x20(%rsp)
cmpb $0x0, 0xc7f79(%r15)
movq %rbp, 0x10(%rsp)
je 0x8996
xorl %r13d, %r13d
movq 0x10(%rsp), %rbp
movq 0x20(%rsp), %rax
btq %r13, %rax
jae 0x88f3
leal 0x1(%r13), %eax
movzbl %al, %r14d
imulq $0x3070, %r14, %r12     # imm = 0x3070
leaq (%r15,%r12), %rdi
movq 0x18(%rsp), %rsi
callq 0x406a
movl %eax, %ebx
cmpb $0x2, %bl
jae 0x8918
movslq 0xc7d30(%r15,%r13,4), %rax
movq 0x8(%rsp), %rcx
cmpb $0x30, (%rcx,%rax)
je 0x89b0
movl 0xc7e34(%r15,%r13,4), %ecx
testl %ecx, %ecx
jle 0x8937
addq 0x8(%rsp), %rax
xorl %r14d, %r14d
xorl %edx, %edx
movzbl (%rax,%rdx), %esi
leal -0x30(%rsi), %edi
cmpl $0x9, %edi
ja 0x89b0
leaq (%r14,%r14,4), %rdi
leaq (%rsi,%rdi,2), %r14
addq $-0x30, %r14
incq %rdx
cmpq %rdx, %rcx
jne 0x88cd
jmp 0x893a
movl 0xc7e34(%r15,%r13,4), %ebx
movslq 0xc7d30(%r15,%r13,4), %rsi
addq 0x8(%rsp), %rsi
movq %rbp, %rdi
movq %rbx, %rdx
callq 0x2170
addq %rbx, %rbp
jmp 0x8974
movzbl %bl, %eax
cmpl $0x2, %eax
jne 0x89b5
movq %r15, %rdi
movl %r14d, %esi
movq %rbp, %rdx
callq 0x7dc6
movq %rax, %rbp
jmp 0x8974
xorl %r14d, %r14d
leaq (%r15,%r12), %rdi
addq $0x60e, %rdi            # imm = 0x60E
movq 0x18(%rsp), %rsi
callq 0x8a62
movq %rax, %rdx
negq %rdx
testb %bl, %bl
cmoveq %rax, %rdx
addq %r14, %rdx
movq %rbp, %rdi
leaq 0x3201(%rip), %rsi      # 0xbb69
xorl %eax, %eax
callq 0x20a0
cltq
addq %rax, %rbp
movb 0xc7f38(%r15,%r13), %al
movb %al, (%rbp)
incq %rbp
incq %r13
movzbl 0xc7f79(%r15), %eax
cmpq %rax, %r13
jb 0x8871
movq 0x10(%rsp), %rax
notq %rax
addq %rbp, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x304c
movl %ebx, %edi
callq 0x306c