// File: /workspace/github_c_makefile_star2_O2/liuhaotian[P]xmppsh/libstrophe/src/sasl.c
// Function: add_key
static char *_add_key(xmpp_ctx_t *ctx, hash_t *table, const char *key, 
		      char *buf, int *len, int quote)
{
    int olen,nlen;
    int keylen, valuelen;
    const char *value, *qvalue;
    char *c;

    /* allocate a zero-length string if necessary */
    if (buf == NULL) {
	buf = xmpp_alloc(ctx, 1);
	buf[0] = '\0';
    }
    if (buf == NULL) return NULL;

    /* get current string length */
    olen = strlen(buf);
    value = hash_get(table, key);
    if (value == NULL) {
	xmpp_error(ctx, "SASL", "couldn't retrieve value for '%s'", key);
	value = "";
    }
    if (quote) {
	qvalue = _make_quoted(ctx, value);
    } else {
	qvalue = value;
    }
    /* added length is key + '=' + value */
    /*   (+ ',' if we're not the first entry   */
    keylen = strlen(key);
    valuelen = strlen(qvalue);
    nlen = (olen ? 1 : 0) + keylen + 1 + valuelen + 1;
    buf = xmpp_realloc(ctx, buf, olen+nlen);

    if (buf != NULL) {
	c = buf + olen;
	if (olen) *c++ = ',';
	memcpy(c, key, keylen); c += keylen;
	*c++ = '=';
	memcpy(c, qvalue, valuelen); c += valuelen;
	*c++ = '\0';
    }

    if (quote) xmpp_free(ctx, (char *)qvalue);

    return buf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, 0xc(%rsp)
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %rbp
testq %rcx, %rcx
jne 0x8057
pushq $0x1
popq %rsi
movq %rbp, %rdi
callq 0x518f
movq %rax, %r12
movb $0x0, (%rax)
movq %r12, %rdi
callq 0x2180
movq %rax, %r13
movq %rbx, %rdi
movq %r14, %rsi
callq 0x657f
movq %rax, %r15
testq %rax, %rax
jne 0x8097
leaq 0x4d4a(%rip), %rsi      # 0xcdc6
leaq 0x4dfd(%rip), %rdx      # 0xce80
movq %rbp, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x52aa
leaq 0x3ff4(%rip), %r15      # 0xc08b
cmpl $0x0, 0xc(%rsp)
movq %rbp, 0x10(%rsp)
je 0x8122
movq %r15, %rdi
callq 0x2180
movq %rax, %rbx
shlq $0x20, %rbx
movabsq $0x300000000, %rsi      # imm = 0x300000000
addq %rbx, %rsi
sarq $0x20, %rsi
movq %rbp, %rdi
callq 0x518f
testq %rax, %rax
je 0x811f
movq %rax, %rbp
movb $0x22, %al
movb %al, (%rbp)
movq %rbp, %rdi
incq %rdi
movq %rbx, %rdx
sarq $0x20, %rdx
movq %r15, %rsi
callq 0x2050
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rbx, %rax
sarq $0x20, %rax
movb $0x22, %cl
movb %cl, (%rbp,%rax)
movabsq $0x200000000, %rax      # imm = 0x200000000
addq %rbx, %rax
sarq $0x20, %rax
movb $0x0, (%rbp,%rax)
movq %rbp, %r15
jmp 0x8122
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x2180
movq %rax, %rbx
movq %r15, %rdi
callq 0x2180
cmpl $0x1, %r13d
movl %r13d, %ecx
sbbl $-0x1, %ecx
movq %rax, %rbp
leal (%rbx,%rcx), %eax
addl %ebp, %eax
addl $0x2, %eax
movslq %eax, %rdx
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x51b4
movq %rax, %r12
testq %rax, %rax
je 0x81a9
movslq %r13d, %rax
leaq (%r12,%rax), %r13
testl %eax, %eax
je 0x8175
movb $0x2c, (%r13)
incq %r13
movslq %ebx, %rbx
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2050
leaq (%rbx,%r13), %r14
leaq (%rbx,%r13), %rdi
incq %rdi
movb $0x3d, -0x1(%rdi)
movslq %ebp, %rbx
movq %r15, %rsi
movq %rbx, %rdx
callq 0x2050
movb $0x0, 0x1(%rbx,%r14)
cmpl $0x0, 0xc(%rsp)
je 0x81bd
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x51a1
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq