// File: /workspace/github_c_makefile_star2_O3/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 0x1938
movq %rsi, %rbx
leaq 0x5c18(%rip), %rdi      # 0x7118
callq 0x2d60
leaq 0x2b1c(%rip), %rdi      # 0x4028
leaq 0x2b1d(%rip), %rsi      # 0x4030
callq 0x1180
movq %rax, 0x5bd1(%rip)      # 0x70f0
cmpq $-0x1, %rax
je 0x193f
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 0x1946
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1110
testl %eax, %eax
jne 0x195a
leaq 0x20(%rsp), %rdi
movl $0x1, %esi
movl $0x200, %edx            # imm = 0x200
movq %r14, %rcx
callq 0x1060
cmpl $0x200, %eax            # imm = 0x200
jne 0x1961
cmpl $0x66676572, 0x20(%rsp) # imm = 0x66676572
jne 0x1968
xorl %eax, %eax
xorl %edx, %edx
movl %edx, %ecx
movl 0x20(%rsp,%rax,4), %esi
movl %esi, %edx
xorl %ecx, %edx
incq %rax
cmpl $0x80, %eax
jne 0x159b
cmpl %ecx, %esi
jne 0x198e
movl 0x24(%rsp), %ebx
movl 0x28(%rsp), %ebp
leaq 0x2c17(%rip), %rdi      # 0x41dd
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x10a0
movq 0x30(%rsp), %rsi
leaq 0x2c26(%rip), %rdi      # 0x4203
xorl %eax, %eax
callq 0x10a0
cmpl $0x0, 0x40(%rsp)
leaq 0x2c46(%rip), %rax      # 0x4236
leaq 0x2c3a(%rip), %rsi      # 0x4231
cmoveq %rax, %rsi
leaq 0x2c1c(%rip), %rdi      # 0x421e
xorl %eax, %eax
callq 0x10a0
cmpl %ebp, %ebx
jne 0x1995
movl 0x38(%rsp), %esi
movl 0x3c(%rsp), %edx
movl %esi, %eax
shll $0x4, %eax
orl %edx, %eax
movl %eax, 0x5ae2(%rip)      # 0x7108
movl 0x48(%rsp), %ebx
movl %ebx, 0x5adc(%rip)      # 0x710c
movl 0x4c(%rsp), %ebp
movl %ebp, 0x5ad6(%rip)      # 0x7110
leaq 0x2c23(%rip), %rdi      # 0x4264
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x10a0
leaq 0x2c28(%rip), %rdi      # 0x427a
movl %ebx, %esi
xorl %eax, %eax
callq 0x10a0
leaq 0x2c30(%rip), %rdi      # 0x4292
movl %ebp, %esi
xorl %eax, %eax
callq 0x10a0
movl 0x5a9f(%rip), %ebx      # 0x7110
movq %r14, %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, 0x5a5b(%rip)      # 0x70f8
cmpq $-0x1, %rax
je 0x19e3
movq %rax, %rbx
movq %r14, 0x18(%rsp)
movq %rax, 0x5a4a(%rip)      # 0x7100
movl 0x5a54(%rip), %ebp      # 0x7110
testl %ebp, %ebp
je 0x1784
xorl %r14d, %r14d
leaq 0x2bdb(%rip), %r15      # 0x42a9
movq %rbx, %r12
movl %ebp, 0x14(%rsp)
movl $0x4, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x1040
testl %eax, %eax
jne 0x19ea
movl 0x8(%r12), %eax
cmpq $0x25, %rax
jb 0x1775
movl %r14d, 0x8(%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 0x59e2(%rip), %rdi      # 0x7118
movq %rax, %rsi
callq 0x2ee3
cmpl $0x0, (%rbp)
jle 0x174c
movl $0x1, 0x28(%r13)
movl %r14d, %eax
addq %rax, %rbp
movl 0x8(%r12), %eax
leaq (%r12,%rax), %rcx
cmpq %rcx, %rbp
jb 0x1702
movq %rcx, %r12
movl 0x14(%rsp), %ebp
movl 0x8(%rsp), %r14d
leaq 0x2b36(%rip), %r15      # 0x42a9
jmp 0x1778
addq %rax, %r12
addl %eax, %r14d
cmpl %ebp, %r14d
jb 0x16d5
movl 0x5982(%rip), %esi      # 0x710c
leaq 0x5987(%rip), %rdi      # 0x7118
callq 0x330d
leaq 0x5983(%rip), %rbx      # 0x7120
cmpq %rbx, %rax
setne %cl
testq %rax, %rax
setne %dl
testb %dl, %cl
jne 0x17cc
movl 0x5959(%rip), %ecx      # 0x710c
leaq 0x2b15(%rip), %rdi      # 0x42cf
leaq 0x2958(%rip), %rdx      # 0x4119
movl %ecx, %esi
xorl %eax, %eax
callq 0x1339
jmp 0x17ed
incl 0x24(%rax)
orb $0x2, 0x28(%rax)
movl 0x5933(%rip), %esi      # 0x710c
leaq 0x2a83(%rip), %rdi      # 0x4263
callq 0x1a02
testl %eax, %eax
je 0x1931
movl 0x5919(%rip), %esi      # 0x710c
leaq 0x28f9(%rip), %rdi      # 0x40f3
leaq 0x2918(%rip), %rdx      # 0x4119
xorl %eax, %eax
callq 0x1339
movl $0x1, %eax
movq %rax, 0x8(%rsp)
movq 0x58ff(%rip), %rsi      # 0x7118
xorl %ebp, %ebp
cmpq %rbx, %rsi
je 0x1909
leaq 0x58ed(%rip), %rdi      # 0x7118
callq 0x2d73
movl $0x0, %r15d
movl $0x0, %r12d
cmpq %rbx, %rax
je 0x190f
movq %rax, %r13
leaq 0x58c9(%rip), %r14      # 0x7118
xorl %r12d, %r12d
xorl %r15d, %r15d
xorl %ebp, %ebp
movl 0x28(%r13), %ecx
testb $0x1, %cl
jne 0x18ad
cmpl $0x0, 0x24(%r13)
jne 0x1887
movl 0x18(%r13), %esi
leaq 0x354d(%rip), %rdi      # 0x4dbf
leaq 0x2dd9(%rip), %rdx      # 0x4652
xorl %eax, %eax
callq 0x1339
incl %r12d
movl 0x28(%r13), %ecx
leal -0x1(%rcx), %eax
testl %eax, %ecx
jne 0x18d1
testl $0xfffffff9, %ecx       # imm = 0xFFFFFFF9
je 0x18ee
movl 0x24(%r13), %r8d
cmpl $0x2, %r8d
jb 0x18ee
movl 0x18(%r13), %esi
leaq 0x3580(%rip), %rdi      # 0x4e2b
jmp 0x18e0
incl %r15d
cmpl $0x2, %ecx
setb %al
movl 0x24(%r13), %r8d
testl %r8d, %r8d
sete %dl
testb %dl, %al
jne 0x18ee
movl 0x18(%r13), %esi
leaq 0x34a9(%rip), %rdi      # 0x4d78
jmp 0x18e0
movl 0x18(%r13), %esi
movl 0x24(%r13), %r8d
leaq 0x34fe(%rip), %rdi      # 0x4dde
leaq 0x2d6b(%rip), %rdx      # 0x4652
xorl %eax, %eax
callq 0x1339
movq %r14, %rdi
movq %r13, %rsi
callq 0x2dc6
movq %rax, %r13
incl %ebp
cmpq %rbx, %rax
jne 0x1857
jmp 0x190f
xorl %r15d, %r15d
xorl %r12d, %r12d
leaq 0x355f(%rip), %rdi      # 0x4e75
movl %ebp, %esi
movl %r15d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x1339
movq 0x18(%rsp), %r14
movq 0x8(%rsp), %r15
jmp 0x19aa
xorl %eax, %eax
jmp 0x180d
callq 0x131d
jmp 0x1952
callq 0x1301
jmp 0x1952
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x12c6
movl $0x1, %r15d
jmp 0x19ce
callq 0x11a0
jmp 0x199a
callq 0x11d3
jmp 0x199a
movq 0x5689(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x280c(%rip), %rsi      # 0x4185
leaq 0x27c9(%rip), %rdx      # 0x4149
leaq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x10d0
jmp 0x199a
callq 0x1206
jmp 0x199a
callq 0x1225
leaq 0x20(%rsp), %rdi
callq 0x1244
movl $0x1, %r15d
cmpq $0x0, 0x574e(%rip)      # 0x7100
je 0x19c6
movq 0x573d(%rip), %rdi      # 0x70f8
movl 0x574f(%rip), %esi      # 0x7110
callq 0x1120
movq %r14, %rdi
callq 0x1070
movl %r15d, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x129a
jmp 0x19aa
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1266
movl $0x1, %r15d
movq 0x18(%rsp), %r14
jmp 0x19aa