// File: /workspace/github_c_makefile_star2_O2/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 0x91fb
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)
leaq 0x20(%rsp), %r14
andq $0x0, (%r14)
leaq 0x28(%rsp), %r15
andq $0x0, (%r15)
leaq 0x30(%rsp), %r12
pushq $0x1
popq %r13
movzbl (%rbx), %eax
cmpl $0x25, %eax
je 0x9263
testl %eax, %eax
je 0x9380
leaq 0x1(%rbx), %rbp
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x90d0
movq %rbp, %rbx
jmp 0x9369
movzbl 0x1(%rbx), %eax
testl %eax, %eax
je 0x9380
addq $0x2, %rbx
cmpl $0x73, %eax
je 0x92c8
cmpl $0x63, %eax
je 0x9296
cmpl $0x64, %eax
je 0x92af
cmpl $0x25, %eax
jne 0x9236
movq %r14, %rdi
movq %r15, %rsi
leaq 0x287b(%rip), %rdx      # 0xbb0f
jmp 0x9303
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x92e1
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x92ef
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x9308
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x9316
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x933f
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x934d
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movb (%rax), %al
movb %al, 0x30(%rsp)
movb $0x0, 0x31(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
jmp 0x9364
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %ecx
movq %r12, %rdi
pushq $0x40
popq %rsi
leaq 0x243e(%rip), %rdx      # 0xb763
xorl %eax, %eax
callq 0x2540
movq %r12, %rdi
callq 0x2150
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
jmp 0x9361
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rbp
movq %rbp, %rdi
callq 0x2150
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %rax, %rcx
callq 0x90d0
testq %rax, %rax
jne 0x9236
movq 0x20(%rsp), %rdi
callq 0x23d0
xorl %eax, %eax
jmp 0x9385
movq 0x20(%rsp), %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq