// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/deark-png.c
// Function: do_generate_png
static int do_generate_png(struct deark_png_encode_info *pei, const u8 *src_pixels)
{
	static const u8 pngsig[8] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a };
	dbuf *cdbuf = NULL;
	int retval = 0;

	// A membuf that we'll use and reuse for each chunk's data
	cdbuf = dbuf_create_membuf(pei->c, 64, 0);

	dbuf_write(pei->outf, pngsig, 8);

	write_png_chunk_IHDR(pei, cdbuf);

	if(pei->linear_colorspace) {
		dbuf_truncate(cdbuf, 0);
		write_png_chunk_gAMA_linear(pei, cdbuf);
	}

	if(pei->has_phys) {
		dbuf_truncate(cdbuf, 0);
		write_png_chunk_pHYs(pei, cdbuf);
	}

	if(pei->internal_mod_time.is_valid && pei->c->preserve_file_times_internal) {
		dbuf_truncate(cdbuf, 0);
		write_png_chunk_tIME(pei, cdbuf);
	}

	if(pei->has_hotspot) {
		dbuf_truncate(cdbuf, 0);
		write_png_chunk_htSP(pei, cdbuf);
	}

	if(pei->include_text_chunk_software) {
		dbuf_truncate(cdbuf, 0);
		write_png_chunk_tEXt(pei, cdbuf, "Software", "Deark");
	}

	dbuf_truncate(cdbuf, 0);
	if(!write_png_chunk_IDATs(pei, cdbuf)) goto done;

	dbuf_truncate(cdbuf, 0);
	write_png_chunk_from_cdbuf(pei, cdbuf, CODE_IEND);
	retval = 1;

done:
	dbuf_close(cdbuf);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl $0x40, %esi
xorl %edx, %edx
callq 0x168020
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x429cb(%rip), %rsi     # 0x1dda20
movl $0x8, %edx
callq 0x166170
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x19b1a0
movq -0x8(%rbp), %rax
cmpb $0x0, 0x49(%rax)
je 0x19b090
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x168900
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x19b260
movq -0x8(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
je 0x19b0b4
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x168900
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x19b2a0
movq -0x8(%rbp), %rax
movzbl 0x50(%rax), %eax
cmpl $0x0, %eax
je 0x19b0ee
movq -0x8(%rbp), %rax
movq (%rax), %rax
movzbl 0xde(%rax), %eax
cmpl $0x0, %eax
je 0x19b0ee
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x168900
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x19b300
movq -0x8(%rbp), %rax
cmpb $0x0, 0x61(%rax)
je 0x19b112
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x168900
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x19b3a0
movq -0x8(%rbp), %rax
cmpb $0x0, 0x60(%rax)
je 0x19b144
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x168900
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0x2e726(%rip), %rdx     # 0x1c985e
leaq 0x3b7b6(%rip), %rcx     # 0x1d68f5
callq 0x19b400
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x168900
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x19b480
cmpl $0x0, %eax
jne 0x19b165
jmp 0x19b18b
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x168900
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x49454e44, %edx       # imm = 0x49454E44
callq 0x19b690
movl $0x1, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1676a0
movl -0x1c(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)