// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/semind.c
// Function: command_search
static void command_search(int argc, char **argv)
{
	char *sql;
	char *dberr = NULL;
	sqlite3_str *query = sqlite3_str_new(semind_db);

	if (chdir(cwd) < 0)
		semind_error(1, errno, "unable to change directory: %s", cwd);

	if (query_appendf(query,
	                  "SELECT"
	                  " file.name,"
	                  " semind.line,"
	                  " semind.column,"
	                  " semind.context,"
	                  " semind.symbol,"
	                  " semind.mode,"
	                  " semind.kind "
	                  "FROM semind, file "
	                  "WHERE semind.file == file.id") < 0)
		goto fail;

	if (semind_search_kind) {
		if (query_appendf(query, " AND semind.kind == %d", semind_search_kind) < 0)
			goto fail;
	}

	if (semind_search_symbol) {
		int ret;

		if (query_appendf(query, " AND ") < 0)
			goto fail;

		if (strpbrk(semind_search_symbol, "*?[]"))
			ret = query_appendf(query, "semind.symbol GLOB %Q", semind_search_symbol);
		else
			ret = query_appendf(query, "semind.symbol == %Q", semind_search_symbol);

		if (ret < 0)
			goto fail;
	}

	if (semind_search_modmask_defined) {
		if (!semind_search_modmask) {
			if (query_appendf(query, " AND semind.mode == %d", semind_search_modmask) < 0)
				goto fail;
		} else if (query_appendf(query, " AND (semind.mode & %d) != 0", semind_search_modmask) < 0)
			goto fail;
	}

	if (semind_search_path) {
		if (query_appendf(query, " AND file.name GLOB %Q", semind_search_path) < 0)
			goto fail;
	}

	if (semind_search_by_location == EXPLAIN_LOCATION) {
		if (query_appendf(query, " AND file.name == %Q", semind_search_filename) < 0)
			goto fail;
		if (semind_search_line &&
		    query_appendf(query, " AND semind.line == %d", semind_search_line) < 0)
			goto fail;
		if (semind_search_column &&
		    query_appendf(query, " AND semind.column == %d", semind_search_column) < 0)
			goto fail;
	} else if (semind_search_by_location == USAGE_BY_LOCATION) {
		if (query_appendf(query, " AND semind.symbol IN (") < 0)
			goto fail;
		if (query_appendf(query,
		                 "SELECT semind.symbol FROM semind, file WHERE"
				 " semind.file == file.id AND"
		                 " file.name == %Q", semind_search_filename) < 0)
			goto fail;
		if (semind_search_line &&
		    query_appendf(query, " AND semind.line == %d", semind_search_line) < 0)
			goto fail;
		if (semind_search_column &&
		    query_appendf(query, " AND semind.column == %d", semind_search_column) < 0)
			goto fail;
		if (query_appendf(query, ")") < 0)
			goto fail;
	}

	if (query_appendf(query, " ORDER BY file.name, semind.line, semind.column ASC", semind_search_path) < 0)
		goto fail;

	sql = sqlite3_str_value(query);

	if (semind_verbose > 1)
		message("SQL: %s", sql);

	sqlite3_exec(semind_db, sql, search_query_callback, NULL, &dberr);
	if (dberr)
		semind_error(1, 0, "sql query failed: %s", dberr);
fail:
	sql = sqlite3_str_finish(query);
	sqlite3_free(sql);

	if (semind_file_fd) {
		fclose(semind_file_fd);
		free(semind_file_name);
	}
	free(semind_line);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movq 0x81d22(%rip), %rdi     # 0x94b20
callq 0x122f0
movq %rax, -0x28(%rbp)
leaq 0x80d02(%rip), %rdi     # 0x93b10
callq 0x12040
cmpl $0x0, %eax
jge 0x12e39
callq 0x12350
movl (%rax), %esi
movl $0x1, %edi
leaq 0x54d8e(%rip), %rdx     # 0x67bb9
leaq 0x80cde(%rip), %rcx     # 0x93b10
movb $0x0, %al
callq 0x131c0
movq -0x28(%rbp), %rdi
leaq 0x54d94(%rip), %rsi     # 0x67bd8
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x12e55
jmp 0x13169
cmpl $0x0, 0x82158(%rip)     # 0x94fb4
je 0x12e82
movq -0x28(%rbp), %rdi
movl 0x8214c(%rip), %edx     # 0x94fb4
leaq 0x54dfe(%rip), %rsi     # 0x67c6d
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x12e80
jmp 0x13169
jmp 0x12e82
cmpq $0x0, 0x82146(%rip)     # 0x94fd0
je 0x12f08
movq -0x28(%rbp), %rdi
leaq 0x54ded(%rip), %rsi     # 0x67c84
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x12ea8
jmp 0x13169
movq 0x82121(%rip), %rdi     # 0x94fd0
leaq 0x54dd4(%rip), %rsi     # 0x67c8a
callq 0x12150
cmpq $0x0, %rax
je 0x12edf
movq -0x28(%rbp), %rdi
movq 0x82104(%rip), %rdx     # 0x94fd0
leaq 0x54dbc(%rip), %rsi     # 0x67c8f
movb $0x0, %al
callq 0x14440
movl %eax, -0x2c(%rbp)
jmp 0x12efb
movq -0x28(%rbp), %rdi
movq 0x820e6(%rip), %rdx     # 0x94fd0
leaq 0x54db4(%rip), %rsi     # 0x67ca5
movb $0x0, %al
callq 0x14440
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jge 0x12f06
jmp 0x13169
jmp 0x12f08
cmpl $0x0, 0x820c9(%rip)     # 0x94fd8
je 0x12f64
cmpl $0x0, 0x820c4(%rip)     # 0x94fdc
jne 0x12f3e
movq -0x28(%rbp), %rdi
movl 0x820b8(%rip), %edx     # 0x94fdc
leaq 0x54d8e(%rip), %rsi     # 0x67cb9
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x12f3c
jmp 0x13169
jmp 0x12f62
movq -0x28(%rbp), %rdi
movl 0x82094(%rip), %edx     # 0x94fdc
leaq 0x54d81(%rip), %rsi     # 0x67cd0
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x12f60
jmp 0x13169
jmp 0x12f62
jmp 0x12f64
cmpq $0x0, 0x8204c(%rip)     # 0x94fb8
je 0x12f93
movq -0x28(%rbp), %rdi
movq 0x8203f(%rip), %rdx     # 0x94fb8
leaq 0x54d6d(%rip), %rsi     # 0x67ced
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x12f91
jmp 0x13169
jmp 0x12f93
cmpl $0x1, 0x82016(%rip)     # 0x94fb0
jne 0x1301a
movq -0x28(%rbp), %rdi
movq 0x82019(%rip), %rdx     # 0x94fc0
leaq 0x54de1(%rip), %rsi     # 0x67d8f
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x12fbf
jmp 0x13169
cmpl $0x0, 0x82002(%rip)     # 0x94fc8
je 0x12fea
movq -0x28(%rbp), %rdi
movl 0x81ff6(%rip), %edx     # 0x94fc8
leaq 0x54d2b(%rip), %rsi     # 0x67d04
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x12fea
jmp 0x13169
cmpl $0x0, 0x81fdb(%rip)     # 0x94fcc
je 0x13015
movq -0x28(%rbp), %rdi
movl 0x81fcf(%rip), %edx     # 0x94fcc
leaq 0x54d17(%rip), %rsi     # 0x67d1b
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x13015
jmp 0x13169
jmp 0x130dc
cmpl $0x2, 0x81f8f(%rip)     # 0x94fb0
jne 0x130da
movq -0x28(%rbp), %rdi
leaq 0x54d02(%rip), %rsi     # 0x67d34
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x13043
jmp 0x13169
movq -0x28(%rbp), %rdi
movq 0x81f72(%rip), %rdx     # 0x94fc0
leaq 0x54cf7(%rip), %rsi     # 0x67d4c
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x13066
jmp 0x13169
cmpl $0x0, 0x81f5b(%rip)     # 0x94fc8
je 0x13091
movq -0x28(%rbp), %rdi
movl 0x81f4f(%rip), %edx     # 0x94fc8
leaq 0x54c84(%rip), %rsi     # 0x67d04
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x13091
jmp 0x13169
cmpl $0x0, 0x81f34(%rip)     # 0x94fcc
je 0x130bc
movq -0x28(%rbp), %rdi
movl 0x81f28(%rip), %edx     # 0x94fcc
leaq 0x54c70(%rip), %rsi     # 0x67d1b
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x130bc
jmp 0x13169
movq -0x28(%rbp), %rdi
leaq 0x59f1b(%rip), %rsi     # 0x6cfe2
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x130d8
jmp 0x13169
jmp 0x130da
jmp 0x130dc
movq -0x28(%rbp), %rdi
movq 0x81ed1(%rip), %rdx     # 0x94fb8
leaq 0x54cb6(%rip), %rsi     # 0x67da4
movb $0x0, %al
callq 0x14440
cmpl $0x0, %eax
jge 0x130fc
jmp 0x13169
movq -0x28(%rbp), %rdi
callq 0x121a0
movq %rax, -0x18(%rbp)
cmpl $0x1, 0x81a1c(%rip)     # 0x94b2c
jle 0x13128
movq -0x18(%rbp), %rcx
xorl %esi, %esi
leaq 0x54677(%rip), %rdx     # 0x67796
movl %esi, %edi
movb $0x0, %al
callq 0x131c0
movq 0x819f1(%rip), %rdi     # 0x94b20
movq -0x18(%rbp), %rsi
leaq 0x1406(%rip), %rdx      # 0x14540
xorl %eax, %eax
movl %eax, %ecx
leaq -0x20(%rbp), %r8
callq 0x12140
cmpq $0x0, -0x20(%rbp)
je 0x13167
movq -0x20(%rbp), %rcx
movl $0x1, %edi
xorl %esi, %esi
leaq 0x54c78(%rip), %rdx     # 0x67dd8
movb $0x0, %al
callq 0x131c0
jmp 0x13169
movq -0x28(%rbp), %rdi
callq 0x12290
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x121b0
cmpq $0x0, 0x81e59(%rip)     # 0x94fe0
je 0x131a1
movq 0x81e50(%rip), %rdi     # 0x94fe0
callq 0x12400
movq 0x81e4c(%rip), %rdi     # 0x94fe8
callq 0x121e0
movq 0x81e48(%rip), %rdi     # 0x94ff0
callq 0x121e0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)