// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/deark-util.c
// Function: de_finfo_set_name_internal
static void de_finfo_set_name_internal(deark *c, de_finfo *fi, de_ucstring *s,
	unsigned int flags)
{
	i64 i;
	int allow_slashes;

	fi->orig_name_was_dot = 0;

	if(fi->file_name_internal) {
		ucstring_destroy(fi->file_name_internal);
		fi->file_name_internal = NULL;
	}
	if(!s) return;

	fi->file_name_internal = s;

	if((flags&DE_SNFLAG_STRIPTRAILINGSLASH) && s->len>0 && s->str[s->len-1]=='/') {
		ucstring_truncate(s, s->len-1);
	}

	if((flags&DE_SNFLAG_FULLPATH)) {
		// This part changes a name like "/a/b.c" to "a/b.c", which is probably
		// better than allowing it to be changed later to "_a/b.c".
		// TODO: I'm undecided about what to do about absolute paths when writing
		// to a zip file. We could leave them there (using an option), or delete
		// them, or prepend ".". Could have special cases if there are two
		/// leading slashes, of if the entire name is "/".
		maybe_delete_leading_slash(s);
	}

	allow_slashes = (c->allow_subdirs && (flags&DE_SNFLAG_FULLPATH));

	if(allow_slashes && s->len==1 && s->str[0]=='.') {
		// Remember that this file was named ".", which can be a valid subdir
		// name in some cases (but at this point we don't even know whether it
		// is a directory).
		fi->orig_name_was_dot = 1;
	}

	for(i=0; i<s->len; i++) {
		if(s->str[i]=='/' && allow_slashes) {
			continue;
		}
		s->str[i] = de_char_to_valid_fn_char(c, s->str[i]);
	}

	ucstring_strip_trailing_spaces(s);

	sanitize_filename1(c, s);

	if(allow_slashes) {
		sanitize_filename2(c, s);
	}

	// Don't allow empty filenames.
	if(s->len<1) {
		ucstring_append_sz(s, "_", DE_ENCODING_LATIN1);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, 0xd(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x15d340
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x171750
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0x18(%rbp)
jne 0x15d34c
jmp 0x15d4b5
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x1c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x15d39c
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jle 0x15d39c
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq $0x1, %rcx
cmpl $0x2f, (%rax,%rcx,4)
jne 0x15d39c
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
subq $0x1, %rsi
callq 0x171230
movl -0x1c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x15d3b0
movq -0x18(%rbp), %rdi
callq 0x15fd20
movq -0x8(%rbp), %rax
movzbl 0x89(%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x2d(%rbp)
je 0x15d3d4
movl -0x1c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x2d(%rbp)
movb -0x2d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x15d405
movq -0x18(%rbp), %rax
cmpq $0x1, 0x10(%rax)
jne 0x15d405
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x2e, (%rax)
jne 0x15d405
movq -0x10(%rbp), %rax
movb $0x1, 0xd(%rax)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x15d46c
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
cmpl $0x2f, (%rax,%rcx,4)
jne 0x15d435
cmpl $0x0, -0x2c(%rbp)
je 0x15d435
jmp 0x15d45e
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x15fd70
movl %eax, %edx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x15d40d
movq -0x18(%rbp), %rdi
callq 0x171360
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15fdf0
cmpl $0x0, -0x2c(%rbp)
je 0x15d495
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15fe60
movq -0x18(%rbp), %rax
cmpq $0x1, 0x10(%rax)
jge 0x15d4b5
movq -0x18(%rbp), %rdi
leaq 0x5955b(%rip), %rsi     # 0x1b6a06
movl $0x5, %edx
callq 0x1715e0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)