// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_io.c
// Function: cram_write_eof_block
int cram_write_eof_block(cram_fd *fd) {
    // EOF block is a container with special values to aid detection
    if (CRAM_MAJOR_VERS(fd->version) >= 2) {
        // Empty container with
        //   ref_seq_id -1
        //   start pos 0x454f46 ("EOF")
        //   span 0
        //   nrec 0
        //   counter 0
        //   nbases 0
        //   1 block (landmark 0)
        //   (CRC32)
        cram_container c;
        memset(&c, 0, sizeof(c));
        c.ref_seq_id = -1;
        c.ref_seq_start = 0x454f46; // "EOF"
        c.ref_seq_span = 0;
        c.record_counter = 0;
        c.num_bases = 0;
        c.num_blocks = 1;
        int32_t land[1] = {0};
        c.landmark = land;

        // An empty compression header block with
        //   method raw (0)
        //   type comp header (1)
        //   content id 0
        //   block contents size 6
        //   raw size 6
        //     empty preservation map (01 00)
        //     empty data series map (01 00)
        //     empty tag map (01 00)
        //   block CRC
        cram_block_compression_hdr ch;
        memset(&ch, 0, sizeof(ch));
        c.comp_hdr_block = cram_encode_compression_header(fd, &c, &ch, 0);

        c.length = c.comp_hdr_block->byte            // Landmark[0]
            + 5                                      // block struct
            + 4*(CRAM_MAJOR_VERS(fd->version) >= 3); // CRC
        if (cram_write_container(fd, &c) < 0 ||
            cram_write_block(fd, c.comp_hdr_block) < 0) {
            cram_close(fd);
            cram_free_block(c.comp_hdr_block);
            return -1;
        }
        if (ch.preservation_map)
            kh_destroy(map, ch.preservation_map);
        cram_free_block(c.comp_hdr_block);

        // V2.1 bytes
        // 0b 00 00 00 ff ff ff ff 0f // Cont HDR: size, ref seq id
        // e0 45 4f 46 00 00 00       // Cont HDR: pos, span, nrec, counter
        // 00 01 00                   // Cont HDR: nbase, nblk, landmark
        // 00 01 00 06 06             // Comp.HDR blk
        // 01 00 01 00 01 00          // Comp.HDR blk

        // V3.0 bytes:
        // 0f 00 00 00 ff ff ff ff 0f // Cont HDR: size, ref seq id
        // e0 45 4f 46 00 00 00       // Cont HDR: pos, span, nrec, counter
        // 00 01 00                   // Cont HDR: nbase, nblk, landmark
        // 05 bd d9 4f                // CRC32
        // 00 01 00 06 06             // Comp.HDR blk
        // 01 00 01 00 01 00          // Comp.HDR blk
        // ee 63 01 4b                // CRC32

        // V4.0 bytes:
        // 0f 00 00 00 8f ff ff ff    // Cont HDR: size, ref seq id
        // 82 95 9e 46 00 00 00       // Cont HDR: pos, span, nrec, counter
        // 00 01 00                   // Cont HDR: nbase, nblk, landmark
        // ac d6 05 bc                // CRC32
        // 00 01 00 06 06             // Comp.HDR blk
        // 01 00 01 00 01 00          // Comp.HDR blk
        // ee 63 01 4b                // CRC32
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6d0, %rsp            # imm = 0x6D0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x2, %eax
jl 0x79ae7
leaq -0x2b0(%rbp), %rdi
xorl %esi, %esi
movl $0x2a0, %edx            # imm = 0x2A0
callq 0x4250
movl $0xffffffff, -0x2ac(%rbp) # imm = 0xFFFFFFFF
movq $0x454f46, -0x2a8(%rbp) # imm = 0x454F46
movq $0x0, -0x2a0(%rbp)
movq $0x0, -0x298(%rbp)
movq $0x0, -0x290(%rbp)
movl $0x1, -0x284(%rbp)
leaq -0x2b4(%rbp), %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x4250
leaq -0x2b4(%rbp), %rax
movq %rax, -0x278(%rbp)
leaq -0x6d0(%rbp), %rdi
xorl %esi, %esi
movl $0x418, %edx            # imm = 0x418
callq 0x4250
movq -0x10(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
leaq -0x6d0(%rbp), %rdx
xorl %ecx, %ecx
callq 0x5a5b0
movq %rax, -0x260(%rbp)
movq -0x260(%rbp), %rax
movq 0x30(%rax), %rax
addq $0x5, %rax
movq -0x10(%rbp), %rcx
movl 0xc(%rcx), %ecx
sarl $0x8, %ecx
cmpl $0x3, %ecx
setge %cl
andb $0x1, %cl
movzbl %cl, %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movl %eax, -0x2b0(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x76030
cmpl $0x0, %eax
jl 0x79aa7
movq -0x10(%rbp), %rdi
movq -0x260(%rbp), %rsi
callq 0x6f400
cmpl $0x0, %eax
jge 0x79ac5
movq -0x10(%rbp), %rdi
callq 0x79b00
movq -0x260(%rbp), %rdi
callq 0x6f940
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x79aee
cmpq $0x0, -0x658(%rbp)
je 0x79adb
movq -0x658(%rbp), %rdi
callq 0x76eb0
movq -0x260(%rbp), %rdi
callq 0x6f940
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x6d0, %rsp            # imm = 0x6D0
popq %rbp
retq
nopw (%rax,%rax)