// File: /workspace/github_c_makefile_star2_O0/salextpuru[P]speccy-toochain/src/mhmt/mhmt-lz.c
// Function: get_lz_price_hrum
ULONG get_lz_price_hrum(ULONG position, struct lzcode * lzcode)
{
    ULONG varlen;
    LONG length,disp;
    length = lzcode->length;
    disp   = lzcode->disp;

    if( length==1 ) {
        if( disp==0 )
            return 9;

        else if( (-8)<=disp && disp<=(-1) )
            return 6;

        else
            goto INVALID_CODE_HRUM;

    } else if( length==2 ) {
        if( (-256)<=disp && disp<=(-1) )
            return 11;

        else
            goto INVALID_CODE_HRUM;

    } else if (3<=length && length<=255) {
        varlen = 3;

        if( 4<=length && length<=15 ) {
            varlen = 5;

            if( length>=6 ) varlen += 2;

            if( length>=9 ) varlen += 2;

            if( length>=12) varlen += 2;

        } else if( 15<length && length<=255 ) {
            varlen = 13;
        }

        if( (-256)<=disp && disp<=(-1) )
            varlen += 9;

        else if( (-4096)<=disp && disp<(-256) )
            varlen += 13;

        else
            goto INVALID_CODE_HRUM;

        return varlen;

    } else {
INVALID_CODE_HRUM:
        printf("mhmt-lz.c:get_lz_price_hrum(): Found invalid code length=%d, displacement=%d\n",length, disp);
        return 0;
    }
}

// Assembly:
subq $0x28, %rsp
movl %edi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x10(%rsp)
movq 0x18(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0xc(%rsp)
cmpl $0x1, 0x10(%rsp)
jne 0x4423
cmpl $0x0, 0xc(%rsp)
jne 0x43ff
movl $0x9, 0x24(%rsp)
jmp 0x4553
movl $0xfffffff8, %eax       # imm = 0xFFFFFFF8
cmpl 0xc(%rsp), %eax
jg 0x441e
cmpl $-0x1, 0xc(%rsp)
jg 0x441e
movl $0x6, 0x24(%rsp)
jmp 0x4553
jmp 0x4535
cmpl $0x2, 0x10(%rsp)
jne 0x444e
movl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl 0xc(%rsp), %eax
jg 0x4449
cmpl $-0x1, 0xc(%rsp)
jg 0x4449
movl $0xb, 0x24(%rsp)
jmp 0x4553
jmp 0x4535
movl $0x3, %eax
cmpl 0x10(%rsp), %eax
jg 0x4533
cmpl $0xff, 0x10(%rsp)
jg 0x4533
movl $0x3, 0x14(%rsp)
movl $0x4, %eax
cmpl 0x10(%rsp), %eax
jg 0x44c5
cmpl $0xf, 0x10(%rsp)
jg 0x44c5
movl $0x5, 0x14(%rsp)
cmpl $0x6, 0x10(%rsp)
jl 0x449f
movl 0x14(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x14(%rsp)
cmpl $0x9, 0x10(%rsp)
jl 0x44b1
movl 0x14(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x14(%rsp)
cmpl $0xc, 0x10(%rsp)
jl 0x44c3
movl 0x14(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x14(%rsp)
jmp 0x44e4
movl $0xf, %eax
cmpl 0x10(%rsp), %eax
jge 0x44e2
cmpl $0xff, 0x10(%rsp)
jg 0x44e2
movl $0xd, 0x14(%rsp)
jmp 0x44e4
movl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl 0xc(%rsp), %eax
jg 0x4503
cmpl $-0x1, 0xc(%rsp)
jg 0x4503
movl 0x14(%rsp), %eax
addl $0x9, %eax
movl %eax, 0x14(%rsp)
jmp 0x4529
movl $0xfffff000, %eax       # imm = 0xFFFFF000
cmpl 0xc(%rsp), %eax
jg 0x4525
cmpl $0xffffff00, 0xc(%rsp)  # imm = 0xFFFFFF00
jge 0x4525
movl 0x14(%rsp), %eax
addl $0xd, %eax
movl %eax, 0x14(%rsp)
jmp 0x4527
jmp 0x4535
jmp 0x4529
movl 0x14(%rsp), %eax
movl %eax, 0x24(%rsp)
jmp 0x4553
jmp 0x4535
movl 0x10(%rsp), %esi
movl 0xc(%rsp), %edx
leaq 0x4f2f(%rip), %rdi      # 0x9473
movb $0x0, %al
callq 0x1040
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nopl (%rax)