// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/src/deark-util.c
// Function: de_puts
void de_puts(deark *c, unsigned int flags, const char *s)
{
	size_t k;

	if(!c || !c->msgfn) {
		fputs(s, stderr);
		return;
	}

	// Scan the printable string for "magic" byte sequences that represent
	// text color changes, etc. It's admittedly a little ugly that we have to
	// do this.
	//
	// We could invent and use any byte sequences we want for this, as long as
	// they will not otherwise occur in "printable" output.
	// I.e., if it's valid UTF-8, it must contain a character we classify as
	// "nonprintable". We could even use actual ANSI escape sequences, since
	// Esc is a nonprintable character (but that would have little benefit,
	// and feel kinda wrong, since this part of the code isn't supposed to
	// know about ANSI escape sequences).
	// Short sequences are preferable, because they're simpler to detect, and
	// because these bytes count against some of our size limits.
	// Valid UTF-8 is probably best, because someday we might want this scheme
	// to be compatible with something else (such as ucstrings).
	// So, we're simply using:
	//   U+0001 : DE_CODEPOINT_HL
	//   U+0002 : DE_CODEPOINT_UNHL
	//   U+0003 : DE_CODEPOINT_RGBSAMPLE (followed by 6 bytes for the RGB color)

	for(k=0; s[k]; k++) {
		if(s[k]=='\x01' || s[k]=='\x02' || s[k]=='\x03') {
			de_puts_advanced(c, flags, s);
			return;
		}
	}

	c->msgfn(c, flags, s);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbp
testq %rdi, %rdi
je 0xde7bb
movq %rdi, %rbx
movq 0x108(%rdi), %rax
testq %rax, %rax
je 0xde7bb
movl %esi, %r14d
movq %rbp, %rcx
movzbl (%rcx), %edx
leal -0x1(%rdx), %esi
cmpl $0x3, %esi
jb 0xde5b2
testl %edx, %edx
je 0xde7a2
incq %rcx
jmp 0xde59a
movq %rbp, %rdi
callq 0x180e0
movq %rax, %r12
leaq 0x1(%rax), %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r15
addq $0x6, %rbp
xorl %r13d, %r13d
xorl %eax, %eax
movl $0x0, 0x14(%rsp)
movq %rbp, 0x18(%rsp)
movq %rbp, %rcx
addq %r13, %rcx
xorl %ebp, %ebp
movq %r13, %rdx
addq %rbp, %rdx
cmpq %r12, %rdx
jae 0xde759
movb -0x6(%rcx,%rbp), %dl
leal -0x1(%rdx), %esi
cmpb $0x2, %sil
jbe 0xde60f
movb %dl, (%r15,%rbp)
incq %rbp
jmp 0xde5ea
movl %r14d, 0xc(%rsp)
movzbl %dl, %r14d
cmpl $0x1, %r14d
je 0xde69b
cmpl $0x3, %r14d
jne 0xde6a3
leaq 0x7(,%rbp), %rdx
addq %r13, %rdx
movl $0x2000, %r8d           # imm = 0x2000
movb $0x1, %sil
movl %esi, 0x10(%rsp)
cmpq %r12, %rdx
ja 0xde694
movb -0x5(%rbp,%rcx), %dl
shlb $0x4, %dl
movzbl -0x4(%rbp,%rcx), %esi
andl $0xf, %esi
movzbl %dl, %edx
orl %esi, %edx
shll $0x10, %edx
movb -0x3(%rbp,%rcx), %sil
shlb $0x4, %sil
movzbl -0x2(%rbp,%rcx), %edi
andl $0xf, %edi
movzbl %sil, %esi
orl %edi, %esi
shll $0x8, %esi
orl %edx, %esi
movb -0x1(%rbp,%rcx), %dl
shlb $0x4, %dl
movzbl (%rbp,%rcx), %ecx
andl $0xf, %ecx
movzbl %dl, %edx
orl %ecx, %edx
orl %esi, %edx
orl $0xff000000, %edx       # imm = 0xFF000000
movl %edx, 0x14(%rsp)
xorl %ecx, %ecx
movl %eax, %r14d
jmp 0xde6d4
movl $0x1000, %r8d           # imm = 0x1000
jmp 0xde6ca
cmpb $0x1, -0x5(%rbp,%rcx)
jne 0xde6c1
testl %eax, %eax
je 0xde6c1
movl $0x0, 0x10(%rsp)
movb $0x1, %cl
pushq $0x1
popq %r14
xorl %r8d, %r8d
jmp 0xde6d4
movl $0x1100, %r8d           # imm = 0x1100
xorl %r14d, %r14d
xorl %ecx, %ecx
movl $0x0, 0x10(%rsp)
testq %rbp, %rbp
je 0xde708
movb $0x0, (%r15,%rbp)
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movq %r15, %rdx
movl %r14d, 0x24(%rsp)
movl %r8d, 0x20(%rsp)
movl %ecx, %r14d
callq *0x108(%rbx)
movl %r14d, %ecx
movl 0x20(%rsp), %r8d
movl 0x24(%rsp), %r14d
testb %cl, %cl
je 0xde715
addq %rbp, %r13
addq $0x2, %r13
jmp 0xde747
movq 0x110(%rbx), %rax
testq %rax, %rax
je 0xde731
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl %r8d, %edx
movl 0x14(%rsp), %ecx
callq *%rax
cmpb $0x0, 0x10(%rsp)
je 0xde741
addq %rbp, %r13
addq $0x7, %r13
jmp 0xde747
addq %rbp, %r13
incq %r13
movl %r14d, %eax
movl 0xc(%rsp), %r14d
movq 0x18(%rsp), %rbp
jmp 0xde5e2
testl %eax, %eax
je 0xde778
movq 0x110(%rbx), %rax
testq %rax, %rax
je 0xde778
movq %rbx, %rdi
movl %r14d, %esi
movl $0x1100, %edx           # imm = 0x1100
xorl %ecx, %ecx
callq *%rax
movb $0x0, (%r15,%rbp)
movq %rbx, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq *0x108(%rbx)
movq %r15, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x18030
movq %rbx, %rdi
movl %r14d, %esi
movq %rbp, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq 0xb3836(%rip), %rax     # 0x191ff8
movq (%rax), %rsi
movq %rbp, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x18130