// File: /workspace/github_c_makefile_star2_O0/intel[P]pf-bb-config/config_app.c
// Function: probe_pci_bus
static int
probe_pci_bus(hw_device *device, char **found_devices)
{
	struct dirent *dirent;
	DIR *dir;
	int num_devices = 0;

	/* Locate PCI Devices */
	dir = opendir(SYS_DIR);
	if (dir == NULL)
		return -1;

	/* If specific PCI address was passed as argument. */
	if (device->pci_address[0] != 0) {
		/* Handle the case when the node prefix 0000: is not included */
		if (strlen(device->pci_address) == 7) {
			char tmp[PCI_STR_SIZE];
			strcpy(tmp, "0000:");
			strcat(tmp, device->pci_address);
			strcpy(device->pci_address, tmp);
		}
		/* Check if this candidate device matches specified PCI address. */
		if (get_device_id(device, device->pci_address)) {
			found_devices[num_devices] = (char *) malloc(PCI_STR_SIZE);
			/* Copy PCI slot of device */
			strncpy(found_devices[num_devices], device->pci_address,
					sizeof(device->pci_address) - NULL_PAD);
			num_devices = 1;
		}
	}
	else {
		/* Iterate Through Directories */
		while ((dirent = readdir(dir)) != NULL) {

			/* Omit Current Directory and 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;
			/* Check if current device matches requested device */
			if (get_device_id(device, dirent->d_name)) {
				found_devices[num_devices] =
						(char *) malloc(PCI_STR_SIZE);
				/* Copy PCI slot of device */
				strncpy(found_devices[num_devices], dirent->d_name,
						sizeof(device->pci_address) - NULL_PAD);
				num_devices++;
			}
		}
	}

	closedir(dir);

	return num_devices;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
leaq 0x15228(%rip), %rdi     # 0x23316
callq 0xd0e0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xe10a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe2a4
movq -0x10(%rbp), %rax
movsbl 0x20(%rax), %eax
cmpl $0x0, %eax
je 0xe1ba
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0xd0f0
cmpq $0x7, %rax
jne 0xe160
leaq -0x3b(%rbp), %rdi
leaq 0x15403(%rip), %rsi     # 0x2353c
callq 0xd0a0
leaq -0x3b(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
callq 0xd3d0
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
leaq -0x3b(%rbp), %rsi
callq 0xd0a0
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
callq 0xe600
testb $0x1, %al
jne 0xe177
jmp 0xe1b5
movl $0xf, %edi
callq 0xd280
movq %rax, %rdx
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
movl $0xd, %edx
callq 0xd080
movl $0x1, -0x2c(%rbp)
jmp 0xe295
jmp 0xe1bc
movq -0x28(%rbp), %rdi
callq 0xd260
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0xe293
movq -0x20(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rdi
addq $0x13, %rdi
callq 0xd0f0
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0x15349(%rip), %rsi     # 0x23543
callq 0xd090
cmpl $0x0, %eax
je 0xe235
movq -0x20(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
addq $0x13, %rdi
callq 0xd0f0
movq -0x50(%rbp), %rdi
movq %rax, %rdx
leaq 0x15317(%rip), %rsi     # 0x23542
callq 0xd090
cmpl $0x0, %eax
jne 0xe237
jmp 0xe1bc
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x13, %rsi
callq 0xe600
testb $0x1, %al
jne 0xe24e
jmp 0xe28e
movl $0xf, %edi
callq 0xd280
movq %rax, %rdx
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x20(%rbp), %rsi
addq $0x13, %rsi
movl $0xd, %edx
callq 0xd080
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xe1bc
jmp 0xe295
movq -0x28(%rbp), %rdi
callq 0xd1b0
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)