// File: /workspace/github_c_makefile_star2_O1/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 0xd12cd
movl $0x81d, %ecx            # imm = 0x81D
btl %eax, %ecx
jae 0xd12cd
xorl %r12d, %r12d
jmp 0xd12d8
leal -0xb(%r15), %eax
cmpl $-0x4, %eax
setb %r12b
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%r13)
movups %xmm0, 0x50(%r13)
movq 0x28(%r13), %rdi
movzbl %r12b, %edx
addl $0xb, %edx
movq %rbx, %rsi
callq 0xcf20f
xorl %ebp, %ebp
testl %eax, %eax
je 0xd189c
leal -0xb(%r15), %eax
cmpl $-0x4, %eax
setb %al
orb %r12b, %al
jne 0xd1316
callq 0xdcdfd
leaq 0x50(%r13), %rbp
cmpl $0x0, 0x88(%rbx)
je 0xd134a
movq (%r13), %rdx
movl (%rdx), %eax
leal -0x1(%rax), %ecx
cmpl $0xa, %r15d
jbe 0xd1364
cmpl $0xc, %ecx
movq %rdx, 0x38(%rsp)
jae 0xd1383
movl $0x81d, %edx            # imm = 0x81D
btl %ecx, %edx
jae 0xd1383
xorl %ecx, %ecx
jmp 0xd138c
cmpl $0xa, %r15d
jbe 0xd17ed
leaq 0x7c7(%rip), %rax       # 0xd1b22
movq %rax, 0x58(%r13)
jmp 0xd1859
cmpl $0xc, %ecx
jae 0xd15bd
movl $0x81d, %edx            # imm = 0x81D
btl %ecx, %edx
jae 0xd15bd
xorl %r12d, %r12d
jmp 0xd15c7
addl $-0xb, %eax
cmpl $-0x4, %eax
setb %cl
movl %ecx, 0x18(%rsp)
movslq 0x8c(%rbx), %r12
movl 0x90(%rbx), %eax
movq %rax, 0x40(%rsp)
leaq 0x1(%r12), %rax
movl 0xc(%rbx), %edx
movl %edx, 0xc(%rsp)
movl 0x10(%rbx), %edx
movl %edx, 0x28(%rsp)
leaq (%r12,%r12), %rsi
movq %rax, 0x10(%rsp)
andq $-0x2, %rax
movq %rax, 0x30(%rsp)
movq %rsi, 0x20(%rsp)
leaq (%rsi,%rax,2), %r15
leaq (,%r12,8), %rax
testb %cl, %cl
movl $0x0, %r14d
cmoveq %rax, %r14
leaq 0x157(%r14,%r15,4), %rax
leaq 0x1bf(%r14,%r15,4), %rsi
cmovneq %rax, %rsi
movl $0x1, %edi
callq 0x56b20
movq %rax, (%rbp)
xorl %ebp, %ebp
testq %rax, %rax
je 0xd189c
leaq (%r14,%r15,4), %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 %ebp, %ebp
cmpb $0x0, 0x18(%rsp)
movl $0x0, %ecx
cmoveq %rdx, %rcx
movq %rcx, 0x48(%r13)
movl 0xc(%rbx), %esi
movl 0x10(%rbx), %edx
movq 0x38(%rsp), %r14
movq 0x10(%r14), %rcx
movl 0x30(%r14), %r10d
subq $0x8, %rsp
movl %r12d, %r8d
movq 0x48(%rsp), %r15
movl %r15d, %r9d
movq %rax, 0x58(%rsp)
pushq %rax
pushq $0x1
pushq %r10
callq 0xcf6a0
addq $0x20, %rsp
testl %eax, %eax
je 0xd189c
movq %r12, 0x48(%rsp)
movq 0x10(%rsp), %r8
sarl %r8d
leal 0x1(%r15), %r9d
sarl %r9d
movl 0xc(%rsp), %r12d
incl %r12d
sarl %r12d
movl 0x28(%rsp), %r15d
incl %r15d
sarl %r15d
movq 0x38(%r13), %rdi
movq 0x18(%r14), %rcx
movl 0x34(%r14), %eax
movq 0x20(%rsp), %rdx
movq 0x50(%rsp), %rsi
leaq (%rsi,%rdx,4), %r10
subq $0x8, %rsp
movl %r12d, %esi
movl %r15d, %edx
movq %r8, 0x18(%rsp)
movl %r9d, 0x14(%rsp)
movq %r10, 0x30(%rsp)
pushq %r10
pushq $0x1
pushq %rax
callq 0xcf6a0
addq $0x20, %rsp
testl %eax, %eax
je 0xd189c
movq 0x40(%r13), %rdi
movq 0x20(%r14), %rcx
movl 0x38(%r14), %eax
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %r14
leaq (%r14,%rdx,4), %r10
subq $0x8, %rsp
movl %r12d, %esi
movl %r15d, %edx
movq 0x18(%rsp), %r8
movl 0x14(%rsp), %r9d
pushq %r10
pushq $0x1
pushq %rax
callq 0xcf6a0
addq $0x20, %rsp
testl %eax, %eax
je 0xd189c
leaq 0xe48(%rip), %rax       # 0xd2396
movq %rax, 0x58(%r13)
movl $0x1, %ebp
cmpb $0x0, 0x18(%rsp)
movq 0x48(%rsp), %r8
movq 0x40(%rsp), %r9
jne 0xd189c
movq 0x30(%rsp), %r10
addq %r10, %r10
movq 0x48(%r13), %rdi
movl 0xc(%rbx), %esi
movl 0x10(%rbx), %edx
movq 0x38(%rsp), %rax
movq 0x28(%rax), %rcx
movl 0x3c(%rax), %eax
leaq (%r14,%r10,4), %r10
subq $0x8, %rsp
pushq %r10
pushq $0x1
pushq %rax
callq 0xcf6a0
addq $0x20, %rsp
movl $0x0, %ebp
testl %eax, %eax
je 0xd189c
leaq 0xe9e(%rip), %rax       # 0xd2452
movq %rax, 0x60(%r13)
jmp 0xd1892
addl $-0xb, %eax
cmpl $-0x4, %eax
setb %r12b
movslq 0x8c(%rbx), %rdx
movl 0x90(%rbx), %eax
movl %eax, 0x10(%rsp)
movl 0xc(%rbx), %eax
movl %eax, 0x38(%rsp)
movl 0x10(%rbx), %eax
movl %eax, 0xc(%rsp)
leaq (%rdx,%rdx), %r15
movzbl %r12b, %eax
movl $0x4, %ecx
subq %rax, %rcx
movq %r15, 0x28(%rsp)
imulq %rcx, %r15
imulq $0x68, %rcx, %rax
movq %rdx, 0x40(%rsp)
imulq %rdx, %rcx
leaq (%rcx,%r15,4), %r14
leaq (%rax,%r14), %rsi
addq $0x1f, %rsi
movl $0x1, %edi
callq 0x56b20
movq %rax, (%rbp)
testq %rax, %rax
movl $0x0, %ebp
je 0xd189c
leaq (%rax,%r15,4), %rcx
leaq (%rax,%r14), %rdi
addq $0x1f, %rdi
andq $-0x20, %rdi
movq %rdi, 0x30(%r13)
leaq 0x68(%rdi), %rdx
movq %rdx, 0x38(%r13)
leaq 0x138(%rdi), %rdx
xorl %ebp, %ebp
movl %r12d, 0x30(%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 0x48(%rsp), %r15
movl %r15d, %r8d
movl 0x18(%rsp), %r14d
movl %r14d, %r9d
pushq %rax
pushq $0x1
pushq $0x0
movq %rax, 0x38(%rsp)
callq 0xcf6a0
addq $0x20, %rsp
testl %eax, %eax
je 0xd189c
movl %r14d, %r9d
movl 0x38(%rsp), %r14d
incl %r14d
sarl %r14d
movl 0xc(%rsp), %r12d
incl %r12d
sarl %r12d
movq 0x38(%r13), %rdi
movq 0x20(%rsp), %rax
leaq (%rax,%r15), %rcx
movq 0x28(%rsp), %rax
movq 0x18(%rsp), %rdx
leaq (%rdx,%rax,4), %rax
subq $0x8, %rsp
movl %r14d, %esi
movl %r12d, %edx
movl %r15d, %r8d
pushq %rax
pushq $0x1
pushq $0x0
callq 0xcf6a0
addq $0x20, %rsp
testl %eax, %eax
je 0xd189c
movq 0x40(%r13), %rdi
movq 0x20(%rsp), %rax
leaq (%rax,%r15,2), %rcx
movq %r15, %rax
shlq $0x4, %rax
addq 0x18(%rsp), %rax
subq $0x8, %rsp
movl %r14d, %esi
movl %r12d, %edx
movl %r15d, %r8d
movl 0x18(%rsp), %r9d
pushq %rax
pushq $0x1
pushq $0x0
callq 0xcf6a0
addq $0x20, %rsp
testl %eax, %eax
je 0xd189c
leaq 0x74d(%rip), %rax       # 0xd1e9f
movq %rax, 0x58(%r13)
callq 0xdd7b5
movl $0x1, %ebp
cmpb $0x0, 0x30(%rsp)
movl 0x10(%rsp), %r9d
movq 0x18(%rsp), %r10
jne 0xd189c
movq 0x48(%r13), %rdi
movl 0xc(%rbx), %esi
movl 0x10(%rbx), %edx
leal (%r15,%r15,2), %eax
cltq
movq 0x20(%rsp), %rcx
addq %rax, %rcx
leaq (%r15,%r15,2), %rax
leaq (%r10,%rax,8), %rax
subq $0x8, %rsp
movl %r15d, %r8d
pushq %rax
pushq $0x1
pushq $0x0
callq 0xcf6a0
addq $0x20, %rsp
movl $0x0, %ebp
testl %eax, %eax
je 0xd189c
leaq 0x919(%rip), %rax       # 0xd20d7
movq %rax, 0x60(%r13)
movq (%r13), %rax
movl (%rax), %eax
cmpl $0xa, %eax
leaq 0x973(%rip), %rcx       # 0xd2145
leaq 0xa8d(%rip), %rdx       # 0xd2266
cmoveq %rcx, %rdx
cmpl $0x5, %eax
cmoveq %rcx, %rdx
movq %rdx, 0x68(%r13)
jmp 0xd1892
callq 0xe14db
leaq 0xcc(%rip), %rax        # 0xd18c5
movq %rax, 0x58(%r13)
cmpl $0x0, 0x58(%rbx)
je 0xd1859
movslq 0xc(%rbx), %rax
leaq 0x1(%rax), %r14
movq %r14, %rsi
andq $-0x2, %rsi
addq %rax, %rsi
movl $0x1, %edi
callq 0x56b20
movq %rax, (%rbp)
testq %rax, %rax
movl $0x0, %ebp
je 0xd189c
sarl %r14d
movq %rax, 0x8(%r13)
movslq 0xc(%rbx), %rcx
addq %rax, %rcx
movq %rcx, 0x10(%r13)
movslq %r14d, %rax
addq %rcx, %rax
movq %rax, 0x18(%r13)
leaq 0xd0(%rip), %rax        # 0xd1920
movq %rax, 0x58(%r13)
callq 0xdcdfd
movl $0x1, %ebp
testb %r12b, %r12b
jne 0xd189c
leaq 0x370(%rip), %rax       # 0xd1bda
cmpl $0x5, %r15d
je 0xd1888
cmpl $0xa, %r15d
je 0xd1888
leaq 0x565(%rip), %rcx       # 0xd1de2
leaq 0x464(%rip), %rax       # 0xd1ce8
cmovaq %rcx, %rax
movq %rax, 0x60(%r13)
cmpl $0xa, %r15d
ja 0xd189c
callq 0xd7d82
movl $0x1, %ebp
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq