// File: /workspace/github_cpp_makefile_star2_O3/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 0x9e27b
testq %rax, %rax
je 0x9e26e
movq %rax, %r14
testl %r12d, %r12d
je 0x9e17a
leaq 0x15cae(%rip), %rsi     # 0xb3e20
movq %rbx, %rdi
callq 0x9214d
xorl %r12d, %r12d
testq %r15, %r15
cmovel %r12d, %ebp
cmpl $0x4, %ebp
jl 0x9e1b0
movzbl (%r15), %eax
shll $0x18, %eax
js 0x9e1ef
movzbl 0x1(%r15), %ecx
shll $0x10, %ecx
movzbl 0x2(%r15), %edx
shll $0x8, %edx
movzbl 0x3(%r15), %r12d
orl %ecx, %r12d
orl %edx, %r12d
orl %eax, %r12d
cmpl %r12d, %ebp
jge 0x9e1be
leaq 0x15cbd(%rip), %rsi     # 0xb3e79
jmp 0x9e1f6
jbe 0x9e1d2
leaq 0x15ce2(%rip), %rsi     # 0xb3ea9
movq %rbx, %rdi
callq 0x9214d
movl %r12d, %ebp
testl %ebp, %ebp
je 0x9e217
movl %ebp, %edx
leaq 0x10(%rsp), %r8
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x9e4ac
movl %eax, %r15d
jmp 0x9e21a
leaq 0x15c51(%rip), %rsi     # 0xb3e47
movq %rbx, %rdi
callq 0x9214d
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x92016
xorl %r15d, %r15d
leal (%r14,%r15), %edx
addl $0x2, %edx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x9d91a
movq 0x8(%rsp), %r12
movb $0x0, 0x1(%r12,%r14)
addq $0x2, %r14
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x9d98f
testl %r15d, %r15d
je 0x9e25b
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x9e752
movq %rbx, %rdi
callq 0x9d9ce
movq %rbx, %rdi
movq %r12, %rsi
callq 0x92016
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq