// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/deark-ucstring.c
// Function: ucstring_append_bytes_ex
void ucstring_append_bytes_ex(de_ucstring *s, const u8 *buf, i64 buflen,
	unsigned int conv_flags, struct de_encconv_state *es)
{
	de_encoding encoding = es->enc;

	// Adjust buflen if necessary.
	if(conv_flags & DE_CONVFLAG_STOP_AT_NUL) {
		char *tmpp;
		tmpp = de_memchr(buf, 0, (size_t)buflen);
		if(tmpp) {
			buflen = (const u8*)tmpp - buf;
		}
	}

	if(encoding==DE_ENCODING_UTF8) {
		append_bytes_utf8(s, buf, buflen, conv_flags, es);
	}
	else if(encoding==DE_ENCODING_UTF16LE || encoding==DE_ENCODING_UTF16BE) {
		append_bytes_utf16(s, buf, buflen, conv_flags, es, (encoding==DE_ENCODING_UTF16LE));
	}
	else if(encoding==DE_ENCODING_CP932) {
		append_bytes_cp932(s->c, s, buf, buflen, conv_flags, es);
	}
	else {
		i64 pos;

		for(pos=0; pos<buflen; pos++) {
			i32 ch;

			ch = de_char_to_unicode_ex(buf[pos], es);
			if(ch==DE_CODEPOINT_INVALID) {
				handle_invalid_byte(s, buf[pos]);
			}
			else {
				ucstring_append_char(s, ch);
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %rbx
movq %rdx, %r15
movq %rsi, %rbp
movq %rdi, %r14
movl (%r8), %r13d
movl %ecx, 0x4(%rsp)
testb $0x1, %cl
je 0xf6c50
movq %rbp, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x18150
movq %rax, %rcx
subq %rbp, %rcx
testq %rax, %rax
cmovneq %rcx, %r15
cmpl $0x2, %r13d
movq %rbp, 0x10(%rsp)
jne 0xf6e11
testq %r15, %r15
jle 0xf6f73
xorl %r13d, %r13d
movq %r15, 0x30(%rsp)
movb (%rbp,%r13), %r12b
movzbl %r12b, %esi
movb 0x1f(%rbx), %al
cmpb $-0x41, %sil
jg 0xf6cdd
testb %al, %al
je 0xf6d3c
movzbl 0x1e(%rbx), %eax
movb %r12b, 0x18(%rbx,%rax)
movzbl 0x1e(%rbx), %ecx
leal 0x1(%rcx), %eax
movb %al, 0x1e(%rbx)
decb 0x1f(%rbx)
jne 0xf6df5
movzbl 0x18(%rbx), %eax
cmpl $0x3, %ecx
je 0xf6daa
cmpl $0x2, %ecx
je 0xf6d87
cmpl $0x1, %ecx
jne 0xf6de8
andl $0x1f, %eax
movl %eax, %ecx
shll $0x6, %ecx
movzbl 0x19(%rbx), %esi
andl $0x3f, %esi
orl %ecx, %esi
cmpb $0x2, %al
jmp 0xf6dde
testb %al, %al
je 0xf6d26
movl %esi, 0x8(%rsp)
movzbl 0x1e(%rbx), %r15d
testq %r15, %r15
movq %r14, %rbp
je 0xf6d11
xorl %r14d, %r14d
movzbl 0x18(%rbx,%r14), %esi
orl $0x10000000, %esi       # imm = 0x10000000
movq %rbp, %rdi
callq 0xf69a2
incq %r14
cmpq %r14, %r15
jne 0xf6cf5
movb $0x0, 0x1f(%rbx)
movq %rbp, %r14
movq 0x30(%rsp), %r15
movq 0x10(%rsp), %rbp
movl 0x8(%rsp), %esi
testb %r12b, %r12b
js 0xf6d47
movq %r14, %rdi
callq 0xf69a2
movb $0x0, 0x1f(%rbx)
jmp 0xf6df5
orl $0x10000000, %esi       # imm = 0x10000000
jmp 0xf6ded
cmpb $-0x21, %r12b
ja 0xf6d5c
movb %r12b, 0x18(%rbx)
movw $0x101, 0x1e(%rbx)      # imm = 0x101
jmp 0xf6df5
cmpb $-0x11, %r12b
ja 0xf6d71
movb %r12b, 0x18(%rbx)
movw $0x201, 0x1e(%rbx)      # imm = 0x201
jmp 0xf6df5
cmpb $-0x9, %r12b
ja 0xf6e06
movb %r12b, 0x18(%rbx)
movw $0x301, 0x1e(%rbx)      # imm = 0x301
jmp 0xf6df5
andl $0xf, %eax
movzbl 0x19(%rbx), %ecx
andl $0x3f, %ecx
shll $0xc, %eax
shll $0x6, %ecx
orl %eax, %ecx
movzbl 0x1a(%rbx), %esi
andl $0x3f, %esi
orl %ecx, %esi
cmpl $0x800, %ecx            # imm = 0x800
jmp 0xf6dde
andl $0x7, %eax
movzbl 0x19(%rbx), %ecx
andl $0x3f, %ecx
shll $0xc, %eax
shll $0x6, %ecx
leal (%rcx,%rax), %edx
movzbl 0x1a(%rbx), %edi
andl $0x3f, %edi
orl %edx, %edi
shll $0x6, %edi
movzbl 0x1b(%rbx), %esi
andl $0x3f, %esi
orl %edi, %esi
addl %ecx, %eax
addl $0xffffbc00, %eax       # imm = 0xFFFFBC00
cmpl $0xffffc000, %eax       # imm = 0xFFFFC000
movl $0xfffd, %eax           # imm = 0xFFFD
cmovbl %eax, %esi
jmp 0xf6ded
andl $0x7f, %eax
movl %eax, %esi
movq %r14, %rdi
callq 0xf69a2
incq %r13
cmpq %r15, %r13
jne 0xf6c70
jmp 0xf6f73
orl $0x10000000, %esi       # imm = 0x10000000
jmp 0xf6d2b
leal -0x3(%r13), %eax
cmpl $0x1, %eax
ja 0xf6fbc
testq %r15, %r15
jle 0xf6f57
leaq 0x18(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x1a(%rbx), %rax
movq %rax, 0x28(%rsp)
xorl %r12d, %r12d
movq %r13, 0x20(%rsp)
movb (%rbp,%r12), %al
movzbl 0x1f(%rbx), %ecx
movb %al, 0x18(%rbx,%rcx)
movb 0x1f(%rbx), %al
incb %al
movb %al, 0x1f(%rbx)
cmpb $0x2, %al
jne 0xf6e6c
cmpl $0x3, %r13d
jne 0xf6e86
movq 0x8(%rsp), %rdi
callq 0xef1c6
jmp 0xf6e90
cmpb $0x4, %al
jb 0xf6f4b
cmpl $0x3, %r13d
jne 0xf6ec4
movq 0x8(%rsp), %rdi
callq 0xef1c6
jmp 0xf6ece
movq 0x8(%rsp), %rdi
callq 0xef15e
movl %eax, %ecx
andl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
cmpl $0xd800, %ecx           # imm = 0xD800
je 0xf6f4b
movq %r14, %rdi
cmpl $0xdc00, %ecx           # imm = 0xDC00
jne 0xf6eb6
movl $0xfffd, %esi           # imm = 0xFFFD
jmp 0xf6eb8
movl %eax, %esi
callq 0xf69a2
xorl %eax, %eax
jmp 0xf6f48
movq 0x8(%rsp), %rdi
callq 0xef15e
movq %rax, %rbp
cmpl $0x3, %r13d
jne 0xf6ee3
movq 0x28(%rsp), %rdi
callq 0xef1c6
jmp 0xf6eed
movq 0x28(%rsp), %rdi
callq 0xef15e
movq %rax, %r13
andl $0xfffffc00, %eax       # imm = 0xFFFFFC00
cmpl $0xdc00, %eax           # imm = 0xDC00
je 0xf6f1c
movq %r14, %rdi
movl $0xfffd, %esi           # imm = 0xFFFD
cmpl $0xd800, %eax           # imm = 0xD800
jne 0xf6f2c
callq 0xf69a2
movzwl 0x1a(%rbx), %eax
movw %ax, 0x18(%rbx)
movb $0x2, %al
jmp 0xf6f3e
shll $0xa, %ebp
leal -0x35fdc00(%rbp,%r13), %esi
movq %r14, %rdi
jmp 0xf6f37
callq 0xf69a2
movq %r14, %rdi
movl %r13d, %esi
callq 0xf69a2
xorl %eax, %eax
movq 0x10(%rsp), %rbp
movq 0x20(%rsp), %r13
movb %al, 0x1f(%rbx)
incq %r12
cmpq %r12, %r15
jne 0xf6e41
testb $0x40, 0x4(%rsp)
jne 0xf6fad
cmpb $0x0, 0x1f(%rbx)
je 0xf6fad
movq %r14, %rdi
movl $0xfffd, %esi           # imm = 0xFFFD
callq 0xf69a2
jmp 0xf6fa9
testb $0x40, 0x4(%rsp)
jne 0xf6fad
cmpb $0x0, 0x1f(%rbx)
je 0xf6fad
movzbl 0x1e(%rbx), %r15d
testq %r15, %r15
je 0xf6fa9
xorl %r12d, %r12d
movzbl 0x18(%rbx,%r12), %esi
orl $0x10000000, %esi       # imm = 0x10000000
movq %r14, %rdi
callq 0xf69a2
incq %r12
cmpq %r12, %r15
jne 0xf6f8d
movb $0x0, 0x1f(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x10, %r13d
jne 0xf70ee
testq %r15, %r15
jle 0xf70a9
movq (%r14), %r13
xorl %r12d, %r12d
movb (%rbp,%r12), %cl
movzbl %cl, %eax
cmpb $0x0, 0x1e(%rbx)
je 0xf703d
movl 0x18(%rbx), %ecx
shll $0x8, %ecx
movzwl %ax, %eax
orl %ecx, %eax
movzwl %ax, %esi
movq %r13, %rdi
xorl %edx, %edx
movq %rsp, %rcx
leaq 0x1c(%rsp), %r8
callq 0x10f19f
movl %eax, %ebp
testl %eax, %eax
je 0xf700f
cmpl $0x0, (%rsp)
jne 0xf7016
movl $0xfffd, (%rsp)         # imm = 0xFFFD
movl (%rsp), %esi
movq %r14, %rdi
callq 0xf69a2
cmpl $0x2, %ebp
jne 0xf7032
movl 0x1c(%rsp), %esi
movq %r14, %rdi
callq 0xf69a2
movb $0x0, 0x1e(%rbx)
movq 0x10(%rsp), %rbp
jmp 0xf709d
leal 0x7f(%rcx), %edx
cmpb $0x1f, %dl
setae %dl
leal 0x20(%rcx), %esi
cmpb $0x1d, %sil
setae %sil
testb %sil, %dl
jne 0xf705f
movb %cl, 0x18(%rbx)
movb $0x1, 0x1e(%rbx)
jmp 0xf709d
testb %cl, %cl
setns %dl
addb $0x5f, %cl
cmpb $0x3f, %cl
setb %cl
orb %dl, %cl
cmpb $0x1, %cl
jne 0xf708b
movzwl %ax, %esi
movq %r13, %rdi
xorl %edx, %edx
movq %rsp, %rcx
leaq 0x1c(%rsp), %r8
callq 0x10f19f
jmp 0xf7092
movl $0xfffd, (%rsp)         # imm = 0xFFFD
movl (%rsp), %esi
movq %r14, %rdi
callq 0xf69a2
incq %r12
cmpq %r12, %r15
jne 0xf6fd5
movzbl 0x1e(%rbx), %r15d
testq %r15, %r15
sete %al
movl 0x4(%rsp), %ecx
andl $0x40, %ecx
shrl $0x6, %ecx
orb %al, %cl
jne 0xf6fad
xorl %r12d, %r12d
movzbl 0x18(%rbx,%r12), %esi
orl $0x10000000, %esi       # imm = 0x10000000
movq %r14, %rdi
callq 0xf69a2
incq %r12
cmpq %r12, %r15
jne 0xf70c9
movb $0x0, 0x1e(%rbx)
jmp 0xf6fad
testq %r15, %r15
jle 0xf6fad
xorl %r12d, %r12d
movzbl (%rbp,%r12), %edi
movq %rbx, %rsi
callq 0xec6fd
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
jne 0xf711a
movzbl (%rbp,%r12), %eax
orl $0x10000000, %eax       # imm = 0x10000000
movq %r14, %rdi
movl %eax, %esi
callq 0xf69a2
incq %r12
cmpq %r12, %r15
jne 0xf70fa
jmp 0xf6fad