// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/juicer.c
// Function: make_juicer_pre_file_from_pa5
static int make_juicer_pre_file_from_pa5(char *f, char *agp, char *fai, int8_t mq, int scale, int count_gap, FILE *fo)
{
    iostream_t *fp;
    char *line;
    char cname0[4096], cname1[4096];
    uint32_t x0, x1, i0, i1;
    uint64_t p0, p1, rec_c, pair_c;
    uint8_t q0, q1;
    CC_ERR_t err0, err1;

    khash_t(str) *hmseq; // for absent sequences
    khint_t k;
    int absent;
    hmseq = kh_init(str);

    sdict_t *sdict = make_sdict_from_index(fai, 0);
    asm_dict_t *dict = agp? make_asm_dict_from_agp(sdict, agp, 1) : make_asm_dict_from_sdict(sdict);

    fp = iostream_open(f);
    if (fp == NULL) {
        fprintf(stderr, "[E::%s] cannot open file %s for reading\n", __func__, f);
        exit(EXIT_FAILURE);
    }

    rec_c = pair_c = 0;
    while ((line = iostream_getline(fp)) != NULL) {
        if (is_empty_line(line))
            continue;
        
        if (++rec_c % 1000000 == 0)
            fprintf(stderr, "[I::%s] %lu million records processed, %lu read pairs \n", __func__, rec_c / 1000000, pair_c);

        cname0[0] = cname1[0] = '\0';
        x0 = x1 = UINT32_MAX;
        q0 = q1 = 255;
        sscanf(line, "%*s %s %u %s %u %hhu %hhu", cname0, &x0, cname1, &x1, &q0, &q1);

        if (q0 < mq || q1 < mq)
            continue;

        err0 = sd_coordinate_conversion(dict, sd_get(sdict, cname0), x0, &i0, &p0, count_gap);
        err1 = sd_coordinate_conversion(dict, sd_get(sdict, cname1), x1, &i1, &p1, count_gap);

        if (err0 != CC_SUCCESS) {
            if (err0 == SEQ_NOT_FOUND) {
                k = kh_put(str, hmseq, cname0, &absent);
                if (absent) {
                    kh_key(hmseq, k) = strdup(cname0);
                    fprintf(stderr, "[W::%s] sequence \"%s\" not found \n", __func__, cname0);
                }
            } else if (err0 == POS_NOT_IN_RANGE) {
                fprintf(stderr, "[W::%s] sequence position \"%s:%u\" not in range \n", __func__, cname0, x0);
            }
        } else if (err1 != CC_SUCCESS) {
            if (err1 == SEQ_NOT_FOUND) {
                k = kh_put(str, hmseq, cname1, &absent);
                if (absent) {
                    kh_key(hmseq, k) = strdup(cname1);
                    fprintf(stderr, "[W::%s] sequence \"%s\" not found \n", __func__, cname1);
                }
            } else if (err1 == POS_NOT_IN_RANGE) {
                fprintf(stderr, "[W::%s] sequence position \"%s:%u\" not in range \n", __func__, cname1, x1);
            }
        } else {
            if (strcmp(dict->s[i0].name, dict->s[i1].name) <= 0)
                fprintf(fo, "0\t%s\t%lu\t0\t1\t%s\t%lu\t1\n", dict->s[i0].name, p0 >> scale, dict->s[i1].name, p1 >> scale);
            else
                fprintf(fo, "0\t%s\t%lu\t1\t1\t%s\t%lu\t0\n", dict->s[i1].name, p1 >> scale, dict->s[i0].name, p0 >> scale);

            ++pair_c;
        }
    }

    fprintf(stderr, "[I::%s] %ld read pairs processed\n", __func__, pair_c);

    for (k = 0; k < kh_end(hmseq); ++k)
        if (kh_exist(hmseq, k))
            free((char *) kh_key(hmseq, k));
    kh_destroy(str, hmseq);

    iostream_close(fp);
    asm_destroy(dict);
    sd_destroy(sdict);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20e0, %rsp           # imm = 0x20E0
movb %cl, %al
movq 0x10(%rbp), %rcx
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb %al, -0x19(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
callq 0x111a0
movq %rax, -0x2088(%rbp)
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x72b0
movq %rax, -0x2098(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1048b
movq -0x2098(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x81b0
movq %rax, -0x20a8(%rbp)
jmp 0x1049e
movq -0x2098(%rbp), %rdi
callq 0x7950
movq %rax, -0x20a8(%rbp)
movq -0x20a8(%rbp), %rax
movq %rax, -0x20a0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2c80
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x104ed
movq 0x7b31(%rip), %rax      # 0x17ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rcx
leaq 0x2f5b(%rip), %rsi      # 0x13430
leaq 0x4378(%rip), %rdx      # 0x14854
movb $0x0, %al
callq 0x2230
movl $0x1, %edi
callq 0x23e0
movq $0x0, -0x2070(%rbp)
movq $0x0, -0x2068(%rbp)
movq -0x30(%rbp), %rdi
callq 0x2f00
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x10987
movq -0x38(%rbp), %rdi
callq 0x2c20
cmpl $0x0, %eax
je 0x1052a
jmp 0x10503
movq -0x2068(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2068(%rbp)
movl $0xf4240, %ecx          # imm = 0xF4240
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
jne 0x10586
movq 0x7aa5(%rip), %rax      # 0x17ff8
movq (%rax), %rdi
movq -0x2068(%rbp), %rax
movl $0xf4240, %ecx          # imm = 0xF4240
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
movq -0x2070(%rbp), %r8
leaq 0x4154(%rip), %rsi      # 0x146cc
leaq 0x42d5(%rip), %rdx      # 0x14854
movb $0x0, %al
callq 0x2230
movb $0x0, -0x2040(%rbp)
movb $0x0, -0x1040(%rbp)
movl $0xffffffff, -0x2048(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x2044(%rbp) # imm = 0xFFFFFFFF
movb $-0x1, -0x2072(%rbp)
movb $-0x1, -0x2071(%rbp)
movq -0x38(%rbp), %rdi
leaq -0x1040(%rbp), %rdx
leaq -0x2040(%rbp), %r8
leaq 0x42a3(%rip), %rsi      # 0x14872
leaq -0x2044(%rbp), %rcx
leaq -0x2048(%rbp), %r9
leaq -0x2071(%rbp), %r10
leaq -0x2072(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x22c0
movzbl -0x2071(%rbp), %eax
movsbl -0x19(%rbp), %ecx
cmpl %ecx, %eax
jl 0x10619
movzbl -0x2072(%rbp), %eax
movsbl -0x19(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1061e
jmp 0x10503
movq -0x20a0(%rbp), %rax
movq %rax, -0x20b8(%rbp)
movq -0x2098(%rbp), %rdi
leaq -0x1040(%rbp), %rsi
callq 0x6a60
movq -0x20b8(%rbp), %rdi
movl %eax, %esi
movl -0x2044(%rbp), %edx
movl -0x24(%rbp), %r9d
leaq -0x204c(%rbp), %rcx
leaq -0x2058(%rbp), %r8
callq 0x95d0
movl %eax, -0x2078(%rbp)
movq -0x20a0(%rbp), %rax
movq %rax, -0x20b0(%rbp)
movq -0x2098(%rbp), %rdi
leaq -0x2040(%rbp), %rsi
callq 0x6a60
movq -0x20b0(%rbp), %rdi
movl %eax, %esi
movl -0x2048(%rbp), %edx
movl -0x24(%rbp), %r9d
leaq -0x2050(%rbp), %rcx
leaq -0x2060(%rbp), %r8
callq 0x95d0
movl %eax, -0x207c(%rbp)
cmpl $0x0, -0x2078(%rbp)
je 0x10780
cmpl $0x1, -0x2078(%rbp)
jne 0x10743
movq -0x2088(%rbp), %rdi
leaq -0x1040(%rbp), %rsi
leaq -0x2090(%rbp), %rdx
callq 0x11290
movl %eax, -0x208c(%rbp)
cmpl $0x0, -0x2090(%rbp)
je 0x10741
leaq -0x1040(%rbp), %rdi
callq 0x2430
movq %rax, %rdx
movq -0x2088(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x208c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq 0x78d6(%rip), %rax      # 0x17ff8
movq (%rax), %rdi
leaq -0x1040(%rbp), %rcx
leaq 0x3fd1(%rip), %rsi      # 0x14704
leaq 0x411a(%rip), %rdx      # 0x14854
movb $0x0, %al
callq 0x2230
jmp 0x1077b
cmpl $0x2, -0x2078(%rbp)
jne 0x10779
movq 0x78a5(%rip), %rax      # 0x17ff8
movq (%rax), %rdi
leaq -0x1040(%rbp), %rcx
movl -0x2044(%rbp), %r8d
leaq 0x3fbb(%rip), %rsi      # 0x14726
leaq 0x40e2(%rip), %rdx      # 0x14854
movb $0x0, %al
callq 0x2230
jmp 0x1077b
jmp 0x10982
cmpl $0x0, -0x207c(%rbp)
je 0x10848
cmpl $0x1, -0x207c(%rbp)
jne 0x1080b
movq -0x2088(%rbp), %rdi
leaq -0x2040(%rbp), %rsi
leaq -0x2090(%rbp), %rdx
callq 0x11290
movl %eax, -0x208c(%rbp)
cmpl $0x0, -0x2090(%rbp)
je 0x10809
leaq -0x2040(%rbp), %rdi
callq 0x2430
movq %rax, %rdx
movq -0x2088(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x208c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq 0x780e(%rip), %rax      # 0x17ff8
movq (%rax), %rdi
leaq -0x2040(%rbp), %rcx
leaq 0x3f09(%rip), %rsi      # 0x14704
leaq 0x4052(%rip), %rdx      # 0x14854
movb $0x0, %al
callq 0x2230
jmp 0x10843
cmpl $0x2, -0x207c(%rbp)
jne 0x10841
movq 0x77dd(%rip), %rax      # 0x17ff8
movq (%rax), %rdi
leaq -0x2040(%rbp), %rcx
movl -0x2048(%rbp), %r8d
leaq 0x3ef3(%rip), %rsi      # 0x14726
leaq 0x401a(%rip), %rdx      # 0x14854
movb $0x0, %al
callq 0x2230
jmp 0x10843
jmp 0x10980
movq -0x20a0(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x204c(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq -0x20a0(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2050(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x2210
cmpl $0x0, %eax
jg 0x108fc
movq 0x10(%rbp), %rdi
movq -0x20a0(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x204c(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdx
movq -0x2058(%rbp), %rax
movl -0x20(%rbp), %ecx
shrq %cl, %rax
movq %rax, -0x20c0(%rbp)
movq -0x20a0(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2050(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %r8
movq -0x2060(%rbp), %r9
movl -0x20(%rbp), %eax
movl %eax, %ecx
shrq %cl, %r9
movq -0x20c0(%rbp), %rcx
leaq 0x3e64(%rip), %rsi      # 0x14757
movb $0x0, %al
callq 0x2230
jmp 0x1096e
movq 0x10(%rbp), %rdi
movq -0x20a0(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2050(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdx
movq -0x2060(%rbp), %rax
movl -0x20(%rbp), %ecx
shrq %cl, %rax
movq %rax, -0x20c8(%rbp)
movq -0x20a0(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x204c(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %r8
movq -0x2058(%rbp), %r9
movl -0x20(%rbp), %eax
movl %eax, %ecx
shrq %cl, %r9
movq -0x20c8(%rbp), %rcx
leaq 0x3e07(%rip), %rsi      # 0x1476e
movb $0x0, %al
callq 0x2230
movq -0x2070(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2070(%rbp)
jmp 0x10982
jmp 0x10503
movq 0x766a(%rip), %rax      # 0x17ff8
movq (%rax), %rdi
movq -0x2070(%rbp), %rcx
leaq 0x3e93(%rip), %rsi      # 0x14832
leaq 0x3eae(%rip), %rdx      # 0x14854
movb $0x0, %al
callq 0x2230
movl $0x0, -0x208c(%rbp)
movl -0x208c(%rbp), %eax
movq -0x2088(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x10a23
movq -0x2088(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x208c(%rbp), %ecx
shrl $0x4, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x208c(%rbp), %ecx
andl $0xf, %ecx
shll %ecx
shrl %cl, %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x10a10
movq -0x2088(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x208c(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
callq 0x2050
jmp 0x10a12
movl -0x208c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x208c(%rbp)
jmp 0x109b7
movq -0x2088(%rbp), %rdi
callq 0x116b0
movq -0x30(%rbp), %rdi
callq 0x2e20
movq -0x20a0(%rbp), %rdi
callq 0x63d0
movq -0x2098(%rbp), %rdi
callq 0x62a0
xorl %eax, %eax
addq $0x20e0, %rsp           # imm = 0x20E0
popq %rbp
retq
nopl (%rax,%rax)