// File: /workspace/github_c_makefile_star2_O2/lucvoo[P]sparse-dev/semind.c
// Function: search_query_callback
static int search_query_callback(void *data, int argc, char **argv, char **colname)
{
	char *fmt = (char *) semind_search_format;
	char buf[32];
	int quote = 0;
	int n = 0;

	while (*fmt != '\0') {
		char c = *fmt;

		if (quote) {
			quote = 0;
			switch (c) {
				case 't': c = '\t'; break;
				case 'r': c = '\r'; break;
				case 'n': c = '\n'; break;
			}
		} else if (c == '%') {
			int colnum = 0;
			char *pos = ++fmt;

			c = *fmt;

			if (c == '\0')
				semind_error(1, 0, "unexpected end of format string");

			switch (c) {
				case 'f': colnum = 0; goto print_string;
				case 'l': colnum = 1; goto print_string;
				case 'c': colnum = 2; goto print_string;
				case 'C': colnum = 3; goto print_string;
				case 'n': colnum = 4; goto print_string;
				case 'm':
					if (n) {
						printf("%.*s", n, buf);
						n = 0;
					}
					print_mode(argv[5]);
					fmt++;
					break;
				case 'k':
					if (n) {
						printf("%.*s", n, buf);
						n = 0;
					}
					printf("%c", atoi(argv[6]));
					fmt++;
					break;
				case 's':
					if (n) {
						printf("%.*s", n, buf);
						n = 0;
					}
					print_file_line(argv[0], atoi(argv[1]));
					fmt++;
					break;

				print_string:
					if (n) {
						printf("%.*s", n, buf);
						n = 0;
					}
					printf("%s", argv[colnum]);
					fmt++;
					break;
				default:
					break;

			}

			if (pos == fmt)
				semind_error(1, 0, "invalid format specification: %%%c", c);

			continue;
		} else if (c == '\\') {
			quote = 1;
			fmt++;
			continue;
		}

		if (n == sizeof(buf)) {
			printf("%.*s", n, buf);
			n = 0;
		}

		buf[n++] = c;
		fmt++;
	}

	if (n)
		printf("%.*s", n, buf);
	printf("\n");

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, 0x8(%rsp)
movq 0x4f500(%rip), %rbx     # 0x602f8
pushq $0x1
popq %rbp
leaq 0x2cfac(%rip), %r15     # 0x3ddae
leaq 0x2c24f(%rip), %r14     # 0x3d058
xorl %r12d, %r12d
movb $0x1, %al
movzbl (%rbx), %r13d
testl %r13d, %r13d
je 0x1115f
testb $0x1, %al
je 0x10e83
cmpl $0x5c, %r13d
jne 0x10e2c
incq %rbx
xorl %eax, %eax
jmp 0x10e0e
cmpl $0x25, %r13d
jne 0x10ea2
movzbl 0x1(%rbx), %r13d
testl %r13d, %r13d
je 0x10e4e
leal -0x63(%r13), %eax
cmpl $0x10, %eax
ja 0x10e62
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
movl %ebp, %edi
xorl %esi, %esi
leaq 0x2cf35(%rip), %rdx     # 0x3dd8e
xorl %eax, %eax
callq 0x10384
jmp 0x10e6c
cmpl $0x43, %r13d
je 0x11120
incq %rbx
movsbl %r13b, %ecx
movl %ebp, %edi
xorl %esi, %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10384
jmp 0x10e0c
cmpl $0x6e, %r13d
je 0x10e9f
cmpl $0x72, %r13d
je 0x10e9a
cmpl $0x74, %r13d
jne 0x10ea2
movb $0x9, %r13b
jmp 0x10ea2
movb $0xd, %r13b
jmp 0x10ea2
movb $0xa, %r13b
cmpl $0x20, %r12d
jne 0x10ec1
xorl %r12d, %r12d
leaq 0x35682(%rip), %rdi     # 0x46534
pushq $0x20
popq %rsi
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xf050
movslq %r12d, %rax
incl %r12d
movb %r13b, 0x10(%rsp,%rax)
incq %rbx
jmp 0x10e0c
pushq $0x1
jmp 0x11122
pushq $0x2
jmp 0x11122
xorl %r13d, %r13d
jmp 0x11124
testl %r12d, %r12d
je 0x10f05
leaq 0x3563e(%rip), %rdi     # 0x46534
movl %r12d, %esi
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xf050
movq 0x8(%rsp), %rax
movq (%rax), %r13
movq 0x8(%rax), %rdi
callq 0xf300
movl %eax, %r12d
movq 0x55c98(%rip), %rdi     # 0x66bb8
testq %rdi, %rdi
je 0x10f35
movq %r13, %rsi
callq 0xf3b0
testl %eax, %eax
je 0x10fb9
movq 0x55c74(%rip), %rdi     # 0x66bb0
testq %rdi, %rdi
je 0x10f52
callq 0xf440
movq 0x55c6b(%rip), %rdi     # 0x66bb8
callq 0xf210
movq %r13, %rdi
callq 0xf3a0
movq %rax, 0x55c57(%rip)     # 0x66bb8
testq %rax, %rax
jne 0x10f7d
callq 0xf390
movl (%rax), %esi
movl %ebp, %edi
leaq 0x3447b(%rip), %rdx     # 0x453f1
xorl %eax, %eax
callq 0x10384
movq %r13, %rdi
leaq 0x33b25(%rip), %rsi     # 0x44aac
callq 0xf1b0
movq %rax, 0x55c1d(%rip)     # 0x66bb0
testq %rax, %rax
jne 0x10fb2
callq 0xf390
movl (%rax), %esi
movl %ebp, %edi
leaq 0x2ce33(%rip), %rdx     # 0x3dddb
movq %r13, %rcx
xorl %eax, %eax
callq 0x10384
andl $0x0, 0x55c0f(%rip)     # 0x66bc8
movl 0x55c09(%rip), %eax     # 0x66bc8
cmpl %r12d, %eax
je 0x11084
incl %eax
movl %eax, 0x55bf8(%rip)     # 0x66bc8
callq 0xf390
movq %rax, %r13
andl $0x0, (%rax)
movq 0x55bce(%rip), %rdx     # 0x66bb0
leaq 0x55bd7(%rip), %rdi     # 0x66bc0
leaq 0x55be0(%rip), %rsi     # 0x66bd0
callq 0xf3c0
movl %eax, 0x55bd1(%rip)     # 0x66bcc
cmpl $-0x1, %eax
jne 0x10fb9
jmp 0x110b7
pushq $0x4
jmp 0x11122
testl %r12d, %r12d
je 0x11027
leaq 0x3551c(%rip), %rdi     # 0x46534
movl %r12d, %esi
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xf050
movq 0x8(%rsp), %rax
movq 0x30(%rax), %rdi
callq 0xf300
movl %eax, %edi
callq 0xf150
jmp 0x11156
testl %r12d, %r12d
je 0x1105c
leaq 0x354e7(%rip), %rdi     # 0x46534
movl %r12d, %esi
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xf050
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0xf300
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x110d9
leaq 0x2ebd4(%rip), %rdi     # 0x3fc4c
xorl %eax, %eax
callq 0xf050
jmp 0x11156
movq 0x55b35(%rip), %rdx     # 0x66bc0
movslq 0x55b3a(%rip), %rsi     # 0x66bcc
cmpb $0xa, -0x1(%rdx,%rsi)
jne 0x110a1
decl %esi
movl %esi, 0x55b2b(%rip)     # 0x66bcc
leaq 0x3548c(%rip), %rdi     # 0x46534
xorl %eax, %eax
callq 0xf050
callq 0xf390
movq %rax, %r13
movl (%r13), %esi
leal 0x1(%rsi), %eax
cmpl $0x2, %eax
jb 0x11156
movl %ebp, %edi
leaq 0x2cd15(%rip), %rdx     # 0x3dde5
xorl %eax, %eax
callq 0x10384
jmp 0x11156
movl %eax, %ecx
andl $0x3, %eax
leaq 0x2ccec(%rip), %rsi     # 0x3ddd1
movb (%rax,%rsi), %al
movb %al, 0x5(%rsp)
movl %ecx, %eax
cltd
pushq $0x4
popq %rdi
idivl %edi
andl $0x3, %eax
movb (%rax,%rsi), %al
movb %al, 0x6(%rsp)
movl %ecx, %eax
cltd
movl $0x400, %ecx            # imm = 0x400
idivl %ecx
andl $0x3, %eax
movb (%rax,%rsi), %al
movb %al, 0x7(%rsp)
leaq 0x2ccbd(%rip), %rdi     # 0x3ddd6
leaq 0x5(%rsp), %rsi
jmp 0x1114f
pushq $0x3
popq %r13
testl %r12d, %r12d
je 0x1113f
leaq 0x35404(%rip), %rdi     # 0x46534
movl %r12d, %esi
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xf050
movq 0x8(%rsp), %rax
movq (%rax,%r13,8), %rsi
leaq 0x38c06(%rip), %rdi     # 0x49d55
xorl %eax, %eax
callq 0xf050
addq $0x2, %rbx
jmp 0x10e09
testl %r12d, %r12d
je 0x1117a
leaq 0x353c9(%rip), %rdi     # 0x46534
leaq 0x10(%rsp), %rdx
movl %r12d, %esi
xorl %eax, %eax
callq 0xf050
pushq $0xa
popq %rdi
callq 0xf150
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop