// File: /workspace/github_c_makefile_star2_O0/dwbuiten[P]obuparse/obuparse.c
// Function: obp_read_global_param
static inline int _obp_read_global_param(_OBPBitReader *br, OBPFrameHeader *fh, uint8_t type, int ref, int idx, OBPError *err)
{
    uint8_t absBits  = 12;
    uint8_t precBits = 15;
    if (idx < 2) {
        if (type == 1) {
            absBits  = 9 - !fh->allow_high_precision_mv;
            precBits = 3 - !fh->allow_high_precision_mv;
        } else {
            absBits  = 12;
            precBits = 6;
        }
    }
    int32_t precDiff = 16 - precBits;
    int32_t round    = ((idx % 3) == 2) ? (1 << 16) : 0;
    int32_t sub      = ((idx % 3) == 2) ? (1 << precBits) : 0;
    int32_t mx       = (1 << absBits);
    int32_t r        = (fh->global_motion_params.prev_gm_params[ref][idx] >> precDiff) - sub;
    int16_t val;
    int ret = _obp_decode_signed_subexp_with_ref(br, -mx, mx + 1, r, &val, err);
    if (ret < 0) {
        return -1;
    }
    if (val < 0) { /* signed shifts are bad. */
        val                                          = -val;
        fh->global_motion_params.gm_params[ref][idx] = (-(val << precDiff) + round);
    } else {
        fh->global_motion_params.gm_params[ref][idx] = (val << precDiff) + round;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb %al, -0x19(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movb $0xc, -0x31(%rbp)
movb $0xf, -0x32(%rbp)
cmpl $0x2, -0x24(%rbp)
jge 0xea81
movzbl -0x19(%rbp), %eax
cmpl $0x1, %eax
jne 0xea77
movq -0x18(%rbp), %rax
cmpl $0x0, 0x104(%rax)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %ecx
movl $0x9, %eax
subl %ecx, %eax
movb %al, -0x31(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x104(%rax)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %ecx
movl $0x3, %eax
subl %ecx, %eax
movb %al, -0x32(%rbp)
jmp 0xea7f
movb $0xc, -0x31(%rbp)
movb $0x6, -0x32(%rbp)
jmp 0xea81
movzbl -0x32(%rbp), %ecx
movl $0x10, %eax
subl %ecx, %eax
movl %eax, -0x38(%rbp)
movl -0x24(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
xorl %eax, %eax
movl $0x10000, %ecx          # imm = 0x10000
cmpl $0x2, %edx
cmovel %ecx, %eax
movl %eax, -0x3c(%rbp)
movl -0x24(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
cmpl $0x2, %edx
jne 0xeaca
movzbl -0x32(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x54(%rbp)
jmp 0xead1
xorl %eax, %eax
movl %eax, -0x54(%rbp)
jmp 0xead1
movl -0x54(%rbp), %eax
movl %eax, -0x40(%rbp)
movzbl -0x31(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
addq $0x200, %rax            # imm = 0x200
addq $0xc8, %rax
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl -0x38(%rbp), %ecx
shrl %cl, %eax
subl -0x40(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
subl -0x44(%rbp), %esi
movl -0x44(%rbp), %edx
addl $0x1, %edx
movl -0x48(%rbp), %ecx
movq -0x30(%rbp), %r9
leaq -0x4a(%rbp), %r8
callq 0xec10
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
jge 0xeb43
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xebbd
movswl -0x4a(%rbp), %eax
cmpl $0x0, %eax
jge 0xeb8a
movswl -0x4a(%rbp), %ecx
xorl %eax, %eax
subl %ecx, %eax
movw %ax, -0x4a(%rbp)
movswl -0x4a(%rbp), %eax
movl -0x38(%rbp), %ecx
shll %cl, %eax
xorl %edx, %edx
subl %eax, %edx
addl -0x3c(%rbp), %edx
movq -0x18(%rbp), %rax
addq $0x200, %rax            # imm = 0x200
addq $0x8, %rax
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0xebb6
movswl -0x4a(%rbp), %edx
movl -0x38(%rbp), %ecx
shll %cl, %edx
addl -0x3c(%rbp), %edx
movq -0x18(%rbp), %rax
addq $0x200, %rax            # imm = 0x200
addq $0x8, %rax
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)