// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/htslib/cram/cram_io.c
// Function: cram_write_SAM_hdr
int cram_write_SAM_hdr(cram_fd *fd, SAM_hdr *hdr) {
    int header_len;
    int blank_block = (CRAM_MAJOR_VERS(fd->version) >= 3);

    /* Write CRAM MAGIC if not yet written. */
    if (fd->file_def->major_version == 0) {
	fd->file_def->major_version = CRAM_MAJOR_VERS(fd->version);
	fd->file_def->minor_version = CRAM_MINOR_VERS(fd->version);
	if (0 != cram_write_file_def(fd, fd->file_def))
	    return -1;
    }

    /* 1.0 requires an UNKNOWN read-group */
    if (CRAM_MAJOR_VERS(fd->version) == 1) {
	if (!sam_hdr_find_rg(hdr, "UNKNOWN"))
	    if (sam_hdr_add(hdr, "RG",
			    "ID", "UNKNOWN", "SM", "UNKNOWN", NULL))
		return -1;
    }

    /* Fix M5 strings */
    if (fd->refs && !fd->no_ref) {
	int i;
	for (i = 0; i < hdr->nref; i++) {
	    SAM_hdr_type *ty;
	    char *ref;

	    if (!(ty = sam_hdr_find(hdr, "SQ", "SN", hdr->ref[i].name)))
		return -1;

	    if (!sam_hdr_find_key(hdr, ty, "M5", NULL)) {
		char unsigned buf[16];
		char buf2[33];
		int rlen;
		hts_md5_context *md5;

		if (!fd->refs ||
		    !fd->refs->ref_id ||
		    !fd->refs->ref_id[i]) {
		    return -1;
		}
		rlen = fd->refs->ref_id[i]->length;
		if (!(md5 = hts_md5_init()))
		    return -1;
		ref = cram_get_ref(fd, i, 1, rlen);
		if (NULL == ref) return -1;
		rlen = fd->refs->ref_id[i]->length; /* In case it just loaded */
		hts_md5_update(md5, ref, rlen);
		hts_md5_final(buf, md5);
		hts_md5_destroy(md5);
		cram_ref_decr(fd->refs, i);

		hts_md5_hex(buf2, buf);
		if (sam_hdr_update(hdr, ty, "M5", buf2, NULL))
		    return -1;
	    }

	    if (fd->ref_fn) {
		char ref_fn[PATH_MAX];
		full_path(ref_fn, fd->ref_fn);
		if (sam_hdr_update(hdr, ty, "UR", ref_fn, NULL))
		    return -1;
	    }
	}
    }

    if (sam_hdr_rebuild(hdr))
	return -1;

    /* Length */
    header_len = sam_hdr_length(hdr);
    if (CRAM_MAJOR_VERS(fd->version) == 1) {
	if (-1 == int32_encode(fd, header_len))
	    return -1;

	/* Text data */
	if (header_len != hwrite(fd->fp, sam_hdr_str(hdr), header_len))
	    return -1;
    } else {
	/* Create block(s) inside a container */
	cram_block *b = cram_new_block(FILE_HEADER, 0);
	cram_container *c = cram_new_container(0, 0);
	int padded_length;
	char *pads;
	int is_cram_3 = (CRAM_MAJOR_VERS(fd->version) >= 3);

	if (!b || !c) {
	    if (b) cram_free_block(b);
	    if (c) cram_free_container(c);
	    return -1;
	}

	int32_put_blk(b, header_len);
	BLOCK_APPEND(b, sam_hdr_str(hdr), header_len);
	BLOCK_UPLEN(b);

	// Compress header block if V3.0 and above
	if (CRAM_MAJOR_VERS(fd->version) >= 3)
	    cram_compress_block(fd, b, NULL, -1, -1);

	if (blank_block) {
	    c->length = b->comp_size + 2 + 4*is_cram_3 +
		itf8_size(b->content_id)   + 
		itf8_size(b->uncomp_size)  +
		itf8_size(b->comp_size);

	    c->num_blocks = 2;
	    c->num_landmarks = 2;
	    if (!(c->landmark = malloc(2*sizeof(*c->landmark)))) {
		cram_free_block(b);
		cram_free_container(c);
		return -1;
	    }
	    c->landmark[0] = 0;
	    c->landmark[1] = c->length;

	    // Plus extra storage for uncompressed secondary blank block
	    padded_length = MIN(c->length*.5, 10000);
	    c->length += padded_length + 2 + 4*is_cram_3 +
		itf8_size(b->content_id) + 
		itf8_size(padded_length)*2;
	} else {
	    // Pad the block instead.
	    c->num_blocks = 1;
	    c->num_landmarks = 1;
	    if (!(c->landmark = malloc(sizeof(*c->landmark))))
		return -1;
	    c->landmark[0] = 0;

	    padded_length = MAX(c->length*1.5, 10000) - c->length;

	    c->length = b->comp_size + padded_length +
		2 + 4*is_cram_3 +
		itf8_size(b->content_id)   + 
		itf8_size(b->uncomp_size)  +
		itf8_size(b->comp_size);

	    if (NULL == (pads = calloc(1, padded_length))) {
		cram_free_block(b);
		cram_free_container(c);
		return -1;
	    }
	    BLOCK_APPEND(b, pads, padded_length);
	    BLOCK_UPLEN(b);
	    free(pads);
	}

	if (-1 == cram_write_container(fd, c)) {
	    cram_free_block(b);
	    cram_free_container(c);
	    return -1;
	}

	if (-1 == cram_write_block(fd, b)) {
	    cram_free_block(b);
	    cram_free_container(c);
	    return -1;
	}

	if (blank_block) {
	    BLOCK_RESIZE(b, padded_length);
	    memset(BLOCK_DATA(b), 0, padded_length);
	    BLOCK_SIZE(b) = padded_length;
	    BLOCK_UPLEN(b);
	    b->method = RAW;
	    if (-1 == cram_write_block(fd, b)) {
		cram_free_block(b);
		cram_free_container(c);
		return -1;
	    }
	}

	cram_free_block(b);
	cram_free_container(c);
    }

    if (-1 == refs_from_header(fd->refs, fd, fd->header))
	return -1;
    if (-1 == refs2id(fd->refs, fd->header))
	return -1;

    if (0 != hflush(fd->fp))
	return -1;

    RP("=== Finishing saving header ===\n");

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1048, %rsp           # imm = 0x1048
movq %rsi, %r13
movq %rdi, %rbx
movl 0xc(%rdi), %eax
movl %eax, %ebp
sarl $0x8, %ebp
movq 0x10(%rdi), %rsi
cmpb $0x0, 0x4(%rsi)
pushq $-0x1
popq %r15
je 0x52ae6
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl $0x100, %eax            # imm = 0x100
jne 0x52a5d
leaq 0x3555d(%rip), %rsi     # 0x87fa9
movq %r13, %rdi
callq 0x59abb
testq %rax, %rax
je 0x52d51
movl %ebp, 0x1c(%rsp)
cmpq $0x0, 0x48(%rbx)
je 0x52a75
cmpl $0x0, 0x20c(%rbx)
je 0x52b05
movq %r13, %rdi
callq 0x592ce
testl %eax, %eax
pushq $-0x1
popq %r15
jne 0x53399
movq %r13, %rdi
callq 0x59a63
movl %eax, %ebp
movl $0xffffff00, %eax       # imm = 0xFFFFFF00
andl 0xc(%rbx), %eax
movq %rbx, %r14
movslq %ebp, %rbx
cmpl $0x100, %eax            # imm = 0x100
jne 0x52d8c
movq %r14, %rdi
movl %ebp, %esi
callq 0x4d8c7
cmpl $-0x1, %eax
je 0x53399
movq (%r14), %r15
movq %r13, %rdi
callq 0x59a5e
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x4c987
cmpq %rbx, %rax
je 0x5334b
jmp 0x53395
movb %bpl, 0x4(%rsi)
movb %al, 0x5(%rsi)
movq %rbx, %rdi
callq 0x52662
testl %eax, %eax
jne 0x53399
movl 0xc(%rbx), %eax
jmp 0x52a39
leaq 0x354ae(%rip), %r14     # 0x87fba
xorl %r15d, %r15d
xorl %ebp, %ebp
movq %rbx, 0x8(%rsp)
movslq 0x38(%r13), %rax
cmpq %rax, %rbp
jge 0x52a75
movq 0x40(%r13), %rax
movq (%rax,%r15,4), %rcx
movq %r13, %rdi
movq %r14, %rsi
leaq 0x35485(%rip), %rdx     # 0x87fbd
callq 0x58d95
testq %rax, %rax
je 0x53395
movq %rax, %r12
movq %rbp, 0x10(%rsp)
movq %r13, %rdi
movq %rax, %rsi
leaq 0x35465(%rip), %rdx     # 0x87fc0
xorl %ecx, %ecx
callq 0x59104
testq %rax, %rax
jne 0x52c48
movq 0x48(%rbx), %rax
testq %rax, %rax
je 0x53395
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x53395
movq (%rax,%r15), %rax
testq %rax, %rax
je 0x53395
movq %rbx, %r14
movq 0x10(%rax), %rbx
callq 0x6121a
testq %rax, %rax
je 0x53395
movq %rax, %rbp
movq %r14, %rdi
movq 0x10(%rsp), %rsi
pushq $0x1
popq %rdx
movl %ebx, %ecx
callq 0x4f8c1
testq %rax, %rax
je 0x53395
movq %r14, %rbx
movq 0x48(%r14), %rcx
movq 0x10(%rcx), %rcx
movq (%rcx,%r15), %rcx
movslq 0x10(%rcx), %rdx
movq %rbp, %rdi
movq %rax, %rsi
callq 0x607fd
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x61100
movq %rbp, %rdi
callq 0x61244
movq 0x48(%rbx), %rdi
movq 0x10(%rsp), %rsi
callq 0x4f48f
movq %r15, %rbp
leaq 0x40(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x61249
movq %r13, %rdi
movq %r12, %rsi
leaq 0x35397(%rip), %rdx     # 0x87fc0
movq %r15, %rcx
movq %rbp, %r15
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x5913d
testl %eax, %eax
leaq 0x35378(%rip), %r14     # 0x87fba
jne 0x53395
movq 0x70(%rbx), %rbp
testq %rbp, %rbp
je 0x52d40
movq %r15, 0x28(%rsp)
cmpb $0x2f, (%rbp)
leaq 0x40(%rsp), %rdi
jne 0x52c82
movl $0x1000, %edx           # imm = 0x1000
movq %rbp, %rsi
movq %rdi, %r15
callq 0x6380
movb $0x0, 0x103f(%rsp)
jmp 0x52d19
movl $0x1000, %esi           # imm = 0x1000
movq %rdi, %r15
callq 0x6370
testq %rax, %rax
je 0x52cd4
movq %r15, %rdi
callq 0x62d0
movq %rax, %rbx
movq %rax, 0x20(%rsp)
shlq $0x20, %rbx
movabsq $0x100000000, %rax      # imm = 0x100000000
leaq (%rbx,%rax), %r14
sarq $0x20, %r14
movq %rbp, %rdi
callq 0x62d0
addq %r14, %rax
leaq 0x352ee(%rip), %r14     # 0x87fba
cmpq $0x1000, %rax           # imm = 0x1000
jb 0x52cee
movl $0x1000, %edx           # imm = 0x1000
movq %r15, %rdi
movq %rbp, %rsi
callq 0x6380
movb $0x0, 0x103f(%rsp)
jmp 0x52d14
sarq $0x20, %rbx
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
movl $0x1000, %edx           # imm = 0x1000
subl 0x20(%rsp), %edx
leaq 0x355d4(%rip), %rsi     # 0x882de
movq %rbp, %rcx
xorl %eax, %eax
callq 0x6170
movq 0x8(%rsp), %rbx
movq %r13, %rdi
movq %r12, %rsi
leaq 0x2c5a8(%rip), %rdx     # 0x7f2ce
movq %r15, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x5913d
testl %eax, %eax
movq 0x28(%rsp), %r15
jne 0x53395
movq 0x10(%rsp), %rbp
incq %rbp
addq $0x8, %r15
jmp 0x52b16
andq $0x0, (%rsp)
leaq 0x35254(%rip), %rsi     # 0x87fb1
leaq 0x35250(%rip), %rdx     # 0x87fb4
leaq 0x3524c(%rip), %r8      # 0x87fb7
leaq 0x35237(%rip), %rcx     # 0x87fa9
movq %r13, %rdi
movq %rcx, %r9
xorl %eax, %eax
callq 0x58809
testl %eax, %eax
jne 0x53399
jmp 0x52a5d
movq %r14, 0x8(%rsp)
xorl %edi, %edi
xorl %esi, %esi
callq 0x4db76
movq %rax, %r12
xorl %edi, %edi
xorl %esi, %esi
callq 0x507fa
movq %rax, %r15
testq %r12, %r12
setne %al
testq %r15, %r15
setne %cl
testb %cl, %al
je 0x52e55
movq 0x8(%rsp), %rax
movl 0xc(%rax), %eax
movl %eax, 0x10(%rsp)
movq %r12, %rdi
movl %ebp, %esi
callq 0x4d917
movl $0x400, %r14d           # imm = 0x400
movq 0x28(%r12), %rax
movq 0x30(%r12), %rbp
leaq (%rbx,%rbp), %rcx
cmpq %rcx, %rax
ja 0x52e70
movq %rax, %xmm0
punpckldq 0x28213(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x2821b(%rip), %xmm0    # 0x7b020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x2c9cf(%rip), %xmm1    # 0x7f7e8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x342a7(%rip), %xmm1    # 0x870d0
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %r14, %rsi
movq %rsi, 0x28(%r12)
movq 0x20(%r12), %rdi
callq 0x6c80
movq %rax, 0x20(%r12)
jmp 0x52dd9
testq %r12, %r12
je 0x52e62
movq %r12, %rdi
callq 0x4e18f
testq %r15, %r15
jne 0x5338d
jmp 0x53395
addq 0x20(%r12), %rbp
movq %r13, %rdi
callq 0x59a5e
movq %rbp, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x6570
addq 0x30(%r12), %rbx
movq %rbx, 0x30(%r12)
movl %ebx, 0x14(%r12)
movl %ebx, 0x10(%r12)
movq 0x8(%rsp), %rdi
cmpl $0x300, 0xc(%rdi)       # imm = 0x300
jl 0x52ebd
pushq $-0x1
popq %rcx
movq %r12, %rsi
xorl %edx, %edx
movl %ecx, %r8d
callq 0x4e2b5
pushq $0x5
popq %rbx
cmpl $0x3, 0x1c(%rsp)
jl 0x52eec
movl 0xc(%r12), %r13d
pushq $0x1
popq %rax
movl %eax, %r14d
cmpl $0x80, %r13d
jb 0x52f83
cmpl $0x4000, %r13d          # imm = 0x4000
jae 0x52f51
pushq $0x2
jmp 0x52f5c
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x24(%r15)
pushq $0x4
popq %rdi
callq 0x69d0
movq %rax, 0x30(%r15)
testq %rax, %rax
pushq $-0x1
popq %r14
je 0x532f8
andl $0x0, (%rax)
cvtsi2sdl (%r15), %xmm1
movsd 0x2c8c5(%rip), %xmm0    # 0x7f7e8
mulsd %xmm1, %xmm0
maxsd 0x34cd1(%rip), %xmm0    # 0x87c00
movl 0xc(%r12), %ecx
pushq $0x1
popq %rdi
movl %edi, %eax
cmpl $0x80, %ecx
jb 0x530b3
cmpl $0x4000, %ecx           # imm = 0x4000
jae 0x52f60
pushq $0x2
jmp 0x52f6e
cmpl $0x200000, %r13d        # imm = 0x200000
jae 0x52f74
pushq $0x3
popq %r14
jmp 0x52f83
cmpl $0x200000, %ecx         # imm = 0x200000
jae 0x530a8
pushq $0x3
popq %rax
jmp 0x530b3
cmpl $0x10000000, %r13d      # imm = 0x10000000
pushq $0x5
popq %r14
sbbl $0x0, %r14d
movl 0x10(%r12), %ecx
movl 0x14(%r12), %esi
movl %eax, %edx
cmpl $0x80, %esi
jb 0x52fbc
cmpl $0x4000, %esi           # imm = 0x4000
jae 0x52fa3
pushq $0x2
jmp 0x52fad
cmpl $0x200000, %esi         # imm = 0x200000
jae 0x52fb0
pushq $0x3
popq %rdx
jmp 0x52fbc
cmpl $0x10000000, %esi       # imm = 0x10000000
pushq $0x5
popq %rdx
sbbl $0x0, %edx
cmpl $0x80, %ecx
jb 0x52fe9
cmpl $0x4000, %ecx           # imm = 0x4000
jae 0x52fd0
pushq $0x2
jmp 0x52fda
cmpl $0x200000, %ecx         # imm = 0x200000
jae 0x52fdd
pushq $0x3
popq %rax
jmp 0x52fe9
cmpl $0x10000000, %ecx       # imm = 0x10000000
pushq $0x5
popq %rax
sbbl $0x0, %eax
xorl %ebx, %ebx
cmpl $0x300, 0x10(%rsp)      # imm = 0x300
setge %bl
leal (%rcx,%rbx,4), %ecx
addl $0x2, %ecx
addl %edx, %r14d
addl %eax, %r14d
addl %ecx, %r14d
movl %r14d, (%r15)
movabsq $0x200000002, %rax      # imm = 0x200000002
movq %rax, 0x24(%r15)
pushq $0x8
popq %rdi
callq 0x69d0
movq %rax, 0x30(%r15)
testq %rax, %rax
je 0x53385
andl $0x0, (%rax)
cvtsi2sd %r14d, %xmm0
mulsd 0x2ad5d(%rip), %xmm0    # 0x7dd98
minsd 0x34bbd(%rip), %xmm0    # 0x87c00
movl %r14d, 0x4(%rax)
cvttsd2si %xmm0, %ebp
cmpl $0x80, %r13d
jae 0x53058
pushq $0x1
jmp 0x53070
cmpl $0x4000, %r13d          # imm = 0x4000
jae 0x53065
pushq $0x2
jmp 0x53070
cmpl $0x200000, %r13d        # imm = 0x200000
jae 0x530e4
pushq $0x3
popq %rdx
leal 0x2(,%rbx,4), %eax
cmpl $0x80, %ebp
jae 0x5308a
pushq $0x2
popq %rcx
movq 0x8(%rsp), %rbx
jmp 0x53108
cmpl $0x4000, %ebp           # imm = 0x4000
movq 0x8(%rsp), %rbx
jae 0x5309b
pushq $0x4
jmp 0x530a5
cmpl $0x200000, %ebp         # imm = 0x200000
jae 0x530f6
pushq $0x6
popq %rcx
jmp 0x53108
cmpl $0x10000000, %ecx       # imm = 0x10000000
movl %ebx, %eax
sbbl $0x0, %eax
subsd %xmm1, %xmm0
movl 0x10(%r12), %ecx
movl 0x14(%r12), %esi
movl %edi, %edx
cmpl $0x80, %esi
jb 0x53124
cmpl $0x4000, %esi           # imm = 0x4000
jae 0x530d7
pushq $0x2
jmp 0x530e1
cmpl $0x200000, %esi         # imm = 0x200000
jae 0x53119
pushq $0x3
popq %rdx
jmp 0x53124
cmpl $0x10000000, %r13d      # imm = 0x10000000
pushq $0x5
popq %rdx
sbbl $0x0, %edx
jmp 0x53071
xorl %ecx, %ecx
cmpl $0x10000000, %ebp       # imm = 0x10000000
setae %cl
leal 0x8(,%rcx,2), %ecx
addl %r14d, %eax
addl %edx, %eax
addl %ecx, %eax
addl %ebp, %eax
movl %eax, (%r15)
jmp 0x5323d
cmpl $0x10000000, %esi       # imm = 0x10000000
movl %ebx, %edx
sbbl $0x0, %edx
cvttsd2si %xmm0, %ebp
cmpl $0x80, %ecx
jb 0x53154
cmpl $0x4000, %ecx           # imm = 0x4000
jae 0x5313c
pushq $0x2
jmp 0x53146
cmpl $0x200000, %ecx         # imm = 0x200000
jae 0x53149
pushq $0x3
popq %rdi
jmp 0x53154
cmpl $0x10000000, %ecx       # imm = 0x10000000
sbbl $0x0, %ebx
movl %ebx, %edi
xorl %esi, %esi
cmpl $0x300, 0x10(%rsp)      # imm = 0x300
setge %sil
leal (%rcx,%rsi,4), %ecx
addl %eax, %ecx
addl %edx, %ecx
addl %ebp, %ecx
leal (%rdi,%rcx), %eax
addl $0x2, %eax
movl %eax, (%r15)
movslq %ebp, %rbx
pushq $0x1
popq %rdi
movq %rbx, %rsi
callq 0x6470
testq %rax, %rax
je 0x532e8
movq %rax, %r13
movl $0x400, %r14d           # imm = 0x400
movq 0x28(%r12), %rax
movq 0x30(%r12), %rdi
leaq (%rdi,%rbx), %rcx
cmpq %rcx, %rax
ja 0x5320c
movq %rax, %xmm0
punpckldq 0x27e5c(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x27e64(%rip), %xmm0    # 0x7b020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x2c618(%rip), %xmm1    # 0x7f7e8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x33ef0(%rip), %xmm1    # 0x870d0
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %r14, %rsi
movq %rsi, 0x28(%r12)
movq 0x20(%r12), %rdi
callq 0x6c80
movq %rax, 0x20(%r12)
jmp 0x53194
addq 0x20(%r12), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x6570
addq 0x30(%r12), %rbx
movq %rbx, 0x30(%r12)
movl %ebx, 0x14(%r12)
movl %ebx, 0x10(%r12)
movq %r13, %rdi
callq 0x68a0
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x51839
cmpl $-0x1, %eax
je 0x53385
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4de55
cmpl $-0x1, %eax
je 0x53385
cmpl $0x3, 0x1c(%rsp)
jl 0x53338
movslq %ebp, %rbx
movl $0x400, %r14d           # imm = 0x400
movq 0x28(%r12), %rax
cmpq %rbx, %rax
ja 0x53300
movq %rax, %xmm0
punpckldq 0x27d80(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x27d88(%rip), %xmm0    # 0x7b020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x2c53c(%rip), %xmm1    # 0x7f7e8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x33e14(%rip), %xmm1    # 0x870d0
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %r14, %rsi
movq %rsi, 0x28(%r12)
movq 0x20(%r12), %rdi
callq 0x6c80
movq %rax, 0x20(%r12)
jmp 0x53279
movq %r12, %rdi
callq 0x4e18f
movq %r15, %rdi
callq 0x5093a
movl %r14d, %r15d
jmp 0x53399
movq 0x20(%r12), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x63b0
movq %rbx, 0x30(%r12)
movl %ebx, 0x14(%r12)
movl %ebx, 0x10(%r12)
andl $0x0, (%r12)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4de55
cmpl $-0x1, %eax
je 0x53385
movq %r12, %rdi
callq 0x4e18f
movq %r15, %rdi
callq 0x5093a
movq %rbx, %r14
movq 0x18(%r14), %rsi
movq 0x48(%r14), %rdi
callq 0x4f127
cmpl $-0x1, %eax
pushq $-0x1
popq %r15
je 0x53399
movq 0x18(%r14), %rsi
movq 0x48(%r14), %rdi
callq 0x4ef70
cmpl $-0x1, %eax
je 0x53399
movq (%r14), %rdi
callq 0x5f83e
xorl %r15d, %r15d
negl %eax
sbbl %r15d, %r15d
jmp 0x53399
movq %r12, %rdi
callq 0x4e18f
movq %r15, %rdi
callq 0x5093a
pushq $-0x1
popq %r15
movl %r15d, %eax
addq $0x1048, %rsp           # imm = 0x1048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq