// File: /workspace/github_c_makefile_star2_O0/ebiggers[P]xpack/lib/xpack_compress.c
// Function: xpack_alloc_compressor
xpack_compressor *
xpack_alloc_compressor(size_t max_buffer_size, int compression_level)
{
	struct xpack_compressor *c;

	c = malloc(offsetof(struct xpack_compressor, hc_mf) +
		   hc_matchfinder_size(max_buffer_size));
	if (!c)
		goto err0;

#ifdef ENABLE_PREPROCESSING
	c->in_buffer = malloc(max_buffer_size);
	if (!c->in_buffer)
		goto err1;
#endif

	c->max_buffer_size = max_buffer_size;

	switch (compression_level) {
	case 1:
		c->impl = compress_greedy;
		c->max_search_depth = 1;
		c->nice_match_length = MIN_MATCH_LEN;
		break;
	case 2:
		c->impl = compress_greedy;
		c->max_search_depth = 8;
		c->nice_match_length = 8;
		break;
	case 3:
		c->impl = compress_greedy;
		c->max_search_depth = 16;
		c->nice_match_length = 16;
		break;
	case 4:
		c->impl = compress_lazy;
		c->max_search_depth = 8;
		c->nice_match_length = 12;
		break;
	case 5:
		c->impl = compress_lazy;
		c->max_search_depth = 16;
		c->nice_match_length = 24;
		break;
	case 6:
		c->impl = compress_lazy;
		c->max_search_depth = 32;
		c->nice_match_length = 48;
		break;
	case 7:
		c->impl = compress_lazy;
		c->max_search_depth = 64;
		c->nice_match_length = 96;
		break;
	case 8:
		c->impl = compress_lazy;
		c->max_search_depth = 128;
		c->nice_match_length = 192;
		break;
	case 9:
		c->impl = compress_lazy;
		c->max_search_depth = 256;
		c->nice_match_length = 384;
		STATIC_ASSERT(EXTRA_LITERAL_SPACE >= 384 * 4 / 3);
		break;
	default:
		goto err2;
	}

	/* max_search_depth == 0 is invalid */
	if (c->max_search_depth < 1)
		c->max_search_depth = 1;

	return c;

err2:
#ifdef ENABLE_PREPROCESSING
	free(c->in_buffer);
err1:
#endif
	free(c);
err0:
	return NULL;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x20(%rsp)
movl %esi, 0x1c(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
shlq $0x2, %rdi
addq $0x60000, %rdi          # imm = 0x60000
addq $0x1765c0, %rdi         # imm = 0x1765C0
callq 0x1060
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
jne 0x13f5
jmp 0x15dd
movq 0x20(%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x18(%rax)
movl 0x1c(%rsp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
subl $0x8, %eax
ja 0x15ae
movq 0x8(%rsp), %rax
leaq 0xcbdb(%rip), %rcx      # 0xe000
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rsp), %rax
leaq 0x1b6(%rip), %rcx       # 0x15f0
movq %rcx, 0x20(%rax)
movq 0x10(%rsp), %rax
movl $0x1, 0x4(%rax)
movq 0x10(%rsp), %rax
movl $0x2, (%rax)
jmp 0x15b0
movq 0x10(%rsp), %rax
leaq 0x18a(%rip), %rcx       # 0x15f0
movq %rcx, 0x20(%rax)
movq 0x10(%rsp), %rax
movl $0x8, 0x4(%rax)
movq 0x10(%rsp), %rax
movl $0x8, (%rax)
jmp 0x15b0
movq 0x10(%rsp), %rax
leaq 0x15e(%rip), %rcx       # 0x15f0
movq %rcx, 0x20(%rax)
movq 0x10(%rsp), %rax
movl $0x10, 0x4(%rax)
movq 0x10(%rsp), %rax
movl $0x10, (%rax)
jmp 0x15b0
movq 0x10(%rsp), %rax
leaq 0x17a2(%rip), %rcx      # 0x2c60
movq %rcx, 0x20(%rax)
movq 0x10(%rsp), %rax
movl $0x8, 0x4(%rax)
movq 0x10(%rsp), %rax
movl $0xc, (%rax)
jmp 0x15b0
movq 0x10(%rsp), %rax
leaq 0x1776(%rip), %rcx      # 0x2c60
movq %rcx, 0x20(%rax)
movq 0x10(%rsp), %rax
movl $0x10, 0x4(%rax)
movq 0x10(%rsp), %rax
movl $0x18, (%rax)
jmp 0x15b0
movq 0x10(%rsp), %rax
leaq 0x174a(%rip), %rcx      # 0x2c60
movq %rcx, 0x20(%rax)
movq 0x10(%rsp), %rax
movl $0x20, 0x4(%rax)
movq 0x10(%rsp), %rax
movl $0x30, (%rax)
jmp 0x15b0
movq 0x10(%rsp), %rax
leaq 0x1721(%rip), %rcx      # 0x2c60
movq %rcx, 0x20(%rax)
movq 0x10(%rsp), %rax
movl $0x40, 0x4(%rax)
movq 0x10(%rsp), %rax
movl $0x60, (%rax)
jmp 0x15b0
movq 0x10(%rsp), %rax
leaq 0x16f8(%rip), %rcx      # 0x2c60
movq %rcx, 0x20(%rax)
movq 0x10(%rsp), %rax
movl $0x80, 0x4(%rax)
movq 0x10(%rsp), %rax
movl $0xc0, (%rax)
jmp 0x15b0
movq 0x10(%rsp), %rax
leaq 0x16cf(%rip), %rcx      # 0x2c60
movq %rcx, 0x20(%rax)
movq 0x10(%rsp), %rax
movl $0x100, 0x4(%rax)       # imm = 0x100
movq 0x10(%rsp), %rax
movl $0x180, (%rax)          # imm = 0x180
jmp 0x15b0
jmp 0x15d3
movq 0x10(%rsp), %rax
cmpl $0x1, 0x4(%rax)
jae 0x15c7
movq 0x10(%rsp), %rax
movl $0x1, 0x4(%rax)
movq 0x10(%rsp), %rax
movq %rax, 0x28(%rsp)
jmp 0x15e6
movq 0x10(%rsp), %rdi
callq 0x1030
movq $0x0, 0x28(%rsp)
movq 0x28(%rsp), %rax
addq $0x38, %rsp
retq