// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/deark-data.c
// Function: de_bytes_to_printable_sz
void de_bytes_to_printable_sz(const u8 *s1, i64 s1_len,
	char *s2, i64 s2_size, unsigned int conv_flags, de_ext_encoding src_ee)
{
	i64 i;
	i64 s2_pos = 0;
	de_ext_encoding src_encoding = DE_EXTENC_GET_BASE(src_ee);

	if(src_encoding!=DE_ENCODING_ASCII) {
		s2[0] = '\0';
		return;
	}

	for(i=0; i<s1_len; i++) {
		int is_printable = 0;

		if(s1[i]=='\0' && (conv_flags & DE_CONVFLAG_STOP_AT_NUL)) {
			break;
		}

		if(s1[i]>=32 && s1[i]<=126) {
			is_printable = 1;
		}

		if(is_printable) {
			if(s2_pos < s2_size-1) {
				s2[s2_pos++] = (char)s1[i];
			}
		}
		else if(conv_flags & DE_CONVFLAG_ALLOW_HL) {
			if(s2_pos < s2_size-6) {
				s2[s2_pos++] = 0x01; // DE_CODEPOINT_HL
				s2[s2_pos++] = '<';
				s2[s2_pos++] = de_get_hexcharUC((int)(s1[i]/16));
				s2[s2_pos++] = de_get_hexcharUC((int)(s1[i]%16));
				s2[s2_pos++] = '>';
				s2[s2_pos++] = 0x02; // DE_CODEPOINT_UNHL
			}
		}
		else {
			if(s2_pos < s2_size-1) {
				s2[s2_pos++] = '_';
			}
		}
	}

	s2[s2_pos] = '\0';
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movl -0x28(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x1, -0x3c(%rbp)
je 0x161af5
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
jmp 0x161ccc
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x161cc0
movl $0x0, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x161b33
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x161b33
jmp 0x161cc0
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x20, %eax
jl 0x161b5c
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x7e, %eax
jg 0x161b5c
movl $0x1, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x161b99
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jge 0x161b94
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x38(%rbp)
movb %dl, (%rax,%rcx)
jmp 0x161cad
movl -0x24(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x161c81
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
subq $0x6, %rcx
cmpq %rcx, %rax
jge 0x161c7f
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb $0x1, (%rax,%rcx)
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb $0x3c, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl %eax, %edi
callq 0x161ce0
movb %al, %dl
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x38(%rbp)
movb %dl, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl %edx, %edi
callq 0x161ce0
movb %al, %dl
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x38(%rbp)
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb $0x3e, (%rax,%rcx)
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb $0x2, (%rax,%rcx)
jmp 0x161cab
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jge 0x161ca9
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb $0x5f, (%rax,%rcx)
jmp 0x161cab
jmp 0x161cad
jmp 0x161caf
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x161afd
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movb $0x0, (%rax,%rcx)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)