// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %rbx
cmpl $0x0, (%rsi)
je 0x1ed06
movq %r12, %rdi
callq 0x321d5
testl %eax, %eax
js 0x1f5bd
movl 0x8(%r12), %r14d
movl %r14d, %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x1f5bd
movq %rbx, (%rsp)
movq 0x20(%r12), %r15
movslq 0x14(%r12), %rbp
movl $0x1, %edi
movl $0x48, %esi
callq 0x4360
testq %rax, %rax
je 0x1f5bd
leaq (%r15,%rbp), %r13
movq %rax, %rbx
movl %r14d, (%rax)
cmpl $0x2, %r14d
jne 0x1ed77
cmpl $0x5, %ebp
jge 0x1ed80
testl %ebp, %ebp
jle 0x1ed6e
movzbl (%r15), %esi
movl %esi, %ecx
shrl $0x4, %ecx
leaq 0x33af7(%rip), %rdx     # 0x52860
cmpl (%rdx,%rcx,4), %ebp
jge 0x1ed83
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x1ee21
movq (%rsp), %r8
jmp 0x1eff9
movb (%r15), %sil
movzbl %sil, %ecx
movl $0x1, %edx
testb %cl, %cl
jns 0x1ee21
movzbl 0x1(%r15), %edx
cmpb $-0x41, %sil
ja 0x1edae
andl $0x3f, %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x1ee21
cmpb $-0x21, %sil
ja 0x1edcd
shll $0x8, %edx
movzbl 0x2(%r15), %esi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %edx, %ecx
orl %esi, %ecx
movl $0x3, %edx
jmp 0x1ee21
cmpb $-0x11, %sil
ja 0x1edf6
shll $0x10, %edx
movzbl 0x2(%r15), %esi
shll $0x8, %esi
movzbl 0x3(%r15), %edi
andl $0xf, %ecx
shll $0x18, %ecx
orl %edx, %ecx
orl %esi, %ecx
orl %edi, %ecx
movl $0x4, %edx
jmp 0x1ee21
shll $0x1c, %ecx
shll $0x14, %edx
orl %ecx, %edx
movzbl 0x2(%r15), %ecx
shll $0xc, %ecx
orl %edx, %ecx
movzbl 0x3(%r15), %edx
shll $0x4, %edx
orl %ecx, %edx
movzbl 0x4(%r15), %ecx
andl $0xf, %ecx
orl %edx, %ecx
movl $0x5, %edx
movl %ecx, 0x4(%rbx)
addq %rdx, %r15
movq %rbp, %rcx
subq %rdx, %rcx
cmpq $0x5, %rcx
jge 0x1ee5b
cmpq %rdx, %rbp
jle 0x1ee8d
movzbl (%r15), %esi
movl %esi, %edx
shrl $0x4, %edx
leaq 0x33a18(%rip), %rdi     # 0x52860
movslq (%rdi,%rdx,4), %rdx
cmpq %rdx, %rcx
movq (%rsp), %r8
jge 0x1ee62
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x1ee95
movb (%r15), %sil
movq (%rsp), %r8
movzbl %sil, %ecx
movl $0x1, %edx
testb %cl, %cl
jns 0x1ee95
movzbl 0x1(%r15), %edx
cmpb $-0x41, %sil
ja 0x1eeff
andl $0x3f, %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x1ee95
xorl %ecx, %ecx
xorl %edx, %edx
movq (%rsp), %r8
movl %ecx, 0x8(%rbx)
addq %rdx, %r15
movq %r13, %rcx
subq %r15, %rcx
cmpq $0x5, %rcx
jge 0x1eece
cmpq %r13, %r15
jae 0x1eec5
movzbl (%r15), %esi
movl %esi, %edx
shrl $0x4, %edx
leaq 0x339a4(%rip), %rdi     # 0x52860
movslq (%rdi,%rdx,4), %rdx
cmpq %rdx, %rcx
jge 0x1eed1
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x1eff3
movb (%r15), %sil
movzbl %sil, %ecx
movl $0x1, %edx
testb %cl, %cl
jns 0x1eff3
movzbl 0x1(%r15), %edx
cmpb $-0x41, %sil
ja 0x1ef21
andl $0x3f, %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x1eff3
cmpb $-0x21, %sil
ja 0x1ef43
shll $0x8, %edx
movzbl 0x2(%r15), %esi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %edx, %ecx
orl %esi, %ecx
movl $0x3, %edx
jmp 0x1ee95
cmpb $-0x21, %sil
ja 0x1ef6f
shll $0x8, %edx
movzbl 0x2(%r15), %esi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %edx, %ecx
orl %esi, %ecx
movl $0x3, %edx
jmp 0x1eff3
cmpb $-0x11, %sil
ja 0x1ef98
shll $0x10, %edx
movzbl 0x2(%r15), %esi
shll $0x8, %esi
movzbl 0x3(%r15), %edi
andl $0xf, %ecx
shll $0x18, %ecx
orl %edx, %ecx
orl %esi, %ecx
orl %edi, %ecx
movl $0x4, %edx
jmp 0x1ee95
cmpb $-0x11, %sil
ja 0x1efc8
shll $0x10, %edx
movzbl 0x2(%r15), %esi
shll $0x8, %esi
movzbl 0x3(%r15), %edi
andl $0xf, %ecx
shll $0x18, %ecx
orl %edx, %ecx
orl %esi, %ecx
orl %edi, %ecx
movl $0x4, %edx
jmp 0x1eff3
shll $0x1c, %ecx
shll $0x14, %edx
orl %ecx, %edx
movzbl 0x2(%r15), %ecx
shll $0xc, %ecx
orl %edx, %ecx
movzbl 0x3(%r15), %edx
shll $0x4, %edx
orl %ecx, %edx
movzbl 0x4(%r15), %ecx
andl $0xf, %ecx
orl %edx, %ecx
movl $0x5, %edx
jmp 0x1ee95
shll $0x1c, %ecx
shll $0x14, %edx
orl %ecx, %edx
movzbl 0x2(%r15), %ecx
shll $0xc, %ecx
orl %edx, %ecx
movzbl 0x3(%r15), %edx
shll $0x4, %edx
orl %ecx, %edx
movzbl 0x4(%r15), %ecx
andl $0xf, %ecx
orl %edx, %ecx
movl $0x5, %edx
movl %ecx, 0xc(%rbx)
addq %rdx, %r15
movq %r13, %rcx
subq %r15, %rcx
cmpq $0x5, %rcx
jge 0x1f02c
cmpq %r13, %r15
jae 0x1f023
movzbl (%r15), %esi
movl %esi, %edx
shrl $0x4, %edx
leaq 0x33846(%rip), %rdi     # 0x52860
movslq (%rdi,%rdx,4), %rdx
cmpq %rdx, %rcx
jge 0x1f02f
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x1f0cd
movb (%r15), %sil
movzbl %sil, %ecx
movl $0x1, %edx
testb %cl, %cl
jns 0x1f0cd
movzbl 0x1(%r15), %edx
cmpb $-0x41, %sil
ja 0x1f05a
andl $0x3f, %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x1f0cd
cmpb $-0x21, %sil
ja 0x1f079
shll $0x8, %edx
movzbl 0x2(%r15), %esi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %edx, %ecx
orl %esi, %ecx
movl $0x3, %edx
jmp 0x1f0cd
cmpb $-0x11, %sil
ja 0x1f0a2
shll $0x10, %edx
movzbl 0x2(%r15), %esi
shll $0x8, %esi
movzbl 0x3(%r15), %edi
andl $0xf, %ecx
shll $0x18, %ecx
orl %edx, %ecx
orl %esi, %ecx
orl %edi, %ecx
movl $0x4, %edx
jmp 0x1f0cd
shll $0x1c, %ecx
shll $0x14, %edx
orl %ecx, %edx
movzbl 0x2(%r15), %ecx
shll $0xc, %ecx
orl %edx, %ecx
movzbl 0x3(%r15), %edx
shll $0x4, %edx
orl %ecx, %edx
movzbl 0x4(%r15), %ecx
andl $0xf, %ecx
orl %edx, %ecx
movl $0x5, %edx
movl %ecx, 0x10(%rbx)
addq %rdx, %r15
addq $0x18, %rax
movq $0x0, 0x18(%rbx)
movl 0xc(%r8), %ecx
sarl $0x8, %ecx
cmpl $0x2, %ecx
jne 0x1f11e
movq %r13, %rcx
subq %r15, %rcx
cmpq $0x5, %rcx
jge 0x1f139
cmpq %r13, %r15
jae 0x1f115
movzbl (%r15), %esi
movl %esi, %edx
shrl $0x4, %edx
leaq 0x33754(%rip), %rdi     # 0x52860
movslq (%rdi,%rdx,4), %rdx
cmpq %rdx, %rcx
jge 0x1f13c
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x1f1da
jle 0x1f1e3
movq %r15, %rdi
movq %rax, %rsi
callq 0x3030b
cltq
addq %rax, %r15
jmp 0x1f1e3
movb (%r15), %sil
movzbl %sil, %ecx
movl $0x1, %edx
testb %cl, %cl
jns 0x1f1da
movzbl 0x1(%r15), %edx
cmpb $-0x41, %sil
ja 0x1f167
andl $0x3f, %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x1f1da
cmpb $-0x21, %sil
ja 0x1f186
shll $0x8, %edx
movzbl 0x2(%r15), %esi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %edx, %ecx
orl %esi, %ecx
movl $0x3, %edx
jmp 0x1f1da
cmpb $-0x11, %sil
ja 0x1f1af
shll $0x10, %edx
movzbl 0x2(%r15), %esi
shll $0x8, %esi
movzbl 0x3(%r15), %edi
andl $0xf, %ecx
shll $0x18, %ecx
orl %edx, %ecx
orl %esi, %ecx
orl %edi, %ecx
movl $0x4, %edx
jmp 0x1f1da
shll $0x1c, %ecx
shll $0x14, %edx
orl %ecx, %edx
movzbl 0x2(%r15), %ecx
shll $0xc, %ecx
orl %edx, %ecx
movzbl 0x3(%r15), %edx
shll $0x4, %edx
orl %ecx, %edx
movzbl 0x4(%r15), %ecx
andl $0xf, %ecx
orl %edx, %ecx
movl $0x5, %edx
addq %rdx, %r15
movslq %ecx, %rcx
movq %rcx, (%rax)
movq %r13, %rax
subq %r15, %rax
cmpq $0x5, %rax
jge 0x1f216
cmpq %r13, %r15
jae 0x1f20d
movzbl (%r15), %edx
movl %edx, %ecx
shrl $0x4, %ecx
leaq 0x3365c(%rip), %rsi     # 0x52860
movslq (%rsi,%rcx,4), %rcx
cmpq %rcx, %rax
jge 0x1f219
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x1f2b3
movb (%r15), %dl
movzbl %dl, %eax
movl $0x1, %ecx
testb %al, %al
jns 0x1f2b3
movzbl 0x1(%r15), %ecx
cmpb $-0x41, %dl
ja 0x1f242
andl $0x3f, %eax
shll $0x8, %eax
orl %ecx, %eax
movl $0x2, %ecx
jmp 0x1f2b3
cmpb $-0x21, %dl
ja 0x1f260
shll $0x8, %ecx
movzbl 0x2(%r15), %edx
andl $0x1f, %eax
shll $0x10, %eax
orl %ecx, %eax
orl %edx, %eax
movl $0x3, %ecx
jmp 0x1f2b3
cmpb $-0x11, %dl
ja 0x1f288
shll $0x10, %ecx
movzbl 0x2(%r15), %edx
shll $0x8, %edx
movzbl 0x3(%r15), %esi
andl $0xf, %eax
shll $0x18, %eax
orl %ecx, %eax
orl %edx, %eax
orl %esi, %eax
movl $0x4, %ecx
jmp 0x1f2b3
shll $0x1c, %eax
shll $0x14, %ecx
orl %eax, %ecx
movzbl 0x2(%r15), %eax
shll $0xc, %eax
orl %ecx, %eax
movzbl 0x3(%r15), %ecx
shll $0x4, %ecx
orl %eax, %ecx
movzbl 0x4(%r15), %eax
andl $0xf, %eax
orl %ecx, %eax
movl $0x5, %ecx
movl %eax, 0x20(%rbx)
addq %rcx, %r15
movq %r13, %rax
subq %r15, %rax
cmpq $0x5, %rax
jge 0x1f2ec
cmpq %r13, %r15
jae 0x1f5b5
movzbl (%r15), %edx
movl %edx, %ecx
shrl $0x4, %ecx
leaq 0x33582(%rip), %rsi     # 0x52860
movslq (%rsi,%rcx,4), %rcx
cmpq %rcx, %rax
jge 0x1f2ef
jmp 0x1f5b5
movb (%r15), %dl
movzbl %dl, %eax
movl $0x1, %r14d
testb %al, %al
jns 0x1f38e
movzbl 0x1(%r15), %ecx
cmpb $-0x41, %dl
ja 0x1f31a
andl $0x3f, %eax
shll $0x8, %eax
orl %ecx, %eax
movl $0x2, %r14d
jmp 0x1f38e
cmpb $-0x21, %dl
ja 0x1f339
shll $0x8, %ecx
movzbl 0x2(%r15), %edx
andl $0x1f, %eax
shll $0x10, %eax
orl %ecx, %eax
orl %edx, %eax
movl $0x3, %r14d
jmp 0x1f38e
cmpb $-0x11, %dl
ja 0x1f362
shll $0x10, %ecx
movzbl 0x2(%r15), %edx
shll $0x8, %edx
movzbl 0x3(%r15), %esi
andl $0xf, %eax
shll $0x18, %eax
orl %ecx, %eax
orl %edx, %eax
orl %esi, %eax
movl $0x4, %r14d
jmp 0x1f38e
shll $0x1c, %eax
shll $0x14, %ecx
orl %eax, %ecx
movzbl 0x2(%r15), %eax
shll $0xc, %eax
orl %ecx, %eax
movzbl 0x3(%r15), %ecx
shll $0x4, %ecx
orl %eax, %ecx
movzbl 0x4(%r15), %eax
andl $0xf, %eax
orl %ecx, %eax
movl $0x5, %r14d
movl %eax, 0x24(%rbx)
testl %eax, %eax
jle 0x1f5b5
movl %eax, %ebp
leaq (,%rbp,4), %rdi
callq 0x4700
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x1f5b5
addq %r14, %r15
xorl %edx, %edx
leaq 0x3349f(%rip), %rcx     # 0x52860
movq %r13, %rsi
subq %r15, %rsi
cmpq $0x5, %rsi
jge 0x1f3ee
cmpq %r13, %r15
jae 0x1f5ad
movzbl (%r15), %r8d
movl %r8d, %edi
shrl $0x4, %edi
movslq (%rcx,%rdi,4), %rdi
cmpq %rdi, %rsi
jge 0x1f3f1
jmp 0x1f5ad
movb (%r15), %r8b
movzbl %r8b, %esi
movl $0x1, %edi
testb %sil, %sil
jns 0x1f494
movzbl 0x1(%r15), %edi
cmpb $-0x41, %r8b
ja 0x1f41d
andl $0x3f, %esi
shll $0x8, %esi
orl %edi, %esi
movl $0x2, %edi
jmp 0x1f494
cmpb $-0x21, %r8b
ja 0x1f43d
shll $0x8, %edi
movzbl 0x2(%r15), %r8d
andl $0x1f, %esi
shll $0x10, %esi
orl %edi, %esi
orl %r8d, %esi
movl $0x3, %edi
jmp 0x1f494
cmpb $-0x11, %r8b
ja 0x1f469
shll $0x10, %edi
movzbl 0x2(%r15), %r8d
shll $0x8, %r8d
movzbl 0x3(%r15), %r9d
andl $0xf, %esi
shll $0x18, %esi
orl %edi, %esi
orl %r8d, %esi
orl %r9d, %esi
movl $0x4, %edi
jmp 0x1f494
shll $0x1c, %esi
shll $0x14, %edi
orl %esi, %edi
movzbl 0x2(%r15), %esi
shll $0xc, %esi
orl %edi, %esi
movzbl 0x3(%r15), %edi
shll $0x4, %edi
orl %esi, %edi
movzbl 0x4(%r15), %esi
andl $0xf, %esi
orl %edi, %esi
movl $0x5, %edi
movl %esi, (%rax,%rdx,4)
addq %rdi, %r15
incq %rdx
cmpq %rbp, %rdx
jb 0x1f3c1
cmpl $0x2, 0x8(%r12)
jne 0x1f4de
movq %r13, %rdx
subq %r15, %rdx
cmpq $0x5, %rdx
movq (%rsp), %r8
jge 0x1f4e7
cmpq %r13, %r15
jae 0x1f4d5
movzbl (%r15), %esi
movl %esi, %edi
shrl $0x4, %edi
movslq (%rcx,%rdi,4), %rcx
cmpq %rcx, %rdx
jge 0x1f4ea
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x1f588
movq (%rsp), %r8
jmp 0x1f58e
movb (%r15), %sil
movzbl %sil, %ecx
movl $0x1, %edx
testb %cl, %cl
jns 0x1f588
movzbl 0x1(%r15), %edx
cmpb $-0x41, %sil
ja 0x1f515
andl $0x3f, %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x1f588
cmpb $-0x21, %sil
ja 0x1f534
shll $0x8, %edx
movzbl 0x2(%r15), %esi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %edx, %ecx
orl %esi, %ecx
movl $0x3, %edx
jmp 0x1f588
cmpb $-0x11, %sil
ja 0x1f55d
shll $0x10, %edx
movzbl 0x2(%r15), %esi
shll $0x8, %esi
movzbl 0x3(%r15), %edi
andl $0xf, %ecx
shll $0x18, %ecx
orl %edx, %ecx
orl %esi, %ecx
orl %edi, %ecx
movl $0x4, %edx
jmp 0x1f588
shll $0x1c, %ecx
shll $0x14, %edx
orl %ecx, %edx
movzbl 0x2(%r15), %ecx
shll $0xc, %ecx
orl %edx, %ecx
movzbl 0x3(%r15), %edx
shll $0x4, %edx
orl %ecx, %edx
movzbl 0x4(%r15), %ecx
andl $0xf, %ecx
orl %edx, %ecx
movl $0x5, %edx
movl %ecx, 0x30(%rbx)
addq %rdx, %r15
movl $0xffffff00, %ecx       # imm = 0xFFFFFF00
andl 0xc(%r8), %ecx
cmpl $0x100, %ecx            # imm = 0x100
jne 0x1f5a4
xorps %xmm0, %xmm0
jmp 0x1f5d5
subq %r15, %r13
cmpq $0xf, %r13
jg 0x1f5d1
movq %rax, %rdi
callq 0x4610
movq %rbx, %rdi
callq 0x4610
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movups (%r15), %xmm0
movups %xmm0, 0x34(%rbx)
jmp 0x1f5bf