// File: /workspace/github_c_makefile_star2_O2/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, %r10d
movq %rdi, -0x8(%rsp)
movabsq $0x7fffffffffffffff, %r11 # imm = 0x7FFFFFFFFFFFFFFF
cmpq %rcx, %rsi
setne %al
cmpl %r8d, %edx
setne %dl
orb %al, %dl
je 0x4fcc
cmpl %r8d, %r10d
jge 0x4f2c
movl %r10d, %r9d
movq %rsi, %r14
movl %r8d, -0xc(%rsp)
jmp 0x4f3a
movl %r8d, %r9d
movq %rcx, %r14
movl %r10d, -0xc(%rsp)
movq %rsi, %rcx
movslq %r9d, %r15
xorl %r12d, %r12d
testl %r15d, %r15d
movl $0x0, %r13d
cmovgl %r15d, %r13d
cmpl %r10d, %r8d
cmovgl %r8d, %r10d
testl %r10d, %r10d
cmovlel %r12d, %r10d
movq -0x8(%rsp), %r8
cmpq %r10, %r12
je 0x4fa9
movq (%rcx,%r12,8), %rsi
xorl %ebp, %ebp
xorl %edi, %edi
cmpq %rbp, %r13
je 0x4f9c
movq %rsi, %rax
mulq (%r14,%rbp,8)
xorl %ebx, %ebx
addq (%r8,%rbp,8), %rdi
setb %bl
addq %rax, %rdi
adcq %rdx, %rbx
shldq $0x1, %rdi, %rbx
andq %r11, %rdi
movq %rdi, (%r8,%rbp,8)
incq %rbp
movq %rbx, %rdi
jmp 0x4f6d
movq %rdi, (%r8,%r15,8)
addq $0x8, %r8
incq %r12
jmp 0x4f60
movl -0xc(%rsp), %eax
addl %eax, %r9d
movslq %r9d, %rax
movq -0x8(%rsp), %rcx
cmpq $0x1, -0x8(%rcx,%rax,8)
sbbl $0x0, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %r10d, %r8
xorl %ebx, %ebx
testl %r10d, %r10d
movl $0x0, %r14d
cmovgl %r10d, %r14d
movq %rsi, %r12
movq -0x8(%rsp), %rbp
movq %rbp, %r13
cmpq %r14, %rbx
je 0x5072
movq (%rsi,%rbx,8), %rax
mulq %rax
movq %rdx, %rcx
addq (%rbp,%rbx,8), %rax
adcq $0x0, %rcx
shldq $0x1, %rax, %rcx
andq %r11, %rax
movq %rax, (%rbp,%rbx,8)
movq (%rsi,%rbx,8), %r9
addq %r9, %r9
movabsq $0x1, %r15
leal (%rbx,%r15), %eax
cmpl %r10d, %eax
jge 0x5059
movq %r9, %rax
mulq (%r12,%r15,8)
xorl %edi, %edi
addq (%r13,%r15,8), %rcx
setb %dil
addq %rax, %rcx
adcq %rdx, %rdi
shldq $0x1, %rcx, %rdi
andq %r11, %rcx
movq %rcx, (%r13,%r15,8)
incq %r15
movq %rdi, %rcx
jmp 0x5023
incq %rbx
movq %rcx, (%rbp,%r8,8)
addq $0x8, %rbp
addq $0x10, %r13
addq $0x8, %r12
jmp 0x4fe9
movl %r10d, %r9d
movl %r10d, %eax
jmp 0x4fad