// File: /workspace/github_c_makefile_star2_O3/tomka[P]cliaspora/str.c
// Function: strduprintf
char *
strduprintf(const char *fmt, ...)
{
	char	*str, *buf, tmp[64];
	size_t  bufsz;
	va_list ap;

	va_start(ap, fmt); buf = NULL; bufsz = 0;
	while (*fmt != '\0') {
		if (*fmt == '%') {
			if (*++fmt == '\0') {
				va_end(ap); return (buf);
			}
		} else {
			if (strdupstrcat(&buf, &bufsz, fmt++, 1) == NULL)
				goto error;
			continue;
		}
		switch(*fmt++) {
		case '%':
			if (strdupstrcat(&buf, &bufsz, "%", 1) == NULL)
				goto error;
			break;	
		case 'c':
			(void)snprintf(tmp, sizeof(tmp), "%c",
			    va_arg(ap, int));
			if (strdupstrcat(&buf, &bufsz, tmp, 1) == NULL)
				goto error;
			break;
		case 'd':
			(void)snprintf(tmp, sizeof(tmp), "%d",
			    va_arg(ap, int));
			if (strdupstrcat(&buf, &bufsz, tmp,
			    strlen(tmp)) == NULL)
				goto error;
			break;
		case 's':
			str = va_arg(ap, char *);
			if (strdupstrcat(&buf, &bufsz, str,
			    strlen(str)) == NULL)
				goto error;
			break;
		}
	}
	va_end(ap);

	return (buf);
error:
	va_end(ap); free(buf);
	return (NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdi, %rbx
leaq 0x70(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x97e3
movaps %xmm0, 0xa0(%rsp)
movaps %xmm1, 0xb0(%rsp)
movaps %xmm2, 0xc0(%rsp)
movaps %xmm3, 0xd0(%rsp)
movaps %xmm4, 0xe0(%rsp)
movaps %xmm5, 0xf0(%rsp)
movaps %xmm6, 0x100(%rsp)
movaps %xmm7, 0x110(%rsp)
movq %rdi, 0x10(%rsp)
leaq 0x160(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rsp)
xorl %eax, %eax
leaq 0x20(%rsp), %r14
movq %rax, (%r14)
leaq 0x28(%rsp), %r15
movq %rax, (%r15)
leaq 0x30(%rsp), %r13
leaq 0x1f42(%rip), %rbp      # 0xb763
movzbl (%rbx), %eax
cmpl $0x25, %eax
je 0x9850
testl %eax, %eax
je 0x997a
leaq 0x1(%rbx), %r12
movl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x96b8
movq %r12, %rbx
jmp 0x9963
movzbl 0x1(%rbx), %eax
testl %eax, %eax
je 0x997a
addq $0x2, %rbx
cmpl $0x63, %eax
jg 0x9888
cmpl $0x25, %eax
je 0x98ab
cmpl $0x63, %eax
jne 0x9821
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x98db
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x98e9
cmpl $0x64, %eax
je 0x98c2
cmpl $0x73, %eax
jne 0x9821
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x9904
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x9912
movl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rsi
leaq 0x2285(%rip), %rdx      # 0xbb42
jmp 0x995e
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x9928
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x9936
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movb (%rax), %al
movb %al, 0x30(%rsp)
movb $0x0, 0x31(%rsp)
movl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
jmp 0x995e
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %r12
movq %r12, %rdi
callq 0x2150
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
jmp 0x995b
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %ecx
movl $0x40, %esi
movq %r13, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2530
movq %r13, %rdi
callq 0x2150
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x96b8
testq %rax, %rax
jne 0x9821
movq 0x20(%rsp), %rdi
callq 0x23c0
xorl %eax, %eax
jmp 0x997f
movq 0x20(%rsp), %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq