// File: /workspace/github_c_makefile_star2_O0/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: lodepng_decode
unsigned lodepng_decode(unsigned char** out, unsigned* w, unsigned* h,
                        LodePNGState* state,
                        const unsigned char* in, size_t insize)
{
  *out = 0;
  decodeGeneric(out, w, h, state, in, insize);
  if(state->error) return state->error;
  if(!state->decoder.color_convert || lodepng_color_mode_equal(&state->info_raw, &state->info_png.color))
  {
    /*same color type, no copying or converting of data needed*/
    /*store the info_png color settings on the info_raw so that the info_raw still reflects what colortype
    the raw image has to the end user*/
    if(!state->decoder.color_convert)
    {
      state->error = lodepng_color_mode_copy(&state->info_raw, &state->info_png.color);
      if(state->error) return state->error;
    }
  }
  else
  {
    /*color conversion needed; sort of copy of the data*/
    unsigned char* data = *out;
    size_t outsize;

    /*TODO: check if this works according to the statement in the documentation: "The converter can convert
    from greyscale input color type, to 8-bit greyscale or greyscale with alpha"*/
    if(!(state->info_raw.colortype == LCT_RGB || state->info_raw.colortype == LCT_RGBA)
       && !(state->info_raw.bitdepth == 8))
    {
      return 56; /*unsupported color mode conversion*/
    }

    outsize = lodepng_get_raw_size(*w, *h, &state->info_raw);
    *out = (unsigned char*)lodepng_malloc(outsize);
    if(!(*out))
    {
      state->error = 83; /*alloc fail*/
    }
    else state->error = lodepng_convert(*out, data, &state->info_raw,
                                        &state->info_png.color, *w, *h);
    lodepng_free(data);
  }
  return state->error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r9
callq 0x73d0
movq -0x28(%rbp), %rax
cmpl $0x0, 0x198(%rax)
je 0x7257
movq -0x28(%rbp), %rax
movl 0x198(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x73c5
movq -0x28(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0x7285
movq -0x28(%rbp), %rdi
addq $0x88, %rdi
movq -0x28(%rbp), %rsi
addq $0xb0, %rsi
addq $0x10, %rsi
callq 0x43a0
cmpl $0x0, %eax
je 0x72e0
movq -0x28(%rbp), %rax
cmpl $0x0, 0x24(%rax)
jne 0x72db
movq -0x28(%rbp), %rdi
addq $0x88, %rdi
movq -0x28(%rbp), %rsi
addq $0xb0, %rsi
addq $0x10, %rsi
callq 0x2f20
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x198(%rax)
movq -0x28(%rbp), %rax
cmpl $0x0, 0x198(%rax)
je 0x72d9
movq -0x28(%rbp), %rax
movl 0x198(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x73c5
jmp 0x72db
jmp 0x73b8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x2, 0x88(%rax)
je 0x731e
movq -0x28(%rbp), %rax
cmpl $0x6, 0x88(%rax)
je 0x731e
movq -0x28(%rbp), %rax
cmpl $0x8, 0x8c(%rax)
je 0x731e
movl $0x38, -0x4(%rbp)
jmp 0x73c5
movq -0x18(%rbp), %rax
movl (%rax), %edi
movq -0x20(%rbp), %rax
movl (%rax), %esi
movq -0x28(%rbp), %rdx
addq $0x88, %rdx
callq 0x32e0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x13b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x736b
movq -0x28(%rbp), %rax
movl $0x53, 0x198(%rax)
jmp 0x73af
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x88, %rdx
movq -0x28(%rbp), %rcx
addq $0xb0, %rcx
addq $0x10, %rcx
movq -0x18(%rbp), %rax
movl (%rax), %r8d
movq -0x20(%rbp), %rax
movl (%rax), %r9d
callq 0x3f90
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x198(%rax)
movq -0x40(%rbp), %rdi
callq 0x1e60
movq -0x28(%rbp), %rax
movl 0x198(%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop