// File: /workspace/github_cpp_makefile_star2_O3/cmirnov[P]triangular-arbitrage/exchange.cpp
// Function: Exchange::arbitrage(int, int, long double, int, std::vector<int, std::allocator<int>>, long double)
void Exchange::arbitrage(int begin, int prev, long double tempPrice, int level, std::vector<int> stack, long double fees) {
	if (level == 0) {
		tempPrice *= (matrix[prev][begin]->get(0))->price;
		if (tempPrice - fees > 1) {
			std::cout << "there is a new arbitrage: ";
			for (int i = 0; i < stack.size(); ++i) {
				std::cout << converter->intToName(stack[i]) << " ";
			}
			std::cout << std::endl << "with a profit = " << tempPrice - fees - 1 << std::endl;
		}
		return;
	}
	if (prev == -1) {
		for (int i = 0; i < matrix.size(); ++i) {
			used[i] = true;
			arbitrage(i, i, 1, level - 1, {i}, buyFee[i]);
			used[i] = false;
		}
	} else {
		for (int i = 0; i < matrix.size(); ++i) {
			if (i != prev && matrix[prev][i] != NULL && !used[i]) {
				used[i] = true;
				stack.push_back(i);
				arbitrage(begin, i, tempPrice * (matrix[prev][i]->get(0))->price, level - 1, stack, fees + sellFee[prev] + buyFee[i]);
				stack.pop_back();
				used[i] = false;
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %r8, %r14
movl %edx, %r13d
movq %rdi, %rbx
fldt 0x20(%rbp)
fldt 0x10(%rbp)
movl %ecx, -0x2c(%rbp)
testl %ecx, %ecx
je 0x2c32
cmpl $-0x1, %r13d
je 0x2d90
movl %esi, -0x5c(%rbp)
movl $0x0, -0x58(%rbp)
movq 0x38(%rbx), %rdx
movq 0x40(%rbx), %rsi
cmpq %rdx, %rsi
je 0x2c29
movabsq $-0x8000000000000000, %r12 # imm = 0x8000000000000000
movslq %r13d, %rax
decl -0x2c(%rbp)
xorl %ecx, %ecx
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
leaq (%rax,%rax,2), %rdi
movq %rdi, -0x38(%rbp)
leaq 0x3f(%r12), %rdi
movq %rdi, -0x80(%rbp)
shlq $0x4, %rax
movq %rax, -0x90(%rbp)
xorl %eax, %eax
fxch %st(1)
fstpt -0x74(%rbp)
fstpt -0x68(%rbp)
fldz
fldz
fstp %st(1)
fstp %st(0)
cmpl %r13d, %eax
jne 0x2a78
movl %r13d, %eax
jmp 0x2c06
movq -0x38(%rbp), %rdi
movq (%rdx,%rdi,8), %rdi
cmpq $0x0, (%rdi,%rcx,8)
je 0x2c06
leal 0x3f(%rax), %r8d
testl %eax, %eax
cmovnsl %eax, %r8d
sarl $0x6, %r8d
movslq %r8d, %r8
shlq $0x3, %r8
addq 0x6689(%rip), %r8       # 0x9130
movq %rcx, %r10
andq -0x80(%rbp), %r10
xorl %r9d, %r9d
cmpq %r12, %r10
setbe %r9b
movl $0x1, %r10d
shlq %cl, %r10
movq -0x8(%r8,%r9,8), %r11
btq %rcx, %r11
jb 0x2bfc
leaq -0x8(,%r9,8), %rcx
orq %r10, %r11
movq %r11, (%r8,%rcx)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x2af5
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r14)
jmp 0x2b0d
movq %r14, %rdi
leaq -0x58(%rbp), %rdx
callq 0x3a22
movq 0x38(%rbx), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x58(%rbp), %r12
movq (%rdi,%r12,8), %rdi
xorl %esi, %esi
callq 0x4722
fldt 0x10(%rax)
fldt -0x68(%rbp)
fmulp %st, %st(1)
fstpt -0xcc(%rbp)
leaq -0xa8(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x31de
movq 0x8(%rbx), %rax
movq 0x20(%rbx), %rcx
movq -0x90(%rbp), %rdx
fldt (%rax,%rdx)
fldt -0x74(%rbp)
faddp %st, %st(1)
movslq -0x58(%rbp), %rax
shlq $0x4, %rax
fldt (%rcx,%rax)
faddp %st, %st(1)
fstpt 0x10(%rsp)
fldt -0xcc(%rbp)
fstpt (%rsp)
movq %rbx, %rdi
movl -0x5c(%rbp), %esi
movl %r12d, %edx
movl -0x2c(%rbp), %ecx
movq %r15, %r8
callq 0x29ce
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
movabsq $-0x8000000000000000, %r12 # imm = 0x8000000000000000
je 0x2ba6
movq -0x98(%rbp), %rsi
subq %rdi, %rsi
callq 0x2150
addq $-0x4, 0x8(%r14)
movslq -0x58(%rbp), %rax
leal 0x3f(%rax), %ecx
testq %rax, %rax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rdx
shlq $0x3, %rdx
addq 0x6567(%rip), %rdx      # 0x9130
movq %rax, %rcx
andq -0x80(%rbp), %rcx
xorl %esi, %esi
cmpq %r12, %rcx
setbe %sil
movq $-0x2, %rdi
movl %eax, %ecx
rolq %cl, %rdi
andq %rdi, -0x8(%rdx,%rsi,8)
movq 0x38(%rbx), %rdx
movq 0x40(%rbx), %rsi
fldt -0x74(%rbp)
fstp %st(0)
fldt -0x68(%rbp)
fstp %st(0)
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
incl %eax
movl %eax, -0x58(%rbp)
movslq %eax, %rcx
movq %rsi, %rdi
subq %rdx, %rdi
sarq $0x3, %rdi
imulq %r8, %rdi
cmpq %rcx, %rdi
fldz
fldz
ja 0x2a67
fstp %st(1)
fstp %st(0)
jmp 0x2d89
movslq %r13d, %rax
movq 0x38(%rbx), %rcx
leaq (%rax,%rax,2), %rax
movslq %esi, %rdx
movq (%rcx,%rax,8), %rax
movq (%rax,%rdx,8), %rdi
xorl %esi, %esi
fxch %st(1)
fstpt -0x74(%rbp)
fstpt -0x68(%rbp)
callq 0x4722
fldt 0x10(%rax)
fldt -0x68(%rbp)
fmulp %st, %st(1)
fldt -0x74(%rbp)
fsubrp %st, %st(1)
fld1
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
jbe 0x2e8c
fstpt -0x38(%rbp)
movq 0x635c(%rip), %rdi      # 0x8fd8
leaq 0x3389(%rip), %rsi      # 0x600c
movl $0x1a, %edx
callq 0x2170
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x2d06
xorl %r12d, %r12d
movq 0x6338(%rip), %r13      # 0x8fd8
leaq 0x337e(%rip), %r15      # 0x6025
movq (%rbx), %rsi
movl (%rax,%r12,4), %edx
leaq -0x58(%rbp), %rdi
callq 0x4190
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %r13, %rdi
callq 0x2170
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x2cf0
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2150
incq %r12
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r12, %rcx
ja 0x2ca7
movq 0x62cb(%rip), %rbx      # 0x8fd8
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
movq %rax, %rbx
leaq 0x32e9(%rip), %rsi      # 0x6027
movl $0x10, %edx
movq %rax, %rdi
callq 0x2170
fld1
fchs
fldt -0x38(%rbp)
faddp %st, %st(1)
fstpt (%rsp)
movq %rbx, %rdi
callq 0x2080
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
fldz
jmp 0x2e8c
fstp %st(1)
fstp %st(0)
movq 0x40(%rbx), %rax
cmpq 0x38(%rbx), %rax
fldz
je 0x2e8c
fstp %st(0)
decl -0x2c(%rbp)
movq 0x6380(%rip), %rax      # 0x9130
movq $0x0, -0x38(%rbp)
leaq -0xc0(%rbp), %r13
xorl %r15d, %r15d
movq %rbx, -0x88(%rbp)
fldz
fstp %st(0)
movl %r15d, %r12d
shrl $0x6, %r12d
movl $0x1, %r14d
movl %r15d, %ecx
shlq %cl, %r14
orq %r14, (%rax,%r12,8)
movl %r15d, -0x58(%rbp)
movl $0x1, %edx
movq %r13, %rbx
movq %r13, %rdi
leaq -0x58(%rbp), %rsi
leaq -0x2d(%rbp), %rcx
callq 0x3198
movq -0x88(%rbp), %rdi
movq 0x20(%rdi), %rax
movq -0x38(%rbp), %rcx
fldt (%rax,%rcx)
fstpt 0x10(%rsp)
fld1
fstpt (%rsp)
movl %r15d, %esi
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
movq %rbx, %r13
movq %rbx, %r8
callq 0x29ce
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x2e4a
movq -0xb0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2150
movq 0x62df(%rip), %rax      # 0x9130
notq %r14
andq %r14, (%rax,%r12,8)
incq %r15
movq -0x88(%rbp), %rbx
movq 0x40(%rbx), %rcx
subq 0x38(%rbx), %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
addq $0x10, -0x38(%rbp)
cmpq %r15, %rcx
fldz
ja 0x2dcb
fstp %st(0)
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x2ef4
movq -0x98(%rbp), %rsi
jmp 0x2ed3
movq %rax, %rbx
jmp 0x2ef4
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x2ef4
movq -0xb0(%rbp), %rsi
subq %rdi, %rsi
jmp 0x2eef
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x2ef4
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2150
movq %rbx, %rdi
callq 0x21f0