// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dec/alpha_dec.c
// Function: ALPHInit
WEBP_NODISCARD static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data,
                                   size_t data_size, const VP8Io* const src_io,
                                   uint8_t* output) {
  int ok = 0;
  const uint8_t* const alpha_data = data + ALPHA_HEADER_LEN;
  const size_t alpha_data_size = data_size - ALPHA_HEADER_LEN;
  int rsrv;
  VP8Io* const io = &dec->io_;

  assert(data != NULL && output != NULL && src_io != NULL);

  VP8FiltersInit();
  dec->output_ = output;
  dec->width_ = src_io->width;
  dec->height_ = src_io->height;
  assert(dec->width_ > 0 && dec->height_ > 0);

  if (data_size <= ALPHA_HEADER_LEN) {
    return 0;
  }

  dec->method_ = (data[0] >> 0) & 0x03;
  dec->filter_ = (WEBP_FILTER_TYPE)((data[0] >> 2) & 0x03);
  dec->pre_processing_ = (data[0] >> 4) & 0x03;
  rsrv = (data[0] >> 6) & 0x03;
  if (dec->method_ < ALPHA_NO_COMPRESSION ||
      dec->method_ > ALPHA_LOSSLESS_COMPRESSION ||
      dec->filter_ >= WEBP_FILTER_LAST ||
      dec->pre_processing_ > ALPHA_PREPROCESSED_LEVELS ||
      rsrv != 0) {
    return 0;
  }

  // Copy the necessary parameters from src_io to io
  if (!VP8InitIo(io)) {
    return 0;
  }
  WebPInitCustomIo(NULL, io);
  io->opaque = dec;
  io->width = src_io->width;
  io->height = src_io->height;

  io->use_cropping = src_io->use_cropping;
  io->crop_left = src_io->crop_left;
  io->crop_right = src_io->crop_right;
  io->crop_top = src_io->crop_top;
  io->crop_bottom = src_io->crop_bottom;
  // No need to copy the scaling parameters.

  if (dec->method_ == ALPHA_NO_COMPRESSION) {
    const size_t alpha_decoded_size = dec->width_ * dec->height_;
    ok = (alpha_data_size >= alpha_decoded_size);
  } else {
    assert(dec->method_ == ALPHA_LOSSLESS_COMPRESSION);
    ok = VP8LDecodeAlphaHeader(dec, alpha_data, alpha_data_size);
  }

  return ok;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x184c7e
cmpq $0x0, -0x30(%rbp)
je 0x184c7e
cmpq $0x0, -0x28(%rbp)
je 0x184c7e
jmp 0x184c9d
leaq 0x3d079(%rip), %rdi     # 0x1c1cfe
leaq 0x3cf23(%rip), %rsi     # 0x1c1baf
movl $0x3b, %edx
leaq 0x3d097(%rip), %rcx     # 0x1c1d2f
callq 0x598a0
callq 0x14d300
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xc8(%rax)
movq -0x28(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jle 0x184ce0
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jle 0x184ce0
jmp 0x184cff
leaq 0x3d0a1(%rip), %rdi     # 0x1c1d88
leaq 0x3cec1(%rip), %rsi     # 0x1c1baf
movl $0x41, %edx
leaq 0x3d035(%rip), %rcx     # 0x1c1d2f
callq 0x598a0
cmpq $0x1, -0x20(%rbp)
ja 0x184d12
movl $0x0, -0x4(%rbp)
jmp 0x184eaf
movq -0x18(%rbp), %rax
movzbl (%rax), %ecx
sarl $0x0, %ecx
andl $0x3, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movzbl (%rax), %ecx
sarl $0x2, %ecx
andl $0x3, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
movzbl (%rax), %ecx
sarl $0x4, %ecx
andl $0x3, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
sarl $0x6, %eax
andl $0x3, %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jl 0x184d8c
movq -0x10(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jg 0x184d8c
movq -0x10(%rbp), %rax
cmpl $0x4, 0xc(%rax)
jae 0x184d8c
movq -0x10(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jg 0x184d8c
cmpl $0x0, -0x4c(%rbp)
je 0x184d98
movl $0x0, -0x4(%rbp)
jmp 0x184eaf
movq -0x58(%rbp), %rdi
callq 0x1850c0
cmpl $0x0, %eax
jne 0x184db2
movl $0x0, -0x4(%rbp)
jmp 0x184eaf
movq -0x58(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x140200
movq -0x10(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
movl (%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rax
movl 0x74(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x74(%rax)
movq -0x28(%rbp), %rax
movl 0x78(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x78(%rax)
movq -0x28(%rbp), %rax
movl 0x7c(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x7c(%rax)
movq -0x28(%rbp), %rax
movl 0x80(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x80(%rax)
movq -0x28(%rbp), %rax
movl 0x84(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x84(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x184e6a
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x10(%rbp), %rcx
imull 0x4(%rcx), %eax
cltq
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x60(%rbp), %rax
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x34(%rbp)
jmp 0x184ea9
movq -0x10(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x184e76
jmp 0x184e95
leaq 0x3cf2f(%rip), %rdi     # 0x1c1dac
leaq 0x3cd2b(%rip), %rsi     # 0x1c1baf
movl $0x67, %edx
leaq 0x3ce9f(%rip), %rcx     # 0x1c1d2f
callq 0x598a0
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x145160
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)