// File: /workspace/github_c_makefile_star2_O1/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 $0x108, %rsp            # imm = 0x108
movq %rsi, %rbp
movq %rdi, %r15
leaq 0x50(%rsp), %rsi
movq %rdx, 0x10(%rsi)
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0x6071
movaps %xmm0, 0x80(%rsp)
movaps %xmm1, 0x90(%rsp)
movaps %xmm2, 0xa0(%rsp)
movaps %xmm3, 0xb0(%rsp)
movaps %xmm4, 0xc0(%rsp)
movaps %xmm5, 0xd0(%rsp)
movaps %xmm6, 0xe0(%rsp)
movaps %xmm7, 0xf0(%rsp)
movl -0x8(%rdi), %r13d
movq %rsi, 0x20(%rsp)
leaq 0x140(%rsp), %rax
movq %rax, 0x18(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, 0x10(%rsp)
cmpb $0x0, (%rbp)
je 0x6403
leaq -0x8(%r15), %r10
movabsq $-0x3333333333333333, %r14 # imm = 0xCCCCCCCCCCCCCCCD
movabsq $0x100000000, %r9       # imm = 0x100000000
cmpl $0x0, 0x4(%r10)
jne 0x60e0
movl $0x1, %esi
movq %r15, %rdi
callq 0x31c0
movabsq $0x100000000, %r9       # imm = 0x100000000
movq %rax, %r15
movq %rax, %r10
addq $-0x8, %r10
movb (%rbp), %al
cmpb $0x25, %al
jne 0x6193
movb 0x1(%rbp), %al
incq %rbp
movzbl %al, %ecx
cmpl $0x54, %ecx
jle 0x6136
cmpl $0x72, %ecx
jg 0x6167
cmpl $0x55, %ecx
je 0x6145
cmpl $0x69, %ecx
jne 0x6193
movq %rbp, 0x28(%rsp)
movl 0x10(%rsp), %ecx
movq %r10, %rbp
cmpq $0x28, %rcx
ja 0x6389
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x6397
cmpl $0x49, %ecx
je 0x61a9
cmpl $0x53, %ecx
je 0x6171
cmpl $0x54, %ecx
jne 0x6193
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x61f5
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x6203
cmpl $0x75, %ecx
je 0x61d3
cmpl $0x73, %ecx
jne 0x6193
movl 0x10(%rsp), %edx
cmpq $0x28, %rdx
ja 0x6210
movq %rdx, %rcx
addq 0x20(%rsp), %rcx
addl $0x8, %edx
movl %edx, 0x10(%rsp)
jmp 0x621e
movslq %r13d, %rcx
movb %al, (%r15,%rcx)
incl (%r10)
incl %r13d
decl 0x4(%r10)
jmp 0x63f5
movq %rbp, 0x28(%rsp)
movl 0x10(%rsp), %ecx
movq %r10, %rbp
cmpq $0x28, %rcx
ja 0x6277
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x6285
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x6292
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x62a0
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movl %r13d, 0xc(%rsp)
movq (%rax), %rcx
jmp 0x62a7
movq 0x18(%rsp), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x18(%rsp)
movl %r13d, 0xc(%rsp)
movq (%rcx), %rdi
movq %rdi, %r13
cmpb $0x73, %al
jne 0x623d
movq %r10, %rbx
callq 0x3130
movq %rbx, %r10
movq %rax, %r12
jmp 0x6241
movl -0x8(%rdi), %r12d
cmpl %r12d, 0x4(%r10)
jge 0x625e
movslq %r12d, %rsi
movq %r15, %rdi
callq 0x31c0
movq %rax, %r15
movq %rax, %rbx
addq $-0x8, %rbx
jmp 0x6261
movq %r10, %rbx
movq %r13, %rsi
movl 0xc(%rsp), %r13d
movslq %r13d, %rdi
addq %r15, %rdi
movslq %r12d, %rdx
jmp 0x63d9
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x30(%rsp), %rdi
movq (%rax), %rsi
jmp 0x639f
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movl %r13d, 0xc(%rsp)
movl (%rax), %ecx
xorl %r13d, %r13d
xorl %r12d, %r12d
leaq 0x2f(%rsp), %rax
movq %rax, %rsi
addq %r9, %r12
movq %rcx, %rax
mulq %r14
leaq 0x1(%rsi), %rax
shrq $0x3, %rdx
leal (%rdx,%rdx), %edi
leal (%rdi,%rdi,4), %edi
movl %ecx, %r8d
subl %edi, %r8d
orb $0x30, %r8b
movb %r8b, 0x1(%rsi)
decl %r13d
cmpq $0x9, %rcx
movq %rdx, %rcx
ja 0x62b2
movq %rbp, 0x28(%rsp)
movb $0x0, 0x1(%rax)
leaq 0x30(%rsp), %rbp
cmpq %rbp, %rax
jbe 0x6315
movq %rbp, %rax
movb (%rax), %cl
movb 0x1(%rsi), %dl
movb %dl, (%rax)
movb %cl, 0x1(%rsi)
incq %rax
leaq -0x1(%rsi), %rcx
cmpq %rsi, %rax
movq %rcx, %rsi
jb 0x62fc
movl %r13d, %eax
negl %eax
cmpl %eax, 0x4(%r10)
jge 0x633b
movq %r12, %rsi
sarq $0x20, %rsi
movq %r15, %rdi
callq 0x31c0
movq %rax, %r14
movq %rax, %rbx
addq $-0x8, %rbx
jmp 0x6341
movq %r15, %r14
movq %r10, %rbx
movl 0xc(%rsp), %r15d
movslq %r15d, %rdi
addq %r14, %rdi
sarq $0x20, %r12
movq %rbp, %rsi
movq %r12, %rdx
callq 0x32f0
subl %r13d, (%rbx)
addl %r13d, 0x4(%rbx)
subl %r13d, %r15d
movl %r15d, %r13d
movq %r14, %r15
movabsq $-0x3333333333333333, %r14 # imm = 0xCCCCCCCCCCCCCCCD
movabsq $0x100000000, %r9       # imm = 0x100000000
movq %rbx, %r10
movq 0x28(%rsp), %rbp
jmp 0x63f5
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x30(%rsp), %rdi
movslq (%rax), %rsi
callq 0x3070
movslq %eax, %r12
cmpl %eax, 0x4(%rbp)
jge 0x63c3
movq %r15, %rdi
movq %r12, %rsi
callq 0x31c0
movq %rax, %r15
movq %rax, %rbx
addq $-0x8, %rbx
jmp 0x63c6
movq %rbp, %rbx
movq 0x28(%rsp), %rbp
movslq %r13d, %rdi
addq %r15, %rdi
leaq 0x30(%rsp), %rsi
movq %r12, %rdx
callq 0x32f0
addl %r12d, (%rbx)
subl %r12d, 0x4(%rbx)
addl %r12d, %r13d
movabsq $0x100000000, %r9       # imm = 0x100000000
movq %rbx, %r10
cmpb $0x0, 0x1(%rbp)
leaq 0x1(%rbp), %rbp
jne 0x60b8
movslq %r13d, %rax
movb $0x0, (%r15,%rax)
movq %r15, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq