// File: ocornoc[P]crolol/src/losslessops.cpp
// Function: crolol::backend::pow(long, long)
saferet backend::pow(int64_t n, int64_t m)
{
	if (n < 0 && m % scale != 0) return make_badarg(m);
	else if (n == 0 && m == 0) return clamp(scale);
	else if (n == 0 && m < 0) return make_badarg(m);
	else if (n == scale || m == 0) return clamp(scale);
	else if (m == scale) return clamp(n);
	
	const float128 nf = static_cast<float128>(n) / scale;
	const float128 mf = static_cast<float128>(m) / scale;
	const float128 size = mp::log2(mp::abs(nf)) * mf;
	
	if (size > slmaxlog2) return clamp(slmax);
	else if (mp::abs(size) > slminlog2) return clamp(slmin);
	else return clamp(static_cast<int128>(
		mp::llrint(mp::trunc(mp::pow(nf, mf) * scale))
	));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x320, %rsp            # imm = 0x320
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
jge 0xb111
movq -0x20(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0xb111
movq -0x20(%rbp), %rdi
callq 0xb080
movl %edx, -0x28(%rbp)
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x8(%rbp)
jmp 0xb48c
cmpq $0x0, -0x18(%rbp)
jne 0xb160
cmpq $0x0, -0x20(%rbp)
jne 0xb160
leaq 0x210ea(%rip), %rsi     # 0x2c210
xorl %eax, %eax
movl %eax, %edx
leaq -0x50(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0xbc50
movq -0x2d8(%rbp), %rdi
callq 0xaee0
movl %edx, -0x58(%rbp)
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x8(%rbp)
jmp 0xb48c
cmpq $0x0, -0x18(%rbp)
jne 0xb191
cmpq $0x0, -0x20(%rbp)
jge 0xb191
movq -0x20(%rbp), %rdi
callq 0xb080
movl %edx, -0x68(%rbp)
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x8(%rbp)
jmp 0xb48c
cmpq $0x3e8, -0x18(%rbp)     # imm = 0x3E8
je 0xb1a2
cmpq $0x0, -0x20(%rbp)
jne 0xb1f2
leaq 0x21067(%rip), %rsi     # 0x2c210
xorl %eax, %eax
movl %eax, %edx
leaq -0x90(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0xbc50
movq -0x2e0(%rbp), %rdi
callq 0xaee0
movl %edx, -0x98(%rbp)
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x98(%rbp), %eax
movl %eax, -0x8(%rbp)
jmp 0xb48c
cmpq $0x3e8, -0x20(%rbp)     # imm = 0x3E8
jne 0xb249
xorl %eax, %eax
movl %eax, %edx
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
leaq -0x18(%rbp), %rsi
callq 0xbc50
movq -0x2e8(%rbp), %rdi
callq 0xaee0
movl %edx, -0xc8(%rbp)
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0xc8(%rbp), %eax
movl %eax, -0x8(%rbp)
jmp 0xb48c
jmp 0xb24b
jmp 0xb24d
jmp 0xb24f
jmp 0xb251
leaq -0x110(%rbp), %rdi
leaq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xbac0
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
leaq 0x20f96(%rip), %rdx     # 0x2c210
callq 0xba40
leaq -0x150(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xbac0
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
leaq 0x20f68(%rip), %rdx     # 0x2c210
callq 0xba40
leaq -0x1b0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xbd90
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0xb9e0
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
leaq -0x130(%rbp), %rdx
callq 0xbd10
leaq -0x170(%rbp), %rdi
leaq 0x351b5(%rip), %rsi     # 0x404b0
callq 0xbdf0
testb $0x1, %al
jne 0xb306
jmp 0xb356
leaq 0x20efb(%rip), %rsi     # 0x2c208
xorl %eax, %eax
movl %eax, %edx
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0xbc50
movq -0x2f0(%rbp), %rdi
callq 0xaee0
movl %edx, -0x1d8(%rbp)
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x1d8(%rbp), %eax
movl %eax, -0x8(%rbp)
jmp 0xb48c
leaq -0x200(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0xbd90
leaq -0x200(%rbp), %rdi
leaq 0x35159(%rip), %rsi     # 0x404d0
callq 0xbdf0
testb $0x1, %al
jne 0xb382
jmp 0xb3d2
leaq 0x20e8f(%rip), %rsi     # 0x2c218
xorl %eax, %eax
movl %eax, %edx
leaq -0x220(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0xbc50
movq -0x2f8(%rbp), %rdi
callq 0xaee0
movl %edx, -0x228(%rbp)
movq %rax, -0x230(%rbp)
movq -0x230(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x228(%rbp), %eax
movl %eax, -0x8(%rbp)
jmp 0xb48c
leaq -0x2c0(%rbp), %rdi
movq %rdi, -0x318(%rbp)
leaq -0xf0(%rbp), %rsi
leaq -0x130(%rbp), %rdx
callq 0xbf50
movq -0x318(%rbp), %rsi
leaq 0x20e0f(%rip), %rdx     # 0x2c210
leaq -0x2a0(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0xbed0
movq -0x310(%rbp), %rsi
leaq -0x280(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0xbe70
movq -0x308(%rbp), %rdi
callq 0xbe50
movq %rax, -0x258(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0x250(%rbp), %rdi
movq %rdi, -0x300(%rbp)
leaq -0x258(%rbp), %rsi
callq 0xbfd0
movq -0x300(%rbp), %rdi
callq 0xaee0
movl %edx, -0x2c8(%rbp)
movq %rax, -0x2d0(%rbp)
movq -0x2d0(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x2c8(%rbp), %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
movl -0x8(%rbp), %edx
addq $0x320, %rsp            # imm = 0x320
popq %rbp
retq
nopl (%rax)