// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/libraries/libwebp/src/dec/io_dec.c
// Function: CustomSetup
static int CustomSetup(VP8Io* io) {
  WebPDecParams* const p = (WebPDecParams*)io->opaque;
  const WEBP_CSP_MODE colorspace = p->output->colorspace;
  const int is_rgb = WebPIsRGBMode(colorspace);
  const int is_alpha = WebPIsAlphaMode(colorspace);

  p->memory = NULL;
  p->emit = NULL;
  p->emit_alpha = NULL;
  p->emit_alpha_row = NULL;
  if (!WebPIoInitFromOptions(p->options, io, is_alpha ? MODE_YUV : MODE_YUVA)) {
    return 0;
  }
  if (is_alpha && WebPIsPremultipliedMode(colorspace)) {
    WebPInitUpsamplers();
  }
  if (io->use_scaling) {
#if !defined(WEBP_REDUCE_SIZE)
    const int ok = is_rgb ? InitRGBRescaler(io, p) : InitYUVRescaler(io, p);
    if (!ok) {
      return 0;    // memory error
    }
#else
    return 0;   // rescaling support not compiled
#endif
  } else {
    if (is_rgb) {
      WebPInitSamplers();
      p->emit = EmitSampledRGB;   // default
      if (io->fancy_upsampling) {
#ifdef FANCY_UPSAMPLING
        const int uv_width = (io->mb_w + 1) >> 1;
        p->memory = WebPSafeMalloc(1ULL, (size_t)(io->mb_w + 2 * uv_width));
        if (p->memory == NULL) {
          return 0;   // memory error.
        }
        p->tmp_y = (uint8_t*)p->memory;
        p->tmp_u = p->tmp_y + io->mb_w;
        p->tmp_v = p->tmp_u + uv_width;
        p->emit = EmitFancyRGB;
        WebPInitUpsamplers();
#endif
      }
    } else {
      p->emit = EmitYUV;
    }
    if (is_alpha) {  // need transparency output
      p->emit_alpha =
          (colorspace == MODE_RGBA_4444 || colorspace == MODE_rgbA_4444) ?
              EmitAlphaRGBA4444
          : is_rgb ? EmitAlphaRGB
          : EmitAlphaYUV;
      if (is_rgb) {
        WebPInitAlphaProcessing();
      }
    }
  }

  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movq 0x38(%rdi), %r13
movq (%r13), %rax
movl (%rax), %r15d
leal -0x1(%r15), %eax
cmpl $0xc, %eax
jae 0xc9432
movl $0x81d, %ecx            # imm = 0x81D
btl %eax, %ecx
jae 0xc9432
xorl %ebp, %ebp
jmp 0xc943d
leal -0xb(%r15), %eax
cmpl $-0x4, %eax
setb %bpl
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%r13)
movups %xmm0, 0x50(%r13)
movq 0x28(%r13), %rdi
movzbl %bpl, %edx
addl $0xb, %edx
movq %rbx, %rsi
callq 0xc772c
xorl %r14d, %r14d
testl %eax, %eax
je 0xc9a1e
leal -0xb(%r15), %eax
cmpl $-0x4, %eax
setb %al
orb %bpl, %al
jne 0xc947c
callq 0xd3681
leaq 0x50(%r13), %r14
cmpl $0x0, 0x88(%rbx)
pushq $0x1
popq %r12
je 0xc94b4
movq (%r13), %rsi
movl (%rsi), %eax
leal -0x1(%rax), %ecx
cmpl $0xa, %r15d
jbe 0xc94ce
cmpl $0xc, %ecx
movq %rsi, 0x40(%rsp)
jae 0xc94ed
movl $0x81d, %edx            # imm = 0x81D
btl %ecx, %edx
jae 0xc94ed
xorl %ecx, %ecx
jmp 0xc94f6
cmpl $0xa, %r15d
jbe 0xc98e3
leaq 0x7cf(%rip), %rax       # 0xc9c94
movq %rax, 0x58(%r13)
jmp 0xc9955
cmpl $0xc, %ecx
jae 0xc972c
movl $0x81d, %edx            # imm = 0x81D
btl %ecx, %edx
jae 0xc972c
xorl %r12d, %r12d
jmp 0xc9736
addl $-0xb, %eax
cmpl $-0x4, %eax
setb %cl
movl %ecx, 0xc(%rsp)
movslq 0x8c(%rbx), %r12
movl 0x90(%rbx), %eax
movq %rax, 0x18(%rsp)
leaq 0x1(%r12), %rax
movl 0xc(%rbx), %edx
movl %edx, 0x28(%rsp)
movl 0x10(%rbx), %edx
movl %edx, 0x10(%rsp)
leaq (%r12,%r12), %rsi
movq %rax, 0x30(%rsp)
andq $-0x2, %rax
movq %rax, 0x38(%rsp)
movq %rsi, 0x20(%rsp)
leaq (%rsi,%rax,2), %r15
leaq (,%r12,8), %rax
testb %cl, %cl
movl $0x0, %ebp
cmoveq %rax, %rbp
leaq 0x157(%rbp,%r15,4), %rax
leaq 0x1bf(%rbp,%r15,4), %rsi
cmovneq %rax, %rsi
pushq $0x1
popq %rdi
callq 0x57c90
movq %rax, (%r14)
xorl %r14d, %r14d
testq %rax, %rax
je 0xc9a1e
leaq (,%r15,4), %rcx
addq %rbp, %rcx
leaq (%rax,%rcx), %rdi
addq $0x1f, %rdi
andq $-0x20, %rdi
movq %rdi, 0x30(%r13)
leaq 0x68(%rdi), %rcx
movq %rcx, 0x38(%r13)
leaq 0xd0(%rdi), %rcx
movq %rcx, 0x40(%r13)
leaq 0x138(%rdi), %rdx
xorl %r14d, %r14d
cmpb $0x0, 0xc(%rsp)
movl $0x0, %ecx
cmoveq %rdx, %rcx
movq %rcx, 0x48(%r13)
movl 0xc(%rbx), %esi
movl 0x10(%rbx), %edx
movq 0x40(%rsp), %r15
movq 0x10(%r15), %rcx
movl 0x30(%r15), %r10d
subq $0x8, %rsp
movl %r12d, %r8d
movq 0x20(%rsp), %r9
movq %rax, 0x58(%rsp)
pushq %rax
pushq $0x1
pushq %r10
callq 0xc78d0
addq $0x20, %rsp
testl %eax, %eax
je 0xc9a1e
movq %r12, 0x48(%rsp)
movq 0x30(%rsp), %r8
sarl %r8d
movq 0x18(%rsp), %rax
leal 0x1(%rax), %r9d
sarl %r9d
movl 0x28(%rsp), %r12d
incl %r12d
sarl %r12d
movl 0x10(%rsp), %r14d
incl %r14d
sarl %r14d
movq 0x38(%r13), %rdi
movq 0x18(%r15), %rcx
movl 0x34(%r15), %eax
movq 0x20(%rsp), %rdx
movq 0x50(%rsp), %rsi
leaq (%rsi,%rdx,4), %rbp
subq $0x8, %rsp
movl %r12d, %esi
movl %r14d, %edx
movq %r8, 0x38(%rsp)
movl %r9d, 0x30(%rsp)
pushq %rbp
pushq $0x1
pushq %rax
callq 0xc78d0
addq $0x20, %rsp
testl %eax, %eax
je 0xc997a
movq 0x40(%r13), %rdi
movq 0x20(%r15), %rcx
movl 0x38(%r15), %eax
movq 0x38(%rsp), %rdx
movq %rbp, 0x10(%rsp)
leaq (,%rdx,4), %r10
addq %rbp, %r10
subq $0x8, %rsp
movl %r12d, %esi
movl %r14d, %edx
movq 0x38(%rsp), %r8
movl 0x30(%rsp), %r9d
pushq %r10
pushq $0x1
pushq %rax
callq 0xc78d0
addq $0x20, %rsp
testl %eax, %eax
je 0xc997a
leaq 0xddb(%rip), %rax       # 0xca49b
movq %rax, 0x58(%r13)
cmpb $0x0, 0xc(%rsp)
jne 0xc98d8
movq 0x38(%rsp), %r8
addq %r8, %r8
movq 0x48(%r13), %rdi
movl 0xc(%rbx), %esi
movl 0x10(%rbx), %edx
movq 0x28(%r15), %rcx
movl 0x3c(%r15), %eax
movq 0x10(%rsp), %r9
leaq (%r9,%r8,4), %r10
subq $0x8, %rsp
movq 0x50(%rsp), %r8
movq 0x20(%rsp), %r9
pushq %r10
pushq $0x1
pushq %rax
callq 0xc78d0
addq $0x20, %rsp
testl %eax, %eax
movl $0x0, %r14d
je 0xc9a1e
leaq 0xe31(%rip), %rax       # 0xca554
movq %rax, 0x60(%r13)
jmp 0xc9a12
addl $-0xb, %eax
cmpl $-0x4, %eax
setb %r12b
movslq 0x8c(%rbx), %rdx
movl 0x90(%rbx), %eax
movl %eax, 0x18(%rsp)
movl 0xc(%rbx), %eax
movl %eax, 0xc(%rsp)
movl 0x10(%rbx), %eax
movl %eax, 0x40(%rsp)
leaq (%rdx,%rdx), %rbp
movzbl %r12b, %eax
pushq $0x4
popq %rcx
subq %rax, %rcx
movq %rbp, 0x28(%rsp)
imulq %rcx, %rbp
imulq $0x68, %rcx, %rax
movq %rdx, 0x30(%rsp)
imulq %rdx, %rcx
leaq (%rcx,%rbp,4), %r15
leaq (%rax,%r15), %rsi
addq $0x1f, %rsi
pushq $0x1
popq %rdi
callq 0x57c90
movq %rax, (%r14)
testq %rax, %rax
movl $0x0, %r14d
je 0xc9a1e
leaq (%rax,%rbp,4), %rcx
leaq (%rax,%r15), %rdi
addq $0x1f, %rdi
andq $-0x20, %rdi
movq %rdi, 0x30(%r13)
leaq 0x68(%rdi), %rdx
movq %rdx, 0x38(%r13)
leaq 0x138(%rdi), %rdx
xorl %r14d, %r14d
movl %r12d, 0x38(%rsp)
testb %r12b, %r12b
movl $0x0, %esi
cmoveq %rdx, %rsi
leaq 0xd0(%rdi), %rdx
movq %rdx, 0x40(%r13)
movq %rsi, 0x48(%r13)
movl 0xc(%rbx), %esi
movl 0x10(%rbx), %edx
subq $0x8, %rsp
movq %rcx, 0x28(%rsp)
movq 0x38(%rsp), %rbp
movl %ebp, %r8d
movl 0x20(%rsp), %r15d
movl %r15d, %r9d
pushq %rax
pushq $0x1
pushq $0x0
movq %rax, 0x30(%rsp)
callq 0xc78d0
addq $0x20, %rsp
testl %eax, %eax
je 0xc9a1e
movl %r15d, %r9d
movl 0xc(%rsp), %r15d
incl %r15d
sarl %r15d
movl 0x40(%rsp), %r12d
incl %r12d
sarl %r12d
movq 0x38(%r13), %rdi
movq 0x20(%rsp), %rax
leaq (%rax,%rbp), %rcx
movq 0x28(%rsp), %rax
movq 0x10(%rsp), %rdx
leaq (%rdx,%rax,4), %rax
subq $0x8, %rsp
movl %r15d, %esi
movl %r12d, %edx
movl %ebp, %r8d
pushq %rax
pushq $0x1
pushq $0x0
callq 0xc78d0
addq $0x20, %rsp
testl %eax, %eax
je 0xc9a1e
movq 0x40(%r13), %rdi
movq 0x20(%rsp), %rax
leaq (%rax,%rbp,2), %rcx
movq %rbp, %rax
shlq $0x4, %rax
addq 0x10(%rsp), %rax
subq $0x8, %rsp
movl %r15d, %esi
movl %r12d, %edx
movq %rbp, %r12
movl %ebp, %r8d
movl 0x20(%rsp), %r9d
movl %r9d, %r15d
pushq %rax
pushq $0x1
pushq $0x0
callq 0xc78d0
addq $0x20, %rsp
testl %eax, %eax
je 0xc9a1e
leaq 0x730(%rip), %rax       # 0xc9ff4
movq %rax, 0x58(%r13)
callq 0xd3cea
cmpb $0x0, 0x38(%rsp)
je 0xc99a0
pushq $0x1
popq %rax
movl %eax, %r14d
jmp 0xc9a1e
callq 0xd567e
leaq 0x156(%rip), %rax       # 0xc9a45
movq %rax, 0x58(%r13)
cmpl $0x0, 0x58(%rbx)
je 0xc9955
movslq 0xc(%rbx), %rax
leaq 0x1(%rax), %r12
movq %r12, %rsi
andq $-0x2, %rsi
addq %rax, %rsi
pushq $0x1
popq %rdi
callq 0x57c90
movq %rax, (%r14)
testq %rax, %rax
movl $0x0, %r14d
je 0xc9a1e
sarl %r12d
movq %rax, 0x8(%r13)
movslq 0xc(%rbx), %rcx
addq %rax, %rcx
movq %rcx, 0x10(%r13)
movslq %r12d, %rax
addq %rcx, %rax
movq %rax, 0x18(%r13)
leaq 0x158(%rip), %rax       # 0xc9aa0
movq %rax, 0x58(%r13)
callq 0xd3681
pushq $0x1
popq %r12
testb %bpl, %bpl
jne 0xc9a1b
cmpl $0xa, %r15d
je 0xc996a
cmpl $0x5, %r15d
jne 0xc9982
leaq 0x3d4(%rip), %rax       # 0xc9d45
movq %rax, 0x60(%r13)
jmp 0xc9a16
xorl %r14d, %r14d
jmp 0xc9a1e
leaq 0x5ca(%rip), %rax       # 0xc9f53
leaq 0x4cc(%rip), %rcx       # 0xc9e5c
cmpl $0xb, %r15d
cmovaeq %rax, %rcx
movq %rcx, 0x60(%r13)
jb 0xc9a16
jmp 0xc9a1b
movq 0x48(%r13), %rdi
movl 0xc(%rbx), %esi
movl 0x10(%rbx), %edx
movq %r12, %r8
leal (%r12,%r12,2), %eax
cltq
movq 0x20(%rsp), %rcx
addq %rax, %rcx
imulq $0x18, %r12, %rax
movq 0x10(%rsp), %r10
addq %rax, %r10
subq $0x8, %rsp
movl %r15d, %r9d
pushq %r10
pushq $0x1
pushq $0x0
callq 0xc78d0
addq $0x20, %rsp
testl %eax, %eax
je 0xc9a1e
leaq 0x816(%rip), %rax       # 0xca1fe
movq %rax, 0x60(%r13)
movq (%r13), %rax
movl (%rax), %eax
cmpl $0xa, %eax
leaq 0x870(%rip), %rcx       # 0xca26c
leaq 0x97d(%rip), %rdx       # 0xca380
cmoveq %rcx, %rdx
cmpl $0x5, %eax
cmoveq %rcx, %rdx
movq %rdx, 0x68(%r13)
pushq $0x1
popq %r12
callq 0xcead0
movl %r12d, %r14d
movl %r14d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq