// File: suhasjains[P]AMR-Solver/src/output.cpp
// Function: std::write_output_file()
void write_output_file() {

	int count = 0;
	int blocknumber;
	double xmin, xmax, ymin, ymax, zmin, zmax;
	int level;
	string eastbc, westbc, northbc, southbc, topbc, bottombc;
        myOctree::NodeBc east_bc, west_bc, north_bc, south_bc, top_bc, bottom_bc;



	ofstream file ("output.pfs");
	if(file.fail()) {
                cerr << "Error opening input file\n";
                exit(1);
        }
		
	file << "blocks" <<endl;
	
	for (std::list<Octree*>::iterator it = nodes.begin(), end = nodes.end(); it != end; ++it)     {
	count++;

	xmin = (*it)->x_min;	
	ymin = (*it)->y_min;	
	zmin = (*it)->z_min;	
	xmax = (*it)->x_max;	
	ymax = (*it)->y_max;	
	zmax = (*it)->z_max;	
	level = (*it)->get_level();
	east_bc = (*it)->bc[myOctree::XDIR][myOctree::RIGHT];
	west_bc = (*it)->bc[myOctree::XDIR][myOctree::LEFT];
	north_bc = (*it)->bc[myOctree::YDIR][myOctree::RIGHT];
	south_bc = (*it)->bc[myOctree::YDIR][myOctree::LEFT];
	top_bc = (*it)->bc[myOctree::ZDIR][myOctree::RIGHT];
	bottom_bc = (*it)->bc[myOctree::ZDIR][myOctree::LEFT];
	
	blocknumber = (*it)->number;

	eastbc = NodeBc_to_string(east_bc);
	westbc = NodeBc_to_string(west_bc);
	northbc = NodeBc_to_string(north_bc);
	southbc = NodeBc_to_string(south_bc);
	topbc = NodeBc_to_string(top_bc);
	bottombc = NodeBc_to_string(bottom_bc);

	file << blocknumber << " " << xmin << " " << xmax << " " << ymin << " " << ymax << " " << zmin << " " << zmax << " " << level<< " " ;			 
	file << eastbc << " " << westbc << " " << northbc << " " << southbc << " " << topbc << " " << bottombc << endl;
		
	}

	file.close();
	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x520, %rsp            # imm = 0x520
movl $0x0, -0x4(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3360
leaq -0x80(%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 0xdb89(%rip), %rsi      # 0x213c4
leaq -0x318(%rbp), %rdi
movl $0x10, %edx
callq 0x32a0
jmp 0x1384e
movq -0x318(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x318(%rbp,%rax), %rdi
callq 0x3030
movb %al, -0x3f9(%rbp)
jmp 0x1386e
movb -0x3f9(%rbp), %al
testb $0x1, %al
jne 0x1387a
jmp 0x138d3
movq 0x1276f(%rip), %rdi     # 0x25ff0
leaq 0xdb47(%rip), %rsi      # 0x213cf
callq 0x3240
jmp 0x1388f
movl $0x1, %edi
callq 0x32e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x320(%rbp)
movl %eax, -0x324(%rbp)
jmp 0x13f7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x320(%rbp)
movl %eax, -0x324(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x33a0
jmp 0x13f7e
leaq 0xdb0f(%rip), %rsi      # 0x213e9
leaq -0x318(%rbp), %rdi
callq 0x3240
movq %rax, -0x408(%rbp)
jmp 0x138ef
movq -0x408(%rbp), %rdi
movq 0x126c3(%rip), %rsi     # 0x25fc0
callq 0x3270
jmp 0x13904
leaq 0x1298d(%rip), %rdi     # 0x26298
callq 0x4490
movq %rax, -0x330(%rbp)
leaq 0x1297a(%rip), %rdi     # 0x26298
callq 0x44c0
movq %rax, -0x338(%rbp)
leaq -0x330(%rbp), %rdi
leaq -0x338(%rbp), %rsi
callq 0x44f0
testb $0x1, %al
jne 0x13946
jmp 0x13f19
movl -0x4(%rbp), %eax
incl %eax
movl %eax, -0x4(%rbp)
leaq -0x330(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x4520
movq -0x418(%rbp), %rdi
movq (%rax), %rax
movsd 0x68(%rax), %xmm0
movsd %xmm0, -0x10(%rbp)
callq 0x4520
movq -0x418(%rbp), %rdi
movq (%rax), %rax
movsd 0x78(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
callq 0x4520
movq -0x418(%rbp), %rdi
movq (%rax), %rax
movsd 0x88(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x4520
movq -0x418(%rbp), %rdi
movq (%rax), %rax
movsd 0x70(%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
callq 0x4520
movq -0x418(%rbp), %rdi
movq (%rax), %rax
movsd 0x80(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0x4520
movq -0x418(%rbp), %rdi
movq (%rax), %rax
movsd 0x90(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
callq 0x4520
movq (%rax), %rdi
callq 0x6ec0
movl %eax, -0x40c(%rbp)
jmp 0x13a10
movl -0x40c(%rbp), %eax
movl %eax, -0x3c(%rbp)
leaq -0x330(%rbp), %rdi
movq %rdi, -0x420(%rbp)
callq 0x4520
movq -0x420(%rbp), %rdi
movq (%rax), %rax
movl 0x38(%rax), %eax
movl %eax, -0x104(%rbp)
callq 0x4520
movq -0x420(%rbp), %rdi
movq (%rax), %rax
movl 0x3c(%rax), %eax
movl %eax, -0x108(%rbp)
callq 0x4520
movq -0x420(%rbp), %rdi
movq (%rax), %rax
movl 0x40(%rax), %eax
movl %eax, -0x10c(%rbp)
callq 0x4520
movq -0x420(%rbp), %rdi
movq (%rax), %rax
movl 0x44(%rax), %eax
movl %eax, -0x110(%rbp)
callq 0x4520
movq -0x420(%rbp), %rdi
movq (%rax), %rax
movl 0x48(%rax), %eax
movl %eax, -0x114(%rbp)
callq 0x4520
movq -0x420(%rbp), %rdi
movq (%rax), %rax
movl 0x4c(%rax), %eax
movl %eax, -0x118(%rbp)
callq 0x4520
movq (%rax), %rax
movl 0x98(%rax), %eax
movl %eax, -0x8(%rbp)
movl -0x104(%rbp), %esi
leaq -0x358(%rbp), %rdi
callq 0x13730
jmp 0x13adc
leaq -0x60(%rbp), %rdi
leaq -0x358(%rbp), %rsi
movq %rsi, -0x428(%rbp)
callq 0x32f0
movq -0x428(%rbp), %rdi
callq 0x3180
movl -0x108(%rbp), %esi
leaq -0x378(%rbp), %rdi
callq 0x13730
jmp 0x13b13
leaq -0x80(%rbp), %rdi
leaq -0x378(%rbp), %rsi
movq %rsi, -0x430(%rbp)
callq 0x32f0
movq -0x430(%rbp), %rdi
callq 0x3180
movl -0x10c(%rbp), %esi
leaq -0x398(%rbp), %rdi
callq 0x13730
jmp 0x13b4a
leaq -0xa0(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movq %rsi, -0x438(%rbp)
callq 0x32f0
movq -0x438(%rbp), %rdi
callq 0x3180
movl -0x110(%rbp), %esi
leaq -0x3b8(%rbp), %rdi
callq 0x13730
jmp 0x13b84
leaq -0xc0(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
movq %rsi, -0x440(%rbp)
callq 0x32f0
movq -0x440(%rbp), %rdi
callq 0x3180
movl -0x114(%rbp), %esi
leaq -0x3d8(%rbp), %rdi
callq 0x13730
jmp 0x13bbe
leaq -0xe0(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
movq %rsi, -0x448(%rbp)
callq 0x32f0
movq -0x448(%rbp), %rdi
callq 0x3180
movl -0x118(%rbp), %esi
leaq -0x3f8(%rbp), %rdi
callq 0x13730
jmp 0x13bf8
leaq -0x100(%rbp), %rdi
leaq -0x3f8(%rbp), %rsi
movq %rsi, -0x458(%rbp)
callq 0x32f0
movq -0x458(%rbp), %rdi
callq 0x3180
movl -0x8(%rbp), %esi
leaq -0x318(%rbp), %rdi
callq 0x3400
movq %rax, -0x450(%rbp)
jmp 0x13c36
movq -0x450(%rbp), %rdi
leaq 0xd578(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x460(%rbp)
jmp 0x13c52
movq -0x460(%rbp), %rdi
movsd -0x10(%rbp), %xmm0
callq 0x3480
movq %rax, -0x468(%rbp)
jmp 0x13c6c
movq -0x468(%rbp), %rdi
leaq 0xd542(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x470(%rbp)
jmp 0x13c88
movq -0x470(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
callq 0x3480
movq %rax, -0x478(%rbp)
jmp 0x13ca2
movq -0x478(%rbp), %rdi
leaq 0xd50c(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x480(%rbp)
jmp 0x13cbe
movq -0x480(%rbp), %rdi
movsd -0x20(%rbp), %xmm0
callq 0x3480
movq %rax, -0x488(%rbp)
jmp 0x13cd8
movq -0x488(%rbp), %rdi
leaq 0xd4d6(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x490(%rbp)
jmp 0x13cf4
movq -0x490(%rbp), %rdi
movsd -0x28(%rbp), %xmm0
callq 0x3480
movq %rax, -0x498(%rbp)
jmp 0x13d0e
movq -0x498(%rbp), %rdi
leaq 0xd4a0(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x4a0(%rbp)
jmp 0x13d2a
movq -0x4a0(%rbp), %rdi
movsd -0x30(%rbp), %xmm0
callq 0x3480
movq %rax, -0x4a8(%rbp)
jmp 0x13d44
movq -0x4a8(%rbp), %rdi
leaq 0xd46a(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x4b0(%rbp)
jmp 0x13d60
movq -0x4b0(%rbp), %rdi
movsd -0x38(%rbp), %xmm0
callq 0x3480
movq %rax, -0x4b8(%rbp)
jmp 0x13d7a
movq -0x4b8(%rbp), %rdi
leaq 0xd434(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x4c0(%rbp)
jmp 0x13d96
movq -0x4c0(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x3400
movq %rax, -0x4c8(%rbp)
jmp 0x13dae
movq -0x4c8(%rbp), %rdi
leaq 0xd400(%rip), %rsi      # 0x211bc
callq 0x3240
jmp 0x13dc3
leaq -0x318(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3220
movq %rax, -0x4d0(%rbp)
jmp 0x13ddc
movq -0x4d0(%rbp), %rdi
leaq 0xd3d2(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x4d8(%rbp)
jmp 0x13df8
movq -0x4d8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x3220
movq %rax, -0x4e0(%rbp)
jmp 0x13e11
movq -0x4e0(%rbp), %rdi
leaq 0xd39d(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x4e8(%rbp)
jmp 0x13e2d
movq -0x4e8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3220
movq %rax, -0x4f0(%rbp)
jmp 0x13e49
movq -0x4f0(%rbp), %rdi
leaq 0xd365(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x4f8(%rbp)
jmp 0x13e65
movq -0x4f8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3220
movq %rax, -0x500(%rbp)
jmp 0x13e81
movq -0x500(%rbp), %rdi
leaq 0xd32d(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x508(%rbp)
jmp 0x13e9d
movq -0x508(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3220
movq %rax, -0x510(%rbp)
jmp 0x13eb9
movq -0x510(%rbp), %rdi
leaq 0xd2f5(%rip), %rsi      # 0x211bc
callq 0x3240
movq %rax, -0x518(%rbp)
jmp 0x13ed5
movq -0x518(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x3220
movq %rax, -0x520(%rbp)
jmp 0x13ef1
movq -0x520(%rbp), %rdi
movq 0x120c1(%rip), %rsi     # 0x25fc0
callq 0x3270
jmp 0x13f06
jmp 0x13f08
leaq -0x330(%rbp), %rdi
callq 0x4550
jmp 0x1392a
leaq -0x318(%rbp), %rdi
callq 0x3370
jmp 0x13f27
leaq -0x318(%rbp), %rdi
callq 0x33a0
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 -0x80(%rbp), %rdi
callq 0x3180
leaq -0x60(%rbp), %rdi
callq 0x3180
addq $0x520, %rsp            # imm = 0x520
popq %rbp
retq
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 -0x80(%rbp), %rdi
callq 0x3180
leaq -0x60(%rbp), %rdi
callq 0x3180
movq -0x320(%rbp), %rdi
callq 0x3420
nopl (%rax)