// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/cram/cram_decode.c
// Function: cram_decode_slice_header
cram_block_slice_hdr *cram_decode_slice_header(cram_fd *fd, cram_block *b) {
    cram_block_slice_hdr *hdr;
    char *cp;
    char *cp_end;
    int i;

    if (b->method != RAW) {
        /* Spec. says slice header should be RAW, but we can future-proof
	   by trying to decode it if it isn't. */
        if (cram_uncompress_block(b) < 0)
            return NULL;
    }
    cp =  (char *)b->data;
    cp_end = cp + b->uncomp_size;

    if (b->content_type != MAPPED_SLICE &&
	b->content_type != UNMAPPED_SLICE)
	return NULL;

    if (!(hdr  = calloc(1, sizeof(*hdr))))
	return NULL;

    hdr->content_type = b->content_type;

    if (b->content_type == MAPPED_SLICE) {
        cp += safe_itf8_get(cp,  cp_end, &hdr->ref_seq_id);
        cp += safe_itf8_get(cp,  cp_end, &hdr->ref_seq_start);
        cp += safe_itf8_get(cp,  cp_end, &hdr->ref_seq_span);
    }
    cp += safe_itf8_get(cp,  cp_end, &hdr->num_records);
    hdr->record_counter = 0;
    if (CRAM_MAJOR_VERS(fd->version) == 2) {
	int32_t i32 = 0;
	cp += safe_itf8_get(cp, cp_end, &i32);
	hdr->record_counter = i32;
    } else if (CRAM_MAJOR_VERS(fd->version) >= 3) {
	cp += ltf8_get(cp, &hdr->record_counter);
    }

    cp += safe_itf8_get(cp, cp_end, &hdr->num_blocks);

    cp += safe_itf8_get(cp, cp_end, &hdr->num_content_ids);
    if (hdr->num_content_ids < 1 ||
	hdr->num_content_ids >= SIZE_MAX / sizeof(int32_t)) {
        /* Slice must have at least one data block,
	   and malloc'd size shouldn't wrap. */
        free(hdr);
        return NULL;
    }
    hdr->block_content_ids = malloc(hdr->num_content_ids * sizeof(int32_t));
    if (!hdr->block_content_ids) {
	free(hdr);
	return NULL;
    }

    for (i = 0; i < hdr->num_content_ids; i++) {
	int l = safe_itf8_get(cp, cp_end,
			      &hdr->block_content_ids[i]);
	if (l <= 0) {
	    free(hdr->block_content_ids);
	    free(hdr);
	    return NULL;
	}
	cp += l;
    }

    if (b->content_type == MAPPED_SLICE) {
        cp += safe_itf8_get(cp,  cp_end, &hdr->ref_base_id);
    }

    if (CRAM_MAJOR_VERS(fd->version) != 1) {
        if (cp_end - cp < 16) {
            free(hdr->block_content_ids);
            free(hdr);
            return NULL;
        }
	memcpy(hdr->md5, cp, 16);
    } else {
	memset(hdr->md5, 0, 16);
    }

    return hdr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0xb2046
movq -0x18(%rbp), %rdi
callq 0x7f790
cmpl $0x0, %eax
jge 0xb2044
movq $0x0, -0x8(%rbp)
jmp 0xb23b7
jmp 0xb2046
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq 0x14(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, 0x8(%rax)
je 0xb2086
movq -0x18(%rbp), %rax
cmpl $0x3, 0x8(%rax)
je 0xb2086
movq $0x0, -0x8(%rbp)
jmp 0xb23b7
movl $0x1, %edi
movl $0x48, %esi
callq 0x6460
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0xb20ac
movq $0x0, -0x8(%rbp)
jmp 0xb23b7
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
cmpl $0x2, 0x8(%rax)
jne 0xb2132
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
addq $0x4, %rdx
callq 0xaf040
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
addq $0x8, %rdx
callq 0xaf040
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
addq $0xc, %rdx
callq 0xaf040
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
addq $0x10, %rdx
callq 0xaf040
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x2, %eax
jne 0xb21a8
movl $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0xaf040
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movslq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0xb21da
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x3, %eax
jl 0xb21d8
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x18, %rsi
callq 0x7c3a0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
jmp 0xb21da
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
addq $0x20, %rdx
callq 0xaf040
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
addq $0x24, %rdx
callq 0xaf040
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x1, 0x24(%rax)
jl 0xb2245
movq -0x20(%rbp), %rax
movslq 0x24(%rax), %rax
movabsq $0x3fffffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rcx, %rax
jb 0xb225b
movq -0x20(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0xb23b7
movq -0x20(%rbp), %rax
movslq 0x24(%rax), %rdi
shlq $0x2, %rdi
callq 0x69c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0xb2298
movq -0x20(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0xb23b7
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jge 0xb2313
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdx
movslq -0x34(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
callq 0xaf040
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jg 0xb22f7
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x6880
movq -0x20(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0xb23b7
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xb229f
movq -0x18(%rbp), %rax
cmpl $0x2, 0x8(%rax)
jne 0xb2342
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
addq $0x30, %rdx
callq 0xaf040
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x1, %eax
je 0xb239b
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
cmpq $0x10, %rax
jge 0xb2382
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x6880
movq -0x20(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0xb23b7
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x34(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x3c(%rax)
jmp 0xb23af
movq -0x20(%rbp), %rdi
addq $0x34, %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x63a0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)