// File: /workspace/github_c_makefile_star2_O0/lmcilroy[P]lzm/lzmencode.c
// Function: lzm_encode_init
unsigned int
lzm_encode_init(struct lzm_state ** const state, const unsigned int format,
    const unsigned int level)
{
	struct lzm_state *statep;
	unsigned int ilevel = level;
	int error = 0;

	*state = NULL;

	/* Currently only support the one format */
	if (format != LZM_FORMAT_1)
		return EINVAL;

	if (ilevel == LZM_LEVEL_DEF)
		ilevel = LZM_LEVEL_FAST;

	if (ilevel >= LZM_LEVEL_COUNT)
		return EINVAL;

	error = lzm_malloc((void **)&statep, sizeof(*statep));
	if (error != 0)
		goto out;

	statep->level = ilevel;
	statep->format = format;
	statep->hash_order = lzm_encode_config[statep->level].hash_order;
	statep->hash_buckets = 1 << statep->hash_order;
	statep->chain_order = lzm_encode_config[statep->level].chain_order;
	statep->chain_mask = (1 << statep->chain_order) - 1;
	statep->last_ht = NULL;
	statep->chains = NULL;

	if (statep->hash_order > 0) {
		error = lzm_malloc((void **)&statep->last_ht,
		    sizeof(*statep->last_ht) << statep->hash_order);
		if (error != 0)
			goto out;
	}

	if (statep->chain_order > 0) {
		error = lzm_malloc((void **)&statep->chains,
		    sizeof(*statep->chains) << statep->chain_order);
		if (error != 0)
			goto out;
	}

	*state = statep;

 out:
	if (error != 0)
		lzm_encode_finish(statep);

	return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
cmpl $0x1, -0x14(%rbp)
je 0x4b9c
movl $0x16, -0x4(%rbp)
jmp 0x4cff
cmpl $-0x1, -0x24(%rbp)
jne 0x4ba9
movl $0x1, -0x24(%rbp)
cmpl $0x8, -0x24(%rbp)
jb 0x4bbb
movl $0x16, -0x4(%rbp)
jmp 0x4cff
leaq -0x20(%rbp), %rdi
movl $0x28, %esi
callq 0x4d10
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x4bd7
jmp 0x4cea
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x20(%rax)
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x20(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, %ecx
leaq 0x55c5(%rip), %rax      # 0xa1c0
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x20(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, %ecx
leaq 0x558d(%rip), %rax      # 0xa1c0
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x20(%rbp), %rax
movl 0x18(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
subl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jbe 0x4ca8
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %ecx
movl $0x8, %eax
shlq %cl, %rax
movl %eax, %esi
callq 0x4d10
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x4ca6
jmp 0x4cea
jmp 0x4ca8
movq -0x20(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jbe 0x4cdf
movq -0x20(%rbp), %rdi
addq $0x8, %rdi
movq -0x20(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
movl $0x8, %eax
shlq %cl, %rax
movl %eax, %esi
callq 0x4d10
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x4cdd
jmp 0x4cea
jmp 0x4cdf
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
cmpl $0x0, -0x28(%rbp)
je 0x4cf9
movq -0x20(%rbp), %rdi
callq 0x4d50
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)