// File: suhasjains[P]AMR-Solver/src/input.cpp
// Function: std::read_blocks(std::basic_ifstream<char, std::char_traits<char>>&)
int read_blocks(ifstream& file) {
	
	string line, str;

	int blocknumber, level;	
	double xmin, xmax, ymin, ymax, zmin, zmax;
	string eastbc, westbc, northbc, southbc, topbc, bottombc;
	myOctree::NodeBc east_bc, west_bc, north_bc, south_bc, top_bc, bottom_bc;
	
	myOctree::NodeBc **bc;
	bc = new myOctree::NodeBc* [3];
	for(int i = 0; i < 3; i++)
     		bc[i] = new myOctree::NodeBc [2];	

	//skips line if line is empty
	getline(file,line);
	while(line.empty()) {
		getline(file, line);
	}


	if(line=="blocks") {


		file >> str;
		if(str != "{") {
			cerr << "Expected an opening bracket" <<endl;				
			exit(1);	
		}
		
		while(file) {
			if(file >> str && str == "}") break;
			else	blocknumber = atoi(str.c_str());

			//file >> blocknumber;
			file >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax;
			file >> level;
			file >> eastbc >> westbc >> northbc >> southbc >> topbc >> bottombc;
						
			bc[myOctree::XDIR][myOctree::RIGHT] = string_to_NodeBc(eastbc);		
			bc[myOctree::XDIR][myOctree::LEFT] = string_to_NodeBc(westbc);		
			bc[myOctree::YDIR][myOctree::RIGHT] = string_to_NodeBc(northbc);		
			bc[myOctree::YDIR][myOctree::LEFT] = string_to_NodeBc(southbc);		
			bc[myOctree::ZDIR][myOctree::RIGHT] = string_to_NodeBc(topbc);		
			bc[myOctree::ZDIR][myOctree::LEFT] = string_to_NodeBc(bottombc);		

			//cerr << blocknumber << xmin << xmax << ymin << ymax << zmin << zmax << endl;

			myOctree::create_node(blocknumber, xmin, xmax, ymin, ymax, zmin, zmax, level, bc);

		}

	}
	
	delete [] bc;

	return blocknumber;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x3360
leaq -0x48(%rbp), %rdi
callq 0x3360
leaq -0xa0(%rbp), %rdi
callq 0x3360
leaq -0xc0(%rbp), %rdi
callq 0x3360
leaq -0xe0(%rbp), %rdi
callq 0x3360
leaq -0x100(%rbp), %rdi
callq 0x3360
leaq -0x120(%rbp), %rdi
callq 0x3360
leaq -0x140(%rbp), %rdi
callq 0x3360
movl $0x18, %edi
callq 0x3040
movq %rax, -0x238(%rbp)
jmp 0x1458c
movq -0x238(%rbp), %rax
movq %rax, -0x160(%rbp)
movl $0x0, -0x170(%rbp)
cmpl $0x3, -0x170(%rbp)
jge 0x14601
movl $0x8, %edi
callq 0x3040
movq %rax, -0x240(%rbp)
jmp 0x145c0
movq -0x240(%rbp), %rdx
movq -0x160(%rbp), %rax
movslq -0x170(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x170(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x170(%rbp)
jmp 0x145a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
jmp 0x14bf7
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x3090
jmp 0x14610
jmp 0x14612
leaq -0x28(%rbp), %rdi
callq 0x33f0
testb $0x1, %al
jne 0x14621
jmp 0x14632
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x3090
jmp 0x14630
jmp 0x14612
leaq 0xcdb0(%rip), %rsi      # 0x213e9
leaq -0x28(%rbp), %rdi
callq 0x169d0
movb %al, -0x241(%rbp)
jmp 0x1464a
movb -0x241(%rbp), %al
testb $0x1, %al
jne 0x14659
jmp 0x14b65
movq -0x8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3320
jmp 0x14668
leaq 0xcda1(%rip), %rsi      # 0x21410
leaq -0x48(%rbp), %rdi
callq 0x16a00
movb %al, -0x242(%rbp)
jmp 0x14680
movb -0x242(%rbp), %al
testb $0x1, %al
jne 0x1468c
jmp 0x146c7
movq 0x1195d(%rip), %rdi     # 0x25ff0
leaq 0xcd78(%rip), %rsi      # 0x21412
callq 0x3240
movq %rax, -0x250(%rbp)
jmp 0x146a8
movq -0x250(%rbp), %rdi
movq 0x1190a(%rip), %rsi     # 0x25fc0
callq 0x3270
jmp 0x146bd
movl $0x1, %edi
callq 0x32e0
jmp 0x146c9
movq -0x8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3310
movb %al, -0x251(%rbp)
jmp 0x146e4
movb -0x251(%rbp), %al
testb $0x1, %al
jne 0x146f3
jmp 0x14b63
movq -0x8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3320
movq %rax, -0x260(%rbp)
jmp 0x14709
movq -0x260(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3310
movb %al, -0x261(%rbp)
jmp 0x14727
movb -0x261(%rbp), %al
testb $0x1, %al
jne 0x14733
jmp 0x1475c
leaq 0xcd10(%rip), %rsi      # 0x2144a
leaq -0x48(%rbp), %rdi
callq 0x169d0
movb %al, -0x262(%rbp)
jmp 0x1474b
movb -0x262(%rbp), %al
testb $0x1, %al
jne 0x14757
jmp 0x1475c
jmp 0x14b63
leaq -0x48(%rbp), %rdi
callq 0x3110
movq %rax, %rdi
callq 0x33c0
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x31e0
movq %rax, -0x270(%rbp)
jmp 0x14786
movq -0x270(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x31e0
movq %rax, -0x278(%rbp)
jmp 0x1479f
movq -0x278(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x31e0
movq %rax, -0x280(%rbp)
jmp 0x147b8
movq -0x280(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x31e0
movq %rax, -0x288(%rbp)
jmp 0x147d1
movq -0x288(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x31e0
movq %rax, -0x290(%rbp)
jmp 0x147ea
movq -0x290(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x31e0
jmp 0x147fc
movq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3170
jmp 0x1480b
movq -0x8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3320
movq %rax, -0x298(%rbp)
jmp 0x14824
movq -0x298(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3320
movq %rax, -0x2a0(%rbp)
jmp 0x14840
movq -0x2a0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3320
movq %rax, -0x2a8(%rbp)
jmp 0x1485c
movq -0x2a8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x3320
movq %rax, -0x2b0(%rbp)
jmp 0x14878
movq -0x2b0(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x3320
movq %rax, -0x2b8(%rbp)
jmp 0x14894
movq -0x2b8(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x3320
jmp 0x148a9
leaq -0x190(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3120
jmp 0x148be
leaq -0x190(%rbp), %rdi
callq 0x13fd0
movl %eax, -0x2bc(%rbp)
jmp 0x148d2
movl -0x2bc(%rbp), %ecx
movq -0x160(%rbp), %rax
movq (%rax), %rax
movl %ecx, (%rax)
leaq -0x190(%rbp), %rdi
callq 0x3180
leaq -0x1b0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3120
jmp 0x14905
leaq -0x1b0(%rbp), %rdi
callq 0x13fd0
movl %eax, -0x2c0(%rbp)
jmp 0x14919
movl -0x2c0(%rbp), %ecx
movq -0x160(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0x4(%rax)
leaq -0x1b0(%rbp), %rdi
callq 0x3180
leaq -0x1d0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3120
jmp 0x1494d
leaq -0x1d0(%rbp), %rdi
callq 0x13fd0
movl %eax, -0x2c4(%rbp)
jmp 0x14961
movl -0x2c4(%rbp), %ecx
movq -0x160(%rbp), %rax
movq 0x8(%rax), %rax
movl %ecx, (%rax)
leaq -0x1d0(%rbp), %rdi
callq 0x3180
leaq -0x1f0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x3120
jmp 0x14995
leaq -0x1f0(%rbp), %rdi
callq 0x13fd0
movl %eax, -0x2c8(%rbp)
jmp 0x149a9
movl -0x2c8(%rbp), %ecx
movq -0x160(%rbp), %rax
movq 0x8(%rax), %rax
movl %ecx, 0x4(%rax)
leaq -0x1f0(%rbp), %rdi
callq 0x3180
leaq -0x210(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x3120
jmp 0x149de
leaq -0x210(%rbp), %rdi
callq 0x13fd0
movl %eax, -0x2cc(%rbp)
jmp 0x149f2
movl -0x2cc(%rbp), %ecx
movq -0x160(%rbp), %rax
movq 0x10(%rax), %rax
movl %ecx, (%rax)
leaq -0x210(%rbp), %rdi
callq 0x3180
leaq -0x230(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x3120
jmp 0x14a26
leaq -0x230(%rbp), %rdi
callq 0x13fd0
movl %eax, -0x2d0(%rbp)
jmp 0x14a3a
movl -0x2d0(%rbp), %ecx
movq -0x160(%rbp), %rax
movq 0x10(%rax), %rax
movl %ecx, 0x4(%rax)
leaq -0x230(%rbp), %rdi
callq 0x3180
movl -0x4c(%rbp), %edi
movsd -0x58(%rbp), %xmm0
movsd -0x60(%rbp), %xmm1
movsd -0x68(%rbp), %xmm2
movsd -0x70(%rbp), %xmm3
movsd -0x78(%rbp), %xmm4
movsd -0x80(%rbp), %xmm5
movl -0x50(%rbp), %esi
movq -0x160(%rbp), %rdx
callq 0x4c40
jmp 0x14a8c
jmp 0x146c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x3180
jmp 0x14bf7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x3180
jmp 0x14bf7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x3180
jmp 0x14bf7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x3180
jmp 0x14bf7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x3180
jmp 0x14bf7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x3180
jmp 0x14bf7
jmp 0x14b65
movq -0x160(%rbp), %rax
movq %rax, -0x2d8(%rbp)
cmpq $0x0, %rax
je 0x14b85
movq -0x2d8(%rbp), %rdi
callq 0x3330
movl -0x4c(%rbp), %eax
movl %eax, -0x2dc(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x3180
leaq -0x120(%rbp), %rdi
callq 0x3180
leaq -0x100(%rbp), %rdi
callq 0x3180
leaq -0xe0(%rbp), %rdi
callq 0x3180
leaq -0xc0(%rbp), %rdi
callq 0x3180
leaq -0xa0(%rbp), %rdi
callq 0x3180
leaq -0x48(%rbp), %rdi
callq 0x3180
leaq -0x28(%rbp), %rdi
callq 0x3180
movl -0x2dc(%rbp), %eax
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
leaq -0x140(%rbp), %rdi
callq 0x3180
leaq -0x120(%rbp), %rdi
callq 0x3180
leaq -0x100(%rbp), %rdi
callq 0x3180
leaq -0xe0(%rbp), %rdi
callq 0x3180
leaq -0xc0(%rbp), %rdi
callq 0x3180
leaq -0xa0(%rbp), %rdi
callq 0x3180
leaq -0x48(%rbp), %rdi
callq 0x3180
leaq -0x28(%rbp), %rdi
callq 0x3180
movq -0x168(%rbp), %rdi
callq 0x3420
nopl (%rax)