// File: /workspace/github_cpp_makefile_star2_O1/aisthesis[P]realnumber/src/find_pi.cpp
// Function: main
int main(int argc, const char * argv[])
{
	//karatsuba::say_hello();

	string str = "1.0";
	RealNumber x(str);
	cout << "x is " << x.to_decimal_string() << endl;
	str = "300000000.0";
	RealNumber y(str);
	cout << "y is " << y.to_decimal_string() << endl;

	try {
		RealNumber("10000000000.0");
	} 
	catch (invalid_argument& ia) {
		cout << ia.what() << endl;
	}
	catch (exception& e) {
		cout << "this exception is expected" << endl;
	}
	RealNumber z = x / y;
	cout << "z is " << z.to_decimal_string() << endl;
	cout << "x.difference(y) is " << x.difference(y).to_decimal_string() << endl;
	
	RealNumber num("2.0");
	RealNumber guess("1.4");
	int iterations = 10;
	
	RealNumber sqrt_two = ConvergentSeries::babylonian_sqrt(num, guess, iterations);
	
	cout << "Square root of 2 is " << sqrt_two.to_decimal_string() << endl;
	cout << "or: " << ConvergentSeries::babylonian_sqrt(RealNumber("2.0"), RealNumber("1.4"), 
																											iterations).to_decimal_string() << endl;
	
	RealNumber pi = ConvergentSeries::gauss_legendre_pi(6, 10, sqrt_two);
	cout << "Pi is\n" << pi.to_decimal_string() << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
leaq -0xc0(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x2c02(%rip), %rsi      # 0x5004
leaq 0x2bfe(%rip), %rdx      # 0x5007
leaq -0xd0(%rbp), %rdi
callq 0x2d52
leaq -0x58(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x2e4c
movq 0x5b9c(%rip), %rdi      # 0x7fc8
leaq 0x2bd5(%rip), %rsi      # 0x5008
movl $0x5, %edx
callq 0x2180
leaq -0x48(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x305c
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x5b6f(%rip), %rdi      # 0x7fc8
callq 0x2180
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
leaq -0x38(%rbp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x24a2
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xd0(%rbp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x2b5a(%rip), %rcx      # 0x500e
movl $0xb, %r8d
xorl %esi, %esi
callq 0x21c0
leaq -0x50(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x2e4c
movq 0x5af0(%rip), %rdi      # 0x7fc8
leaq 0x2b3b(%rip), %rsi      # 0x501a
movl $0x5, %edx
callq 0x2180
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x305c
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x5ac3(%rip), %rdi      # 0x7fc8
callq 0x2180
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2549
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x2ac9(%rip), %rsi      # 0x5020
leaq 0x2acf(%rip), %rdx      # 0x502d
callq 0x2d52
leaq -0xf8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e4c
leaq -0xf8(%rbp), %rdi
callq 0x3048
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2594
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x90(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x3684
movq 0x5a19(%rip), %rdi      # 0x7fc8
leaq 0x2a93(%rip), %rsi      # 0x5049
movl $0x5, %edx
callq 0x2180
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x305c
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x59e9(%rip), %rdi      # 0x7fc8
callq 0x2180
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2623
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
movq 0x599e(%rip), %rdi      # 0x7fc8
leaq 0x2a1e(%rip), %rsi      # 0x504f
movl $0x13, %edx
callq 0x2180
leaq -0xb0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x3460
leaq -0x48(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x305c
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x595a(%rip), %rdi      # 0x7fc8
callq 0x2180
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x26b2
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xb0(%rbp), %rdi
callq 0x3048
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x2997(%rip), %rsi      # 0x5063
leaq 0x2993(%rip), %rdx      # 0x5066
callq 0x2d52
leaq -0x88(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e4c
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x26fd
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x295c(%rip), %rsi      # 0x5067
leaq 0x2958(%rip), %rdx      # 0x506a
callq 0x2d52
leaq -0x80(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e4c
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2739
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x48(%rbp), %rcx
movq $0xa, (%rcx)
leaq -0x60(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x3728
movq 0x5869(%rip), %rdi      # 0x7fc8
leaq 0x2905(%rip), %rsi      # 0x506b
movl $0x14, %edx
callq 0x2180
leaq -0x48(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x305c
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x583c(%rip), %rdi      # 0x7fc8
callq 0x2180
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x27d0
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
movq 0x57f1(%rip), %rdi      # 0x7fc8
leaq 0x28a2(%rip), %rsi      # 0x5080
movl $0x4, %edx
callq 0x2180
leaq -0xa0(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x2869(%rip), %rsi      # 0x5063
leaq 0x2865(%rip), %rdx      # 0x5066
leaq -0xb0(%rbp), %rdi
callq 0x2d52
leaq -0x70(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x2e4c
leaq -0xe0(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x2838(%rip), %rsi      # 0x5067
leaq 0x2834(%rip), %rdx      # 0x506a
leaq -0xf0(%rbp), %rdi
callq 0x2d52
leaq -0x68(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x2e4c
leaq -0x100(%rbp), %rcx
movq $0xa, (%rcx)
leaq -0x78(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x3728
leaq -0x48(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x305c
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x573b(%rip), %rdi      # 0x7fc8
callq 0x2180
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x28d1
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x78(%rbp), %rdi
callq 0x3048
leaq -0x68(%rbp), %rdi
callq 0x3048
movq -0xf0(%rbp), %rdi
cmpq %r13, %rdi
je 0x28fe
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x70(%rbp), %rdi
callq 0x3048
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2922
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x48(%rbp), %rsi
movq $0x6, (%rsi)
leaq -0xf0(%rbp), %rdx
movq $0xa, (%rdx)
leaq -0xb0(%rbp), %rdi
leaq -0x60(%rbp), %rcx
callq 0x3881
movq 0x5676(%rip), %rdi      # 0x7fc8
leaq 0x272c(%rip), %rsi      # 0x5085
movl $0x6, %edx
callq 0x2180
leaq -0x48(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x305c
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x5646(%rip), %rdi      # 0x7fc8
callq 0x2180
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x29c6
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xb0(%rbp), %rdi
callq 0x3048
leaq -0x60(%rbp), %rdi
callq 0x3048
leaq -0x80(%rbp), %rdi
callq 0x3048
leaq -0x88(%rbp), %rdi
callq 0x3048
leaq -0x90(%rbp), %rdi
callq 0x3048
leaq -0x50(%rbp), %rdi
callq 0x3048
leaq -0x58(%rbp), %rdi
callq 0x3048
movq -0xd0(%rbp), %rdi
cmpq %r15, %rdi
je 0x2a29
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x2160
xorl %eax, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a3f
movq %rax, %rbx
jmp 0x2bdf
jmp 0x2baf
movq %rax, %rbx
jmp 0x2c05
movq %rax, %rbx
jmp 0x2c0e
movq %rax, %rbx
jmp 0x2c17
movq %rax, %rbx
jmp 0x2c32
movq %rax, %rbx
jmp 0x2c3b
jmp 0x2baf
jmp 0x2baf
movq %rax, %rbx
jmp 0x2c71
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2c7a
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x2c7a
movq %rax, %rbx
jmp 0x2c7a
jmp 0x2ce8
jmp 0x2bb7
movq %rax, %rbx
jmp 0x2cdf
jmp 0x2bb7
jmp 0x2bb7
movq %rdx, %r14
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2af3
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x2af3
jmp 0x2b93
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x2, %r14d
jne 0x2b2b
movq %rbx, %rdi
callq 0x2080
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x54b7(%rip), %rdi      # 0x7fc8
movq %rax, %rsi
callq 0x2150
movq %rax, %rdi
callq 0x2090
callq 0x21e0
jmp 0x2594
cmpl $0x1, %r14d
jne 0x2c92
movq %rbx, %rdi
callq 0x2080
movq 0x5484(%rip), %rdi      # 0x7fc8
leaq 0x24e3(%rip), %rsi      # 0x502e
movl $0x1a, %edx
callq 0x2180
movq 0x546c(%rip), %rdi      # 0x7fc8
callq 0x2090
callq 0x21e0
jmp 0x2594
jmp 0x2b93
jmp 0x2b93
movq %rax, %rbx
callq 0x21e0
jmp 0x2c92
movq %rax, %rbx
callq 0x21e0
jmp 0x2c92
movq %rax, %rdi
callq 0x2d44
jmp 0x2b93
movq %rax, %rbx
jmp 0x2c92
jmp 0x2bbf
jmp 0x2bbf
movq %rax, %rbx
jmp 0x2ca4
movq %rax, %rbx
jmp 0x2cbf
movq %rax, %rbx
jmp 0x2c68
movq %rax, %rbx
jmp 0x2c86
movq %rax, %rbx
jmp 0x2c9b
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2bdf
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xb0(%rbp), %rdi
callq 0x3048
jmp 0x2c68
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2c05
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x78(%rbp), %rdi
callq 0x3048
leaq -0x68(%rbp), %rdi
callq 0x3048
movq -0xf0(%rbp), %rdi
cmpq %r13, %rdi
je 0x2c32
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x70(%rbp), %rdi
callq 0x3048
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2c68
movq -0xa0(%rbp), %rsi
jmp 0x2c60
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2c68
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x60(%rbp), %rdi
callq 0x3048
leaq -0x80(%rbp), %rdi
callq 0x3048
leaq -0x88(%rbp), %rdi
callq 0x3048
leaq -0x90(%rbp), %rdi
callq 0x3048
leaq -0x50(%rbp), %rdi
callq 0x3048
leaq -0x58(%rbp), %rdi
callq 0x3048
movq -0xd0(%rbp), %rdi
cmpq %r15, %rdi
je 0x2cbf
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2210
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2cdf
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xb0(%rbp), %rdi
jmp 0x2c81
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2c86
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x2c86
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2c92
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x2c92
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c9b
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x2c9b