// File: /workspace/github_c_makefile_star2_O1/intel[P]pf-bb-config/config_app.c
// Function: main
int
main(int argc, char *argv[])
{
	int i, ret = 0, num_devices;
	hw_device device;
	char *found_devices[10];
	char log_file_main[BB_ACC_LOG_FILE_LEN];
	char log_file_resp[BB_ACC_LOG_FILE_LEN];

	memset(&device, 0, sizeof(device));

	if (bbdev_parse_args(argc, argv, &device) > 0)
		return 0;

	event_init_fd();
	printf("%s\n", PF_BB_VERSION);

	/* Set Device Info */
	ret = set_device(&device);
	if (ret != 0) {
		printf("ERR: Device '%s' is not supported\n", device.device_name);
		return 0;
	}

	/* Check if device is installed */
	num_devices = probe_pci_bus(&device, found_devices);
	if (num_devices == 0) {
		printf("ERR: No devices found!!\n");
		return -1;
	} else if (num_devices < 0) {
		return num_devices;
	}

	ret = select_device(&device, found_devices, num_devices);
	if (ret != 0) {
		printf("ERR: Need to select device.\n");
		return -1;
	}

	sprintf(log_file_main, "%s/pf_bb_cfg_%s.log", BB_ACC_DEFAULT_LOG_PATH,
			device.pci_address);
	sprintf(log_file_resp, "%s/pf_bb_cfg_%s_response.log", BB_ACC_DEFAULT_LOG_PATH,
			device.pci_address);
	if (bb_acc_logInit(log_file_main, log_file_resp, BB_ACC_MAX_LOG_FILE_SIZE,
			INFO, device.vfio_mode)) {
		printf("ERR: Logfile init failed\n");
		return -1;
	}

	/* Configure Device */
	ret = configure_device(&device);
	if (ret != 0) {
		printf("ERR: Device configuration failed!\n");
		if (device.vfio_mode)
			printf("Log file = /var/log/pf_bb_cfg_%s.log\n", device.pci_address);
		return ret;
	}

	/* Free memory for stored PCI slots */
	for (i = 0; i < num_devices; i++)
		free(found_devices[i]);

	if (device.vfio_mode) {
		printf("%s PF [%s] configuration complete!\n",
				device.device_name, device.pci_address);
		LOG(INFO, "Running in daemon mode for VFIO VF token");
		printf("Log file = /var/log/pf_bb_cfg_%s.log\n", device.pci_address);
		daemonize(&device);
	}

	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6e8, %rsp            # imm = 0x6E8
movq %rsi, %r15
movl %edi, %ebp
leaq 0xe0(%rsp), %rdi
xorl %ebx, %ebx
movl $0x580, %edx            # imm = 0x580
xorl %esi, %esi
callq 0xd180
movq (%r15), %rdx
cmpl $0x1, %ebp
jne 0xdaec
leaq 0xd77a(%rip), %rdi      # 0x1b25a
leaq 0xd645(%rip), %rsi      # 0x1b12c
jmp 0xdbed
movq %rdx, 0x8(%rsp)
movq 0x8(%r15), %rax
leaq 0x1bc(%rsp), %rbx
movq %rax, -0xdc(%rbx)
leaq 0x100(%rsp), %r12
leaq 0xd73d(%rip), %r13      # 0x1b250
movq 0x254be(%rip), %r14     # 0x32fd8
movl %ebp, %edi
movq %r15, %rsi
movq %r13, %rdx
callq 0xd370
cmpl $0x6f, %eax
jg 0xdb43
cmpl $0x63, %eax
je 0xdb70
cmpl $0x66, %eax
jne 0xdb97
movq (%r14), %rax
movq %rax, 0xf0(%rsp)
jmp 0xdb1a
cmpl $0x70, %eax
je 0xdb7d
cmpl $0x76, %eax
jne 0xdbd8
movl $0x1, 0x19c(%rsp)
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x1861b
testl %eax, %eax
jns 0xdb1a
jmp 0xdf93
movq (%r14), %rax
movq %rax, 0xe8(%rsp)
jmp 0xdb1a
movq (%r14), %rsi
movl $0xd, %edx
movq %r12, %rdi
callq 0xd090
movb $0x0, 0x10e(%rsp)
jmp 0xdb1a
cmpl $-0x1, %eax
jne 0xdbd8
callq 0x194c8
leaq 0xd584(%rip), %rdi      # 0x1b12c
callq 0xd0c0
leaq 0xe0(%rsp), %rdi
callq 0xd57c
testl %eax, %eax
je 0xdc08
movq 0xe0(%rsp), %rsi
leaq 0xd58b(%rip), %rdi      # 0x1b158
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xd150
jmp 0xdbf4
leaq 0xd67b(%rip), %rdi      # 0x1b25a
leaq 0xd546(%rip), %rsi      # 0x1b12c
xorl %ebx, %ebx
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0xd150
movl %ebx, %eax
addq $0x6e8, %rsp            # imm = 0x6E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd605(%rip), %rdi      # 0x1b214
callq 0xd100
testq %rax, %rax
je 0xdcaf
movq %rax, %rbx
cmpb $0x0, 0x100(%rsp)
je 0xdcba
leaq 0x100(%rsp), %r14
movq %r14, %rdi
callq 0xd110
cmpq $0x7, %rax
jne 0xdc6d
leaq 0x60(%rsp), %r15
movw $0x3a, 0x4(%r15)
movl $0x30303030, (%r15)     # imm = 0x30303030
movq %r15, %rdi
movq %r14, %rsi
callq 0xd3d0
movq %r14, %rdi
movq %r15, %rsi
callq 0xd0b0
leaq 0xe0(%rsp), %rdi
movq %r14, %rsi
callq 0xe0e6
testb %al, %al
je 0xdd5f
movl $0xf, %edi
callq 0xd280
movq %rax, 0x10(%rsp)
movl $0xd, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0xd090
movl $0x1, %r12d
jmp 0xdd62
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0xdd6a
movq %rbx, %rdi
callq 0xd270
testq %rax, %rax
je 0xdd5f
movq %rax, %r13
xorl %r12d, %r12d
leaq 0xd9b0(%rip), %r14      # 0x1b688
leaq 0xd9a8(%rip), %r15      # 0x1b687
addq $0x13, %r13
movq %r13, %rdi
callq 0xd110
movq %rax, %rbp
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0xd0a0
testl %eax, %eax
je 0xdd12
movq %r13, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0xd0a0
testl %eax, %eax
jne 0xdd24
movq %rbx, %rdi
callq 0xd270
movq %rax, %r13
testq %rax, %rax
jne 0xdcdf
jmp 0xdd62
leaq 0xe0(%rsp), %rdi
movq %r13, %rsi
callq 0xe0e6
testb %al, %al
je 0xdd12
movl $0xf, %edi
callq 0xd280
movslq %r12d, %r12
movq %rax, 0x10(%rsp,%r12,8)
movl $0xd, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0xd090
incl %r12d
jmp 0xdd12
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0xd1c0
testl %r12d, %r12d
je 0xde07
js 0xde13
cmpl $0x2, %r12d
jl 0xde1b
movl %r12d, %r15d
leaq 0xd87e(%rip), %rdi      # 0x1b60b
callq 0xd0c0
leaq 0xd6ee(%rip), %rbx      # 0x1b487
xorl %r14d, %r14d
movq 0x10(%rsp,%r14,8), %rdx
incq %r14
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0xd150
cmpq %r14, %r15
jne 0xdd9c
leaq 0xd6d4(%rip), %rdi      # 0x1b491
xorl %eax, %eax
callq 0xd150
leaq 0xe47f(%rip), %rdi      # 0x1c24a
leaq 0x60(%rsp), %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0xd3b0
movslq (%rbx), %rcx
testq %rcx, %rcx
jle 0xdea5
cmpl $0x1, %eax
jne 0xdea5
cmpl %r15d, %ecx
jg 0xdea5
leaq 0x100(%rsp), %rdi
movq 0x8(%rsp,%rcx,8), %rsi
jmp 0xde28
leaq 0xd7e5(%rip), %rdi      # 0x1b5f3
jmp 0xdeb8
movl %r12d, %ebx
jmp 0xdbf4
leaq 0x100(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0xd, %edx
callq 0xd090
leaq 0x100(%rsp), %r14
leaq 0xd33a(%rip), %rsi      # 0x1b17b
leaq 0xd347(%rip), %rbx      # 0x1b18f
leaq 0x60(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd3e0
leaq 0xd334(%rip), %rsi      # 0x1b198
leaq 0x660(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd3e0
movl 0x9c(%r14), %r8d
movl $0x200000, %edx         # imm = 0x200000
movq %r15, %rdi
movq %r13, %rsi
movl $0x2, %ecx
callq 0x19db2
testl %eax, %eax
je 0xdec7
leaq 0xd71b(%rip), %rdi      # 0x1b5be
jmp 0xdeb8
leaq 0xd7bb(%rip), %rdi      # 0x1b667
callq 0xd0c0
leaq 0xd71f(%rip), %rdi      # 0x1b5d7
callq 0xd0c0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0xdbf4
leaq 0xe0(%rsp), %rdi
callq 0xdf9a
testl %eax, %eax
je 0xdf03
movl %eax, %ebx
leaq 0xd6bb(%rip), %rdi      # 0x1b59c
callq 0xd0c0
cmpl $0x0, 0x19c(%rsp)
je 0xdbf4
leaq 0xd2ba(%rip), %rdi      # 0x1b1b5
movq %r14, %rsi
jmp 0xdbcf
cmpl $0x2, %r12d
movl $0x1, %ebx
cmovgel %r12d, %ebx
xorl %r15d, %r15d
movq 0x10(%rsp,%r15,8), %rdi
callq 0xd030
incq %r15
cmpq %r15, %rbx
jne 0xdf13
cmpl $0x0, 0x19c(%rsp)
je 0xdf93
leaq 0xe0(%rsp), %r15
movq (%r15), %rsi
leaq 0xd577(%rip), %rdi      # 0x1b4b8
xorl %ebx, %ebx
movq %r14, %rdx
xorl %eax, %eax
callq 0xd150
callq 0xe395
leaq 0x25f77(%rip), %rcx     # 0x33ed0
movq 0x10(%rcx), %r8
leaq 0xd277(%rip), %rdx      # 0x1b1db
movl $0x2, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
leaq 0xd239(%rip), %rdi      # 0x1b1b5
movq %r14, %rsi
xorl %eax, %eax
callq 0xd150
movq %r15, %rdi
callq 0x19903
jmp 0xdbf4
xorl %ebx, %ebx
jmp 0xdbf4