// File: /workspace/github_c_makefile_star2_O0/intel[P]pf-bb-config/config_app.c
// Function: get_device_id
static bool
get_device_id(hw_device *device, const char *location)
{
	unsigned long vendor_id = -1, device_id = -1;
	struct dirent *dirent;
	DIR *dir;
	char pci_path[PATH_MAX];

	snprintf(pci_path, sizeof(pci_path), "%s/%s", SYS_DIR, location);
	dir = opendir(pci_path);
	if (dir == NULL) {
		LOG(ERR, "Failed to open %s (%s)", pci_path, strerror(errno));
		return false;
	}

	while ((dirent = readdir(dir)) != NULL) {
		char file_path[PATH_MAX];

		/* Omit Current Directory & Previous Directory Lookup */
		if (strncmp(dirent->d_name, CUR_DIR,
				strlen(dirent->d_name)) == 0 ||
				strncmp(dirent->d_name, PREV_DIR,
				strlen(dirent->d_name)) == 0)
			continue;

		/* Set filepath as next PCI folder (xxxx:xx:xx.x) */
		int snprintf_ret =  snprintf(file_path, sizeof(file_path), "%s/%s",
				pci_path, dirent->d_name);
		if (snprintf_ret < 0)
			LOG(ERR, "Failed to format PCI path");

		/* Get Device ID */
		if (strncmp(dirent->d_name, DEVICE_FILE,
				strlen(dirent->d_name)) == 0 &&
				dirent->d_type == DT_REG)
			device_id = get_file_val(file_path);

		/* Get Vendor ID */
		if (strncmp(dirent->d_name, VENDOR_FILE,
				strlen(dirent->d_name)) == 0 &&
				dirent->d_type == DT_REG)
			vendor_id = get_file_val(file_path);
	}

	closedir(dir);
	/* Check if device is found */
	return (vendor_id == device->vendor_id &&
			device_id == device->device_id);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2090, %rsp           # imm = 0x2090
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $-0x1, -0x20(%rbp)
movq $-0x1, -0x28(%rbp)
leaq -0x1040(%rbp), %rdi
movq -0x18(%rbp), %r8
movl $0x1000, %esi           # imm = 0x1000
leaq 0x14cd6(%rip), %rdx     # 0x23310
leaq 0x14cd5(%rip), %rcx     # 0x23316
movb $0x0, %al
callq 0xd160
leaq -0x1040(%rbp), %rdi
callq 0xd0e0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0xe6ca
callq 0xe9a0
movq %rax, -0x2060(%rbp)
leaq 0x2d25e(%rip), %rax     # 0x3b8d0
movq (%rax), %rax
movq %rax, -0x2058(%rbp)
leaq -0x1040(%rbp), %rax
movq %rax, -0x2050(%rbp)
callq 0xd060
movl (%rax), %edi
callq 0xd410
movq -0x2060(%rbp), %rcx
movq -0x2058(%rbp), %r8
movq -0x2050(%rbp), %r9
xorl %esi, %esi
leaq 0x14e91(%rip), %rdx     # 0x23545
movl %esi, %edi
movq %rax, (%rsp)
movb $0x0, %al
callq 0x216e0
movb $0x0, -0x1(%rbp)
jmp 0xe8a4
jmp 0xe6cc
movq -0x38(%rbp), %rdi
callq 0xd260
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0xe85f
movq -0x30(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x2068(%rbp)
movq -0x30(%rbp), %rdi
addq $0x13, %rdi
callq 0xd0f0
movq -0x2068(%rbp), %rdi
movq %rax, %rdx
leaq 0x14e33(%rip), %rsi     # 0x23543
callq 0xd090
cmpl $0x0, %eax
je 0xe751
movq -0x30(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x2070(%rbp)
movq -0x30(%rbp), %rdi
addq $0x13, %rdi
callq 0xd0f0
movq -0x2070(%rbp), %rdi
movq %rax, %rdx
leaq 0x14dfb(%rip), %rsi     # 0x23542
callq 0xd090
cmpl $0x0, %eax
jne 0xe756
jmp 0xe6cc
leaq -0x2040(%rbp), %rdi
leaq -0x1040(%rbp), %rcx
movq -0x30(%rbp), %r8
addq $0x13, %r8
movl $0x1000, %esi           # imm = 0x1000
leaq 0x14b98(%rip), %rdx     # 0x23310
movb $0x0, %al
callq 0xd160
movl %eax, -0x2044(%rbp)
cmpl $0x0, -0x2044(%rbp)
jge 0xe7b2
callq 0xe9a0
movq %rax, %rcx
leaq 0x2d133(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
xorl %esi, %esi
leaq 0x14dba(%rip), %rdx     # 0x23563
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movq -0x30(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x2078(%rbp)
movq -0x30(%rbp), %rdi
addq $0x13, %rdi
callq 0xd0f0
movq -0x2078(%rbp), %rdi
movq %rax, %rdx
leaq 0x14eff(%rip), %rsi     # 0x236de
callq 0xd090
cmpl $0x0, %eax
jne 0xe806
movq -0x30(%rbp), %rax
movzbl 0x12(%rax), %eax
cmpl $0x8, %eax
jne 0xe806
leaq -0x2040(%rbp), %rdi
callq 0xe8c0
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x2080(%rbp)
movq -0x30(%rbp), %rdi
addq $0x13, %rdi
callq 0xd0f0
movq -0x2080(%rbp), %rdi
movq %rax, %rdx
leaq 0x14d51(%rip), %rsi     # 0x23584
callq 0xd090
cmpl $0x0, %eax
jne 0xe85a
movq -0x30(%rbp), %rax
movzbl 0x12(%rax), %eax
cmpl $0x8, %eax
jne 0xe85a
leaq -0x2040(%rbp), %rdi
callq 0xe8c0
movq %rax, -0x20(%rbp)
jmp 0xe6cc
movq -0x38(%rbp), %rdi
callq 0xd1b0
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq 0x18(%rax), %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x2081(%rbp)
jne 0xe899
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
cmpq %rcx, %rax
sete %al
movb %al, -0x2081(%rbp)
movb -0x2081(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x2090, %rsp           # imm = 0x2090
popq %rbp
retq
nopw %cs:(%rax,%rax)