// File: /workspace/github_c_makefile_star2_O1/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 $0x218, %rsp            # imm = 0x218
cmpl $0x1, %edi
jle 0x1933
movq %rsi, %rbx
leaq 0x5c18(%rip), %rdi      # 0x7118
callq 0x2d88
leaq 0x2b1c(%rip), %rdi      # 0x4028
leaq 0x2b1d(%rip), %rsi      # 0x4030
callq 0x1180
movq %rax, 0x5bd1(%rip)      # 0x70f0
cmpq $-0x1, %rax
je 0x193a
leaq 0x2d33(%rip), %rsi      # 0x4263
xorl %edi, %edi
callq 0x1130
movq 0x8(%rbx), %rdi
leaq 0x2b37(%rip), %rsi      # 0x4079
callq 0x1140
testq %rax, %rax
je 0x1941
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1110
testl %eax, %eax
jne 0x1955
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
movl $0x200, %edx            # imm = 0x200
movq %r15, %rcx
callq 0x1060
cmpl $0x200, %eax            # imm = 0x200
jne 0x195c
cmpl $0x66676572, 0x10(%rsp) # imm = 0x66676572
jne 0x1963
xorl %eax, %eax
xorl %edx, %edx
movl %edx, %ecx
movl 0x10(%rsp,%rax,4), %esi
movl %esi, %edx
xorl %ecx, %edx
incq %rax
cmpl $0x80, %eax
jne 0x159b
cmpl %ecx, %esi
jne 0x1989
movl 0x14(%rsp), %esi
movl 0x18(%rsp), %edx
leaq 0x2c17(%rip), %rdi      # 0x41dd
xorl %eax, %eax
callq 0x10a0
movq 0x20(%rsp), %rsi
leaq 0x2c2a(%rip), %rdi      # 0x4203
xorl %eax, %eax
callq 0x10a0
cmpl $0x0, 0x30(%rsp)
leaq 0x2c4a(%rip), %rax      # 0x4236
leaq 0x2c3e(%rip), %rsi      # 0x4231
cmoveq %rax, %rsi
leaq 0x2c20(%rip), %rdi      # 0x421e
xorl %eax, %eax
callq 0x10a0
movl 0x14(%rsp), %eax
cmpl 0x18(%rsp), %eax
jne 0x1990
movl 0x28(%rsp), %esi
movl 0x2c(%rsp), %edx
movl %esi, %eax
shll $0x4, %eax
orl %edx, %eax
movl %eax, 0x5ae0(%rip)      # 0x7108
movq 0x38(%rsp), %rax
movq %rax, 0x5ad8(%rip)      # 0x710c
leaq 0x2c29(%rip), %rdi      # 0x4264
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x10a0
movl 0x38(%rsp), %esi
leaq 0x2c2a(%rip), %rdi      # 0x427a
xorl %eax, %eax
callq 0x10a0
movl 0x3c(%rsp), %esi
leaq 0x2c30(%rip), %rdi      # 0x4292
xorl %eax, %eax
callq 0x10a0
movl 0x5aa1(%rip), %ebx      # 0x7110
movq %r15, %rdi
callq 0x10f0
movl $0x1000, %r9d           # imm = 0x1000
xorl %edi, %edi
movq %rbx, %rsi
movl $0x1, %edx
movl $0x1, %ecx
movl %eax, %r8d
callq 0x1090
movq %rax, 0x5a5d(%rip)      # 0x70f8
cmpq $-0x1, %rax
je 0x19de
movq %rax, %rbx
movq %r15, 0x8(%rsp)
movq %rax, 0x5a4c(%rip)      # 0x7100
movl 0x5a56(%rip), %ebp      # 0x7110
testl %ebp, %ebp
je 0x1780
xorl %r14d, %r14d
leaq 0x2bdd(%rip), %r15      # 0x42a9
movq %rbx, %r12
movl %ebp, 0x4(%rsp)
movl $0x4, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x1040
testl %eax, %eax
jne 0x19e5
movl 0x8(%r12), %eax
cmpq $0x25, %rax
jb 0x1771
movl %r14d, (%rsp)
leaq 0x24(%r12), %rbp
movl (%rbp), %eax
movl %eax, %r14d
negl %r14d
cmovsl %eax, %r14d
movl %ebp, %r15d
subl %ebx, %r15d
movl $0x1, %edi
movl $0x30, %esi
callq 0x10c0
movq %rax, %r13
movl %r15d, 0x18(%rax)
movl %r14d, 0x20(%rax)
leaq 0x59e5(%rip), %rdi      # 0x7118
movq %rax, %rsi
callq 0x2f0b
cmpl $0x0, (%rbp)
jle 0x1749
movl $0x1, 0x28(%r13)
movl %r14d, %eax
addq %rax, %rbp
movl 0x8(%r12), %eax
leaq (%r12,%rax), %rcx
cmpq %rcx, %rbp
jb 0x16ff
movq %rcx, %r12
movl 0x4(%rsp), %ebp
movl (%rsp), %r14d
leaq 0x2b3a(%rip), %r15      # 0x42a9
jmp 0x1774
addq %rax, %r12
addl %eax, %r14d
cmpl %ebp, %r14d
jb 0x16d3
movl 0x5986(%rip), %esi      # 0x710c
leaq 0x598b(%rip), %rdi      # 0x7118
callq 0x3329
leaq 0x5987(%rip), %rbx      # 0x7120
cmpq %rbx, %rax
setne %cl
testq %rax, %rax
setne %dl
testb %dl, %cl
jne 0x17cd
movl 0x595d(%rip), %ecx      # 0x710c
leaq 0x2b19(%rip), %rdi      # 0x42cf
leaq 0x295c(%rip), %rdx      # 0x4119
movl %ecx, %esi
xorl %eax, %eax
callq 0x1339
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x17e6
incl 0x24(%rax)
orb $0x2, 0x28(%rax)
movl 0x5932(%rip), %esi      # 0x710c
leaq 0x2a82(%rip), %rdi      # 0x4263
callq 0x19fb
movl %eax, 0x4(%rsp)
testl %eax, %eax
je 0x1809
movl 0x5918(%rip), %esi      # 0x710c
leaq 0x28f8(%rip), %rdi      # 0x40f3
leaq 0x2917(%rip), %rdx      # 0x4119
xorl %eax, %eax
callq 0x1339
movq 0x5908(%rip), %rsi      # 0x7118
movq %rbx, %r14
cmpq %rbx, %rsi
je 0x1827
leaq 0x58f9(%rip), %rdi      # 0x7118
callq 0x2d9b
movq %rax, %r14
cmpq %rbx, %r14
je 0x18fc
leaq 0x2e1b(%rip), %rbp      # 0x4652
leaq 0x58da(%rip), %rbx      # 0x7118
leaq 0x58db(%rip), %r15      # 0x7120
movl $0x0, (%rsp)
xorl %r12d, %r12d
xorl %r13d, %r13d
movl 0x28(%r14), %ecx
testb $0x1, %cl
jne 0x18a4
cmpl $0x0, 0x24(%r14)
jne 0x187a
movl 0x18(%r14), %esi
leaq 0x3552(%rip), %rdi      # 0x4dbf
movq %rbp, %rdx
xorl %eax, %eax
callq 0x1339
incl (%rsp)
movl 0x28(%r14), %ecx
leal -0x1(%rcx), %eax
testl %eax, %ecx
jne 0x18c7
testl $0xfffffff9, %ecx       # imm = 0xFFFFFFF9
je 0x18e0
movl 0x24(%r14), %r8d
cmpl $0x2, %r8d
jb 0x18e0
movl 0x18(%r14), %esi
leaq 0x3589(%rip), %rdi      # 0x4e2b
jmp 0x18d6
incl %r12d
cmpl $0x1, %ecx
ja 0x18b3
cmpl $0x0, 0x24(%r14)
je 0x18e0
movl 0x18(%r14), %esi
movl 0x24(%r14), %r8d
leaq 0x34b6(%rip), %rdi      # 0x4d78
movq %rbp, %rdx
jmp 0x18d9
movl 0x18(%r14), %esi
movl 0x24(%r14), %r8d
leaq 0x3508(%rip), %rdi      # 0x4dde
movq %rbp, %rdx
xorl %eax, %eax
callq 0x1339
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2dee
movq %rax, %r14
incl %r13d
cmpq %r15, %rax
jne 0x1852
jmp 0x1909
xorl %r13d, %r13d
xorl %r12d, %r12d
movl $0x0, (%rsp)
leaq 0x3565(%rip), %rdi      # 0x4e75
movl %r13d, %esi
movl %r12d, %edx
movl (%rsp), %ecx
xorl %eax, %eax
callq 0x1339
xorl %r14d, %r14d
cmpl $0x0, 0x4(%rsp)
setne %r14b
movq 0x8(%rsp), %r15
jmp 0x19a5
callq 0x131d
jmp 0x194d
callq 0x1301
jmp 0x194d
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x12c6
movl $0x1, %r14d
jmp 0x19c9
callq 0x11a0
jmp 0x1995
callq 0x11d3
jmp 0x1995
movq 0x568e(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x2811(%rip), %rsi      # 0x4185
leaq 0x27ce(%rip), %rdx      # 0x4149
leaq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x10d0
jmp 0x1995
callq 0x1206
jmp 0x1995
callq 0x1225
leaq 0x10(%rsp), %rdi
callq 0x1244
movl $0x1, %r14d
cmpq $0x0, 0x5753(%rip)      # 0x7100
je 0x19c1
movq 0x5742(%rip), %rdi      # 0x70f8
movl 0x5754(%rip), %esi      # 0x7110
callq 0x1120
movq %r15, %rdi
callq 0x1070
movl %r14d, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x129a
jmp 0x19a5
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1266
movl $0x1, %r14d
jmp 0x192c