// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dec/quant_dec.c
// Function: VP8ParseQuant
void VP8ParseQuant(VP8Decoder* const dec) {
  VP8BitReader* const br = &dec->br_;
  const int base_q0 = VP8GetValue(br, 7, "global-header");
  const int dqy1_dc = VP8Get(br, "global-header") ?
       VP8GetSignedValue(br, 4, "global-header") : 0;
  const int dqy2_dc = VP8Get(br, "global-header") ?
       VP8GetSignedValue(br, 4, "global-header") : 0;
  const int dqy2_ac = VP8Get(br, "global-header") ?
       VP8GetSignedValue(br, 4, "global-header") : 0;
  const int dquv_dc = VP8Get(br, "global-header") ?
       VP8GetSignedValue(br, 4, "global-header") : 0;
  const int dquv_ac = VP8Get(br, "global-header") ?
       VP8GetSignedValue(br, 4, "global-header") : 0;

  const VP8SegmentHeader* const hdr = &dec->segment_hdr_;
  int i;

  for (i = 0; i < NUM_MB_SEGMENTS; ++i) {
    int q;
    if (hdr->use_segment_) {
      q = hdr->quantizer_[i];
      if (!hdr->absolute_delta_) {
        q += base_q0;
      }
    } else {
      if (i > 0) {
        dec->dqm_[i] = dec->dqm_[0];
        continue;
      } else {
        q = base_q0;
      }
    }
    {
      VP8QuantMatrix* const m = &dec->dqm_[i];
      m->y1_mat_[0] = kDcTable[clip(q + dqy1_dc, 127)];
      m->y1_mat_[1] = kAcTable[clip(q + 0,       127)];

      m->y2_mat_[0] = kDcTable[clip(q + dqy2_dc, 127)] * 2;
      // For all x in [0..284], x*155/100 is bitwise equal to (x*101581) >> 16.
      // The smallest precision for that is '(x*6349) >> 12' but 16 is a good
      // word size.
      m->y2_mat_[1] = (kAcTable[clip(q + dqy2_ac, 127)] * 101581) >> 16;
      if (m->y2_mat_[1] < 8) m->y2_mat_[1] = 8;

      m->uv_mat_[0] = kDcTable[clip(q + dquv_dc, 117)];
      m->uv_mat_[1] = kAcTable[clip(q + dquv_ac, 127)];

      m->uv_quant_ = q + dquv_ac;   // for dithering strength evaluation
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x7, %esi
callq 0x181ef0
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x181ef0
cmpl $0x0, %eax
je 0x18512f
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x182020
movl %eax, -0x44(%rbp)
jmp 0x185136
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x185136
movl -0x44(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x181ef0
cmpl $0x0, %eax
je 0x185162
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x182020
movl %eax, -0x48(%rbp)
jmp 0x185169
xorl %eax, %eax
movl %eax, -0x48(%rbp)
jmp 0x185169
movl -0x48(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x181ef0
cmpl $0x0, %eax
je 0x185195
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x182020
movl %eax, -0x4c(%rbp)
jmp 0x18519c
xorl %eax, %eax
movl %eax, -0x4c(%rbp)
jmp 0x18519c
movl -0x4c(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x181ef0
cmpl $0x0, %eax
je 0x1851c8
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x182020
movl %eax, -0x50(%rbp)
jmp 0x1851cf
xorl %eax, %eax
movl %eax, -0x50(%rbp)
jmp 0x1851cf
movl -0x50(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x181ef0
cmpl $0x0, %eax
je 0x1851fb
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x182020
movl %eax, -0x54(%rbp)
jmp 0x185202
xorl %eax, %eax
movl %eax, -0x54(%rbp)
jmp 0x185202
movl -0x54(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
addq $0x84, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
cmpl $0x4, -0x34(%rbp)
jge 0x1853dd
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x185255
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl 0xc(%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x185253
movl -0x14(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x1852ac
cmpl $0x0, -0x34(%rbp)
jle 0x1852a4
movq -0x8(%rbp), %rax
addq $0x424, %rax            # imm = 0x424
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
movq 0x424(%rcx), %rdx
movq %rdx, (%rax)
movq 0x42c(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x434(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x43c(%rcx), %rcx
movq %rcx, 0x18(%rax)
jmp 0x1853cf
movl -0x14(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x1852ac
movq -0x8(%rbp), %rax
addq $0x424, %rax            # imm = 0x424
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl -0x38(%rbp), %edi
addl -0x18(%rbp), %edi
movl $0x7f, %esi
callq 0x1853f0
movslq %eax, %rcx
leaq 0x3cb81(%rip), %rax     # 0x1c1e60
movzbl (%rax,%rcx), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movl -0x38(%rbp), %edi
addl $0x0, %edi
movl $0x7f, %esi
callq 0x1853f0
movslq %eax, %rcx
leaq 0x3cbdd(%rip), %rax     # 0x1c1ee0
movzwl (%rax,%rcx,2), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x38(%rbp), %edi
addl -0x1c(%rbp), %edi
movl $0x7f, %esi
callq 0x1853f0
movslq %eax, %rcx
leaq 0x3cb38(%rip), %rax     # 0x1c1e60
movzbl (%rax,%rcx), %ecx
shll %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x38(%rbp), %edi
addl -0x20(%rbp), %edi
movl $0x7f, %esi
callq 0x1853f0
movslq %eax, %rcx
leaq 0x3cb91(%rip), %rax     # 0x1c1ee0
movzwl (%rax,%rcx,2), %eax
imull $0x18ccd, %eax, %ecx    # imm = 0x18CCD
sarl $0x10, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rax
cmpl $0x8, 0xc(%rax)
jge 0x185378
movq -0x40(%rbp), %rax
movl $0x8, 0xc(%rax)
movl -0x38(%rbp), %edi
addl -0x24(%rbp), %edi
movl $0x75, %esi
callq 0x1853f0
movslq %eax, %rcx
leaq 0x3cace(%rip), %rax     # 0x1c1e60
movzbl (%rax,%rcx), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x38(%rbp), %edi
addl -0x28(%rbp), %edi
movl $0x7f, %esi
callq 0x1853f0
movslq %eax, %rcx
leaq 0x3cb29(%rip), %rax     # 0x1c1ee0
movzwl (%rax,%rcx,2), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x38(%rbp), %ecx
addl -0x28(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x18(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x18521d
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)