// File: /workspace/github_c_makefile_star2_O1/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, %ebp
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r13
testq %rcx, %rcx
jne 0x8400
movl $0x1, %esi
movq %r13, %rdi
callq 0x5281
movq %rax, %r15
movb $0x0, (%rax)
movq %r15, %rdi
callq 0x2180
movq %rax, %r12
movq %rbx, %rdi
movq %r14, %rsi
callq 0x67a3
movq %rax, %rbx
testq %rax, %rax
jne 0x8440
leaq 0x59a1(%rip), %rsi      # 0xddc6
leaq 0x5a54(%rip), %rdx      # 0xde80
movq %r13, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x539c
leaq 0x4c4b(%rip), %rbx      # 0xd08b
movl %ebp, 0xc(%rsp)
testl %ebp, %ebp
movq %r13, 0x10(%rsp)
je 0x84c9
movq %rbx, %rdi
callq 0x2180
movq %rax, %rbp
shlq $0x20, %rbp
movabsq $0x300000000, %rsi      # imm = 0x300000000
addq %rbp, %rsi
sarq $0x20, %rsi
movq %r13, %rdi
callq 0x5281
movq %rax, %r13
testq %rax, %rax
je 0x84cc
movb $0x22, %al
movb %al, (%r13)
movq %r13, %rdi
incq %rdi
movq %rbp, %rdx
sarq $0x20, %rdx
movq %rbx, %rsi
callq 0x2050
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rbp, %rax
sarq $0x20, %rax
movb $0x22, %cl
movb %cl, (%r13,%rax)
movabsq $0x200000000, %rax      # imm = 0x200000000
addq %rbp, %rax
sarq $0x20, %rax
movb $0x0, (%r13,%rax)
jmp 0x84cc
movq %rbx, %r13
movq %r14, %rdi
callq 0x2180
movq %rax, %rbx
movq %r13, %rdi
callq 0x2180
cmpl $0x1, %r12d
movl %r12d, %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 %r15, %rsi
callq 0x52a6
movq %rax, %r15
testq %rax, %rax
je 0x8553
movslq %r12d, %rax
leaq (%r15,%rax), %r12
testl %eax, %eax
je 0x851f
movb $0x2c, (%r12)
incq %r12
movslq %ebx, %rbx
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2050
leaq (%r12,%rbx), %r14
leaq (%r12,%rbx), %rdi
incq %rdi
movb $0x3d, -0x1(%rdi)
movslq %ebp, %rbx
movq %r13, %rsi
movq %rbx, %rdx
callq 0x2050
movb $0x0, 0x1(%rbx,%r14)
cmpl $0x0, 0xc(%rsp)
je 0x8567
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x5293
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq