// File: /workspace/github_c_makefile_star2_O1/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, 0xc(%rsp)
testq %rdi, %rdi
je 0xe915a
movq %rdi, %rbx
movq 0x108(%rdi), %rax
testq %rax, %rax
je 0xe915a
movq %r14, %rcx
movzbl (%rcx), %edx
leal -0x1(%rdx), %esi
cmpl $0x3, %esi
jb 0xe8f2b
testl %edx, %edx
je 0xe9140
incq %rcx
jmp 0xe8f13
movq %r14, %rdi
callq 0x180e0
movq %rax, %r12
leaq 0x1(%rax), %rsi
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
callq 0xe969b
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
testq %r12, %r12
je 0xe90e8
movl $0x0, 0x4(%rsp)
xorl %ebx, %ebx
xorl %r13d, %r13d
movq 0x10(%rsp), %rdi
movb (%r14,%r13), %al
leal -0x1(%rax), %ecx
cmpb $0x2, %cl
ja 0xe8fc4
movzbl %al, %eax
movl $0x1000, %ebp           # imm = 0x1000
cmpl $0x1, %eax
je 0xe9050
cmpl $0x3, %eax
je 0xe8fe1
cmpl $0x2, %eax
jne 0xe9059
cmpb $0x1, 0x1(%r14,%r13)
jne 0xe8fd7
cmpl $0x0, 0x4(%rsp)
je 0xe8fd7
movl $0x0, 0x8(%rsp)
movb $0x1, %r15b
movl $0x1, 0x4(%rsp)
xorl %ebp, %ebp
jmp 0xe9071
incq %r13
movq 0x18(%rsp), %rcx
movb %al, (%rcx,%rbx)
incq %rbx
jmp 0xe90c1
cmpl $0x1, %eax
je 0xe9050
cmpl $0x3, %eax
jne 0xe9059
leaq 0x7(%r13), %rax
movl $0x2000, %ebp           # imm = 0x2000
movb $0x1, %cl
movl %ecx, 0x8(%rsp)
cmpq %r12, %rax
ja 0xe904b
movb 0x1(%r14,%r13), %al
movb 0x3(%r14,%r13), %cl
shlb $0x4, %al
movzbl 0x2(%r14,%r13), %edx
andl $0xf, %edx
movzbl %al, %eax
orl %edx, %eax
shll $0x10, %eax
shlb $0x4, %cl
movzbl 0x4(%r14,%r13), %edx
andl $0xf, %edx
movzbl %cl, %ecx
orl %edx, %ecx
shll $0x8, %ecx
orl %eax, %ecx
movb 0x5(%r14,%r13), %al
shlb $0x4, %al
movzbl 0x6(%r14,%r13), %edx
andl $0xf, %edx
movzbl %al, %eax
orl %edx, %eax
orl %ecx, %eax
orl $0xff000000, %eax       # imm = 0xFF000000
movq %rax, 0x20(%rsp)
xorl %r15d, %r15d
jmp 0xe9071
xorl %r15d, %r15d
movl %eax, 0x4(%rsp)
jmp 0xe9069
movl $0x1100, %ebp           # imm = 0x1100
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
movl $0x0, 0x8(%rsp)
testq %rbx, %rbx
je 0xe9093
movq 0x18(%rsp), %rdx
movb $0x0, (%rdx,%rbx)
movl 0xc(%rsp), %esi
movq 0x10(%rsp), %rax
callq *0x108(%rax)
movq 0x10(%rsp), %rdi
testb %r15b, %r15b
jne 0xe90bb
movq 0x110(%rdi), %rax
testq %rax, %rax
je 0xe90b6
movl 0xc(%rsp), %esi
movl %ebp, %edx
movq 0x20(%rsp), %rcx
callq *%rax
movq 0x10(%rsp), %rdi
testb %r15b, %r15b
je 0xe90cc
addq $0x2, %r13
xorl %ebx, %ebx
cmpq %r12, %r13
jb 0xe8f70
jmp 0xe90de
cmpb $0x0, 0x8(%rsp)
je 0xe90d9
addq $0x7, %r13
jmp 0xe90bf
incq %r13
jmp 0xe90bf
cmpl $0x0, 0x4(%rsp)
sete %al
jmp 0xe90f1
movb $0x1, %al
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
testb %al, %al
jne 0xe9113
movq 0x110(%rdi), %rax
testq %rax, %rax
je 0xe9113
movl 0xc(%rsp), %esi
movl $0x1100, %edx           # imm = 0x1100
xorl %ecx, %ecx
callq *%rax
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r14
movb $0x0, (%r14,%rbx)
movl 0xc(%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 0xc(%rsp), %esi
movq %r14, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq 0xa5e97(%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