// File: /workspace/github_c_makefile_star2_O0/JimKent[P]linearSat/lib/common.c
// Function: slPairListToString
char *slPairListToString(struct slPair *list,boolean quoteIfSpaces)
// Returns an allocated string of pairs in form of [name1=val1 name2=val2 ...]
// If requested, will wrap name or val in quotes if contain spaces: [name1="val 1" "name 2"=val2]
{
// Don't rely on dyString.  We should do the accounting ourselves and not create extra dependencies.
int count = 0;
struct slPair *pair = list;
for (;pair != NULL; pair = pair->next)
    {
    assert(pair->name != NULL && pair->val != NULL); // Better assert and get this over with,
                                                     // complete with stack
    count += strlen(pair->name);
    count += strlen((char *)(pair->val));
    count += 2; // = and ' ' delimit
    if (quoteIfSpaces)
        {
        if (hasWhiteSpace(pair->name))
            count += 2; // " and "
        if (hasWhiteSpace((char *)(pair->val)))
            count += 2; // " and "
        }
    }
if (count == 0)
    return NULL;

char *str = needMem(count+5); // A bit of slop

char *strPtr = str;
for (pair = list; pair != NULL; pair = pair->next, strPtr += strlen(strPtr))
    {
    if (pair != list) // Not first cycle
        *strPtr++ = ' ';
    if (hasWhiteSpace(pair->name))
        {
        if (quoteIfSpaces)
            sprintf(strPtr,"\"%s\"=",pair->name);
        else
            {
            warn("slPairListToString() Unexpected white space in name: [%s]\n", pair->name);
            sprintf(strPtr,"%s=",pair->name); // warn but still make string
            }
        }
    else
        sprintf(strPtr,"%s=",pair->name);
    strPtr += strlen(strPtr);
    if (hasWhiteSpace((char *)(pair->val)))
        {
        if (quoteIfSpaces)
            sprintf(strPtr,"\"%s\"",(char *)(pair->val));
        else
            {
            warn("slPairListToString() Unexpected white space in val: [%s]\n", (char *)(pair->val));
            sprintf(strPtr,"%s",(char *)(pair->val)); // warn but still make string
            }
        }
    else
        sprintf(strPtr,"%s",(char *)(pair->val));
    }
return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x9dcd
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x9d21
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x9d21
jmp 0x9d40
leaq 0x1a659(%rip), %rdi     # 0x24381
leaq 0x1a67a(%rip), %rsi     # 0x243a9
movl $0x472, %edx            # imm = 0x472
leaq 0x1a677(%rip), %rcx     # 0x243b2
callq 0x32d0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x31f0
movq %rax, %rcx
movslq -0x18(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x18(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x31f0
movq %rax, %rcx
movslq -0x18(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x9dbb
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x9c80
cmpl $0x0, %eax
je 0x9d9e
movl -0x18(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x18(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x9c80
cmpl $0x0, %eax
je 0x9db9
movl -0x18(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x18(%rbp)
jmp 0x9dbb
jmp 0x9dbd
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x9cfe
cmpl $0x0, -0x18(%rbp)
jne 0x9de0
movq $0x0, -0x8(%rbp)
jmp 0x9f65
movl -0x18(%rbp), %eax
addl $0x5, %eax
movslq %eax, %rdi
callq 0x152f0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x9f5d
movq -0x20(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x9e29
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb $0x20, (%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x9c80
cmpl $0x0, %eax
je 0x9e8f
cmpl $0x0, -0x14(%rbp)
je 0x9e5d
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x1a58d(%rip), %rsi     # 0x243e1
movb $0x0, %al
callq 0x36a0
jmp 0x9e8d
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x1a57b(%rip), %rdi     # 0x243e7
movb $0x0, %al
callq 0xf8f0
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x1a59c(%rip), %rsi     # 0x24422
movb $0x0, %al
callq 0x36a0
jmp 0x9ea9
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x1a580(%rip), %rsi     # 0x24422
movb $0x0, %al
callq 0x36a0
movq -0x30(%rbp), %rdi
callq 0x31f0
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x9c80
cmpl $0x0, %eax
je 0x9f20
cmpl $0x0, -0x14(%rbp)
je 0x9eee
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x1bd03(%rip), %rsi     # 0x25be8
movb $0x0, %al
callq 0x36a0
jmp 0x9f1e
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x1a529(%rip), %rdi     # 0x24426
movb $0x0, %al
callq 0xf8f0
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x1a695(%rip), %rsi     # 0x245ac
movb $0x0, %al
callq 0x36a0
jmp 0x9f3a
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x1a679(%rip), %rsi     # 0x245ac
movb $0x0, %al
callq 0x36a0
jmp 0x9f3c
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
callq 0x31f0
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9e02
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nop