// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/cram/cram_io.c
// Function: cram_compress_block
int cram_compress_block(cram_fd *fd, cram_block *b, cram_metrics *metrics,
			int method, int level) {

    char *comp = NULL;
    size_t comp_size = 0;
    int strat;

    if (b->method != RAW) {
        // Maybe already compressed if s->block[0] was compressed and
        // we have e.g. s->block[DS_BA] set to s->block[0] due to only
        // one base type present and hence using E_HUFFMAN on block 0.
        // A second explicit attempt to compress the same block then
        // occurs.
        return 0;
    }

    if (method == -1) {
	method = 1<<GZIP;
	if (fd->use_bz2)
	    method |= 1<<BZIP2;
	if (fd->use_lzma)
	    method |= 1<<LZMA;
    }

    if (level == -1)
	level = fd->level;

    //fprintf(stderr, "IN: block %d, sz %d\n", b->content_id, b->uncomp_size);

    if (method == RAW || level == 0 || b->uncomp_size == 0) {
	b->method = RAW;
	b->comp_size = b->uncomp_size;
	//fprintf(stderr, "Skip block id %d\n", b->content_id);
	return 0;
    }

    if (metrics) {
	pthread_mutex_lock(&fd->metrics_lock);
	if (metrics->trial > 0 || --metrics->next_trial <= 0) {
	    size_t sz_best = INT_MAX;
	    size_t sz_gz_rle = 0;
	    size_t sz_gz_def = 0;
	    size_t sz_rans0 = 0;
	    size_t sz_rans1 = 0;
	    size_t sz_bzip2 = 0;
	    size_t sz_lzma = 0;
	    int method_best = 0;
	    char *c_best = NULL, *c = NULL;

	    if (metrics->revised_method)
		method = metrics->revised_method;
	    else
		metrics->revised_method = method;

	    if (metrics->next_trial == 0) {
		metrics->next_trial = TRIAL_SPAN;
		metrics->trial = NTRIALS;
		metrics->sz_gz_rle /= 2;
		metrics->sz_gz_def /= 2;
		metrics->sz_rans0  /= 2;
		metrics->sz_rans1  /= 2;
		metrics->sz_bzip2  /= 2;
		metrics->sz_lzma   /= 2;
	    }

	    pthread_mutex_unlock(&fd->metrics_lock);
	    
	    if (method & (1<<GZIP_RLE)) {
		c = cram_compress_by_method((char *)b->data, b->uncomp_size,
					    &sz_gz_rle, GZIP, 1, Z_RLE);
		if (c && sz_best > sz_gz_rle) {
		    sz_best = sz_gz_rle;
		    method_best = GZIP_RLE;
		    if (c_best)
			free(c_best);
		    c_best = c;
		} else if (c) {
		    free(c);
		} else {
		    sz_gz_rle = b->uncomp_size*2+1000;
		}

		//fprintf(stderr, "Block %d; %d->%d\n", b->content_id, b->uncomp_size, sz_gz_rle);
	    }

	    if (method & (1<<GZIP)) {
		c = cram_compress_by_method((char *)b->data, b->uncomp_size,
					    &sz_gz_def, GZIP, level,
					    Z_FILTERED);
		if (c && sz_best > sz_gz_def) {
		    sz_best = sz_gz_def;
		    method_best = GZIP;
		    if (c_best)
			free(c_best);
		    c_best = c;
		} else if (c) {
		    free(c);
		} else {
		    sz_gz_def = b->uncomp_size*2+1000;
		}

		//fprintf(stderr, "Block %d; %d->%d\n", b->content_id, b->uncomp_size, sz_gz_def);
	    }

	    if (method & (1<<RANS0)) {
		c = cram_compress_by_method((char *)b->data, b->uncomp_size,
					    &sz_rans0, RANS0, 0, 0);
		if (c && sz_best > sz_rans0) {
		    sz_best = sz_rans0;
		    method_best = RANS0;
		    if (c_best)
			free(c_best);
		    c_best = c;
		} else if (c) {
		    free(c);
		} else {
		    sz_rans0 = b->uncomp_size*2+1000;
		}
	    }

	    if (method & (1<<RANS1)) {
		c = cram_compress_by_method((char *)b->data, b->uncomp_size,
					    &sz_rans1, RANS1, 0, 0);
		if (c && sz_best > sz_rans1) {
		    sz_best = sz_rans1;
		    method_best = RANS1;
		    if (c_best)
			free(c_best);
		    c_best = c;
		} else if (c) {
		    free(c);
		} else {
		    sz_rans1 = b->uncomp_size*2+1000;
		}
	    }

	    if (method & (1<<BZIP2)) {
		c = cram_compress_by_method((char *)b->data, b->uncomp_size,
					    &sz_bzip2, BZIP2, level, 0);
		if (c && sz_best > sz_bzip2) {
		    sz_best = sz_bzip2;
		    method_best = BZIP2;
		    if (c_best)
			free(c_best);
		    c_best = c;
		} else if (c) {
		    free(c);
		} else {
		    sz_bzip2 = b->uncomp_size*2+1000;
		}
	    }

	    if (method & (1<<LZMA)) {
		c = cram_compress_by_method((char *)b->data, b->uncomp_size,
					    &sz_lzma, LZMA, level, 0);
		if (c && sz_best > sz_lzma) {
		    sz_best = sz_lzma;
		    method_best = LZMA;
		    if (c_best)
			free(c_best);
		    c_best = c;
		} else if (c) {
		    free(c);
		} else {
		    sz_lzma = b->uncomp_size*2+1000;
		}
	    }

	    //fprintf(stderr, "sz_best = %d\n", sz_best);

	    free(b->data);
	    b->data = (unsigned char *)c_best;
	    //printf("method_best = %s\n", cram_block_method2str(method_best));
	    b->method = method_best == GZIP_RLE ? GZIP : method_best;
	    b->comp_size = sz_best;

	    pthread_mutex_lock(&fd->metrics_lock);
	    metrics->sz_gz_rle += sz_gz_rle;
	    metrics->sz_gz_def += sz_gz_def;
	    metrics->sz_rans0  += sz_rans0;
	    metrics->sz_rans1  += sz_rans1;
	    metrics->sz_bzip2  += sz_bzip2;
	    metrics->sz_lzma   += sz_lzma;
	    if (--metrics->trial == 0) {
		int best_method = RAW;
		int best_sz = INT_MAX;

		// Scale methods by cost
		if (fd->level <= 3) {
		    metrics->sz_rans1  *= 1.02;
		    metrics->sz_gz_def *= 1.04;
		    metrics->sz_bzip2  *= 1.08;
		    metrics->sz_lzma   *= 1.10;
		} else if (fd->level <= 6) {
		    metrics->sz_rans1  *= 1.01;
		    metrics->sz_gz_def *= 1.02;
		    metrics->sz_bzip2  *= 1.03;
		    metrics->sz_lzma   *= 1.05;
		}

		if (method & (1<<GZIP_RLE) && best_sz > metrics->sz_gz_rle)
		    best_sz = metrics->sz_gz_rle, best_method = GZIP_RLE;

		if (method & (1<<GZIP) && best_sz > metrics->sz_gz_def)
		    best_sz = metrics->sz_gz_def, best_method = GZIP;

		if (method & (1<<RANS0) && best_sz > metrics->sz_rans0)
		    best_sz = metrics->sz_rans0, best_method = RANS0;

		if (method & (1<<RANS1) && best_sz > metrics->sz_rans1)
		    best_sz = metrics->sz_rans1, best_method = RANS1;

		if (method & (1<<BZIP2) && best_sz > metrics->sz_bzip2)
		    best_sz = metrics->sz_bzip2, best_method = BZIP2;

		if (method & (1<<LZMA) && best_sz > metrics->sz_lzma)
		    best_sz = metrics->sz_lzma, best_method = LZMA;

		if (best_method == GZIP_RLE) {
		    metrics->method = GZIP;
		    metrics->strat  = Z_RLE;
		} else {
		    metrics->method = best_method;
		    metrics->strat  = Z_FILTERED;
		}

		// If we see at least MAXFAIL trials in a row for a specific
		// compression method with more than MAXDELTA aggregate
		// size then we drop this from the list of methods used
		// for this block type.
#define MAXDELTA 0.20
#define MAXFAILS 4
		if (best_method == GZIP_RLE) {
		    metrics->gz_rle_cnt = 0;
		    metrics->gz_rle_extra = 0;
		} else if (best_sz < metrics->sz_gz_rle) {
		    double r = (double)metrics->sz_gz_rle / best_sz - 1;
		    if (++metrics->gz_rle_cnt >= MAXFAILS && 
			(metrics->gz_rle_extra += r) >= MAXDELTA)
			method &= ~(1<<GZIP_RLE);
		}

		if (best_method == GZIP) {
		    metrics->gz_def_cnt = 0;
		    metrics->gz_def_extra = 0;
		} else if (best_sz < metrics->sz_gz_def) {
		    double r = (double)metrics->sz_gz_def / best_sz - 1;
		    if (++metrics->gz_def_cnt >= MAXFAILS &&
			(metrics->gz_def_extra += r) >= MAXDELTA)
			method &= ~(1<<GZIP);
		}

		if (best_method == RANS0) {
		    metrics->rans0_cnt = 0;
		    metrics->rans0_extra = 0;
		} else if (best_sz < metrics->sz_rans0) {
		    double r = (double)metrics->sz_rans0 / best_sz - 1;
		    if (++metrics->rans0_cnt >= MAXFAILS &&
			(metrics->rans0_extra += r) >= MAXDELTA)
			method &= ~(1<<RANS0);
		}

		if (best_method == RANS1) {
		    metrics->rans1_cnt = 0;
		    metrics->rans1_extra = 0;
		} else if (best_sz < metrics->sz_rans1) {
		    double r = (double)metrics->sz_rans1 / best_sz - 1;
		    if (++metrics->rans1_cnt >= MAXFAILS &&
			(metrics->rans1_extra += r) >= MAXDELTA)
			method &= ~(1<<RANS1);
		}

		if (best_method == BZIP2) {
		    metrics->bzip2_cnt = 0;
		    metrics->bzip2_extra = 0;
		} else if (best_sz < metrics->sz_bzip2) {
		    double r = (double)metrics->sz_bzip2 / best_sz - 1;
		    if (++metrics->bzip2_cnt >= MAXFAILS &&
			(metrics->bzip2_extra += r) >= MAXDELTA)
			method &= ~(1<<BZIP2);
		}

		if (best_method == LZMA) {
		    metrics->lzma_cnt = 0;
		    metrics->lzma_extra = 0;
		} else if (best_sz < metrics->sz_lzma) {
		    double r = (double)metrics->sz_lzma / best_sz - 1;
		    if (++metrics->lzma_cnt >= MAXFAILS &&
			(metrics->lzma_extra += r) >= MAXDELTA)
			method &= ~(1<<LZMA);
		}

		//if (method != metrics->revised_method)
		//    fprintf(stderr, "%d: method from %x to %x\n",
		//	    b->content_id, metrics->revised_method, method);
		metrics->revised_method = method;
	    }
	    pthread_mutex_unlock(&fd->metrics_lock);
	} else {
	    strat = metrics->strat;
	    method = metrics->method;

	    pthread_mutex_unlock(&fd->metrics_lock);
	    comp = cram_compress_by_method((char *)b->data, b->uncomp_size,
					   &comp_size, method,
					   level, strat);
	    if (!comp)
		return -1;
	    free(b->data);
	    b->data = (unsigned char *)comp;
	    b->comp_size = comp_size;
	    b->method = method;
	}

    } else {
	// no cached metrics, so just do zlib?
	comp = cram_compress_by_method((char *)b->data, b->uncomp_size,
				       &comp_size, GZIP, level, Z_FILTERED);
	if (!comp) {
	    fprintf(stderr, "Compression failed!\n");
	    return -1;
	}
	free(b->data);
	b->data = (unsigned char *)comp;
	b->comp_size = comp_size;
	b->method = GZIP;
    }

    if (fd->verbose)
	fprintf(stderr, "Compressed block ID %d from %d to %d by method %s\n",
		b->content_id, b->uncomp_size, b->comp_size,
		cram_block_method2str(b->method));

    if (b->method == RANS1)
	b->method = RANS0; // Spec just has RANS (not 0/1) with auto-sensing

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x7f9a3
movl $0x0, -0x4(%rbp)
jmp 0x808e2
cmpl $-0x1, -0x24(%rbp)
jne 0x7f9de
movl $0x2, -0x24(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x214(%rax)
je 0x7f9c6
movl -0x24(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x21c(%rax)
je 0x7f9dc
movl -0x24(%rbp), %eax
orl $0x8, %eax
movl %eax, -0x24(%rbp)
jmp 0x7f9de
cmpl $-0x1, -0x28(%rbp)
jne 0x7f9ee
movq -0x10(%rbp), %rax
movl 0x78(%rax), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x7fa04
cmpl $0x0, -0x28(%rbp)
je 0x7fa04
movq -0x18(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jne 0x7fa28
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x808e2
cmpq $0x0, -0x20(%rbp)
je 0x807c8
movq -0x10(%rbp), %rdi
addq $0x8870, %rdi           # imm = 0x8870
callq 0x6ae0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jg 0x7fa62
movq -0x20(%rbp), %rcx
movl 0x4(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x4(%rcx)
cmpl $0x0, %eax
jg 0x80735
movq $0x7fffffff, -0x48(%rbp) # imm = 0x7FFFFFFF
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movq $0x0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x40(%rax)
je 0x7facd
movq -0x20(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x24(%rbp)
jmp 0x7fad7
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x7fbc6
movq -0x20(%rbp), %rax
movl $0x32, 0x4(%rax)
movq -0x20(%rbp), %rax
movl $0x3, (%rax)
movq -0x20(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl 0x8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xf8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl 0xc(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xf0(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0xe8(%rbp)
movl 0x10(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0xe0(%rbp)
movl 0x14(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xe0(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl 0x18(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xd8(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl 0x1c(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xd0(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rdi
addq $0x8870, %rdi           # imm = 0x8870
callq 0x64e0
movl -0x24(%rbp), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x7fc8f
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rsi
leaq -0x50(%rbp), %rdx
movl $0x1, %r8d
movl $0x3, %r9d
movl %r8d, %ecx
callq 0x808f0
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x7fc5f
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jbe 0x7fc5f
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0xb, -0x7c(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x7fc4f
movq -0x88(%rbp), %rdi
callq 0x6880
movq -0x90(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x7fc8d
cmpq $0x0, -0x90(%rbp)
je 0x7fc77
movq -0x90(%rbp), %rdi
callq 0x6880
jmp 0x7fc8b
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
shll %eax
addl $0x3e8, %eax            # imm = 0x3E8
cltq
movq %rax, -0x50(%rbp)
jmp 0x7fc8d
jmp 0x7fc8f
movl -0x24(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x7fd44
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rsi
movl -0x28(%rbp), %r8d
leaq -0x58(%rbp), %rdx
movl $0x1, %r9d
movl %r9d, %ecx
callq 0x808f0
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x7fd14
movq -0x48(%rbp), %rax
cmpq -0x58(%rbp), %rax
jbe 0x7fd14
movq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x1, -0x7c(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x7fd04
movq -0x88(%rbp), %rdi
callq 0x6880
movq -0x90(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x7fd42
cmpq $0x0, -0x90(%rbp)
je 0x7fd2c
movq -0x90(%rbp), %rdi
callq 0x6880
jmp 0x7fd40
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
shll %eax
addl $0x3e8, %eax            # imm = 0x3E8
cltq
movq %rax, -0x58(%rbp)
jmp 0x7fd42
jmp 0x7fd44
movl -0x24(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x7fdf7
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rsi
leaq -0x60(%rbp), %rdx
movl $0x4, %ecx
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0x808f0
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x7fdc7
movq -0x48(%rbp), %rax
cmpq -0x60(%rbp), %rax
jbe 0x7fdc7
movq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x4, -0x7c(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x7fdb7
movq -0x88(%rbp), %rdi
callq 0x6880
movq -0x90(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x7fdf5
cmpq $0x0, -0x90(%rbp)
je 0x7fddf
movq -0x90(%rbp), %rdi
callq 0x6880
jmp 0x7fdf3
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
shll %eax
addl $0x3e8, %eax            # imm = 0x3E8
cltq
movq %rax, -0x60(%rbp)
jmp 0x7fdf5
jmp 0x7fdf7
movl -0x24(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x7feac
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rsi
leaq -0x68(%rbp), %rdx
movl $0xa, %ecx
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0x808f0
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x7fe7c
movq -0x48(%rbp), %rax
cmpq -0x68(%rbp), %rax
jbe 0x7fe7c
movq -0x68(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0xa, -0x7c(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x7fe6c
movq -0x88(%rbp), %rdi
callq 0x6880
movq -0x90(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x7feaa
cmpq $0x0, -0x90(%rbp)
je 0x7fe94
movq -0x90(%rbp), %rdi
callq 0x6880
jmp 0x7fea8
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
shll %eax
addl $0x3e8, %eax            # imm = 0x3E8
cltq
movq %rax, -0x68(%rbp)
jmp 0x7feaa
jmp 0x7feac
movl -0x24(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x7ff60
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rsi
movl -0x28(%rbp), %r8d
leaq -0x70(%rbp), %rdx
movl $0x2, %ecx
xorl %r9d, %r9d
callq 0x808f0
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x7ff30
movq -0x48(%rbp), %rax
cmpq -0x70(%rbp), %rax
jbe 0x7ff30
movq -0x70(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x2, -0x7c(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x7ff20
movq -0x88(%rbp), %rdi
callq 0x6880
movq -0x90(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x7ff5e
cmpq $0x0, -0x90(%rbp)
je 0x7ff48
movq -0x90(%rbp), %rdi
callq 0x6880
jmp 0x7ff5c
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
shll %eax
addl $0x3e8, %eax            # imm = 0x3E8
cltq
movq %rax, -0x70(%rbp)
jmp 0x7ff5e
jmp 0x7ff60
movl -0x24(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x80014
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rsi
movl -0x28(%rbp), %r8d
leaq -0x78(%rbp), %rdx
movl $0x3, %ecx
xorl %r9d, %r9d
callq 0x808f0
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x7ffe4
movq -0x48(%rbp), %rax
cmpq -0x78(%rbp), %rax
jbe 0x7ffe4
movq -0x78(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x3, -0x7c(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x7ffd4
movq -0x88(%rbp), %rdi
callq 0x6880
movq -0x90(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x80012
cmpq $0x0, -0x90(%rbp)
je 0x7fffc
movq -0x90(%rbp), %rdi
callq 0x6880
jmp 0x80010
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
shll %eax
addl $0x3e8, %eax            # imm = 0x3E8
cltq
movq %rax, -0x78(%rbp)
jmp 0x80012
jmp 0x80014
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x6880
movq -0x88(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
cmpl $0xb, -0x7c(%rbp)
jne 0x80043
movl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x8004c
movl -0x7c(%rbp), %eax
movl %eax, -0xfc(%rbp)
movl -0xfc(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rdi
addq $0x8870, %rdi           # imm = 0x8870
callq 0x6ae0
movq -0x50(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq 0x8(%rax), %rcx
addq %rdx, %rcx
movl %ecx, 0x8(%rax)
movq -0x58(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq 0xc(%rax), %rcx
addq %rdx, %rcx
movl %ecx, 0xc(%rax)
movq -0x60(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq 0x10(%rax), %rcx
addq %rdx, %rcx
movl %ecx, 0x10(%rax)
movq -0x68(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq 0x14(%rax), %rcx
addq %rdx, %rcx
movl %ecx, 0x14(%rax)
movq -0x70(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq 0x18(%rax), %rcx
addq %rdx, %rcx
movl %ecx, 0x18(%rax)
movq -0x78(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq 0x1c(%rax), %rcx
addq %rdx, %rcx
movl %ecx, 0x1c(%rax)
movq -0x20(%rbp), %rcx
movl (%rcx), %eax
addl $-0x1, %eax
movl %eax, (%rcx)
cmpl $0x0, %eax
jne 0x80720
movl $0x0, -0x94(%rbp)
movl $0x7fffffff, -0x98(%rbp) # imm = 0x7FFFFFFF
movq -0x10(%rbp), %rax
cmpl $0x3, 0x78(%rax)
jg 0x80185
movq -0x20(%rbp), %rax
cvtsi2sdl 0x14(%rax), %xmm0
movsd 0x62aac(%rip), %xmm1    # 0xe2bd0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x14(%rax)
movq -0x20(%rbp), %rax
cvtsi2sdl 0xc(%rax), %xmm0
movsd 0x62ab0(%rip), %xmm1    # 0xe2bf0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rax
cvtsi2sdl 0x18(%rax), %xmm0
movsd 0x62a8c(%rip), %xmm1    # 0xe2be8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x18(%rax)
movq -0x20(%rbp), %rax
cvtsi2sdl 0x1c(%rax), %xmm0
movsd 0x62a68(%rip), %xmm1    # 0xe2be0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x1c(%rax)
jmp 0x80201
movq -0x10(%rbp), %rax
cmpl $0x6, 0x78(%rax)
jg 0x801ff
movq -0x20(%rbp), %rax
cvtsi2sdl 0x14(%rax), %xmm0
movsd 0x62a38(%rip), %xmm1    # 0xe2bd8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x14(%rax)
movq -0x20(%rbp), %rax
cvtsi2sdl 0xc(%rax), %xmm0
movsd 0x62a14(%rip), %xmm1    # 0xe2bd0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rax
cvtsi2sdl 0x18(%rax), %xmm0
movsd 0x629f0(%rip), %xmm1    # 0xe2bc8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x18(%rax)
movq -0x20(%rbp), %rax
cvtsi2sdl 0x1c(%rax), %xmm0
movsd 0x5c97c(%rip), %xmm1    # 0xdcb70
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x1c(%rax)
jmp 0x80201
movl -0x24(%rbp), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x80234
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jle 0x80234
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x98(%rbp)
movl $0xb, -0x94(%rbp)
movl -0x24(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x80265
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jle 0x80265
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x98(%rbp)
movl $0x1, -0x94(%rbp)
movl -0x24(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x80296
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jle 0x80296
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x98(%rbp)
movl $0x4, -0x94(%rbp)
movl -0x24(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x802c9
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jle 0x802c9
movq -0x20(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x98(%rbp)
movl $0xa, -0x94(%rbp)
movl -0x24(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x802fa
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jle 0x802fa
movq -0x20(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x98(%rbp)
movl $0x2, -0x94(%rbp)
movl -0x24(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x8032b
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jle 0x8032b
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x98(%rbp)
movl $0x3, -0x94(%rbp)
cmpl $0xb, -0x94(%rbp)
jne 0x8034c
movq -0x20(%rbp), %rax
movl $0x1, 0x20(%rax)
movq -0x20(%rbp), %rax
movl $0x3, 0x24(%rax)
jmp 0x80364
movl -0x94(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x20(%rbp), %rax
movl $0x1, 0x24(%rax)
cmpl $0xb, -0x94(%rbp)
jne 0x80386
movq -0x20(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x48(%rax)
jmp 0x80403
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x80401
movq -0x20(%rbp), %rax
cvtsi2sdl 0x8(%rax), %xmm0
cvtsi2sdl -0x98(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x574d6(%rip), %xmm1    # 0xd7888
subsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movq -0x20(%rbp), %rcx
movl 0x28(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x28(%rcx)
cmpl $0x4, %eax
jl 0x803ff
movsd -0xa0(%rbp), %xmm0
movq -0x20(%rbp), %rax
addsd 0x48(%rax), %xmm0
movsd %xmm0, 0x48(%rax)
movsd 0x6280a(%rip), %xmm1    # 0xe2bf8
ucomisd %xmm1, %xmm0
jb 0x803ff
movl -0x24(%rbp), %eax
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
movl %eax, -0x24(%rbp)
jmp 0x80401
jmp 0x80403
cmpl $0x1, -0x94(%rbp)
jne 0x80425
movq -0x20(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x50(%rax)
jmp 0x804a0
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x8049e
movq -0x20(%rbp), %rax
cvtsi2sdl 0xc(%rax), %xmm0
cvtsi2sdl -0x98(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x57437(%rip), %xmm1    # 0xd7888
subsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
movq -0x20(%rbp), %rcx
movl 0x2c(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rcx)
cmpl $0x4, %eax
jl 0x8049c
movsd -0xa8(%rbp), %xmm0
movq -0x20(%rbp), %rax
addsd 0x50(%rax), %xmm0
movsd %xmm0, 0x50(%rax)
movsd 0x6276b(%rip), %xmm1    # 0xe2bf8
ucomisd %xmm1, %xmm0
jb 0x8049c
movl -0x24(%rbp), %eax
andl $-0x3, %eax
movl %eax, -0x24(%rbp)
jmp 0x8049e
jmp 0x804a0
cmpl $0x4, -0x94(%rbp)
jne 0x804c2
movq -0x20(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x58(%rax)
jmp 0x8053d
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x8053b
movq -0x20(%rbp), %rax
cvtsi2sdl 0x10(%rax), %xmm0
cvtsi2sdl -0x98(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x5739a(%rip), %xmm1    # 0xd7888
subsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x20(%rbp), %rcx
movl 0x30(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x30(%rcx)
cmpl $0x4, %eax
jl 0x80539
movsd -0xb0(%rbp), %xmm0
movq -0x20(%rbp), %rax
addsd 0x58(%rax), %xmm0
movsd %xmm0, 0x58(%rax)
movsd 0x626ce(%rip), %xmm1    # 0xe2bf8
ucomisd %xmm1, %xmm0
jb 0x80539
movl -0x24(%rbp), %eax
andl $-0x11, %eax
movl %eax, -0x24(%rbp)
jmp 0x8053b
jmp 0x8053d
cmpl $0xa, -0x94(%rbp)
jne 0x8055f
movq -0x20(%rbp), %rax
movl $0x0, 0x34(%rax)
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x60(%rax)
jmp 0x805dc
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x805da
movq -0x20(%rbp), %rax
cvtsi2sdl 0x14(%rax), %xmm0
cvtsi2sdl -0x98(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x572fd(%rip), %xmm1    # 0xd7888
subsd %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0x20(%rbp), %rcx
movl 0x34(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x34(%rcx)
cmpl $0x4, %eax
jl 0x805d8
movsd -0xb8(%rbp), %xmm0
movq -0x20(%rbp), %rax
addsd 0x60(%rax), %xmm0
movsd %xmm0, 0x60(%rax)
movsd 0x62631(%rip), %xmm1    # 0xe2bf8
ucomisd %xmm1, %xmm0
jb 0x805d8
movl -0x24(%rbp), %eax
andl $0xfffffbff, %eax       # imm = 0xFFFFFBFF
movl %eax, -0x24(%rbp)
jmp 0x805da
jmp 0x805dc
cmpl $0x2, -0x94(%rbp)
jne 0x805fe
movq -0x20(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x68(%rax)
jmp 0x80679
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x80677
movq -0x20(%rbp), %rax
cvtsi2sdl 0x18(%rax), %xmm0
cvtsi2sdl -0x98(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x5725e(%rip), %xmm1    # 0xd7888
subsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0x20(%rbp), %rcx
movl 0x38(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x38(%rcx)
cmpl $0x4, %eax
jl 0x80675
movsd -0xc0(%rbp), %xmm0
movq -0x20(%rbp), %rax
addsd 0x68(%rax), %xmm0
movsd %xmm0, 0x68(%rax)
movsd 0x62592(%rip), %xmm1    # 0xe2bf8
ucomisd %xmm1, %xmm0
jb 0x80675
movl -0x24(%rbp), %eax
andl $-0x5, %eax
movl %eax, -0x24(%rbp)
jmp 0x80677
jmp 0x80679
cmpl $0x3, -0x94(%rbp)
jne 0x8069b
movq -0x20(%rbp), %rax
movl $0x0, 0x3c(%rax)
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x70(%rax)
jmp 0x80716
movl -0x98(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jge 0x80714
movq -0x20(%rbp), %rax
cvtsi2sdl 0x1c(%rax), %xmm0
cvtsi2sdl -0x98(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x571c1(%rip), %xmm1    # 0xd7888
subsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
movq -0x20(%rbp), %rcx
movl 0x3c(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rcx)
cmpl $0x4, %eax
jl 0x80712
movsd -0xc8(%rbp), %xmm0
movq -0x20(%rbp), %rax
addsd 0x70(%rax), %xmm0
movsd %xmm0, 0x70(%rax)
movsd 0x624f5(%rip), %xmm1    # 0xe2bf8
ucomisd %xmm1, %xmm0
jb 0x80712
movl -0x24(%rbp), %eax
andl $-0x9, %eax
movl %eax, -0x24(%rbp)
jmp 0x80714
jmp 0x80716
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x10(%rbp), %rdi
addq $0x8870, %rdi           # imm = 0x8870
callq 0x64e0
jmp 0x807c3
movq -0x20(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8870, %rdi           # imm = 0x8870
callq 0x64e0
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rsi
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x3c(%rbp), %r9d
leaq -0x38(%rbp), %rdx
callq 0x808f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x80794
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x808e2
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x6880
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x24(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x8084d
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rsi
movl -0x28(%rbp), %r8d
leaq -0x38(%rbp), %rdx
movl $0x1, %r9d
movl %r9d, %ecx
callq 0x808f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x8081d
movq 0x847d0(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
leaq 0x62560(%rip), %rsi     # 0xe2d6a
movb $0x0, %al
callq 0x6a80
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x808e2
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x6880
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1fc(%rax)
je 0x808c8
movq 0x8476f(%rip), %rax     # 0x104fd0
movq (%rax), %rax
movq %rax, -0x110(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x108(%rbp)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x104(%rbp)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x100(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %edi
callq 0x809f0
movq -0x110(%rbp), %rdi
movl -0x108(%rbp), %edx
movl -0x104(%rbp), %ecx
movl -0x100(%rbp), %r8d
movq %rax, %r9
leaq 0x624be(%rip), %rsi     # 0xe2d7f
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rax
cmpl $0xa, (%rax)
jne 0x808db
movq -0x18(%rbp), %rax
movl $0x4, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nop