// File: /workspace/github_c_makefile_star2_O0/tditlu[P]shadetabler/src/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*/
    unsigned char* data = *out;
    size_t outsize;

    /*TODO: check if this works according to the statement in the documentation: "The converter can convert
    from grayscale input color type, to 8-bit grayscale or grayscale 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 0xc550
movq -0x28(%rbp), %rax
cmpl $0x0, 0x1f0(%rax)
je 0xc3d7
movq -0x28(%rbp), %rax
movl 0x1f0(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0xc545
movq -0x28(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
je 0xc405
movq -0x28(%rbp), %rdi
addq $0x90, %rdi
movq -0x28(%rbp), %rsi
addq $0xb8, %rsi
addq $0x10, %rsi
callq 0x7b30
cmpl $0x0, %eax
je 0xc460
movq -0x28(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
jne 0xc45b
movq -0x28(%rbp), %rdi
addq $0x90, %rdi
movq -0x28(%rbp), %rsi
addq $0xb8, %rsi
addq $0x10, %rsi
callq 0x63a0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x1f0(%rax)
movq -0x28(%rbp), %rax
cmpl $0x0, 0x1f0(%rax)
je 0xc459
movq -0x28(%rbp), %rax
movl 0x1f0(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0xc545
jmp 0xc45b
jmp 0xc538
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x2, 0x90(%rax)
je 0xc49e
movq -0x28(%rbp), %rax
cmpl $0x6, 0x90(%rax)
je 0xc49e
movq -0x28(%rbp), %rax
cmpl $0x8, 0x94(%rax)
je 0xc49e
movl $0x38, -0x4(%rbp)
jmp 0xc545
movq -0x18(%rbp), %rax
movl (%rax), %edi
movq -0x20(%rbp), %rax
movl (%rax), %esi
movq -0x28(%rbp), %rdx
addq $0x90, %rdx
callq 0x68a0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x3de0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xc4eb
movq -0x28(%rbp), %rax
movl $0x53, 0x1f0(%rax)
jmp 0xc52f
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x90, %rdx
movq -0x28(%rbp), %rcx
addq $0xb8, %rcx
addq $0x10, %rcx
movq -0x18(%rbp), %rax
movl (%rax), %r8d
movq -0x20(%rbp), %rax
movl (%rax), %r9d
callq 0x76b0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x1f0(%rax)
movq -0x40(%rbp), %rdi
callq 0x5060
movq -0x28(%rbp), %rax
movl 0x1f0(%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop