// File: /workspace/github_c_makefile_star2_O0/intel[P]pf-bb-config/vrb1/vrb1_cfg_app.c
// Function: vrb1_fft_reconfig
static int
vrb1_fft_reconfig(uint8_t *d, bool lut_programming, hw_device *accel_pci_dev)
{
	int16_t gTDWinCoff[VRB1_LUT_SIZE], ret, offset, i, pageIdx;
	const char *lut_filename;
	FILE *fp;
	bool unsafe_path;

	/* Default FFT configuration. */
	vrb1_reg_fast_write(d, HWPfFftConfig0, VRB1_FFT_CFG_0);

	if (!lut_programming)
		return 0;

	/* Load the FFT windows LUT. */
	lut_filename = accel_pci_dev->fft_lut_filename;
	unsafe_path = cfg_file_check_path_safety(lut_filename);
	if (unsafe_path == true) {
		LOG(ERR, "error, FFT LUT file path \"%s\" is not safe", lut_filename);
		return -ENOENT;
	}

	fp = fopen(lut_filename, "rb");
	if (fp == NULL) {
		LOG(ERR, "  Error reading from FFT LUT %s", lut_filename);
		return -ENOENT;
	}
	ret = fread((char *)gTDWinCoff, VRB1_LUT_SIZE * 2, 1, fp);
	if (ret <= 0) {
		LOG(ERR, "  Error reading from FFT LUT %s", lut_filename);
		fclose(fp);
		return -ENOENT;
	}
	LOG(INFO, "  FFT Window coeffs preloading from %s", lut_filename);

	offset = VRB1_FFT_FIRST_OFFSET;
	pageIdx = 0;
	vrb1_reg_fast_write(d, HWPfFftRamPageAccess, VRB1_FFT_RAM_EN);
	for (i = 0; i < VRB1_LUT_SIZE; i++) {
		vrb1_reg_fast_write(d, HWPfFftRamOff + offset *	VRB1_BYTES_IN_WORD, gTDWinCoff[i]);
		offset++;
		if ((offset % VRB1_FFT_PAGE_SIZE) == 0) {
			offset = 0;
			pageIdx++;
			fflush(stdout);
			vrb1_reg_fast_write(d, HWPfFftRamPageAccess, VRB1_FFT_RAM_EN + pageIdx);
		}
	}

	vrb1_reg_fast_write(d, HWPfFftRamPageAccess, VRB1_FFT_RAM_DIS);
	fclose(fp);

	vrb_fft_win_check(gTDWinCoff, accel_pci_dev);

	vrb_fft_lut_md5sum(lut_filename, accel_pci_dev);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xfe40, %rsp           # imm = 0xFE40
movb %sil, %al
movq %rdi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl $0xb58004, %esi         # imm = 0xB58004
movl $0x2001, %edx           # imm = 0x2001
callq 0x14210
testb $0x1, -0x11(%rbp)
jne 0x163c0
movl $0x0, -0x4(%rbp)
jmp 0x16657
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xfe30(%rbp)
movq -0xfe30(%rbp), %rdi
callq 0x17fc0
andb $0x1, %al
movb %al, -0xfe39(%rbp)
movb -0xfe39(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x1642a
callq 0x16250
movq %rax, %rcx
leaq 0x254ce(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movq -0xfe30(%rbp), %r9
xorl %esi, %esi
leaq 0xe556(%rip), %rdx      # 0x2496b
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x16657
movq -0xfe30(%rbp), %rdi
leaq 0xe564(%rip), %rsi      # 0x2499c
callq 0xd330
movq %rax, -0xfe38(%rbp)
cmpq $0x0, -0xfe38(%rbp)
jne 0x16485
callq 0x16250
movq %rax, %rcx
leaq 0x25473(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movq -0xfe30(%rbp), %r9
xorl %esi, %esi
leaq 0xe52f(%rip), %rdx      # 0x2499f
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x16657
leaq -0xfe20(%rbp), %rdi
movq -0xfe38(%rbp), %rcx
movl $0xfe00, %esi           # imm = 0xFE00
movl $0x1, %edx
callq 0xd0b0
movw %ax, -0xfe22(%rbp)
movswl -0xfe22(%rbp), %eax
cmpl $0x0, %eax
jg 0x164f8
callq 0x16250
movq %rax, %rcx
leaq 0x2540c(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movq -0xfe30(%rbp), %r9
xorl %esi, %esi
leaq 0xe4c8(%rip), %rdx      # 0x2499f
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movq -0xfe38(%rbp), %rdi
callq 0xd0d0
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x16657
callq 0x16250
movq %rax, %rcx
leaq 0x253c9(%rip), %rax     # 0x3b8d0
movq 0x10(%rax), %r8
movq -0xfe30(%rbp), %r9
movl $0x2, %edi
xorl %esi, %esi
leaq 0xe4a6(%rip), %rdx      # 0x249c6
movb $0x0, %al
callq 0x216e0
movw $0x100, -0xfe24(%rbp)   # imm = 0x100
movw $0x0, -0xfe28(%rbp)
movq -0x10(%rbp), %rdi
movl $0xb5800c, %esi         # imm = 0xB5800C
movl $0x80000000, %edx       # imm = 0x80000000
callq 0x14210
movw $0x0, -0xfe26(%rbp)
movswl -0xfe26(%rbp), %eax
cmpl $0x7f00, %eax           # imm = 0x7F00
jge 0x16614
movq -0x10(%rbp), %rdi
movswl -0xfe24(%rbp), %esi
shll $0x2, %esi
addl $0xb58800, %esi         # imm = 0xB58800
movswq -0xfe26(%rbp), %rax
movswl -0xfe20(%rbp,%rax,2), %edx
callq 0x14210
movw -0xfe24(%rbp), %ax
addw $0x1, %ax
movw %ax, -0xfe24(%rbp)
movswl -0xfe24(%rbp), %eax
movl $0x200, %ecx            # imm = 0x200
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x165fb
movw $0x0, -0xfe24(%rbp)
movw -0xfe28(%rbp), %ax
addw $0x1, %ax
movw %ax, -0xfe28(%rbp)
movq 0x23a00(%rip), %rax     # 0x39fd8
movq (%rax), %rdi
callq 0xd290
movq -0x10(%rbp), %rdi
movswl -0xfe28(%rbp), %edx
addl $0x80000000, %edx       # imm = 0x80000000
movl $0xb5800c, %esi         # imm = 0xB5800C
callq 0x14210
jmp 0x165fd
movw -0xfe26(%rbp), %ax
addw $0x1, %ax
movw %ax, -0xfe26(%rbp)
jmp 0x16555
movq -0x10(%rbp), %rdi
movl $0xb5800c, %esi         # imm = 0xB5800C
xorl %edx, %edx
callq 0x14210
movq -0xfe38(%rbp), %rdi
callq 0xd0d0
leaq -0xfe20(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x13b90
movq -0xfe30(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x13d80
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xfe40, %rsp           # imm = 0xFE40
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)