// File: /workspace/github_c_makefile_star2_O3/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 0xf67f3
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 0xf69b4
testq %r15, %r15
jle 0xf6b0e
xorl %r13d, %r13d
movq %r15, 0x30(%rsp)
movb (%rbp,%r13), %r12b
movzbl %r12b, %esi
movb 0x1f(%rbx), %al
cmpb $-0x41, %sil
jg 0xf6880
testb %al, %al
je 0xf68df
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 0xf6998
movzbl 0x18(%rbx), %eax
cmpl $0x3, %ecx
je 0xf694d
cmpl $0x2, %ecx
je 0xf692a
cmpl $0x1, %ecx
jne 0xf698b
andl $0x1f, %eax
movl %eax, %ecx
shll $0x6, %ecx
movzbl 0x19(%rbx), %esi
andl $0x3f, %esi
orl %ecx, %esi
cmpb $0x2, %al
jmp 0xf6981
testb %al, %al
je 0xf68c9
movl %esi, 0x8(%rsp)
movzbl 0x1e(%rbx), %r15d
testq %r15, %r15
movq %r14, %rbp
je 0xf68b4
xorl %r14d, %r14d
movzbl 0x18(%rbx,%r14), %esi
orl $0x10000000, %esi       # imm = 0x10000000
movq %rbp, %rdi
callq 0xf6542
incq %r14
cmpq %r14, %r15
jne 0xf6898
movb $0x0, 0x1f(%rbx)
movq %rbp, %r14
movq 0x30(%rsp), %r15
movq 0x10(%rsp), %rbp
movl 0x8(%rsp), %esi
testb %r12b, %r12b
js 0xf68ea
movq %r14, %rdi
callq 0xf6542
movb $0x0, 0x1f(%rbx)
jmp 0xf6998
orl $0x10000000, %esi       # imm = 0x10000000
jmp 0xf6990
cmpb $-0x21, %r12b
ja 0xf68ff
movb %r12b, 0x18(%rbx)
movw $0x101, 0x1e(%rbx)      # imm = 0x101
jmp 0xf6998
cmpb $-0x11, %r12b
ja 0xf6914
movb %r12b, 0x18(%rbx)
movw $0x201, 0x1e(%rbx)      # imm = 0x201
jmp 0xf6998
cmpb $-0x9, %r12b
ja 0xf69a9
movb %r12b, 0x18(%rbx)
movw $0x301, 0x1e(%rbx)      # imm = 0x301
jmp 0xf6998
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 0xf6981
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 0xf6990
andl $0x7f, %eax
movl %eax, %esi
movq %r14, %rdi
callq 0xf6542
incq %r13
cmpq %r15, %r13
jne 0xf6813
jmp 0xf6b0e
orl $0x10000000, %esi       # imm = 0x10000000
jmp 0xf68ce
leal -0x3(%r13), %eax
cmpl $0x1, %eax
ja 0xf6b57
testq %r15, %r15
jle 0xf6af2
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 0xf6a0f
cmpl $0x3, %r13d
jne 0xf6a36
movq 0x8(%rsp), %rdi
callq 0xeebc4
jmp 0xf6a40
cmpb $0x4, %al
jb 0xf6ae6
cmpl $0x3, %r13d
jne 0xf6a71
movq 0x8(%rsp), %rdi
callq 0xeebc4
movq %rax, %r13
movq 0x28(%rsp), %rdi
callq 0xeebc4
jmp 0xf6a88
movq 0x8(%rsp), %rdi
callq 0xeeb5c
movl %eax, %ecx
andl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
cmpl $0xd800, %ecx           # imm = 0xD800
je 0xf6ae6
movq %r14, %rdi
cmpl $0xdc00, %ecx           # imm = 0xDC00
jne 0xf6a66
movl $0xfffd, %esi           # imm = 0xFFFD
jmp 0xf6a68
movl %eax, %esi
callq 0xf6542
xorl %eax, %eax
jmp 0xf6ae3
movq 0x8(%rsp), %rdi
callq 0xeeb5c
movq %rax, %r13
movq 0x28(%rsp), %rdi
callq 0xeeb5c
movq %rax, %rbp
andl $0xfffffc00, %eax       # imm = 0xFFFFFC00
cmpl $0xdc00, %eax           # imm = 0xDC00
je 0xf6ab7
movq %r14, %rdi
movl $0xfffd, %esi           # imm = 0xFFFD
cmpl $0xd800, %eax           # imm = 0xD800
jne 0xf6ac8
callq 0xf6542
movzwl 0x1a(%rbx), %eax
movw %ax, 0x18(%rbx)
movb $0x2, %al
jmp 0xf6ad9
shll $0xa, %r13d
leal -0x35fdc00(%r13,%rbp), %esi
movq %r14, %rdi
jmp 0xf6ad2
callq 0xf6542
movq %r14, %rdi
movl %ebp, %esi
callq 0xf6542
xorl %eax, %eax
movq 0x10(%rsp), %rbp
movq 0x20(%rsp), %r13
movb %al, 0x1f(%rbx)
incq %r12
cmpq %r12, %r15
jne 0xf69e4
testb $0x40, 0x4(%rsp)
jne 0xf6b48
cmpb $0x0, 0x1f(%rbx)
je 0xf6b48
movq %r14, %rdi
movl $0xfffd, %esi           # imm = 0xFFFD
callq 0xf6542
jmp 0xf6b44
testb $0x40, 0x4(%rsp)
jne 0xf6b48
cmpb $0x0, 0x1f(%rbx)
je 0xf6b48
movzbl 0x1e(%rbx), %r15d
testq %r15, %r15
je 0xf6b44
xorl %r12d, %r12d
movzbl 0x18(%rbx,%r12), %esi
orl $0x10000000, %esi       # imm = 0x10000000
movq %r14, %rdi
callq 0xf6542
incq %r12
cmpq %r12, %r15
jne 0xf6b28
movb $0x0, 0x1f(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x10, %r13d
jne 0xf6c9a
testq %r15, %r15
jle 0xf6c55
movq (%r14), %r13
xorl %r12d, %r12d
movb (%rbp,%r12), %cl
movzbl %cl, %eax
cmpb $0x0, 0x1e(%rbx)
je 0xf6be4
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 0x10f117
movl %eax, %ebp
testl %eax, %eax
sete %al
movl (%rsp), %esi
testl %esi, %esi
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xf6bc0
movl $0xfffd, (%rsp)         # imm = 0xFFFD
movl $0xfffd, %esi           # imm = 0xFFFD
movq %r14, %rdi
callq 0xf6542
cmpl $0x2, %ebp
jne 0xf6bd9
movl 0x1c(%rsp), %esi
movq %r14, %rdi
callq 0xf6542
movb $0x0, 0x1e(%rbx)
movq 0x10(%rsp), %rbp
jmp 0xf6c49
leal 0x7f(%rcx), %edx
cmpb $0x1f, %dl
setae %dl
leal 0x20(%rcx), %esi
cmpb $0x1d, %sil
setae %sil
testb %sil, %dl
jne 0xf6c06
movb %cl, 0x18(%rbx)
movb $0x1, 0x1e(%rbx)
jmp 0xf6c49
testb %cl, %cl
setns %dl
addb $0x5f, %cl
cmpb $0x3f, %cl
setb %cl
orb %dl, %cl
cmpb $0x1, %cl
jne 0xf6c35
movzwl %ax, %esi
movq %r13, %rdi
xorl %edx, %edx
movq %rsp, %rcx
leaq 0x1c(%rsp), %r8
callq 0x10f117
movl (%rsp), %esi
jmp 0xf6c41
movl $0xfffd, (%rsp)         # imm = 0xFFFD
movl $0xfffd, %esi           # imm = 0xFFFD
movq %r14, %rdi
callq 0xf6542
incq %r12
cmpq %r12, %r15
jne 0xf6b70
movzbl 0x1e(%rbx), %r15d
testq %r15, %r15
sete %al
movl 0x4(%rsp), %ecx
andl $0x40, %ecx
shrl $0x6, %ecx
orb %al, %cl
jne 0xf6b48
xorl %r12d, %r12d
movzbl 0x18(%rbx,%r12), %esi
orl $0x10000000, %esi       # imm = 0x10000000
movq %r14, %rdi
callq 0xf6542
incq %r12
cmpq %r12, %r15
jne 0xf6c75
movb $0x0, 0x1e(%rbx)
jmp 0xf6b48
testq %r15, %r15
jle 0xf6b48
xorl %r12d, %r12d
movzbl (%rbp,%r12), %edi
movq %rbx, %rsi
callq 0xec0ad
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
jne 0xf6cc6
movzbl (%rbp,%r12), %eax
orl $0x10000000, %eax       # imm = 0x10000000
movq %r14, %rdi
movl %eax, %esi
callq 0xf6542
incq %r12
cmpq %r12, %r15
jne 0xf6ca6
jmp 0xf6b48