// File: /workspace/github_c_makefile_star2_O3/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, %r14
movl %esi, 0x4(%rsp)
testq %rdi, %rdi
je 0xe854b
movq %rdi, %rbx
movq 0x108(%rdi), %rax
testq %rax, %rax
je 0xe854b
movq %r14, %rcx
movzbl (%rcx), %edx
leal -0x1(%rdx), %esi
cmpl $0x3, %esi
jb 0xe8346
testl %edx, %edx
je 0xe8531
incq %rcx
jmp 0xe832e
movq %r14, %rdi
callq 0x180e0
movq %rax, %r15
leaq 0x1(%rax), %rsi
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
testq %r15, %r15
je 0xe84fd
movq %r15, %r8
xorl %eax, %eax
xorl %ebx, %ebx
xorl %r13d, %r13d
movq 0x8(%rsp), %rdi
movq %r15, 0x20(%rsp)
movb (%r14,%r13), %cl
leal -0x1(%rcx), %edx
cmpb $0x2, %dl
ja 0xe8422
movzbl %cl, %ebp
cmpl $0x1, %ebp
je 0xe8435
cmpl $0x3, %ebp
jne 0xe843d
leaq 0x7(%r13), %rcx
movl $0x2000, %r9d           # imm = 0x2000
movb $0x1, %r15b
cmpq %r8, %rcx
ja 0xe841b
movb 0x1(%r14,%r13), %cl
movb 0x3(%r14,%r13), %dl
shlb $0x4, %cl
movzbl 0x2(%r14,%r13), %esi
andl $0xf, %esi
movzbl %cl, %ecx
orl %esi, %ecx
shll $0x10, %ecx
shlb $0x4, %dl
movzbl 0x4(%r14,%r13), %esi
andl $0xf, %esi
movzbl %dl, %edx
orl %esi, %edx
shll $0x8, %edx
orl %ecx, %edx
movb 0x5(%r14,%r13), %cl
shlb $0x4, %cl
movzbl 0x6(%r14,%r13), %esi
andl $0xf, %esi
movzbl %cl, %ecx
orl %esi, %ecx
orl %edx, %ecx
orl $0xff000000, %ecx       # imm = 0xFF000000
movq %rcx, 0x18(%rsp)
xorl %r12d, %r12d
movl %eax, %ebp
jmp 0xe8467
incq %r13
movq 0x10(%rsp), %rdx
movb %cl, (%rdx,%rbx)
incq %rbx
jmp 0xe84d5
movl $0x1000, %r9d           # imm = 0x1000
jmp 0xe8461
cmpb $0x1, 0x1(%r14,%r13)
jne 0xe8459
testl %eax, %eax
je 0xe8459
xorl %r15d, %r15d
movb $0x1, %r12b
movl $0x1, %ebp
xorl %r9d, %r9d
jmp 0xe8467
movl $0x1100, %r9d           # imm = 0x1100
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %r15d, %r15d
testq %rbx, %rbx
je 0xe8494
movq 0x10(%rsp), %rdx
movb $0x0, (%rdx,%rbx)
movl 0x4(%rsp), %esi
movq 0x8(%rsp), %rax
movl %r9d, %ebx
callq *0x108(%rax)
movl %ebx, %r9d
movq 0x20(%rsp), %r8
movq 0x8(%rsp), %rdi
testb %r12b, %r12b
je 0xe849f
addq $0x2, %r13
jmp 0xe84d1
movq 0x110(%rdi), %rax
testq %rax, %rax
je 0xe84c3
movl 0x4(%rsp), %esi
movl %r9d, %edx
movq 0x18(%rsp), %rcx
callq *%rax
movq 0x20(%rsp), %r8
movq 0x8(%rsp), %rdi
testb %r15b, %r15b
je 0xe84ce
addq $0x7, %r13
jmp 0xe84d1
incq %r13
xorl %ebx, %ebx
movl %ebp, %eax
cmpq %r8, %r13
jb 0xe838d
testl %eax, %eax
je 0xe8504
movq 0x110(%rdi), %rax
testq %rax, %rax
je 0xe8504
movl 0x4(%rsp), %esi
movl $0x1100, %edx           # imm = 0x1100
xorl %ecx, %ecx
callq *%rax
jmp 0xe84ff
xorl %ebx, %ebx
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %r14
movb $0x0, (%r14,%rbx)
movl 0x4(%rsp), %esi
movq %r14, %rdx
callq *0x108(%rdi)
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x18030
movq %rbx, %rdi
movl 0x4(%rsp), %esi
movq %r14, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq 0xa6aa6(%rip), %rax     # 0x18eff8
movq (%rax), %rsi
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x18130