// File: /workspace/github_c_makefile_star2_O1/aerospike[P]aerospike-common/src/main/aerospike/as_string_builder.c
// Function: as_string_builder_append_bytes
bool
as_string_builder_append_bytes(as_string_builder* sb, uint8_t* src, uint32_t size)
{
	if (sb->resize) {
		// Ensure buffer is large enough to receive bytes.
		// min capacity = old length + 3 chars per byte including separator + 2 bracket chars
		// - 1 extra separator + 1 null byte.
		uint32_t min_capacity = sb->length + (size * 3) + 2;

		if (min_capacity > sb->capacity) {
			if (! as_sb_increase_capacity(sb, min_capacity)) {
				return false;
			}
		}

		char* trg = &sb->data[sb->length];
		*trg++ = '[';

		for (uint32_t i = 0; i < size; i++) {
			uint8_t b = src[i];
			*trg++ = as_hex_chars[(b >> 4) & 0xf];
			*trg++ = as_hex_chars[b & 0xf];
			*trg++ = ' ';
		}
		trg--; // truncate last separator
		*trg++ = ']';
		*trg = 0;
		sb->length = (int)(trg - sb->data);
	}
	else {
		if (! as_sb_append_char(sb, '[')) {
			return false;
		}

		for (uint32_t i = 0; i < size; i++) {
			if (! as_sb_append_byte(sb, src[i])) {
				return false;
			}
		}
		sb->length--; // truncate last separator

		if (! as_sb_append_char(sb, ']')) {
			return false;
		}
	}
	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
movl 0xc(%rdi), %eax
cmpb $0x1, 0x10(%rdi)
jne 0x10bba
leal (%r15,%r15,2), %ecx
leal 0x2(%rax,%rcx), %esi
cmpl 0x8(%rbx), %esi
jbe 0x10b61
movq %rbx, %rdi
callq 0x10cb0
testb %al, %al
je 0x10ca8
movq (%rbx), %rax
movl 0xc(%rbx), %ecx
leaq 0x1(%rax,%rcx), %rax
movb $0x5b, -0x1(%rax)
testl %r15d, %r15d
je 0x10baa
movl %r15d, %ecx
movq 0xf451(%rip), %rdx      # 0x1ffd0
movzbl (%r14), %esi
movl %esi, %edi
shrl $0x4, %edi
movb (%rdx,%rdi), %dil
movb %dil, (%rax)
andl $0xf, %esi
movb (%rdx,%rsi), %sil
movb %sil, 0x1(%rax)
movb $0x20, 0x2(%rax)
addq $0x3, %rax
incq %r14
decq %rcx
jne 0x10b7f
movw $0x5d, -0x1(%rax)
subl (%rbx), %eax
movl %eax, 0xc(%rbx)
jmp 0x10ca4
leal 0x1(%rax), %ecx
cmpl 0x8(%rbx), %ecx
jae 0x10ca8
movq (%rbx), %rdx
movl %ecx, 0xc(%rbx)
movb $0x5b, (%rdx,%rax)
movq (%rbx), %rax
movl 0xc(%rbx), %ecx
movb $0x0, (%rax,%rcx)
testl %r15d, %r15d
setne %al
je 0x10c80
movl 0xc(%rbx), %edi
leal 0x3(%rdi), %ecx
cmpl 0x8(%rbx), %ecx
jae 0x10c7c
movl %r15d, %eax
leaq -0x1(%rax), %rdx
xorl %ecx, %ecx
movq 0xf3cb(%rip), %rsi      # 0x1ffd0
movzbl (%r14,%rcx), %r8d
movl %r8d, %r9d
shrl $0x4, %r9d
movb (%rsi,%r9), %r9b
movq (%rbx), %r10
leal 0x1(%rdi), %r11d
movl %r11d, 0xc(%rbx)
movl %edi, %edi
movb %r9b, (%r10,%rdi)
andl $0xf, %r8d
movb (%rsi,%r8), %dil
movq (%rbx), %r8
movl 0xc(%rbx), %r9d
leal 0x1(%r9), %r10d
movl %r10d, 0xc(%rbx)
movb %dil, (%r8,%r9)
movq (%rbx), %rdi
movl 0xc(%rbx), %r8d
leal 0x1(%r8), %r9d
movl %r9d, 0xc(%rbx)
movb $0x20, (%rdi,%r8)
movq (%rbx), %rdi
movl 0xc(%rbx), %r8d
movb $0x0, (%rdi,%r8)
cmpq %rcx, %rdx
je 0x10c80
movl 0xc(%rbx), %edi
leal 0x3(%rdi), %r8d
incq %rcx
cmpl 0x8(%rbx), %r8d
jb 0x10c05
cmpq %rax, %rcx
setb %al
testb %al, %al
jne 0x10ca8
movl 0xc(%rbx), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rbx)
cmpl 0x8(%rbx), %eax
jae 0x10ca8
movq (%rbx), %rdx
movl %eax, 0xc(%rbx)
movl %ecx, %eax
movb $0x5d, (%rdx,%rax)
movq (%rbx), %rax
movl 0xc(%rbx), %ecx
movb $0x0, (%rax,%rcx)
movb $0x1, %al
jmp 0x10caa
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq