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

	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;
	}

	res = regf_parse_root();
	if (res)
		PR_WARN(st.root_off, "root", "tree contains errors\n");

	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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
cmpl $0x1, %edi
jle 0x167a
movq %rsi, %rbx
leaq 0x5e68(%rip), %rdi      # 0x7118
callq 0x2a20
leaq 0x2d6c(%rip), %rdi      # 0x4028
leaq 0x2d6d(%rip), %rsi      # 0x4030
callq 0x1180
movq %rax, 0x5e21(%rip)      # 0x70f0
cmpq $-0x1, %rax
je 0x168f
leaq 0x2f83(%rip), %rsi      # 0x4263
xorl %edi, %edi
callq 0x1130
movq 0x8(%rbx), %rdi
leaq 0x2d87(%rip), %rsi      # 0x4079
callq 0x1140
testq %rax, %rax
je 0x16ad
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1110
testl %eax, %eax
jne 0x16e6
leaq 0x20(%rsp), %rdi
pushq $0x1
popq %rsi
movl $0x200, %edx            # imm = 0x200
movq %r14, %rcx
callq 0x1060
cmpl $0x200, %eax            # imm = 0x200
jne 0x1705
cmpl $0x66676572, 0x20(%rsp) # imm = 0x66676572
jne 0x1731
xorl %eax, %eax
xorl %ecx, %ecx
cmpl $0x80, %eax
je 0x1359
xorl 0x20(%rsp,%rax,4), %ecx
incq %rax
jmp 0x1349
testl %ecx, %ecx
jne 0x1757
movl 0x24(%rsp), %ebx
movl 0x28(%rsp), %ebp
leaq 0x2e6d(%rip), %rdi      # 0x41dd
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x10a0
movq 0x30(%rsp), %rsi
leaq 0x2e7c(%rip), %rdi      # 0x4203
xorl %eax, %eax
callq 0x10a0
cmpl $0x0, 0x40(%rsp)
leaq 0x2e9c(%rip), %rax      # 0x4236
leaq 0x2e90(%rip), %rsi      # 0x4231
cmoveq %rax, %rsi
leaq 0x2e72(%rip), %rdi      # 0x421e
xorl %eax, %eax
callq 0x10a0
cmpl %ebp, %ebx
jne 0x176a
movl 0x38(%rsp), %esi
movl 0x3c(%rsp), %edx
movl %esi, %eax
shll $0x4, %eax
orl %edx, %eax
movl %eax, 0x5d38(%rip)      # 0x7108
movl 0x48(%rsp), %ebx
movl %ebx, 0x5d32(%rip)      # 0x710c
movl 0x4c(%rsp), %ebp
movl %ebp, 0x5d2c(%rip)      # 0x7110
leaq 0x2e79(%rip), %rdi      # 0x4264
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x10a0
leaq 0x2e7e(%rip), %rdi      # 0x427a
movl %ebx, %esi
xorl %eax, %eax
callq 0x10a0
leaq 0x2e86(%rip), %rdi      # 0x4292
movl %ebp, %esi
xorl %eax, %eax
callq 0x10a0
movl 0x5cf5(%rip), %ebx      # 0x7110
movq %r14, %rdi
callq 0x10f0
pushq $0x1
popq %rcx
movl $0x1000, %r9d           # imm = 0x1000
xorl %edi, %edi
movq %rbx, %rsi
movl %ecx, %edx
movl %ecx, 0x8(%rsp)
movl %eax, %r8d
callq 0x1090
movq %rax, 0x5cb2(%rip)      # 0x70f8
cmpq $-0x1, %rax
je 0x17e6
movq %rax, %rbx
movq %r14, 0x10(%rsp)
movq %rax, 0x5ca1(%rip)      # 0x7100
movl 0x5cab(%rip), %eax      # 0x7110
movl %eax, 0xc(%rsp)
movq %rbx, %r14
cmpl 0xc(%rsp), %r15d
jae 0x1502
movq %r14, %rdi
leaq 0x2e28(%rip), %rsi      # 0x42a9
pushq $0x4
popq %rdx
callq 0x1040
testl %eax, %eax
jne 0x181a
movq %r15, 0x18(%rsp)
leaq 0x24(%r14), %r13
movl 0x8(%r14), %eax
leaq (%r14,%rax), %rcx
cmpq %rcx, %r13
jae 0x14f3
movl (%r13), %eax
movl %eax, %ebp
negl %ebp
cmovsl %eax, %ebp
movl %r13d, %r15d
subl %ebx, %r15d
pushq $0x1
popq %rdi
pushq $0x30
popq %rsi
callq 0x10c0
movq %rax, %r12
movl %r15d, 0x18(%rax)
movl %ebp, 0x20(%rax)
leaq 0x5c44(%rip), %rdi      # 0x7118
movq %rax, %rsi
callq 0x2ba3
cmpl $0x0, (%r13)
jle 0x14ec
movl $0x1, 0x28(%r12)
movl %ebp, %eax
addq %rax, %r13
jmp 0x149a
addl 0x18(%rsp), %eax
movq %rcx, %r14
movl %eax, %r15d
jmp 0x146c
movl 0x5c04(%rip), %edi      # 0x710c
callq 0x1859
testq %rax, %rax
je 0x1539
incl 0x24(%rax)
orb $0x2, 0x28(%rax)
movl 0x5bed(%rip), %esi      # 0x710c
leaq 0x2d3d(%rip), %rdi      # 0x4263
callq 0x187a
testl %eax, %eax
jne 0x1556
movl $0x0, 0x8(%rsp)
jmp 0x1571
movl 0x5bcd(%rip), %ecx      # 0x710c
leaq 0x2d89(%rip), %rdi      # 0x42cf
leaq 0x2bcc(%rip), %rdx      # 0x4119
movl %ecx, %esi
xorl %eax, %eax
callq 0x2fdc
movl 0x5bb0(%rip), %esi      # 0x710c
leaq 0x2b90(%rip), %rdi      # 0x40f3
leaq 0x2baf(%rip), %rdx      # 0x4119
xorl %eax, %eax
callq 0x2fdc
movq 0x5ba0(%rip), %rsi      # 0x7118
leaq 0x5ba1(%rip), %rbp      # 0x7120
movq %rbp, %r14
cmpq %rbp, %rsi
je 0x1596
leaq 0x5b8a(%rip), %rdi      # 0x7118
callq 0x2a33
movq %rax, %r14
leaq 0x5b7b(%rip), %r15      # 0x7118
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %ebx, %ebx
cmpq %rbp, %r14
je 0x165a
movl 0x28(%r14), %ecx
testb $0x1, %cl
jne 0x1603
cmpl $0x0, 0x24(%r14)
jne 0x15dd
movl 0x18(%r14), %esi
leaq 0x37f6(%rip), %rdi      # 0x4dbf
leaq 0x3082(%rip), %rdx      # 0x4652
xorl %eax, %eax
callq 0x2fdc
incl %ebx
movl 0x28(%r14), %ecx
leal -0x1(%rcx), %eax
testl %eax, %ecx
jne 0x1627
testl $0xfffffff9, %ecx       # imm = 0xFFFFFFF9
je 0x1644
movl 0x24(%r14), %r8d
cmpl $0x2, %r8d
jb 0x1644
movl 0x18(%r14), %esi
leaq 0x382a(%rip), %rdi      # 0x4e2b
jmp 0x1636
incl %r12d
cmpl $0x2, %ecx
setb %al
movl 0x24(%r14), %r8d
testl %r8d, %r8d
sete %dl
testb %dl, %al
jne 0x1644
movl 0x18(%r14), %esi
leaq 0x3753(%rip), %rdi      # 0x4d78
jmp 0x1636
movl 0x18(%r14), %esi
movl 0x24(%r14), %r8d
leaq 0x37a8(%rip), %rdi      # 0x4dde
leaq 0x3015(%rip), %rdx      # 0x4652
xorl %eax, %eax
callq 0x2fdc
movq %r15, %rdi
movq %r14, %rsi
callq 0x2a86
movq %rax, %r14
incl %r13d
jmp 0x15a5
leaq 0x3814(%rip), %rdi      # 0x4e75
movl %r13d, %esi
movl %r12d, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2fdc
movq 0x10(%rsp), %r14
jmp 0x17ac
movq 0x5977(%rip), %rax      # 0x6ff8
movq (%rax), %rcx
leaq 0x2979(%rip), %rdi      # 0x4004
pushq $0x23
jmp 0x16a2
movq 0x5962(%rip), %rax      # 0x6ff8
movq (%rax), %rcx
leaq 0x2997(%rip), %rdi      # 0x4037
pushq $0x41
popq %rsi
pushq $0x1
popq %rdx
callq 0x1160
jmp 0x16de
movq 0x5944(%rip), %rax      # 0x6ff8
movq (%rax), %r14
movq 0x8(%rbx), %rbx
callq 0x1030
movl (%rax), %edi
callq 0x1170
leaq 0x29ae(%rip), %rsi      # 0x407c
movq %r14, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x10d0
pushq $0x1
popq %rax
jmp 0x17d4
movq 0x590b(%rip), %rax      # 0x6ff8
movq (%rax), %rbx
callq 0x1030
movl (%rax), %edi
callq 0x1170
leaq 0x2a1b(%rip), %rsi      # 0x411e
jmp 0x1722
movq 0x58ec(%rip), %rax      # 0x6ff8
movq (%rax), %rbx
callq 0x1030
movl (%rax), %edi
callq 0x1170
leaq 0x2a3a(%rip), %rsi      # 0x415c
leaq 0x2a20(%rip), %rdx      # 0x4149
movq %rbx, %rdi
movq %rax, %rcx
jmp 0x174e
movq 0x58c0(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x2a43(%rip), %rsi      # 0x4185
leaq 0x2a00(%rip), %rdx      # 0x4149
leaq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x10d0
jmp 0x1789
movq 0x589a(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x2a4c(%rip), %rsi      # 0x41b4
jmp 0x177b
movq 0x5887(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x2ac1(%rip), %rsi      # 0x423c
leaq 0x29c7(%rip), %rdx      # 0x4149
xorl %eax, %eax
callq 0x10d0
movq 0x5868(%rip), %rax      # 0x6ff8
movq (%rax), %rcx
leaq 0x2907(%rip), %rdi      # 0x40a1
pushq $0x1d
popq %rsi
pushq $0x1
popq %rdx
callq 0x1160
pushq $0x1
popq %rax
movl %eax, 0x8(%rsp)
cmpq $0x0, 0x594c(%rip)      # 0x7100
je 0x17c8
movq 0x593b(%rip), %rdi      # 0x70f8
movl 0x594d(%rip), %esi      # 0x7110
callq 0x1120
movq %r14, %rdi
callq 0x1070
movl 0x8(%rsp), %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x580b(%rip), %rax      # 0x6ff8
movq (%rax), %rbx
callq 0x1030
movl (%rax), %edi
callq 0x1170
leaq 0x28bc(%rip), %rsi      # 0x40bf
movl $0x0, 0x8(%rsp)
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x10d0
jmp 0x17ac
movq 0x57d7(%rip), %r15      # 0x6ff8
movq (%r15), %rdi
subl %ebx, %r14d
leaq 0x2a80(%rip), %rsi      # 0x42ae
movl %r14d, %edx
xorl %eax, %eax
callq 0x10d0
movq (%r15), %rcx
leaq 0x2897(%rip), %rdi      # 0x40d9
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x1160
pushq $0x1
popq %rax
movl %eax, 0x8(%rsp)
jmp 0x1670