// File: /workspace/github_c_makefile_star2_O0/rsa9000[P]regfanalysistools/regfdump.c
// Function: main
int main(int argc, char *argv[])
{
	FILE *fp;
	int res = 0;
	unsigned off;

	if (argc < 2) {
		fprintf(stderr, "Registry file not specified, exit.\n");
		return EXIT_FAILURE;
	}

	rbtree_init(&st.cells);

	st.icd = iconv_open("WCHAR_T", "UTF-16");
	if (st.icd == (iconv_t)-1) {
		fprintf(stderr, "Could not create iconv descriptor to convert UTF-16BE to WCHAR_T\n");
		return EXIT_FAILURE;
	}

	setlocale(LC_CTYPE, "");

	fp = fopen(argv[1], "rb");
	if (!fp) {
		fprintf(stderr, "Could not open registry file %s: %s\n", argv[1], strerror(errno));
		return EXIT_FAILURE;
	}

	res = regf_parse_fheader(fp);
	if (res) {
		fprintf(stderr, "Could not parse file header!\n");
		goto exit;
	}

	st.__data = mmap(NULL, st.data_sz, PROT_READ, MAP_SHARED, fileno(fp),
			 0x1000);
	if (st.__data == MAP_FAILED) {
		fprintf(stderr, "Could mmap hbin data: %s\n",
			strerror(errno));
		goto exit;
	}
	st.data = st.__data;

	res = regf_scan_data(st.data, st.data_sz);
	if (res) {
		fprintf(stderr, "Could not scan hbin data\n");
		goto exit;
	}

	for (off = 0; off < st.data_sz; off += res) {
		res = regf_parse_hbin(off);
		if (res <= 0) {
			PR_WARN(off, "hbin", "could not parse hbin\n");
			goto exit;
		}
	}
	res = 0;

	regf_cells_stat();

exit:
	if (st.data != NULL)
		munmap(st.__data, st.data_sz);

	fclose(fp);

	return res ? EXIT_FAILURE : EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x12c7
movq 0x6d4e(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x3d80(%rip), %rsi      # 0x5034
movb $0x0, %al
callq 0x10d0
movl $0x1, -0x4(%rbp)
jmp 0x151a
leaq 0x6e12(%rip), %rdi      # 0x80e0
addq $0x28, %rdi
callq 0x3530
leaq 0x3d7a(%rip), %rdi      # 0x5058
leaq 0x3d7b(%rip), %rsi      # 0x5060
callq 0x1170
movq %rax, 0x6def(%rip)      # 0x80e0
movq $-0x1, %rax
cmpq %rax, 0x6de1(%rip)      # 0x80e0
jne 0x1325
movq 0x6cf0(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x3d55(%rip), %rsi      # 0x5067
movb $0x0, %al
callq 0x10d0
movl $0x1, -0x4(%rbp)
jmp 0x151a
xorl %edi, %edi
leaq 0x3f65(%rip), %rsi      # 0x5293
callq 0x1130
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x3d67(%rip), %rsi      # 0x50a9
callq 0x1140
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x139d
movq 0x6c9f(%rip), %rax      # 0x7ff8
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1160
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq %rax, %rcx
leaq 0x3d22(%rip), %rsi      # 0x50ac
movb $0x0, %al
callq 0x10d0
movl $0x1, -0x4(%rbp)
jmp 0x151a
movq -0x18(%rbp), %rdi
callq 0x1530
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x13cc
movq 0x6c42(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x3d11(%rip), %rsi      # 0x50d1
movb $0x0, %al
callq 0x10d0
jmp 0x14e0
movl 0x6d2e(%rip), %eax      # 0x8100
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x10f0
movq -0x38(%rbp), %rsi
movl %eax, %r8d
xorl %eax, %eax
movl %eax, %edi
movl $0x1, %ecx
movl $0x1000, %r9d           # imm = 0x1000
movl %ecx, %edx
callq 0x1080
movq %rax, 0x6ce5(%rip)      # 0x80e8
movq $-0x1, %rax
cmpq %rax, 0x6cd7(%rip)      # 0x80e8
jne 0x1447
movq 0x6bde(%rip), %rax      # 0x7ff8
movq (%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1160
movq -0x40(%rbp), %rdi
movq %rax, %rdx
leaq 0x3cb4(%rip), %rsi      # 0x50ef
movb $0x0, %al
callq 0x10d0
jmp 0x14e0
movq 0x6c9a(%rip), %rax      # 0x80e8
movq %rax, 0x6c9b(%rip)      # 0x80f0
movq 0x6c94(%rip), %rdi      # 0x80f0
movl 0x6c9e(%rip), %esi      # 0x8100
callq 0x1860
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x148a
movq 0x6b81(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x3c88(%rip), %rsi      # 0x5109
movb $0x0, %al
callq 0x10d0
jmp 0x14e0
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl 0x6c66(%rip), %eax      # 0x8100
jae 0x14d4
movl -0x20(%rbp), %edi
callq 0x19a0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jg 0x14c7
movl -0x20(%rbp), %esi
leaq 0x3c6c(%rip), %rdi      # 0x5123
leaq 0x3e74(%rip), %rdx      # 0x5332
movb $0x0, %al
callq 0x45e0
jmp 0x14e0
jmp 0x14c9
movl -0x1c(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x1491
movl $0x0, -0x1c(%rbp)
callq 0x1a80
cmpq $0x0, 0x6c08(%rip)      # 0x80f0
je 0x14fe
movq 0x6bf7(%rip), %rdi      # 0x80e8
movl 0x6c09(%rip), %eax      # 0x8100
movl %eax, %esi
callq 0x1120
movq -0x18(%rbp), %rdi
callq 0x1070
movl -0x1c(%rbp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)