// File: lunasorcery[P]brailify/./stb/stb_image.h
// Function: stbi__load_and_postprocess_16bit(stbi__context*, int*, int*, int*, int)
static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp)
{
   stbi__result_info ri;
   void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16);

   if (result == NULL)
      return NULL;

   if (ri.bits_per_channel != 16) {
      STBI_ASSERT(ri.bits_per_channel == 8);
      result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp);
      ri.bits_per_channel = 16;
   }

   // @TODO: move stbi__convert_format16 to here
   // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision

   if (stbi__vertically_flip_on_load) {
      int w = *x, h = *y;
      int channels = req_comp ? req_comp : *comp;
      int row,col,z;
      stbi__uint16 *image = (stbi__uint16 *) result;

      // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once
      for (row = 0; row < (h>>1); row++) {
         for (col = 0; col < w; col++) {
            for (z = 0; z < channels; z++) {
               stbi__uint16 temp = image[(row * w + col) * channels + z];
               image[(row * w + col) * channels + z] = image[((h - row - 1) * w + col) * channels + z];
               image[((h - row - 1) * w + col) * channels + z] = temp;
            }
         }
      }
   }

   return (stbi__uint16 *) result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x2c(%rbp), %r8d
leaq -0x38(%rbp), %r9
movl $0x10, (%rsp)
callq 0x3af0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x17bb
movq $0x0, -0x8(%rbp)
jmp 0x1973
cmpl $0x10, -0x38(%rbp)
je 0x1836
cmpl $0x8, -0x38(%rbp)
jne 0x17c9
jmp 0x17e8
leaq 0x1f744(%rip), %rdi     # 0x20f14
leaq 0x1ee8c(%rip), %rsi     # 0x20663
movl $0x482, %edx            # imm = 0x482
leaq 0x1f74a(%rip), %rcx     # 0x20f2d
callq 0x1090
movq -0x40(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x6c(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x68(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x1813
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x7c(%rbp)
jmp 0x1819
movl -0x2c(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x68(%rbp), %edx
movl -0x6c(%rbp), %esi
movq -0x78(%rbp), %rdi
movl -0x7c(%rbp), %ecx
callq 0x17830
movq %rax, -0x40(%rbp)
movl $0x10, -0x38(%rbp)
cmpl $0x0, 0x250fb(%rip)     # 0x26938
je 0x196b
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x1863
movl -0x2c(%rbp), %eax
movl %eax, -0x80(%rbp)
jmp 0x186c
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl -0x48(%rbp), %ecx
sarl %ecx
cmpl %ecx, %eax
jge 0x1969
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x1959
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x1949
movq -0x60(%rbp), %rax
movl -0x50(%rbp), %ecx
imull -0x44(%rbp), %ecx
addl -0x54(%rbp), %ecx
imull -0x4c(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
movw (%rax,%rcx,2), %ax
movw %ax, -0x62(%rbp)
movq -0x60(%rbp), %rax
movl -0x48(%rbp), %ecx
subl -0x50(%rbp), %ecx
subl $0x1, %ecx
imull -0x44(%rbp), %ecx
addl -0x54(%rbp), %ecx
imull -0x4c(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
movw (%rax,%rcx,2), %dx
movq -0x60(%rbp), %rax
movl -0x50(%rbp), %ecx
imull -0x44(%rbp), %ecx
addl -0x54(%rbp), %ecx
imull -0x4c(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movw -0x62(%rbp), %dx
movq -0x60(%rbp), %rax
movl -0x48(%rbp), %ecx
subl -0x50(%rbp), %ecx
subl $0x1, %ecx
imull -0x44(%rbp), %ecx
addl -0x54(%rbp), %ecx
imull -0x4c(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x18ab
jmp 0x194b
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x1898
jmp 0x195b
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1881
jmp 0x196b
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq