// File: /workspace/github_c_makefile_star2_O2/andyfighting[P]hiredis_timer_cmpt/sds.c
// Function: sdscatfmt
sds sdscatfmt(sds s, char const *fmt, ...) {
    struct sdshdr *sh = (void*) (s-(sizeof(struct sdshdr)));
    size_t initlen = sdslen(s);
    const char *f = fmt;
    int i;
    va_list ap;

    va_start(ap,fmt);
    f = fmt;    /* Next format specifier byte to process. */
    i = initlen; /* Position of the next byte to write to dest str. */
    while(*f) {
        char next, *str;
        int l;
        long long num;
        unsigned long long unum;

        /* Make sure there is always space for at least 1 char. */
        if (sh->free == 0) {
            s = sdsMakeRoomFor(s,1);
            sh = (void*) (s-(sizeof(struct sdshdr)));
        }

        switch(*f) {
        case '%':
            next = *(f+1);
            f++;
            switch(next) {
            case 's':
            case 'S':
                str = va_arg(ap,char*);
                l = (next == 's') ? strlen(str) : sdslen(str);
                if (sh->free < l) {
                    s = sdsMakeRoomFor(s,l);
                    sh = (void*) (s-(sizeof(struct sdshdr)));
                }
                memcpy(s+i,str,l);
                sh->len += l;
                sh->free -= l;
                i += l;
                break;
            case 'i':
            case 'I':
                if (next == 'i')
                    num = va_arg(ap,int);
                else
                    num = va_arg(ap,long long);
                {
                    char buf[SDS_LLSTR_SIZE];
                    l = sdsll2str(buf,num);
                    if (sh->free < l) {
                        s = sdsMakeRoomFor(s,l);
                        sh = (void*) (s-(sizeof(struct sdshdr)));
                    }
                    memcpy(s+i,buf,l);
                    sh->len += l;
                    sh->free -= l;
                    i += l;
                }
                break;
            case 'u':
            case 'U':
            case 'T':
                if (next == 'u')
                    unum = va_arg(ap,unsigned int);
                else if(next == 'U')
                    unum = va_arg(ap,unsigned long long);
                else
                    unum = (unsigned long long)va_arg(ap,size_t);
                {
                    char buf[SDS_LLSTR_SIZE];
                    l = sdsull2str(buf,unum);
                    if (sh->free < l) {
                        s = sdsMakeRoomFor(s,l);
                        sh = (void*) (s-(sizeof(struct sdshdr)));
                    }
                    memcpy(s+i,buf,l);
                    sh->len += l;
                    sh->free -= l;
                    i += l;
                }
                break;
            default: /* Handle %% and generally %<unknown>. */
                s[i++] = next;
                sh->len += 1;
                sh->free -= 1;
                break;
            }
            break;
        default:
            s[i++] = *f;
            sh->len += 1;
            sh->free -= 1;
            break;
        }
        f++;
    }
    va_end(ap);

    /* Add null-term */
    s[i] = '\0';
    return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rsi, %rbx
movq %rdi, %r12
leaq 0x40(%rsp), %rsi
movq %rdx, 0x10(%rsi)
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0x5962
movdqa %xmm0, 0x70(%rsp)
movaps %xmm1, 0x80(%rsp)
movaps %xmm2, 0x90(%rsp)
movaps %xmm3, 0xa0(%rsp)
movaps %xmm4, 0xb0(%rsp)
movaps %xmm5, 0xc0(%rsp)
movaps %xmm6, 0xd0(%rsp)
movaps %xmm7, 0xe0(%rsp)
leaq -0x8(%rdi), %r14
movl -0x8(%rdi), %r15d
movq %rsi, 0x10(%rsp)
leaq 0x130(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
pushq $0x1
popq %rbp
movb (%rbx), %al
movslq %r15d, %r15
testb %al, %al
je 0x5bb9
cmpl $0x0, 0x4(%r14)
jne 0x59b8
movq %r12, %rdi
movq %rbp, %rsi
callq 0x31d0
movq %rax, %r12
movq %rax, %r14
addq $-0x8, %r14
movb (%rbx), %al
cmpb $0x25, %al
jne 0x5a12
movzbl 0x1(%rbx), %eax
incq %rbx
cmpl $0x49, %eax
je 0x5aa3
cmpl $0x53, %eax
je 0x59f2
cmpl $0x54, %eax
je 0x5a34
cmpl $0x55, %eax
je 0x5a34
cmpl $0x69, %eax
je 0x5a83
cmpl $0x75, %eax
je 0x5a4d
cmpl $0x73, %eax
jne 0x5ac3
movl (%rsp), %edx
cmpq $0x28, %rdx
ja 0x5acc
movq %rdx, %rcx
addq 0x10(%rsp), %rcx
addl $0x8, %edx
movl %edx, (%rsp)
jmp 0x5ada
movb %al, (%r12,%r15)
leal 0x1(%r15), %eax
movq (%r14), %xmm0
paddd 0x39f9(%rip), %xmm0     # 0x9420
movq %xmm0, (%r14)
movl %eax, %r15d
jmp 0x5bb1
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x5a6d
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x5a7b
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x5b2e
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x5b3c
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rsi
jmp 0x5b3e
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x5b4a
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x5b58
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x5b5d
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x5b6b
movb %al, (%r12,%r15)
jmp 0x5a16
movq 0x8(%rsp), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq (%rcx), %r13
cmpb $0x73, %al
jne 0x5aeb
movq %r13, %rdi
callq 0x3140
jmp 0x5aef
movl -0x8(%r13), %eax
movslq %eax, %rbp
cmpl %eax, 0x4(%r14)
jge 0x5b0d
movq %r12, %rdi
movq %rbp, %rsi
callq 0x31d0
movq %rax, %r12
movq %rax, %r14
addq $-0x8, %r14
leaq (%r12,%r15), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x3300
addl %ebp, (%r14)
subl %ebp, 0x4(%r14)
addl %ebp, %r15d
pushq $0x1
popq %rbp
jmp 0x5bb1
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %esi
leaq 0x20(%rsp), %rdi
callq 0x3510
jmp 0x5b78
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movslq (%rax), %rsi
jmp 0x5b6e
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rsi
leaq 0x20(%rsp), %rdi
callq 0x3070
movslq %eax, %r13
cmpl %eax, 0x4(%r14)
jge 0x5b96
movq %r12, %rdi
movq %r13, %rsi
callq 0x31d0
movq %rax, %r12
movq %rax, %r14
addq $-0x8, %r14
leaq (%r12,%r15), %rdi
leaq 0x20(%rsp), %rsi
movq %r13, %rdx
callq 0x3300
addl %r13d, (%r14)
subl %r13d, 0x4(%r14)
addl %r13d, %r15d
incq %rbx
jmp 0x598d
movb $0x0, (%r12,%r15)
movq %r12, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq