// File: /workspace/github_c_makefile_star2_O0/phillbush[P]hoc/code.c
// Function: format
static char *
format(char *s, Datum *p)
{
	char buf[BUFSIZ];
	char *fmt, *save, *t;
	int n;

	fmt = NULL;
	t = buf; 
	while (*s) {
		if (t + 1 >= buf + sizeof buf)
			goto error;
		if (*s != '%') {
			*t++ = *s++;
			continue;
		}
		if (*(s+1) == '%') {
			*t++ = '%';
			s += 2;
			continue;
		}
		save = s++;
		while (strchr("#-+ 0", *s))
			s++;
		while (isdigit(*s))
			s++;
		if (*s == '.')
			s++;
		while (isdigit(*s))
			s++;
		if ((fmt = strndup(save, s - save + 1)) == NULL)
			goto error;
		switch (*s) {
		case 'd':
		case 'i':
		case 'o':
		case 'u':
		case 'X':
		case 'x':
			/* int */
			if (!p || p->isstr)
				goto wrong;
			n = snprintf(t, BUFSIZ - (t - buf), fmt, (int)p->u.val);
			break;
		case 'f':
		case 'F':
		case 'e':
		case 'E':
		case 'g':
		case 'G':
		case 'a':
		case 'A':
			/* double */
			if (!p || p->isstr)
				goto wrong;
			n = snprintf(t, BUFSIZ - (t - buf), fmt, p->u.val);
			break;
		case 'c':
			/* char */
			if (!p || !p->isstr)
				goto wrong;
			n = snprintf(t, BUFSIZ - (t - buf), fmt, *p->u.str->s);
			break;
		case 's':
			/* string */
			if (!p || !p->isstr)
				goto wrong;
			n = snprintf(t, BUFSIZ - (t - buf), fmt, p->u.str->s);
			break;
		default:
			if ((n = strlen(fmt)) < BUFSIZ - (t - buf))
				strncpy(t, fmt, strlen(fmt));
			else
				goto error;
			break;
		}
		s++;
		if (n > BUFSIZ - (t - buf) + 1)
			goto error;
		t += n;
		p = p->next;
		free(fmt);
		fmt = NULL;
	}
	*t = '\0';
	if ((s = strdup(buf)) == NULL)
		goto error;
	return s;

wrong:
	free(fmt);
	warning("wrong format");
	return NULL;

error:
	free(fmt);
	warning("out of memory");
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2060, %rsp           # imm = 0x2060
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x2028(%rbp)
leaq -0x2020(%rbp), %rax
movq %rax, -0x2038(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x499a
movq -0x2038(%rbp), %rax
addq $0x1, %rax
leaq -0x2020(%rbp), %rcx
addq $0x2000, %rcx           # imm = 0x2000
cmpq %rcx, %rax
jb 0x45bc
jmp 0x49ea
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x25, %eax
je 0x45f2
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb (%rax), %cl
movq -0x2038(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x2038(%rbp)
movb %cl, (%rax)
jmp 0x458c
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x25, %eax
jne 0x4628
movq -0x2038(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x2038(%rbp)
movb $0x25, (%rax)
movq -0x10(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x10(%rbp)
jmp 0x458c
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movq %rax, -0x2030(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %esi
leaq 0x6e87(%rip), %rdi      # 0xb4d3
callq 0x20f0
cmpq $0x0, %rax
je 0x4665
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x463e
jmp 0x4667
callq 0x22d0
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x4695
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x4667
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x46ad
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x46af
callq 0x22d0
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x46dd
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x46af
movq -0x2030(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x2030(%rbp), %rax
subq %rax, %rsi
addq $0x1, %rsi
callq 0x2150
movq %rax, -0x2028(%rbp)
cmpq $0x0, %rax
jne 0x470d
jmp 0x49ea
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
addl $-0x41, %eax
movl %eax, %ecx
movq %rcx, -0x2048(%rbp)
subl $0x37, %eax
ja 0x48a6
movq -0x2048(%rbp), %rax
leaq 0x6929(%rip), %rcx      # 0xb060
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x0, -0x18(%rbp)
je 0x4751
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0x4756
jmp 0x49c6
movq -0x2038(%rbp), %rdi
movq -0x2038(%rbp), %rax
leaq -0x2020(%rbp), %rcx
subq %rcx, %rax
movl $0x2000, %esi           # imm = 0x2000
subq %rax, %rsi
movq -0x2028(%rbp), %rdx
movq -0x18(%rbp), %rax
cvttsd2si 0x8(%rax), %ecx
movb $0x0, %al
callq 0x2120
movl %eax, -0x203c(%rbp)
jmp 0x491f
cmpq $0x0, -0x18(%rbp)
je 0x47a9
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0x47ae
jmp 0x49c6
movq -0x2038(%rbp), %rdi
movq -0x2038(%rbp), %rax
leaq -0x2020(%rbp), %rcx
subq %rcx, %rax
movl $0x2000, %esi           # imm = 0x2000
subq %rax, %rsi
movq -0x2028(%rbp), %rdx
movq -0x18(%rbp), %rax
movsd 0x8(%rax), %xmm0
movb $0x1, %al
callq 0x2120
movl %eax, -0x203c(%rbp)
jmp 0x491f
cmpq $0x0, -0x18(%rbp)
je 0x4801
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x4806
jmp 0x49c6
movq -0x2038(%rbp), %rdi
movq -0x2038(%rbp), %rax
leaq -0x2020(%rbp), %rcx
subq %rcx, %rax
movl $0x2000, %esi           # imm = 0x2000
subq %rax, %rsi
movq -0x2028(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movsbl (%rax), %ecx
movb $0x0, %al
callq 0x2120
movl %eax, -0x203c(%rbp)
jmp 0x491f
cmpq $0x0, -0x18(%rbp)
je 0x485f
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x4864
jmp 0x49c6
movq -0x2038(%rbp), %rdi
movq -0x2038(%rbp), %rax
leaq -0x2020(%rbp), %rcx
subq %rcx, %rax
movl $0x2000, %esi           # imm = 0x2000
subq %rax, %rsi
movq -0x2028(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rcx
movb $0x0, %al
callq 0x2120
movl %eax, -0x203c(%rbp)
jmp 0x491f
movq -0x2028(%rbp), %rdi
callq 0x20e0
movl %eax, -0x203c(%rbp)
cltq
movq -0x2038(%rbp), %rdx
leaq -0x2020(%rbp), %rcx
subq %rcx, %rdx
movl $0x2000, %ecx           # imm = 0x2000
subq %rdx, %rcx
cmpq %rcx, %rax
jge 0x4918
movq -0x2038(%rbp), %rax
movq %rax, -0x2058(%rbp)
movq -0x2028(%rbp), %rax
movq %rax, -0x2050(%rbp)
movq -0x2028(%rbp), %rdi
callq 0x20e0
movq -0x2058(%rbp), %rdi
movq -0x2050(%rbp), %rsi
movq %rax, %rdx
callq 0x2050
jmp 0x491d
jmp 0x49ea
jmp 0x491f
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movslq -0x203c(%rbp), %rax
movq -0x2038(%rbp), %rdx
leaq -0x2020(%rbp), %rcx
subq %rcx, %rdx
movl $0x2000, %ecx           # imm = 0x2000
subq %rdx, %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jle 0x4959
jmp 0x49ea
movl -0x203c(%rbp), %ecx
movq -0x2038(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x2038(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x2028(%rbp), %rdi
callq 0x2030
movq $0x0, -0x2028(%rbp)
jmp 0x458c
movq -0x2038(%rbp), %rax
movb $0x0, (%rax)
leaq -0x2020(%rbp), %rdi
callq 0x22a0
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
jne 0x49bc
jmp 0x49ea
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4a0c
movq -0x2028(%rbp), %rdi
callq 0x2030
leaq 0x6b00(%rip), %rdi      # 0xb4d9
movb $0x0, %al
callq 0x25f0
movq $0x0, -0x8(%rbp)
jmp 0x4a0c
movq -0x2028(%rbp), %rdi
callq 0x2030
leaq 0x6763(%rip), %rdi      # 0xb160
movb $0x0, %al
callq 0x25f0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x2060, %rsp           # imm = 0x2060
popq %rbp
retq
nopl (%rax)