// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/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 0x2cb63
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl $0x100, %eax            # imm = 0x100
jne 0x2cada
leaq 0x180b2(%rip), %rsi     # 0x44b7b
movq %r13, %rdi
callq 0x33d06
testq %rax, %rax
je 0x2cdce
movl %ebp, 0x1c(%rsp)
cmpq $0x0, 0x48(%rbx)
je 0x2caf2
cmpl $0x0, 0x20c(%rbx)
je 0x2cb82
movq %r13, %rdi
callq 0x3354a
testl %eax, %eax
pushq $-0x1
popq %r15
jne 0x2d416
movq %r13, %rdi
callq 0x33cae
movl %eax, %ebp
movl $0xffffff00, %eax       # imm = 0xFFFFFF00
andl 0xc(%rbx), %eax
movq %rbx, %r14
movslq %ebp, %rbx
cmpl $0x100, %eax            # imm = 0x100
jne 0x2ce09
movq %r14, %rdi
movl %ebp, %esi
callq 0x2785f
cmpl $-0x1, %eax
je 0x2d416
movq (%r14), %r15
movq %r13, %rdi
callq 0x33ca9
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x2691f
cmpq %rbx, %rax
je 0x2d3c8
jmp 0x2d412
movb %bpl, 0x4(%rsi)
movb %al, 0x5(%rsi)
movq %rbx, %rdi
callq 0x2c6df
testl %eax, %eax
jne 0x2d416
movl 0xc(%rbx), %eax
jmp 0x2cab6
leaq 0x1913b(%rip), %r14     # 0x45cc4
xorl %r15d, %r15d
xorl %ebp, %ebp
movq %rbx, 0x8(%rsp)
movslq 0x38(%r13), %rax
cmpq %rax, %rbp
jge 0x2caf2
movq 0x40(%r13), %rax
movq (%rax,%r15,4), %rcx
movq %r13, %rdi
movq %r14, %rsi
leaq 0x19112(%rip), %rdx     # 0x45cc7
callq 0x33011
testq %rax, %rax
je 0x2d412
movq %rax, %r12
movq %rbp, 0x10(%rsp)
movq %r13, %rdi
movq %rax, %rsi
leaq 0x190f2(%rip), %rdx     # 0x45cca
xorl %ecx, %ecx
callq 0x33380
testq %rax, %rax
jne 0x2ccc5
movq 0x48(%rbx), %rax
testq %rax, %rax
je 0x2d412
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x2d412
movq (%rax,%r15), %rax
testq %rax, %rax
je 0x2d412
movq %rbx, %r14
movq 0x10(%rax), %rbx
callq 0x3bb7a
testq %rax, %rax
je 0x2d412
movq %rax, %rbp
movq %r14, %rdi
movq 0x10(%rsp), %rsi
pushq $0x1
popq %rdx
movl %ebx, %ecx
callq 0x297f3
testq %rax, %rax
je 0x2d412
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 0x3b15d
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x3ba60
movq %rbp, %rdi
callq 0x3bba4
movq 0x48(%rbx), %rdi
movq 0x10(%rsp), %rsi
callq 0x293cc
movq %r15, %rbp
leaq 0x40(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x3bba9
movq %r13, %rdi
movq %r12, %rsi
leaq 0x19024(%rip), %rdx     # 0x45cca
movq %r15, %rcx
movq %rbp, %r15
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x333b9
testl %eax, %eax
leaq 0x19005(%rip), %r14     # 0x45cc4
jne 0x2d412
movq 0x70(%rbx), %rbp
testq %rbp, %rbp
je 0x2cdbd
movq %r15, 0x28(%rsp)
cmpb $0x2f, (%rbp)
leaq 0x40(%rsp), %rdi
jne 0x2ccff
movl $0x1000, %edx           # imm = 0x1000
movq %rbp, %rsi
movq %rdi, %r15
callq 0x42c0
movb $0x0, 0x103f(%rsp)
jmp 0x2cd96
movl $0x1000, %esi           # imm = 0x1000
movq %rdi, %r15
callq 0x42b0
testq %rax, %rax
je 0x2cd51
movq %r15, %rdi
callq 0x4210
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 0x4210
addq %r14, %rax
leaq 0x18f7b(%rip), %r14     # 0x45cc4
cmpq $0x1000, %rax           # imm = 0x1000
jb 0x2cd6b
movl $0x1000, %edx           # imm = 0x1000
movq %r15, %rdi
movq %rbp, %rsi
callq 0x42c0
movb $0x0, 0x103f(%rsp)
jmp 0x2cd91
sarq $0x20, %rbx
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
movl $0x1000, %edx           # imm = 0x1000
subl 0x20(%rsp), %edx
leaq 0x1935f(%rip), %rsi     # 0x460e6
movq %rbp, %rcx
xorl %eax, %eax
callq 0x4100
movq 0x8(%rsp), %rbx
movq %r13, %rdi
movq %r12, %rsi
leaq 0x18f2a(%rip), %rdx     # 0x45ccd
movq %r15, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x333b9
testl %eax, %eax
movq 0x28(%rsp), %r15
jne 0x2d412
movq 0x10(%rsp), %rbp
incq %rbp
addq $0x8, %r15
jmp 0x2cb93
andq $0x0, (%rsp)
leaq 0x183bc(%rip), %rsi     # 0x45196
leaq 0x18ee0(%rip), %rdx     # 0x45cc1
leaq 0x17d4d(%rip), %r8      # 0x44b35
leaq 0x17d8c(%rip), %rcx     # 0x44b7b
movq %r13, %rdi
movq %rcx, %r9
xorl %eax, %eax
callq 0x32b15
testl %eax, %eax
jne 0x2d416
jmp 0x2cada
movq %r14, 0x8(%rsp)
xorl %edi, %edi
xorl %esi, %esi
callq 0x27b0e
movq %rax, %r12
xorl %edi, %edi
xorl %esi, %esi
callq 0x2a877
movq %rax, %r15
testq %r12, %r12
setne %al
testq %r15, %r15
setne %cl
testb %cl, %al
je 0x2ced2
movq 0x8(%rsp), %rax
movl 0xc(%rax), %eax
movl %eax, 0x10(%rsp)
movq %r12, %rdi
movl %ebp, %esi
callq 0x278af
movl $0x400, %r14d           # imm = 0x400
movq 0x28(%r12), %rax
movq 0x30(%r12), %rbp
leaq (%rbx,%rbp), %rcx
cmpq %rcx, %rax
ja 0x2ceed
movq %rax, %xmm0
punpckldq 0x16b16(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x16b1e(%rip), %xmm0    # 0x439a0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x17b4a(%rip), %xmm1    # 0x449e0
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x16a72(%rip), %xmm1    # 0x43918
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 0x48c0
movq %rax, 0x20(%r12)
jmp 0x2ce56
testq %r12, %r12
je 0x2cedf
movq %r12, %rdi
callq 0x28127
testq %r15, %r15
jne 0x2d40a
jmp 0x2d412
addq 0x20(%r12), %rbp
movq %r13, %rdi
callq 0x33ca9
movq %rbp, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x4420
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 0x2cf3a
pushq $-0x1
popq %rcx
movq %r12, %rsi
xorl %edx, %edx
movl %ecx, %r8d
callq 0x2824d
pushq $0x5
popq %rbx
cmpl $0x3, 0x1c(%rsp)
jl 0x2cf69
movl 0xc(%r12), %r13d
pushq $0x1
popq %rax
movl %eax, %r14d
cmpl $0x80, %r13d
jb 0x2d000
cmpl $0x4000, %r13d          # imm = 0x4000
jae 0x2cfce
pushq $0x2
jmp 0x2cfd9
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x24(%r15)
pushq $0x4
popq %rdi
callq 0x46f0
movq %rax, 0x30(%r15)
testq %rax, %rax
pushq $-0x1
popq %r14
je 0x2d375
andl $0x0, (%rax)
cvtsi2sdl (%r15), %xmm1
movsd 0x17a40(%rip), %xmm0    # 0x449e0
mulsd %xmm1, %xmm0
maxsd 0x1896c(%rip), %xmm0    # 0x45918
movl 0xc(%r12), %ecx
pushq $0x1
popq %rdi
movl %edi, %eax
cmpl $0x80, %ecx
jb 0x2d130
cmpl $0x4000, %ecx           # imm = 0x4000
jae 0x2cfdd
pushq $0x2
jmp 0x2cfeb
cmpl $0x200000, %r13d        # imm = 0x200000
jae 0x2cff1
pushq $0x3
popq %r14
jmp 0x2d000
cmpl $0x200000, %ecx         # imm = 0x200000
jae 0x2d125
pushq $0x3
popq %rax
jmp 0x2d130
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 0x2d039
cmpl $0x4000, %esi           # imm = 0x4000
jae 0x2d020
pushq $0x2
jmp 0x2d02a
cmpl $0x200000, %esi         # imm = 0x200000
jae 0x2d02d
pushq $0x3
popq %rdx
jmp 0x2d039
cmpl $0x10000000, %esi       # imm = 0x10000000
pushq $0x5
popq %rdx
sbbl $0x0, %edx
cmpl $0x80, %ecx
jb 0x2d066
cmpl $0x4000, %ecx           # imm = 0x4000
jae 0x2d04d
pushq $0x2
jmp 0x2d057
cmpl $0x200000, %ecx         # imm = 0x200000
jae 0x2d05a
pushq $0x3
popq %rax
jmp 0x2d066
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 0x46f0
movq %rax, 0x30(%r15)
testq %rax, %rax
je 0x2d402
andl $0x0, (%rax)
cvtsi2sd %r14d, %xmm0
mulsd 0x16850(%rip), %xmm0    # 0x43908
minsd 0x18858(%rip), %xmm0    # 0x45918
movl %r14d, 0x4(%rax)
cvttsd2si %xmm0, %ebp
cmpl $0x80, %r13d
jae 0x2d0d5
pushq $0x1
jmp 0x2d0ed
cmpl $0x4000, %r13d          # imm = 0x4000
jae 0x2d0e2
pushq $0x2
jmp 0x2d0ed
cmpl $0x200000, %r13d        # imm = 0x200000
jae 0x2d161
pushq $0x3
popq %rdx
leal 0x2(,%rbx,4), %eax
cmpl $0x80, %ebp
jae 0x2d107
pushq $0x2
popq %rcx
movq 0x8(%rsp), %rbx
jmp 0x2d185
cmpl $0x4000, %ebp           # imm = 0x4000
movq 0x8(%rsp), %rbx
jae 0x2d118
pushq $0x4
jmp 0x2d122
cmpl $0x200000, %ebp         # imm = 0x200000
jae 0x2d173
pushq $0x6
popq %rcx
jmp 0x2d185
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 0x2d1a1
cmpl $0x4000, %esi           # imm = 0x4000
jae 0x2d154
pushq $0x2
jmp 0x2d15e
cmpl $0x200000, %esi         # imm = 0x200000
jae 0x2d196
pushq $0x3
popq %rdx
jmp 0x2d1a1
cmpl $0x10000000, %r13d      # imm = 0x10000000
pushq $0x5
popq %rdx
sbbl $0x0, %edx
jmp 0x2d0ee
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 0x2d2ba
cmpl $0x10000000, %esi       # imm = 0x10000000
movl %ebx, %edx
sbbl $0x0, %edx
cvttsd2si %xmm0, %ebp
cmpl $0x80, %ecx
jb 0x2d1d1
cmpl $0x4000, %ecx           # imm = 0x4000
jae 0x2d1b9
pushq $0x2
jmp 0x2d1c3
cmpl $0x200000, %ecx         # imm = 0x200000
jae 0x2d1c6
pushq $0x3
popq %rdi
jmp 0x2d1d1
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 0x4370
testq %rax, %rax
je 0x2d365
movq %rax, %r13
movl $0x400, %r14d           # imm = 0x400
movq 0x28(%r12), %rax
movq 0x30(%r12), %rdi
leaq (%rdi,%rbx), %rcx
cmpq %rcx, %rax
ja 0x2d289
movq %rax, %xmm0
punpckldq 0x1675f(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x16767(%rip), %xmm0    # 0x439a0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x17793(%rip), %xmm1    # 0x449e0
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x166bb(%rip), %xmm1    # 0x43918
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 0x48c0
movq %rax, 0x20(%r12)
jmp 0x2d211
addq 0x20(%r12), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4420
addq 0x30(%r12), %rbx
movq %rbx, 0x30(%r12)
movl %ebx, 0x14(%r12)
movl %ebx, 0x10(%r12)
movq %r13, %rdi
callq 0x4600
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2b8b6
cmpl $-0x1, %eax
je 0x2d402
movq %rbx, %rdi
movq %r12, %rsi
callq 0x27ded
cmpl $-0x1, %eax
je 0x2d402
cmpl $0x3, 0x1c(%rsp)
jl 0x2d3b5
movslq %ebp, %rbx
movl $0x400, %r14d           # imm = 0x400
movq 0x28(%r12), %rax
cmpq %rbx, %rax
ja 0x2d37d
movq %rax, %xmm0
punpckldq 0x16683(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1668b(%rip), %xmm0    # 0x439a0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x176b7(%rip), %xmm1    # 0x449e0
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x165df(%rip), %xmm1    # 0x43918
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 0x48c0
movq %rax, 0x20(%r12)
jmp 0x2d2f6
movq %r12, %rdi
callq 0x28127
movq %r15, %rdi
callq 0x2a9b7
movl %r14d, %r15d
jmp 0x2d416
movq 0x20(%r12), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x42e0
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 0x27ded
cmpl $-0x1, %eax
je 0x2d402
movq %r12, %rdi
callq 0x28127
movq %r15, %rdi
callq 0x2a9b7
movq %rbx, %r14
movq 0x18(%r14), %rsi
movq 0x48(%r14), %rdi
callq 0x29064
cmpl $-0x1, %eax
pushq $-0x1
popq %r15
je 0x2d416
movq 0x18(%r14), %rsi
movq 0x48(%r14), %rdi
callq 0x28ead
cmpl $-0x1, %eax
je 0x2d416
movq (%r14), %rdi
callq 0x3a18e
xorl %r15d, %r15d
negl %eax
sbbl %r15d, %r15d
jmp 0x2d416
movq %r12, %rdi
callq 0x28127
movq %r15, %rdi
callq 0x2a9b7
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