// File: /workspace/github_c_makefile_star2_O0/miniupnp[P]hfsplustools/src/hfscommon.c
// Function: print_node
int print_node(const unsigned char * p)
{
	uint16_t num_records;
	uint16_t rec;
	uint8_t kind;
	const unsigned char * q;
	/* node descriptor */
	printf("fLink=%u ", readu32(p));
	printf("bLink=%u ", readu32(p+4));
	kind = p[8];
	printf("kind=%u ", kind);
	 /* kBTLeafNode       = -1,
    kBTIndexNode      =  0,
    kBTHeaderNode     =  1,
    kBTMapNode        =  2 */
	printf("height=%u ", p[9]);
	num_records = readu16(p+10);
	printf("numRecords=%u\n", num_records);
	q = p + 14;
	if(kind == 1) { /* header node */
		unsigned totalNodes;
		/* 1st : B-Tree Header Record */
		catalog_root_node = readu32(q + 2);
		catalog_first_leaf_node = readu32(q + 10);
		catalog_last_leaf_node = readu32(q + 14);
		printf("rootNode = %u\n", catalog_root_node);
		printf("leafRecords = %u\n", readu32(q + 6));
		printf("firstLeafNode = %u\n", catalog_first_leaf_node);
		printf("lastLeafNode = %u\n", catalog_last_leaf_node);
		catalog_node_size = readu16(q + 18);
		totalNodes = readu32(q + 22);
		printf("nodeSize=%u\n", catalog_node_size);
		printf("maxKeyLength=%u\n", readu16(q + 20));
		printf("totalNodes=%u (%u bytes)\n",
		       totalNodes, totalNodes * catalog_node_size);
		printf("freeNodes=%u\n", readu32(q + 26));
		printf("clumpSize=%u\n", readu32(q + 32));
		printf("btreeType=%u\n", q[36]);
		printf("keyCompareType=%u\n", q[37]);
		printf("attributes %08X\n", readu32(q + 38));
		if(catalog_block_count * block_size != totalNodes * catalog_node_size) {
			fprintf(stderr, "ERROR catalog size inconsistency ! (at offset %d=0x%0x in catalog)\n", (int)(q + 22 - p), (int)(q + 22 - p));
			return 0;
		}
		q = q + 106;
		/* 2nd : User Data Record. 128 bytes */
		printf("User Data Record : \n");
		hexdump(q, 128, 0);
		q = q + 128;
		/* 3rd : B-tree Map Record. nodeSize - 256 bytes */
		printf("B-tree Map Record (first 128 bytes...) :\n");
		hexdump(q, 128 /*catalog_node_size - 256*/, 0);
	} else if(kind == 0) {	/* index node */
		for(rec = 0; rec < num_records; rec++) {
			/* record */
			uint16_t key_length = readu16(q);
			uint32_t node_number = readu32(q + key_length + 2);
			printf("%3u ", rec);
			printf("length=%u\n", key_length);
			//hexdump(q + 2, key_length, 0);
			printf("    ");
			print_hfs_uni(q + 6);
			printf(" parentId=%u ", readu32(q + 2));
			printf("=> %u\n", node_number);
			q += key_length + 2 + 4;
		}
	} else if(kind == 255) {	/* leaf node */
		for(rec = 0; rec < num_records; rec++) {
			uint16_t key_length = readu16(q);
			uint16_t record_type;
			uint32_t parent_id = readu32(q + 2);
			printf("  %2hu ", rec);
			print_hfs_uni(q + 6);
			q += key_length + 2;
			record_type = readu16(q);
			switch(record_type) {
			case 1: /* folder record */
				printf(" folder parentId=%u\n", parent_id);
				q += 88;
				break;
			case 2: /* file record */
				printf(" file parentId=%u\n", parent_id);
				q += 248;
				break;
			case 3:	/* folder thread record */
			case 4: /* file thread record */
				printf(" %s thread ", record_type == 3 ? "folder" : "file");
				printf("%sId=%u ", record_type == 3 ? "folder" : "file", parent_id);
				q += 4;
				parent_id = readu32(q);
				q += 4;
				printf("parentId=%u ", parent_id);
				print_hfs_uni(q);
				q += 2 * (1 + readu16(q));
				printf("\n");
				break;
			default:
				printf("\nrecord type %u not recognized\n", record_type);
				return 0;
			}
		}
	} else {
		printf("unprocessed kind %u\n", kind);
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1af0
movl %eax, %esi
leaq 0x23b9(%rip), %rdi      # 0x45c7
movb $0x0, %al
callq 0x1080
movq -0x10(%rbp), %rdi
addq $0x4, %rdi
callq 0x1af0
movl %eax, %esi
leaq 0x23a6(%rip), %rdi      # 0x45d1
movb $0x0, %al
callq 0x1080
movq -0x10(%rbp), %rax
movb 0x8(%rax), %al
movb %al, -0x15(%rbp)
movzbl -0x15(%rbp), %esi
leaq 0x2394(%rip), %rdi      # 0x45db
movb $0x0, %al
callq 0x1080
movq -0x10(%rbp), %rax
movzbl 0x9(%rax), %esi
leaq 0x2387(%rip), %rdi      # 0x45e4
movb $0x0, %al
callq 0x1080
movq -0x10(%rbp), %rdi
addq $0xa, %rdi
callq 0x1ab0
movw %ax, -0x12(%rbp)
movzwl -0x12(%rbp), %esi
leaq 0x236f(%rip), %rdi      # 0x45ef
movb $0x0, %al
callq 0x1080
movq -0x10(%rbp), %rax
addq $0xe, %rax
movq %rax, -0x20(%rbp)
movzbl -0x15(%rbp), %eax
cmpl $0x1, %eax
jne 0x24e4
movq -0x20(%rbp), %rdi
addq $0x2, %rdi
callq 0x1af0
movl %eax, 0x4e1d(%rip)      # 0x70d0
movq -0x20(%rbp), %rdi
addq $0xa, %rdi
callq 0x1af0
movl %eax, 0x4e0e(%rip)      # 0x70d4
movq -0x20(%rbp), %rdi
addq $0xe, %rdi
callq 0x1af0
movl %eax, 0x4dff(%rip)      # 0x70d8
movl 0x4df1(%rip), %esi      # 0x70d0
leaq 0x2318(%rip), %rdi      # 0x45fe
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
addq $0x6, %rdi
callq 0x1af0
movl %eax, %esi
leaq 0x230a(%rip), %rdi      # 0x460d
movb $0x0, %al
callq 0x1080
movl 0x4dc4(%rip), %esi      # 0x70d4
leaq 0x2308(%rip), %rdi      # 0x461f
movb $0x0, %al
callq 0x1080
movl 0x4db4(%rip), %esi      # 0x70d8
leaq 0x2308(%rip), %rdi      # 0x4633
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
addq $0x12, %rdi
callq 0x1ab0
movzwl %ax, %eax
movl %eax, 0x4d94(%rip)      # 0x70dc
movq -0x20(%rbp), %rdi
addq $0x16, %rdi
callq 0x1af0
movl %eax, -0x24(%rbp)
movl 0x4d7e(%rip), %esi      # 0x70dc
leaq 0x22e1(%rip), %rdi      # 0x4646
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
addq $0x14, %rdi
callq 0x1ab0
movzwl %ax, %esi
leaq 0x22d0(%rip), %rdi      # 0x4653
movb $0x0, %al
callq 0x1080
movl -0x24(%rbp), %esi
movl -0x24(%rbp), %edx
imull 0x4d45(%rip), %edx      # 0x70dc
leaq 0x22c6(%rip), %rdi      # 0x4664
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
addq $0x1a, %rdi
callq 0x1af0
movl %eax, %esi
leaq 0x22c3(%rip), %rdi      # 0x467e
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
addq $0x20, %rdi
callq 0x1af0
movl %eax, %esi
leaq 0x22b4(%rip), %rdi      # 0x468c
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rax
movzbl 0x24(%rax), %esi
leaq 0x22ac(%rip), %rdi      # 0x469a
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rax
movzbl 0x25(%rax), %esi
leaq 0x22a4(%rip), %rdi      # 0x46a8
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
addq $0x26, %rdi
callq 0x1af0
movl %eax, %esi
leaq 0x229a(%rip), %rdi      # 0x46bb
movb $0x0, %al
callq 0x1080
movl 0x4c9e(%rip), %eax      # 0x70cc
imull 0x4c8f(%rip), %eax      # 0x70c4
movl -0x24(%rbp), %ecx
imull 0x4c9d(%rip), %ecx      # 0x70dc
cmpl %ecx, %eax
je 0x2489
movq 0x4bae(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
movq -0x20(%rbp), %rax
addq $0x16, %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
movq -0x20(%rbp), %rax
addq $0x16, %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
leaq 0x2256(%rip), %rsi      # 0x46cc
movb $0x0, %al
callq 0x10c0
movl $0x0, -0x4(%rbp)
jmp 0x27c0
movq -0x20(%rbp), %rax
addq $0x6a, %rax
movq %rax, -0x20(%rbp)
leaq 0x2274(%rip), %rdi      # 0x4710
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
movl $0x80, %esi
xorl %edx, %edx
callq 0x1970
movq -0x20(%rbp), %rax
addq $0x80, %rax
movq %rax, -0x20(%rbp)
leaq 0x225d(%rip), %rdi      # 0x4725
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
movl $0x80, %esi
xorl %edx, %edx
callq 0x1970
jmp 0x27b9
movzbl -0x15(%rbp), %eax
cmpl $0x0, %eax
jne 0x25c8
movw $0x0, -0x14(%rbp)
movzwl -0x14(%rbp), %eax
movzwl -0x12(%rbp), %ecx
cmpl %ecx, %eax
jge 0x25c3
movq -0x20(%rbp), %rdi
callq 0x1ab0
movw %ax, -0x26(%rbp)
movq -0x20(%rbp), %rdi
movzwl -0x26(%rbp), %eax
cltq
addq %rax, %rdi
addq $0x2, %rdi
callq 0x1af0
movl %eax, -0x2c(%rbp)
movzwl -0x14(%rbp), %esi
leaq 0x2217(%rip), %rdi      # 0x474f
movb $0x0, %al
callq 0x1080
movzwl -0x26(%rbp), %esi
leaq 0x220a(%rip), %rdi      # 0x4754
movb $0x0, %al
callq 0x1080
leaq 0x2207(%rip), %rdi      # 0x475f
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
addq $0x6, %rdi
callq 0x27d0
movq -0x20(%rbp), %rdi
addq $0x2, %rdi
callq 0x1af0
movl %eax, %esi
leaq 0x21e2(%rip), %rdi      # 0x4764
movb $0x0, %al
callq 0x1080
movl -0x2c(%rbp), %esi
leaq 0x21df(%rip), %rdi      # 0x4772
movb $0x0, %al
callq 0x1080
movzwl -0x26(%rbp), %ecx
addl $0x2, %ecx
addl $0x4, %ecx
movq -0x20(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movw -0x14(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x14(%rbp)
jmp 0x24f7
jmp 0x27b7
movzbl -0x15(%rbp), %eax
cmpl $0xff, %eax
jne 0x27a3
movw $0x0, -0x14(%rbp)
movzwl -0x14(%rbp), %eax
movzwl -0x12(%rbp), %ecx
cmpl %ecx, %eax
jge 0x27a1
movq -0x20(%rbp), %rdi
callq 0x1ab0
movw %ax, -0x2e(%rbp)
movq -0x20(%rbp), %rdi
addq $0x2, %rdi
callq 0x1af0
movl %eax, -0x34(%rbp)
movzwl -0x14(%rbp), %esi
leaq 0x2164(%rip), %rdi      # 0x4779
xorl %eax, %eax
callq 0x1080
movq -0x20(%rbp), %rdi
addq $0x6, %rdi
callq 0x27d0
movzwl -0x2e(%rbp), %eax
movq -0x20(%rbp), %rcx
leaq 0x2(%rax,%rcx), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1ab0
movw %ax, -0x30(%rbp)
movzwl -0x30(%rbp), %eax
movl %eax, -0x38(%rbp)
subl $0x1, %eax
je 0x266f
jmp 0x2655
movl -0x38(%rbp), %eax
subl $0x2, %eax
je 0x2691
jmp 0x265f
movl -0x38(%rbp), %eax
addl $-0x3, %eax
subl $0x2, %eax
jb 0x26b5
jmp 0x2773
movl -0x34(%rbp), %esi
leaq 0x2108(%rip), %rdi      # 0x4781
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rax
addq $0x58, %rax
movq %rax, -0x20(%rbp)
jmp 0x278e
movl -0x34(%rbp), %esi
leaq 0x20fb(%rip), %rdi      # 0x4796
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rax
addq $0xf8, %rax
movq %rax, -0x20(%rbp)
jmp 0x278e
movzwl -0x30(%rbp), %ecx
leaq 0x20fc(%rip), %rsi      # 0x47bc
leaq 0x20ee(%rip), %rax      # 0x47b5
cmpl $0x3, %ecx
cmoveq %rax, %rsi
leaq 0x20d4(%rip), %rdi      # 0x47a9
movb $0x0, %al
callq 0x1080
movzwl -0x30(%rbp), %ecx
leaq 0x20d5(%rip), %rsi      # 0x47bc
leaq 0x20c7(%rip), %rax      # 0x47b5
cmpl $0x3, %ecx
cmoveq %rax, %rsi
movl -0x34(%rbp), %edx
leaq 0x20c2(%rip), %rdi      # 0x47c1
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1af0
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x20(%rbp)
movl -0x34(%rbp), %esi
leaq 0x2031(%rip), %rdi      # 0x4765
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
callq 0x27d0
movq -0x20(%rbp), %rdi
callq 0x1ab0
movzwl %ax, %ecx
addl $0x1, %ecx
shll %ecx
movq -0x20(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
leaq 0x1a2f(%rip), %rdi      # 0x4199
movb $0x0, %al
callq 0x1080
jmp 0x278e
movzwl -0x30(%rbp), %esi
leaq 0x204c(%rip), %rdi      # 0x47ca
movb $0x0, %al
callq 0x1080
movl $0x0, -0x4(%rbp)
jmp 0x27c0
jmp 0x2790
movw -0x14(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x14(%rbp)
jmp 0x25dd
jmp 0x27b5
movzbl -0x15(%rbp), %esi
leaq 0x203c(%rip), %rdi      # 0x47ea
movb $0x0, %al
callq 0x1080
jmp 0x27b7
jmp 0x27b9
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)