// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, 0x18(%rsp)
movl %ecx, %r9d
movq %rdi, %r12
pushq $0xc
popq %rdi
cmpl $0x1, %r8d
jg 0x7643
cmpb $0x1, %dl
jne 0x7647
xorl %edi, %edi
cmpl $0x0, 0x104(%rsi)
sete %dil
movl %edi, %ecx
xorl $0x3, %ecx
xorl $0x9, %edi
jmp 0x764a
pushq $0xf
jmp 0x7649
pushq $0x6
popq %rcx
pushq $0x10
popq %r10
subl %ecx, %r10d
xorl %r13d, %r13d
pushq $0x3
popq %r11
movl %r8d, %eax
xorl %edx, %edx
divl %r11d
pushq $-0x1
popq %rax
movl %eax, %r11d
shll %cl, %r11d
xorl %eax, %eax
cmpl $0x2, %edx
sete %al
cmovnel %r13d, %r11d
pushq $0x1
popq %r14
movl %r14d, %edx
movl %edi, %ecx
shll %cl, %edx
shll $0x10, %eax
movl %eax, 0xc(%rsp)
movslq %r9d, %rax
imulq $0x18, %rax, %rax
addq %rax, %rsi
movl %r8d, %eax
movq %rsi, 0x40(%rsp)
movq %rax, 0x28(%rsp)
movl 0x2c8(%rsi,%rax,4), %eax
movl %r10d, 0x10(%rsp)
movl %r10d, %ecx
shrl %cl, %eax
leal 0x1(,%rdx,2), %esi
movq %rdx, 0x38(%rsp)
addl %edx, %r11d
addl %eax, %r11d
movq %r11, 0x30(%rsp)
pushq $0x2
popq %rbx
movl %esi, 0x14(%rsp)
cmpl $0x2, %ebx
movl %ebx, %ebp
pushq $0x3
popq %rax
cmovel %eax, %ebp
movl %r14d, %r15d
movl %ebp, %ecx
shll %cl, %r15d
shll %cl, %eax
addl %r13d, %eax
cmpl %esi, %eax
jge 0x7723
movzbl 0x20(%r12), %eax
pushq $0x8
popq %rcx
subl %eax, %ecx
sarl $0x3, %ecx
movslq %ecx, %rax
movq 0x8(%r12), %rcx
subq 0x10(%r12), %rcx
cmpq %rax, %rcx
jb 0x7771
movq %r12, %rdi
movl %r14d, %esi
callq 0x24ef
testl %eax, %eax
je 0x7743
addl %r15d, %r13d
incl %ebx
movl 0x14(%rsp), %esi
jmp 0x76cd
subl %r13d, %esi
leaq 0x24(%rsp), %rdx
movq %r12, %rdi
movq 0x18(%rsp), %rcx
callq 0x743d
testl %eax, %eax
js 0x778b
movl 0x24(%rsp), %r13d
jmp 0x77a2
cmpl $0x100, %ebp            # imm = 0x100
jae 0x782d
movzbl 0x20(%r12), %eax
movl %ebp, %ecx
subl %eax, %ecx
addl $0x7, %ecx
sarl $0x3, %ecx
movslq %ecx, %rax
movq 0x8(%r12), %rcx
subq 0x10(%r12), %rcx
cmpq %rax, %rcx
jae 0x7793
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rsi
leaq 0x9e9(%rip), %rdx       # 0x816d
xorl %eax, %eax
callq 0x1030
pushq $-0x1
popq %rax
jmp 0x781e
movzbl %bpl, %esi
movq %r12, %rdi
callq 0x24ef
addl %eax, %r13d
movq 0x30(%rsp), %rcx
testl %ecx, %ecx
movq 0x40(%rsp), %rbx
movl 0x14(%rsp), %edx
js 0x77d1
leal (%rcx,%rcx), %eax
cmpl %edx, %eax
jle 0x77d1
decl %edx
movl %edx, %edi
subl %ecx, %edi
movl %edx, %ebp
movl %r13d, %esi
callq 0x784c
movl %ebp, %ecx
subl %eax, %ecx
jmp 0x77dd
movl %ecx, %edi
movl %r13d, %esi
callq 0x784c
movl %eax, %ecx
subw 0x38(%rsp), %cx
js 0x77ff
movzwl %cx, %eax
movl 0x10(%rsp), %ecx
shll %cl, %eax
addl 0xc(%rsp), %eax
movq 0x28(%rsp), %rcx
movl %eax, 0x208(%rbx,%rcx,4)
jmp 0x781c
negl %ecx
movswl %cx, %eax
movl 0x10(%rsp), %ecx
shll %cl, %eax
movl 0xc(%rsp), %ecx
subl %eax, %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x208(%rbx,%rax,4)
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd39(%rip), %rdi       # 0x856d
leaq 0x890(%rip), %rsi       # 0x80cb
leaq 0xd35(%rip), %rcx       # 0x8577
movl $0xf3, %edx
callq 0x1040