// File: /workspace/github_c_makefile_star2_O0/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
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 0x12d7
movq 0x7d3e(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x4d9c(%rip), %rsi      # 0x6060
movb $0x0, %al
callq 0x10e0
movl $0x1, -0x4(%rbp)
jmp 0x14ff
leaq 0x7e12(%rip), %rdi      # 0x90f0
addq $0x28, %rdi
callq 0x3b60
leaq 0x4d96(%rip), %rdi      # 0x6084
leaq 0x4d97(%rip), %rsi      # 0x608c
callq 0x1180
movq %rax, 0x7def(%rip)      # 0x90f0
movq $-0x1, %rax
cmpq %rax, 0x7de1(%rip)      # 0x90f0
jne 0x1335
movq 0x7ce0(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x4d71(%rip), %rsi      # 0x6093
movb $0x0, %al
callq 0x10e0
movl $0x1, -0x4(%rbp)
jmp 0x14ff
xorl %edi, %edi
leaq 0x4f86(%rip), %rsi      # 0x62c4
callq 0x1140
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x4d83(%rip), %rsi      # 0x60d5
callq 0x1150
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x13ad
movq 0x7c8f(%rip), %rax      # 0x8ff8
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 0x1170
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq %rax, %rcx
leaq 0x4d3e(%rip), %rsi      # 0x60d8
movb $0x0, %al
callq 0x10e0
movl $0x1, -0x4(%rbp)
jmp 0x14ff
movq -0x18(%rbp), %rdi
callq 0x1510
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x13dc
movq 0x7c32(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x4d2d(%rip), %rsi      # 0x60fd
movb $0x0, %al
callq 0x10e0
jmp 0x14c5
movl 0x7d2e(%rip), %eax      # 0x9110
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1100
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 0x1090
movq %rax, 0x7ce5(%rip)      # 0x90f8
movq $-0x1, %rax
cmpq %rax, 0x7cd7(%rip)      # 0x90f8
jne 0x1454
movq 0x7bce(%rip), %rax      # 0x8ff8
movq (%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1170
movq -0x40(%rbp), %rdi
movq %rax, %rdx
leaq 0x4cd0(%rip), %rsi      # 0x611b
movb $0x0, %al
callq 0x10e0
jmp 0x14c5
movq 0x7c9d(%rip), %rax      # 0x90f8
movq %rax, 0x7c9e(%rip)      # 0x9100
movq 0x7c97(%rip), %rdi      # 0x9100
movl 0x7ca1(%rip), %esi      # 0x9110
callq 0x1840
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x1497
movq 0x7b74(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x4ca7(%rip), %rsi      # 0x6135
movb $0x0, %al
callq 0x10e0
jmp 0x14c5
callq 0x1980
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x14c0
movl 0x7c61(%rip), %esi      # 0x910c
leaq 0x4c9d(%rip), %rdi      # 0x614f
leaq 0x4cbc(%rip), %rdx      # 0x6175
movb $0x0, %al
callq 0x4c10
callq 0x1a00
cmpq $0x0, 0x7c33(%rip)      # 0x9100
je 0x14e3
movq 0x7c22(%rip), %rdi      # 0x90f8
movl 0x7c34(%rip), %eax      # 0x9110
movl %eax, %esi
callq 0x1130
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
nopl (%rax,%rax)