// File: /workspace/github_c_makefile_star2_O3/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, %rbx
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 0x5f45
movdqa %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)
movb (%rbx), %al
testb %al, %al
je 0x6292
leaq -0x8(%r15), %rbp
movabsq $-0x3333333333333333, %r14 # imm = 0xCCCCCCCCCCCCCCCD
movabsq $0x100000000, %r9       # imm = 0x100000000
cmpl $0x0, 0x4(%rbp)
jne 0x5fb5
movl $0x1, %esi
movq %r15, %rdi
callq 0x31c0
movabsq $0x100000000, %r9       # imm = 0x100000000
movq %rax, %r15
movq %rax, %rbp
addq $-0x8, %rbp
movb (%rbx), %al
cmpb $0x25, %al
jne 0x6059
movb 0x1(%rbx), %al
incq %rbx
movzbl %al, %ecx
cmpl $0x54, %ecx
jle 0x5ffc
cmpl $0x72, %ecx
jg 0x602d
cmpl $0x55, %ecx
je 0x600b
cmpl $0x69, %ecx
jne 0x6059
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x6224
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x6232
cmpl $0x49, %ecx
je 0x607a
cmpl $0x53, %ecx
je 0x6037
cmpl $0x54, %ecx
jne 0x6059
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x60be
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x60cc
cmpl $0x75, %ecx
je 0x609c
cmpl $0x73, %ecx
jne 0x6059
movl 0x10(%rsp), %edx
cmpq $0x28, %rdx
ja 0x60d9
movq %rdx, %rcx
addq 0x20(%rsp), %rcx
addl $0x8, %edx
movl %edx, 0x10(%rsp)
jmp 0x60e7
movslq %r13d, %rcx
incl %r13d
movb %al, (%r15,%rcx)
movq (%rbp), %xmm0
paddd 0x33b0(%rip), %xmm0     # 0x9420
movq %xmm0, (%rbp)
jmp 0x6284
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x6130
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x613e
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x614b
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x6159
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movl %r13d, 0xc(%rsp)
movq (%rax), %rcx
jmp 0x6160
movq 0x18(%rsp), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq (%rcx), %rdi
cmpb $0x73, %al
movl %r13d, 0xc(%rsp)
movq %rdi, %r13
jne 0x60fd
callq 0x3130
jmp 0x6100
movl -0x8(%rdi), %eax
movslq %eax, %r12
cmpl %eax, 0x4(%rbp)
jge 0x611d
movq %r15, %rdi
movq %r12, %rsi
callq 0x31c0
movq %rax, %r15
movq %rax, %rbp
addq $-0x8, %rbp
movq %r13, %rsi
movl 0xc(%rsp), %r13d
movslq %r13d, %rdi
addq %r15, %rdi
jmp 0x6267
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x30(%rsp), %rdi
movq (%rax), %rsi
jmp 0x623a
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 0x616b
movb $0x0, 0x1(%rax)
leaq 0x30(%rsp), %r14
cmpq %r14, %rax
jbe 0x61c9
movq %r14, %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 0x61b0
movl %r13d, %eax
negl %eax
sarq $0x20, %r12
cmpl %eax, 0x4(%rbp)
jge 0x61eb
movq %r15, %rdi
movq %r12, %rsi
callq 0x31c0
movq %rax, %rbp
addq $-0x8, %rbp
jmp 0x61ee
movq %r15, %rax
movl 0xc(%rsp), %r15d
movslq %r15d, %rdi
addq %rax, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rax, %r14
callq 0x32f0
subl %r13d, (%rbp)
addl %r13d, 0x4(%rbp)
subl %r13d, %r15d
movl %r15d, %r13d
movq %r14, %r15
movabsq $-0x3333333333333333, %r14 # imm = 0xCCCCCCCCCCCCCCCD
jmp 0x627a
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 0x625c
movq %r15, %rdi
movq %r12, %rsi
callq 0x31c0
movq %rax, %r15
movq %rax, %rbp
addq $-0x8, %rbp
movslq %r13d, %rdi
addq %r15, %rdi
leaq 0x30(%rsp), %rsi
movq %r12, %rdx
callq 0x32f0
addl %r12d, (%rbp)
subl %r12d, 0x4(%rbp)
addl %r12d, %r13d
movabsq $0x100000000, %r9       # imm = 0x100000000
movb 0x1(%rbx), %al
incq %rbx
testb %al, %al
jne 0x5f8c
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