// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/png/pngwutil.c
// Function: png_write_iCCP
void /* PRIVATE */
png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
   png_charp profile, int profile_len)
{
   PNG_iCCP;
   png_size_t name_len;
   png_charp new_name;
   compression_state comp;
   int embedded_profile_len = 0;

   png_debug(1, "in png_write_iCCP");

   comp.num_output_ptr = 0;
   comp.max_output_ptr = 0;
   comp.output_ptr = NULL;
   comp.input = NULL;
   comp.input_len = 0;

   if ((name_len = png_check_keyword(png_ptr, name,
      &new_name)) == 0)
      return;

   if (compression_type != PNG_COMPRESSION_TYPE_BASE)
      png_warning(png_ptr, "Unknown compression type in iCCP chunk");

   if (profile == NULL)
      profile_len = 0;

   if (profile_len > 3)
      embedded_profile_len =
          ((*( (png_bytep)profile    ))<<24) |
          ((*( (png_bytep)profile + 1))<<16) |
          ((*( (png_bytep)profile + 2))<< 8) |
          ((*( (png_bytep)profile + 3))    );

   if (embedded_profile_len < 0)
   {
      png_warning(png_ptr,
        "Embedded profile length in iCCP chunk is negative");
      png_free(png_ptr, new_name);
      return;
   }

   if (profile_len < embedded_profile_len)
   {
      png_warning(png_ptr,
        "Embedded profile length too large in iCCP chunk");
      png_free(png_ptr, new_name);
      return;
   }

   if (profile_len > embedded_profile_len)
   {
      png_warning(png_ptr,
        "Truncating profile to actual length in iCCP chunk");
      profile_len = embedded_profile_len;
   }

   if (profile_len)
      profile_len = png_text_compress(png_ptr, profile,
        (png_size_t)profile_len, PNG_COMPRESSION_TYPE_BASE, &comp);

   /* Make sure we include the NULL after the name and the compression type */
   png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,
          (png_uint_32)(name_len + profile_len + 2));
   new_name[name_len + 1] = 0x00;
   png_write_chunk_data(png_ptr, (png_bytep)new_name,
     (png_size_t)(name_len + 2));

   if (profile_len)
      png_write_compressed_data_out(png_ptr, &comp);

   png_write_chunk_end(png_ptr);
   png_free(png_ptr, new_name);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %r8d, %ebp
movq %rcx, %r15
movl %edx, %r12d
movq %rdi, %rbx
movb $0x0, 0x4(%rsp)
movl $0x50434369, (%rsp)     # imm = 0x50434369
movq $0x0, 0x28(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movl $0x0, 0x20(%rsp)
leaq 0x8(%rsp), %rdx
callq 0x9ec1f
testq %rax, %rax
je 0x9ec12
movq %rax, %r14
testl %r12d, %r12d
je 0x9eb4c
leaq 0x1528c(%rip), %rsi     # 0xb3dd0
movq %rbx, %rdi
callq 0x92e6e
xorl %r12d, %r12d
testq %r15, %r15
cmovel %r12d, %ebp
cmpl $0x4, %ebp
jl 0x9eb61
movl (%r15), %r12d
bswapl %r12d
testl %r12d, %r12d
js 0x9eb74
cmpl %r12d, %ebp
jge 0x9eb8a
leaq 0x152b7(%rip), %rsi     # 0xb3e29
jmp 0x9eb7b
leaq 0x1527c(%rip), %rsi     # 0xb3df7
movq %rbx, %rdi
callq 0x92e6e
movq 0x8(%rsp), %r15
jmp 0x9ec07
jle 0x9eb9e
leaq 0x152c6(%rip), %rsi     # 0xb3e59
movq %rbx, %rdi
callq 0x92e6e
movl %r12d, %ebp
testl %ebp, %ebp
je 0x9ebbb
movl %ebp, %edx
leaq 0x10(%rsp), %r8
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x9ee4b
movl %eax, %r12d
jmp 0x9ebbe
xorl %r12d, %r12d
leal (%r14,%r12), %edx
addl $0x2, %edx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x9e30e
movq 0x8(%rsp), %r15
movb $0x0, 0x1(%r15,%r14)
addq $0x2, %r14
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x9e383
testl %r12d, %r12d
je 0x9ebff
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x9f0fb
movq %rbx, %rdi
callq 0x9e3c2
movq %rbx, %rdi
movq %r15, %rsi
callq 0x92d32
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq