// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %r9, 0x20(%rsp)
movl %ecx, %eax
movq %rdi, %r15
movl $0xc, %edi
movl $0xf, %ecx
cmpl $0x1, %r8d
jg 0x794c
movl $0x6, %ecx
cmpb $0x1, %dl
jne 0x794c
xorl %edi, %edi
cmpl $0x0, 0x104(%rsi)
sete %dil
movl %edi, %ecx
xorl $0x3, %ecx
xorl $0x9, %edi
movl $0x10, %r9d
subl %ecx, %r9d
imull $0xaaaaaaab, %r8d, %edx # imm = 0xAAAAAAAB
addl $0xaaaaaaaa, %edx       # imm = 0xAAAAAAAA
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
shll %cl, %r11d
xorl %r12d, %r12d
xorl %r10d, %r10d
cmpl $0x55555555, %edx       # imm = 0x55555555
setb %r10b
cmovael %r12d, %r11d
movl $0x1, %edx
movl %edi, %ecx
shll %cl, %edx
cltq
leaq (%rax,%rax,2), %rax
leaq (%rsi,%rax,8), %rax
movl %r8d, %ecx
movq %rax, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movl 0x2c8(%rax,%rcx,4), %eax
movl %r9d, (%rsp)
movl %r9d, %ecx
shrl %cl, %eax
shll $0x10, %r10d
movl %r10d, 0x4(%rsp)
leal 0x1(,%rdx,2), %ebp
movq %rdx, 0x8(%rsp)
addl %edx, %r11d
addl %eax, %r11d
movq %r11, 0x30(%rsp)
movl $0x3, %r13d
movl $0x8, %ebx
xorl %r14d, %r14d
movzbl 0x20(%r15), %eax
movl $0x8, %ecx
subl %eax, %ecx
sarl $0x3, %ecx
movslq %ecx, %rax
movq 0x8(%r15), %rcx
subq 0x10(%r15), %rcx
cmpq %rax, %rcx
jb 0x7a88
movq %r15, %rdi
movl $0x1, %esi
callq 0x244e
testl %eax, %eax
je 0x7a5b
addl %ebx, %r14d
leal 0x3(%r12), %r13d
movl $0x8, %ebx
movl %r12d, %ecx
shll %cl, %ebx
movl $0x18, %eax
shll %cl, %eax
leal 0x1(%r12), %ecx
addl %r14d, %eax
movl %ecx, %r12d
cmpl %ebp, %eax
jl 0x79dd
movl %ebp, %esi
subl %r14d, %esi
leaq 0x2c(%rsp), %rdx
movq %r15, %rdi
movq 0x20(%rsp), %rcx
callq 0x7703
testl %eax, %eax
js 0x7aa2
movl 0x2c(%rsp), %r14d
jmp 0x7abb
cmpl $0x100, %r13d           # imm = 0x100
jae 0x7ba7
movzbl 0x20(%r15), %eax
movl %r13d, %ecx
subl %eax, %ecx
addl $0x7, %ecx
sarl $0x3, %ecx
movslq %ecx, %rax
movq 0x8(%r15), %rcx
subq 0x10(%r15), %rcx
cmpq %rax, %rcx
jae 0x7aac
movq 0x20(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rsi
leaq 0x71e(%rip), %rdx       # 0x81b9
xorl %eax, %eax
callq 0x1030
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x7b98
movzbl %r13b, %esi
movq %r15, %rdi
callq 0x244e
addl %eax, %r14d
movq 0x30(%rsp), %r8
testl %r8d, %r8d
js 0x7ae7
leal (%r8,%r8), %eax
cmpl %ebp, %eax
jle 0x7afb
decl %ebp
movl %ebp, %eax
subl %r8d, %eax
movl %r14d, %ecx
leal (%rax,%rax), %edx
movslq %edx, %rdx
cmpq %rdx, %rcx
jbe 0x7b37
movl (%rsp), %ecx
jmp 0x7b54
movl %r14d, %eax
leal (%r8,%r8), %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jbe 0x7b05
movl (%rsp), %ecx
jmp 0x7b5a
movl %r14d, %ecx
cltq
cmpq %rax, %rcx
ja 0x7af6
testb $0x1, %r14b
movl (%rsp), %ecx
movl 0x4(%rsp), %edx
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rax
jne 0x7b29
shrl %r14d
addl %r8d, %r14d
jmp 0x7b6d
incl %r14d
shrl %r14d
subl %r14d, %r8d
movl %r8d, %r14d
jmp 0x7b6d
testb $0x1, %r14b
movl (%rsp), %ecx
jne 0x7b48
shrl %r14d
addl %eax, %r14d
jmp 0x7b54
incl %r14d
shrl %r14d
subl %r14d, %eax
movl %eax, %r14d
subl %r14d, %ebp
movl %ebp, %r14d
movl 0x4(%rsp), %edx
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rax
subw %ax, %r14w
js 0x7b84
movzwl %r14w, %eax
shll %cl, %eax
addl %edx, %eax
movl %eax, 0x208(%rsi,%rdi,4)
jmp 0x7b96
negl %r14d
movswl %r14w, %eax
shll %cl, %eax
subl %eax, %edx
movl %edx, 0x208(%rsi,%rdi,4)
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa0b(%rip), %rdi       # 0x85b9
leaq 0x562(%rip), %rsi       # 0x8117
leaq 0xa07(%rip), %rcx       # 0x85c3
movl $0xf3, %edx
callq 0x1040