// File: /workspace/github_cpp_makefile_star2_O1/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 0x1f048
movq %r12, %rdi
callq 0x32ec9
testl %eax, %eax
js 0x1f8e7
movl 0x8(%r12), %r14d
movl %r14d, %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x1f8e7
movq %rbx, (%rsp)
movq 0x20(%r12), %r15
movslq 0x14(%r12), %rbp
movl $0x1, %edi
movl $0x48, %esi
callq 0x4360
testq %rax, %rax
je 0x1f8e7
leaq (%r15,%rbp), %r13
movq %rax, %rbx
movl %r14d, (%rax)
cmpl $0x2, %r14d
jne 0x1f0b7
cmpl $0x4, %ebp
jg 0x1f0c0
testl %ebp, %ebp
jle 0x1f0ae
movzbl (%r15), %ecx
shrl $0x4, %ecx
leaq 0x35657(%rip), %rdx     # 0x54700
cmpl (%rdx,%rcx,4), %ebp
jge 0x1f0c0
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x1f15b
movq (%rsp), %r8
jmp 0x1f2ee
movzbl (%r15), %ecx
movl $0x1, %edx
testb %cl, %cl
jns 0x1f15b
movzbl 0x1(%r15), %edx
cmpb $-0x41, %cl
ja 0x1f0ea
andl $0x3f, %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x1f15b
cmpb $-0x21, %cl
ja 0x1f108
shll $0x8, %edx
movzbl 0x2(%r15), %esi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %edx, %ecx
orl %esi, %ecx
movl $0x3, %edx
jmp 0x1f15b
cmpb $-0x11, %cl
ja 0x1f130
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 0x1f15b
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 $0x4, %rcx
jg 0x1f18f
cmpq %rdx, %rbp
jle 0x1f189
movzbl (%r15), %edx
shrl $0x4, %edx
leaq 0x35580(%rip), %rsi     # 0x54700
movslq (%rsi,%rdx,4), %rdx
cmpq %rdx, %rcx
jge 0x1f18f
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x1f19c
movzbl (%r15), %ecx
movl $0x1, %edx
testb %cl, %cl
js 0x1f204
movq (%rsp), %r8
movl %ecx, 0x8(%rbx)
addq %rdx, %r15
movq %r13, %rcx
subq %r15, %rcx
cmpq $0x4, %rcx
jg 0x1f1d7
cmpq %r13, %r15
jae 0x1f1ce
movzbl (%r15), %edx
shrl $0x4, %edx
leaq 0x3553b(%rip), %rsi     # 0x54700
movslq (%rsi,%rdx,4), %rdx
cmpq %rdx, %rcx
jge 0x1f1d7
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x1f2e8
movzbl (%r15), %ecx
movl $0x1, %edx
testb %cl, %cl
jns 0x1f2e8
movzbl 0x1(%r15), %edx
cmpb $-0x41, %cl
ja 0x1f224
andl $0x3f, %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x1f2e8
movzbl 0x1(%r15), %edx
cmpb $-0x41, %cl
movq (%rsp), %r8
ja 0x1f245
andl $0x3f, %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x1f1a0
cmpb $-0x21, %cl
ja 0x1f266
shll $0x8, %edx
movzbl 0x2(%r15), %esi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %edx, %ecx
orl %esi, %ecx
movl $0x3, %edx
jmp 0x1f2e8
cmpb $-0x21, %cl
ja 0x1f28e
shll $0x8, %edx
movzbl 0x2(%r15), %esi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %edx, %ecx
orl %esi, %ecx
movl $0x3, %edx
jmp 0x1f1a0
cmpb $-0x11, %cl
ja 0x1f2bd
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 0x1f2e8
cmpb $-0x11, %cl
ja 0x1f49a
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 0x1f1a0
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 $0x4, %rcx
jg 0x1f31f
cmpq %r13, %r15
jae 0x1f316
movzbl (%r15), %edx
shrl $0x4, %edx
leaq 0x353f3(%rip), %rsi     # 0x54700
movslq (%rsi,%rdx,4), %rdx
cmpq %rdx, %rcx
jge 0x1f31f
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x1f3ba
movzbl (%r15), %ecx
movl $0x1, %edx
testb %cl, %cl
jns 0x1f3ba
movzbl 0x1(%r15), %edx
cmpb $-0x41, %cl
ja 0x1f349
andl $0x3f, %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x1f3ba
cmpb $-0x21, %cl
ja 0x1f367
shll $0x8, %edx
movzbl 0x2(%r15), %esi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %edx, %ecx
orl %esi, %ecx
movl $0x3, %edx
jmp 0x1f3ba
cmpb $-0x11, %cl
ja 0x1f38f
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 0x1f3ba
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 0x1f409
movq %r13, %rcx
subq %r15, %rcx
cmpq $0x4, %rcx
jg 0x1f424
cmpq %r13, %r15
jae 0x1f400
movzbl (%r15), %edx
shrl $0x4, %edx
leaq 0x35309(%rip), %rsi     # 0x54700
movslq (%rsi,%rdx,4), %rdx
cmpq %rdx, %rcx
jge 0x1f424
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x1f4f5
jle 0x1f4fe
movq %r15, %rdi
movq %rax, %rsi
callq 0x30f2b
cltq
addq %rax, %r15
jmp 0x1f4fe
movzbl (%r15), %ecx
movl $0x1, %edx
testb %cl, %cl
jns 0x1f4f5
movzbl 0x1(%r15), %edx
cmpb $-0x41, %cl
ja 0x1f451
andl $0x3f, %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x1f4f5
cmpb $-0x21, %cl
ja 0x1f472
shll $0x8, %edx
movzbl 0x2(%r15), %esi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %edx, %ecx
orl %esi, %ecx
movl $0x3, %edx
jmp 0x1f4f5
cmpb $-0x11, %cl
ja 0x1f4ca
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 0x1f4f5
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 0x1f1a0
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 $0x4, %rax
jg 0x1f52f
cmpq %r13, %r15
jae 0x1f526
movzbl (%r15), %ecx
shrl $0x4, %ecx
leaq 0x351e3(%rip), %rdx     # 0x54700
movslq (%rdx,%rcx,4), %rcx
cmpq %rcx, %rax
jge 0x1f52f
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x1f5c7
movzbl (%r15), %eax
movl $0x1, %ecx
testb %al, %al
jns 0x1f5c7
movzbl 0x1(%r15), %ecx
cmpb $-0x41, %al
ja 0x1f558
andl $0x3f, %eax
shll $0x8, %eax
orl %ecx, %eax
movl $0x2, %ecx
jmp 0x1f5c7
cmpb $-0x21, %al
ja 0x1f575
shll $0x8, %ecx
movzbl 0x2(%r15), %edx
andl $0x1f, %eax
shll $0x10, %eax
orl %ecx, %eax
orl %edx, %eax
movl $0x3, %ecx
jmp 0x1f5c7
cmpb $-0x11, %al
ja 0x1f59c
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 0x1f5c7
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 $0x4, %rax
jg 0x1f5ff
cmpq %r13, %r15
jae 0x1f5f5
movzbl (%r15), %ecx
shrl $0x4, %ecx
leaq 0x35114(%rip), %rdx     # 0x54700
movslq (%rdx,%rcx,4), %rcx
cmpq %rcx, %rax
jge 0x1f5ff
xorl %eax, %eax
xorl %r14d, %r14d
jmp 0x1f69c
movzbl (%r15), %eax
movl $0x1, %r14d
testb %al, %al
jns 0x1f69c
movzbl 0x1(%r15), %ecx
cmpb $-0x41, %al
ja 0x1f62a
andl $0x3f, %eax
shll $0x8, %eax
orl %ecx, %eax
movl $0x2, %r14d
jmp 0x1f69c
cmpb $-0x21, %al
ja 0x1f648
shll $0x8, %ecx
movzbl 0x2(%r15), %edx
andl $0x1f, %eax
shll $0x10, %eax
orl %ecx, %eax
orl %edx, %eax
movl $0x3, %r14d
jmp 0x1f69c
cmpb $-0x11, %al
ja 0x1f670
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 0x1f69c
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 0x1f8df
movl %eax, %edi
shlq $0x2, %rdi
callq 0x4700
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x1f8df
addq %r14, %r15
cmpl $0x0, 0x24(%rbx)
jle 0x1f7d5
xorl %ebp, %ebp
movq %r13, %rax
subq %r15, %rax
cmpq $0x4, %rax
jg 0x1f702
movb $0x1, %r14b
cmpq %r13, %r15
jae 0x1f6f9
movzbl (%r15), %ecx
shrl $0x4, %ecx
leaq 0x35010(%rip), %rdx     # 0x54700
movslq (%rdx,%rcx,4), %rcx
cmpq %rcx, %rax
jge 0x1f702
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x1f79e
movzbl (%r15), %eax
testb %al, %al
js 0x1f714
movl $0x1, %ecx
jmp 0x1f79b
movzbl 0x1(%r15), %ecx
cmpb $-0x41, %al
ja 0x1f72c
andl $0x3f, %eax
shll $0x8, %eax
orl %ecx, %eax
movl $0x2, %ecx
jmp 0x1f79b
cmpb $-0x21, %al
ja 0x1f749
shll $0x8, %ecx
movzbl 0x2(%r15), %edx
andl $0x1f, %eax
shll $0x10, %eax
orl %ecx, %eax
orl %edx, %eax
movl $0x3, %ecx
jmp 0x1f79b
cmpb $-0x11, %al
ja 0x1f770
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 0x1f79b
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
xorl %r14d, %r14d
movq 0x28(%rbx), %rdi
movl %eax, (%rdi,%rbp,4)
testb %r14b, %r14b
je 0x1f7b9
callq 0x4610
movq %rbx, %rdi
callq 0x4610
jmp 0x1f7bc
addq %rcx, %r15
testb %r14b, %r14b
jne 0x1f8e7
incq %rbp
movslq 0x24(%rbx), %rax
cmpq %rax, %rbp
jl 0x1f6ce
cmpl $0x2, 0x8(%r12)
jne 0x1f812
movq %r13, %rax
subq %r15, %rax
cmpq $0x4, %rax
movq (%rsp), %rdi
jg 0x1f81b
cmpq %r13, %r15
jae 0x1f809
movzbl (%r15), %ecx
shrl $0x4, %ecx
leaq 0x34f00(%rip), %rdx     # 0x54700
movslq (%rdx,%rcx,4), %rcx
cmpq %rcx, %rax
jge 0x1f81b
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x1f8b3
movq (%rsp), %rdi
jmp 0x1f8b9
movzbl (%r15), %eax
movl $0x1, %ecx
testb %al, %al
jns 0x1f8b3
movzbl 0x1(%r15), %ecx
cmpb $-0x41, %al
ja 0x1f844
andl $0x3f, %eax
shll $0x8, %eax
orl %ecx, %eax
movl $0x2, %ecx
jmp 0x1f8b3
cmpb $-0x21, %al
ja 0x1f861
shll $0x8, %ecx
movzbl 0x2(%r15), %edx
andl $0x1f, %eax
shll $0x10, %eax
orl %ecx, %eax
orl %edx, %eax
movl $0x3, %ecx
jmp 0x1f8b3
cmpb $-0x11, %al
ja 0x1f888
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 0x1f8b3
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, 0x30(%rbx)
addq %rcx, %r15
movl $0xffffff00, %eax       # imm = 0xFFFFFF00
andl 0xc(%rdi), %eax
cmpl $0x100, %eax            # imm = 0x100
jne 0x1f8cd
xorps %xmm0, %xmm0
jmp 0x1f8ff
subq %r15, %r13
cmpq $0xf, %r13
jg 0x1f8fb
movq 0x28(%rbx), %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 0x1f8e9