// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/juicer.c
// Function: assembly_annotation
static uint64_t assembly_annotation(const char *f, sdict_t *sdict, const char *out_agp, const char *out_annot, 
        const char *out_lift, int *scale, uint64_t max_s, uint64_t *g)
{
    uint32_t i, j, c, n, m;
    int *seqs;
    FILE *fo_agp, *fo_annot, *fo_lift;
    uint64_t genome_size, scaled_gs;
    asm_dict_t *dict;
    sd_seg_t seg;

    fo_agp = fopen(out_agp, "w");
    fo_annot = fopen(out_annot, "w");
    fo_lift = fopen(out_lift, "w");
    
    dict = make_asm_dict_from_agp(sdict, f, 1);
    n = dict->u + dict->n;
    seqs = (int *) calloc(n, sizeof(int));
    genome_size = 0;
    c = j = 0;
    m = dict->s[j++].n;
    for (i = 0; i < dict->u; ++i) {
        seg = dict->seg[i];
        fprintf(fo_agp, "assembly\t%lu\t%lu\t%u\t%s\t%s\t%u\t%u\t%s\n", 
                genome_size + 1, genome_size + seg.y, i + 1, agp_component_type_val(seg.t),
                sdict->s[seg.c>>1].name, seg.x + 1, seg.x + seg.y, agp_orientation_val(seg.r));
        fprintf(fo_annot, ">ctg%08u.1 %u %u\n", i + 1, i + 1, seg.y);
        fprintf(fo_lift, "ctg%08u.1\t%u\t%u\t%u\t%s\t%s\t%u\t%u\t%s\n",
                i + 1, 1, seg.y, 1, agp_component_type_val(seg.t), sdict->s[seg.c>>1].name, 
                seg.x + 1, seg.x + seg.y, agp_orientation_val(AGP_OT_PLUS));
        if (i == m) {
            m += dict->s[j++].n;
            ++c;
        }
        seqs[c++] = (int) (i + 1) * (seg.r == AGP_OT_MINUS? -1 : 1);
        genome_size += seg.y;
    }

    for (i = 0; i < n; ++i) {
        // seqs[n - 1] is always 0
        if (seqs[i]) {
            fprintf(fo_annot, "%d", seqs[i]);
            fputc(seqs[i + 1]? ' ' : '\n', fo_annot);
        }
    }
    
    fclose(fo_agp);
    fclose(fo_annot);
    fclose(fo_lift);
    free(seqs);

    asm_destroy(dict);

    scaled_gs = linear_scale(genome_size, scale, max_s);
    *g = genome_size;
    
    return scaled_gs;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x4607(%rip), %rsi      # 0x13010
callq 0x2340
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x45f3(%rip), %rsi      # 0x13010
callq 0x2340
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rdi
leaq 0x45df(%rip), %rsi      # 0x13010
callq 0x2340
movq %rax, -0x78(%rbp)
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x81b0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x90(%rbp), %rcx
addl (%rcx), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2200
movq %rax, -0x60(%rbp)
movq $0x0, -0x80(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x90(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x48(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x48(%rbp)
movl %ecx, %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, -0x54(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x90(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jae 0xed56
movq -0x90(%rbp), %rax
movq 0x20(%rax), %rsi
movl -0x44(%rbp), %eax
imulq $0x30, %rax, %rax
addq %rax, %rsi
leaq -0xc0(%rbp), %rdi
movl $0x30, %edx
callq 0x2250
movq -0x68(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x100(%rbp)
movq -0x80(%rbp), %rax
movl -0xa0(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0xf8(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
movl -0x9c(%rbp), %edi
callq 0x10f50
movq %rax, -0xe8(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl -0xa8(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rbx
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe0(%rbp)
movl -0xa4(%rbp), %eax
addl -0xa0(%rbp), %eax
movl %eax, -0xdc(%rbp)
movl -0x98(%rbp), %edi
callq 0x11030
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rdx
movq -0xf8(%rbp), %rcx
movl -0xec(%rbp), %r8d
movq -0xe8(%rbp), %r9
movl -0xe0(%rbp), %r11d
movl -0xdc(%rbp), %r10d
leaq 0x5a92(%rip), %rsi      # 0x14655
movq %rbx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x2230
movq -0x70(%rbp), %rdi
movl -0x44(%rbp), %edx
addl $0x1, %edx
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl -0xa0(%rbp), %r8d
leaq 0x5a7e(%rip), %rsi      # 0x14679
movb $0x0, %al
callq 0x2230
movq -0x78(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
movl -0xa0(%rbp), %eax
movl %eax, -0xcc(%rbp)
movl -0x9c(%rbp), %edi
callq 0x10f50
movq %rax, %r14
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl -0xa8(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rbx
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
movl -0xa4(%rbp), %eax
addl -0xa0(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl $0x2b5d0, %edi          # imm = 0x2B5D0
callq 0x11030
movq -0xd8(%rbp), %rdi
movl -0xd0(%rbp), %edx
movl -0xcc(%rbp), %r8d
movl -0xc8(%rbp), %r11d
movl -0xc4(%rbp), %r10d
leaq 0x59e8(%rip), %rsi      # 0x1468b
movl $0x1, %r9d
movl %r9d, %ecx
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movb $0x0, %al
callq 0x2230
movl -0x44(%rbp), %eax
cmpl -0x54(%rbp), %eax
jne 0xed04
movq -0x90(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x48(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x48(%rbp)
movl %ecx, %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
addl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x44(%rbp), %edx
addl $0x1, %edx
movl -0x98(%rbp), %esi
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x2b5d2, %esi          # imm = 0x2B5D2
cmovel %ecx, %eax
imull %eax, %edx
movq -0x60(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x4c(%rbp)
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
movl -0xa0(%rbp), %eax
addq -0x80(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xeabe
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x50(%rbp), %eax
jae 0xedc3
movq -0x60(%rbp), %rax
movl -0x44(%rbp), %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0xedb6
movq -0x70(%rbp), %rdi
movq -0x60(%rbp), %rax
movl -0x44(%rbp), %ecx
movl (%rax,%rcx,4), %edx
leaq 0x459d(%rip), %rsi      # 0x13324
movb $0x0, %al
callq 0x2230
movq -0x60(%rbp), %rax
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %ecx
movl $0xa, %edi
movl $0x20, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edi
movq -0x70(%rbp), %rsi
callq 0x21e0
jmp 0xedb8
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xed5d
movq -0x68(%rbp), %rdi
callq 0x2120
movq -0x70(%rbp), %rdi
callq 0x2120
movq -0x78(%rbp), %rdi
callq 0x2120
movq -0x60(%rbp), %rdi
callq 0x2050
movq -0x90(%rbp), %rdi
callq 0x63d0
movq -0x80(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq 0x10(%rbp), %rdx
callq 0x2a20
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x88(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)