// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/deark-zip.c
// Function: de_zip_create_file
int de_zip_create_file(deark *c)
{
	struct zipw_ctx *zzz;
	const char *opt_level;

	if(c->zip_data) return 1; // Already created. Shouldn't happen.

	zzz = de_malloc(c, sizeof(struct zipw_ctx));
	zzz->c = c;
	c->zip_data = (void*)zzz;
	zzz->crc32o = de_crcobj_create(c, DE_CRCOBJ_CRC32_IEEE);

	zzz->cmprlevel = MZ_BEST_COMPRESSION; // default
	opt_level = de_get_ext_option(c, "archive:zipcmprlevel");
	if(opt_level) {
		i64 opt_level_n = de_atoi64(opt_level);
		if(opt_level_n>9) {
			zzz->cmprlevel = 9;
		}
		else if(opt_level_n<0) {
			zzz->cmprlevel = MZ_DEFAULT_LEVEL;
		}
		else {
			zzz->cmprlevel = (unsigned int)opt_level_n;
		}
	}

	if(c->archive_to_stdout) {
		zzz->pFilename = "[stdout]";
	}
	else {
		if(c->output_archive_filename) {
			zzz->pFilename = c->output_archive_filename;
		}
		else {
			zzz->pFilename = "output.zip";
		}
	}

	if(c->archive_to_stdout) {
		zzz->outf = dbuf_create_unmanaged_file_stdout(c, "[ZIP stdout stream]");
	}
	else {
		de_info(c, "Creating %s", zzz->pFilename);
		zzz->outf = dbuf_create_unmanaged_file(c, zzz->pFilename, c->overwrite_mode, 0);
	}

	zzz->cdir = dbuf_create_membuf(c, 1024, 0);

	if(zzz->outf->btype==DBUF_TYPE_NULL) {
		de_err(c, "Failed to create ZIP file");
		dbuf_close(zzz->outf);
		zzz->outf = NULL;
		return 0;
	}

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x138(%rax)
je 0x162336
movl $0x1, -0x4(%rbp)
jmp 0x162508
movq -0x10(%rbp), %rdi
movl $0x38, %esi
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x138(%rax)
movq -0x10(%rbp), %rdi
movl $0x10, %esi
callq 0x15eac0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x18(%rbp), %rax
movl $0x9, 0x10(%rax)
movq -0x10(%rbp), %rdi
leaq 0x7271a(%rip), %rsi     # 0x1d4aab
callq 0x15cb30
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1623e7
movq -0x20(%rbp), %rdi
callq 0x15ccc0
movq %rax, -0x28(%rbp)
cmpq $0x9, -0x28(%rbp)
jle 0x1623c2
movq -0x18(%rbp), %rax
movl $0x9, 0x10(%rax)
jmp 0x1623e5
cmpq $0x0, -0x28(%rbp)
jge 0x1623d6
movq -0x18(%rbp), %rax
movl $0x6, 0x10(%rax)
jmp 0x1623e3
movq -0x28(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
jmp 0x1623e5
jmp 0x1623e7
movq -0x10(%rbp), %rax
cmpb $0x0, 0x88(%rax)
je 0x162405
movq -0x18(%rbp), %rax
leaq 0x72a81(%rip), %rcx     # 0x1d4e80
movq %rcx, 0x8(%rax)
jmp 0x162439
movq -0x10(%rbp), %rax
cmpq $0x0, 0x160(%rax)
je 0x162428
movq -0x10(%rbp), %rax
movq 0x160(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x162437
movq -0x18(%rbp), %rax
leaq 0x7268d(%rip), %rcx     # 0x1d4ac0
movq %rcx, 0x8(%rax)
jmp 0x162439
movq -0x10(%rbp), %rax
cmpb $0x0, 0x88(%rax)
je 0x162463
movq -0x10(%rbp), %rdi
leaq 0x7267a(%rip), %rsi     # 0x1d4acb
callq 0x167b10
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x1624a5
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x72669(%rip), %rsi     # 0x1d4adf
movb $0x0, %al
callq 0x15c0c0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movl 0xd8(%rax), %edx
xorl %ecx, %ecx
callq 0x1679e0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rdi
movl $0x400, %esi            # imm = 0x400
xorl %edx, %edx
callq 0x168020
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
cmpl $0x0, (%rax)
jne 0x162501
movq -0x10(%rbp), %rdi
leaq 0x72613(%rip), %rsi     # 0x1d4aeb
movb $0x0, %al
callq 0x15bfb0
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1676a0
movq -0x18(%rbp), %rax
movq $0x0, 0x20(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x162508
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)