// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/utils/quant_levels_dec_utils.c
// Function: InitParams
static int InitParams(uint8_t* const data, int width, int height, int stride,
                      int radius, SmoothParams* const p) {
  const int R = 2 * radius + 1;  // total size of the kernel

  const size_t size_scratch_m = (R + 1) * width * sizeof(*p->start_);
  const size_t size_m =  width * sizeof(*p->average_);
  const size_t size_lut = (1 + 2 * LUT_SIZE) * sizeof(*p->correction_);
  const size_t total_size = size_scratch_m + size_m + size_lut;
  uint8_t* mem = (uint8_t*)WebPSafeMalloc(1U, total_size);

  if (mem == NULL) return 0;
  p->mem_ = (void*)mem;

  p->start_ = (uint16_t*)mem;
  p->cur_ = p->start_;
  p->end_ = p->start_ + R * width;
  p->top_ = p->end_ - width;
  memset(p->top_, 0, width * sizeof(*p->top_));
  mem += size_scratch_m;

  p->average_ = (uint16_t*)mem;
  mem += size_m;

  p->width_ = width;
  p->height_ = height;
  p->stride_ = stride;
  p->src_ = data;
  p->dst_ = data;
  p->radius_ = radius;
  p->scale_ = (1 << (FIX + LFIX)) / (R * R);  // normalization constant
  p->row_ = -radius;

  // analyze the input distribution so we can best-fit the threshold
  CountLevels(p);

  // correction table
  p->correction_ = ((int16_t*)mem) + LUT_SIZE;
  InitCorrectionLUT(p->correction_, p->min_level_dist_);

  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl -0x20(%rbp), %eax
shll %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
imull -0x14(%rbp), %eax
cltq
shlq %rax
movq %rax, -0x38(%rbp)
movslq -0x14(%rbp), %rax
shlq %rax
movq %rax, -0x40(%rbp)
movq $0xffe, -0x48(%rbp)     # imm = 0xFFE
movq -0x38(%rbp), %rax
addq -0x40(%rbp), %rax
addq $0xffe, %rax            # imm = 0xFFE
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rsi
movl $0x1, %edi
callq 0x5b060
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x185e15
movl $0x0, -0x4(%rbp)
jmp 0x185f4f
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rcx
movl -0x2c(%rbp), %eax
imull -0x14(%rbp), %eax
cltq
shlq %rax
addq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rcx
movslq -0x14(%rbp), %rdx
xorl %eax, %eax
subq %rdx, %rax
shlq %rax
addq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rdi
movslq -0x14(%rbp), %rdx
shlq %rdx
xorl %esi, %esi
callq 0x5a200
movq -0x38(%rbp), %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x40(%rbp), %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x18(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x20(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x20(%rax)
movl -0x2c(%rbp), %ecx
imull -0x2c(%rbp), %ecx
movl $0x40000, %eax          # imm = 0x40000
cltd
idivl %ecx
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x24(%rax)
xorl %ecx, %ecx
subl -0x20(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x28(%rbp), %rdi
callq 0x186330
movq -0x58(%rbp), %rcx
addq $0x7fe, %rcx            # imm = 0x7FE
movq -0x28(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x28(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x64(%rax), %esi
callq 0x1864d0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)