// File: /workspace/github_cpp_makefile_star2_O2/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
andq $0x0, 0x28(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andl $0x0, 0x20(%rsp)
leaq 0x8(%rsp), %rdx
callq 0x8fb3e
testq %rax, %rax
je 0x8fb31
movq %rax, %r14
testl %r12d, %r12d
je 0x8fa3d
leaq 0x1509b(%rip), %rsi     # 0xa4ad0
movq %rbx, %rdi
callq 0x84a53
xorl %r12d, %r12d
testq %r15, %r15
cmovel %r12d, %ebp
cmpl $0x4, %ebp
jl 0x8fa73
movzbl (%r15), %eax
shll $0x18, %eax
js 0x8fab2
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 0x8fa81
leaq 0x150aa(%rip), %rsi     # 0xa4b29
jmp 0x8fab9
jbe 0x8fa95
leaq 0x150cf(%rip), %rsi     # 0xa4b59
movq %rbx, %rdi
callq 0x84a53
movl %r12d, %ebp
testl %ebp, %ebp
je 0x8fada
movl %ebp, %edx
leaq 0x10(%rsp), %r8
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x8fd37
movl %eax, %r15d
jmp 0x8fadd
leaq 0x1503e(%rip), %rsi     # 0xa4af7
movq %rbx, %rdi
callq 0x84a53
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x84923
xorl %r15d, %r15d
leal (%r14,%r15), %edx
addl $0x2, %edx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x8f233
movq 0x8(%rsp), %r12
movb $0x0, 0x1(%r12,%r14)
addq $0x2, %r14
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x8f2a4
testl %r15d, %r15d
je 0x8fb1e
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x8ffd2
movq %rbx, %rdi
callq 0x8f2e3
movq %rbx, %rdi
movq %r12, %rsi
callq 0x84923
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq