// File: /workspace/github_c_makefile_star2_O3/cyb70289[P]tt/src/apn/integer/basic.c
// Function: mul_buf_classic
static int mul_buf_classic(_tt_word *intr, const _tt_word *int1, int msb1,
		const _tt_word *int2, int msb2)
{
	_tt_word c, *r = intr;
	_tt_word_double t0, m;
#ifndef _TT_LP64_
	_tt_word_double t1, t2, t3;
#endif

	/* Square can be faster */
	if (_tt_unlikely(int1 == int2 && msb1 == msb2)) {
		for (int i = 0; i < msb1; i++) {
			t0 = (_tt_word_double)int1[i]*int1[i] + r[i];
			r[i] = t0 & ~_tt_word_top_bit;
			c = t0 >> _tt_word_bits;
			m = int1[i] << 1;

			int j = i + 1;
#ifndef _TT_LP64_
			for (; j <= msb1-4; j += 4) {
				t0 = m * int1[j] + r[j];
				t1 = m * int1[j+1] + r[j+1];
				t2 = m * int1[j+2] + r[j+2];
				t3 = m * int1[j+3] + r[j+3];

				t0 += c;
				r[j] = t0 & ~_tt_word_top_bit;
				t1 += t0 >> _tt_word_bits;
				r[j+1] = t1 & ~_tt_word_top_bit;
				t2 += t1 >> _tt_word_bits;
				r[j+2] = t2 & ~_tt_word_top_bit;
				t3 += t2 >> _tt_word_bits;
				r[j+3] = t3 & ~_tt_word_top_bit;
				c = t3 >> _tt_word_bits;
			}
#endif
			for (; j < msb1; j++) {
				t0 = m * int1[j] + r[j] + c;
				c = t0 >> _tt_word_bits;
				r[j] = t0 & ~_tt_word_top_bit;
			}
			r[msb1] = c;

			r++;
		}
	} else {
		bool swap = msb1 < msb2;
#ifndef _TT_LP64_
		swap = !swap;
#endif
		if (swap) {
			__tt_swap(msb1, msb2);
			__tt_swap(int1, int2);
		}

		for (int i = 0; i < msb1; i++) {
			c = 0;
			m = int1[i];

			int j = 0;
#ifndef _TT_LP64_
			for (; j <= msb2-4; j += 4) {
				t0 = m * int2[j] + r[j];
				t1 = m * int2[j+1] + r[j+1];
				t2 = m * int2[j+2] + r[j+2];
				t3 = m * int2[j+3] + r[j+3];

				t0 += c;
				r[j] = t0 & ~_tt_word_top_bit;
				t1 += t0 >> _tt_word_bits;
				r[j+1] = t1 & ~_tt_word_top_bit;
				t2 += t1 >> _tt_word_bits;
				r[j+2] = t2 & ~_tt_word_top_bit;
				t3 += t2 >> _tt_word_bits;
				r[j+3] = t3 & ~_tt_word_top_bit;
				c = t3 >> _tt_word_bits;
			}
#endif
			for (; j < msb2; j++) {
				t0 = m * int2[j] + r[j] + c;
				c = t0 >> _tt_word_bits;
				r[j] = t0 & ~_tt_word_top_bit;
			}
			r[msb2] = c;

			r++;
		}
	}

	/* Top int may be 0 */
	int msb = msb1 + msb2;
	if (intr[msb-1] == 0)
		msb--;

	return msb;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %edx, %r9d
cmpq %rcx, %rsi
setne %al
cmpl %r8d, %edx
setne %dl
orb %al, %dl
je 0x5b84
movq %rcx, %r10
cmpl %r8d, %r9d
jge 0x5ad1
movl %r9d, %ecx
movq %rsi, %r11
jmp 0x5add
movl %r8d, %ecx
movq %r10, %r11
movl %r9d, %r8d
movq %rsi, %r10
testl %r8d, %r8d
jle 0x5b6a
movabsq $0x7fffffffffffffff, %r9 # imm = 0x7FFFFFFFFFFFFFFF
movslq %ecx, %rbx
movl %r8d, -0x4(%rsp)
movl %r8d, %r14d
movl %ebx, %r15d
xorl %r12d, %r12d
movq %rdi, -0x10(%rsp)
movq %rdi, %r13
movq %r10, %rdi
testl %ecx, %ecx
jle 0x5b4c
movq (%rdi,%r12,8), %rsi
xorl %ebp, %ebp
xorl %r10d, %r10d
movq %rsi, %rax
mulq (%r11,%rbp,8)
xorl %r8d, %r8d
addq (%r13,%rbp,8), %r10
setb %r8b
addq %rax, %r10
adcq %rdx, %r8
shldq $0x1, %r10, %r8
andq %r9, %r10
movq %r10, (%r13,%rbp,8)
incq %rbp
movq %r8, %r10
cmpq %rbp, %r15
jne 0x5b19
jmp 0x5b4f
xorl %r8d, %r8d
movq %r8, (%r13,%rbx,8)
addq $0x8, %r13
incq %r12
cmpq %r14, %r12
jne 0x5b0c
movq -0x10(%rsp), %rdi
movl -0x4(%rsp), %r8d
addl %r8d, %ecx
movslq %ecx, %rax
cmpq $0x1, -0x8(%rdi,%rax,8)
sbbl $0x0, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r9d, %r9d
jle 0x5c43
movabsq $0x7fffffffffffffff, %r10 # imm = 0x7FFFFFFFFFFFFFFF
movl %r9d, %r11d
xorl %r8d, %r8d
movq %r11, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %rdi, -0x10(%rsp)
movq %rdi, %r12
movq (%rsi,%r8,8), %rax
mulq %rax
movq %rdx, %rcx
addq (%r12,%r8,8), %rax
adcq $0x0, %rcx
shldq $0x1, %rax, %rcx
andq %r10, %rax
movq %rax, (%r12,%r8,8)
leaq 0x1(%r8), %r13
cmpq %r11, %r13
jae 0x5c11
movq (%rsi,%r8,8), %r8
addq %r8, %r8
movl $0x1, %ebp
movq %r8, %rax
mulq (%r14,%rbp,8)
xorl %edi, %edi
addq (%r15,%rbp,8), %rcx
setb %dil
addq %rax, %rcx
adcq %rdx, %rdi
shldq $0x1, %rcx, %rdi
andq %r10, %rcx
movq %rcx, (%r15,%rbp,8)
incq %rbp
movq %rdi, %rcx
cmpq %rbp, %rbx
jne 0x5be1
jmp 0x5c14
movq %rcx, %rdi
movq %rdi, (%r12,%r11,8)
addq $0x8, %r12
addq $0x10, %r15
addq $0x8, %r14
decq %rbx
movq %r13, %r8
cmpq %r11, %r13
jne 0x5bae
movl %r9d, %ecx
movl %r9d, %r8d
movq -0x10(%rsp), %rdi
jmp 0x5b6a
movl %r9d, %ecx
movl %r9d, %r8d
jmp 0x5b6a