// File: /workspace/github_c_makefile_star2_O0/cyb70289[P]tt/tests/decimal.c
// Function: verify_mul
static void verify_mul(int count)
{
	bool fail = false;
	char s[1024];
	struct tt_dec *dec1, *dec2, *dec3;

	int old_level = tt_log_set_level(TT_LOG_WARN);

	/* Special case */
	dec1 = tt_dec_alloc(0);
	dec2 = tt_dec_alloc(0);
	dec3 = tt_dec_alloc(0);
	const struct {
		const char *add1, *add2, *result;
	} cases[] = {
		{ "0", "0", "0", },
		{ "0E-10", "-0E-20", "-0E-30" },
		{ "1E-2000", "0.0", "0E-2001" },
		{ "0.0", "1E-2000", "0E-2001" },
		{ "100E-10", "-0.0", "-0E-9" },
		{ "100E-10", "0", "0" },

	};
	for (int i = 0; i < sizeof(cases)/sizeof(cases[0]); i++) {
		tt_dec_from_string(dec1, cases[i].add1);
		tt_dec_from_string(dec2, cases[i].add2);
		tt_dec_mul(dec3, dec1, dec2);
		tt_dec_to_string(dec3, s, 360);
		if (_tt_dec_sanity(dec3)) {
			tt_error("Sanity error");
			fail = true;
			break;
		}
		if (strcmp(s, cases[i].result)) {
			tt_error("%s * %s => %s",
					cases[i].add1, cases[i].add2, s);
			fail = true;
			break;
		}
	}
	tt_dec_free(dec1);
	tt_dec_free(dec2);
	tt_dec_free(dec3);
	if (fail)
		return;

	/* Big number */
	printf("Mul big number...\n");
	dec1 = tt_dec_alloc(30);
	dec2 = tt_dec_alloc(50);
	dec3 = tt_dec_alloc(40);
	for (int i = 0; i < count; i++) {
		double d1, d2;
		long double ld;
		char s1[128], s2[128];
		ld = get_num(s1, 1, 100);
		tt_dec_from_string(dec1, s1);
		ld *= get_num(s2, 1, 100);
		tt_dec_from_string(dec2, s2);
		double prec = 1E-15;
		tt_dec_mul(dec3, dec2, dec1);
		tt_dec_mul(dec2, dec1, dec2);
		tt_dec_to_float(dec3, &d1);
		tt_dec_to_float(dec2, &d2);

		if (_tt_dec_sanity(dec1) || _tt_dec_sanity(dec2) ||
				_tt_dec_sanity(dec3)) {
			tt_error("Sanity error");
			fail = true;
			break;
		}

		if (!deq(ld, d1, prec) || !deq(ld, d2, prec)) {
			tt_warn("Num mul mismatch: %s * %s\nMach: %.18LE\n"
					"DEC:  %.18E\nDEC:  %.18E",
					s1, s2, ld, d1, d2);
		}
	}

	tt_dec_free(dec1);
	tt_dec_free(dec2);
	tt_dec_free(dec3);
	if (fail)
		return;

#ifdef __STDC_IEC_559__
	/* Random float */
	printf("Mul float...\n");
	dec1 = tt_dec_alloc(0);
	dec2 = tt_dec_alloc(0);
	dec3 = tt_dec_alloc(0);

	for (int i = 0; i < count; i++) {
		double d1 = gen_float(150);
		double d2 = gen_float(150);
		double prec = 1E-15;

		tt_dec_from_float(dec1, d1);
		tt_dec_from_float(dec2, d2);

		tt_dec_mul(dec3, dec1, dec2);
		tt_dec_mul(dec1, dec2, dec1);

		if (_tt_dec_sanity(dec1) || _tt_dec_sanity(dec2) ||
				_tt_dec_sanity(dec3)) {
			tt_error("Sanity error");
			fail = true;
			break;
		}

		double vd1, vd2;
		tt_dec_to_float(dec3, &vd1);
		tt_dec_to_float(dec1, &vd2);

		double ds = d1 * d2;
		if (!deq(vd1, ds, prec) || !deq(vd2, ds, prec)) {
			tt_warn("Float mul mismatch: %.18E * %.18E\n"
					"Mach: %.18E\nDEC:  %.18E\nDEC:  %.18E",
					d1, d2, ds, vd1, vd2);
		}
	}
	tt_dec_free(dec1);
	tt_dec_free(dec2);
	tt_dec_free(dec3);
#endif
	tt_log_set_level(old_level);
}

// Assembly:
subq $0x658, %rsp            # imm = 0x658
movl %edi, 0x654(%rsp)
movb $0x0, 0x653(%rsp)
movl $0x1, %edi
callq 0x10ac0
movl %eax, 0x234(%rsp)
xorl %edi, %edi
callq 0x4660
movq %rax, 0x248(%rsp)
xorl %edi, %edi
callq 0x4660
movq %rax, 0x240(%rsp)
xorl %edi, %edi
callq 0x4660
movq %rax, 0x238(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0x21a4d(%rip), %rsi     # 0x24be0
movl $0x90, %edx
callq 0x2150
movl $0x0, 0x19c(%rsp)
movslq 0x19c(%rsp), %rax
cmpq $0x6, %rax
jae 0x3319
movq 0x248(%rsp), %rdi
movslq 0x19c(%rsp), %rcx
leaq 0x1a0(%rsp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x5690
movq 0x240(%rsp), %rdi
movslq 0x19c(%rsp), %rcx
leaq 0x1a0(%rsp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x5690
movq 0x238(%rsp), %rdi
movq 0x248(%rsp), %rsi
movq 0x240(%rsp), %rdx
callq 0x6b80
movq 0x238(%rsp), %rdi
leaq 0x250(%rsp), %rsi
movl $0x168, %edx            # imm = 0x168
callq 0x5dc0
movq 0x238(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
je 0x3276
xorl %edi, %edi
leaq 0x11fc9(%rip), %rsi     # 0x15224
leaq 0x11e1c(%rip), %rdx     # 0x1507e
movb $0x0, %al
callq 0x10770
movb $0x1, 0x653(%rsp)
jmp 0x3319
leaq 0x250(%rsp), %rdi
movslq 0x19c(%rsp), %rcx
leaq 0x1a0(%rsp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
callq 0x2120
cmpl $0x0, %eax
je 0x3301
movslq 0x19c(%rsp), %rcx
leaq 0x1a0(%rsp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movslq 0x19c(%rsp), %rdx
leaq 0x1a0(%rsp), %rax
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq 0x8(%rax), %r8
leaq 0x250(%rsp), %r9
xorl %edi, %edi
leaq 0x11f3b(%rip), %rsi     # 0x15224
leaq 0x11f3f(%rip), %rdx     # 0x1522f
movb $0x0, %al
callq 0x10770
movb $0x1, 0x653(%rsp)
jmp 0x3319
jmp 0x3303
movl 0x19c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x19c(%rsp)
jmp 0x31a8
movq 0x248(%rsp), %rdi
callq 0x47e0
movq 0x240(%rsp), %rdi
callq 0x47e0
movq 0x238(%rsp), %rdi
callq 0x47e0
testb $0x1, 0x653(%rsp)
je 0x334f
jmp 0x37fd
leaq 0x11ee7(%rip), %rdi     # 0x1523d
movb $0x0, %al
callq 0x20c0
movl $0x1e, %edi
callq 0x4660
movq %rax, 0x248(%rsp)
movl $0x32, %edi
callq 0x4660
movq %rax, 0x240(%rsp)
movl $0x28, %edi
callq 0x4660
movq %rax, 0x238(%rsp)
movl $0x0, 0x198(%rsp)
movl 0x198(%rsp), %eax
cmpl 0x654(%rsp), %eax
jge 0x35a0
leaq 0xf0(%rsp), %rdi
movq %rdi, 0x10(%rsp)
movl $0x1, %esi
movl %esi, 0x18(%rsp)
movl $0x64, %edx
movl %edx, 0x1c(%rsp)
callq 0x4230
movq 0x10(%rsp), %rsi
fstpt 0x170(%rsp)
movq 0x248(%rsp), %rdi
callq 0x5690
movl 0x18(%rsp), %esi
movl 0x1c(%rsp), %edx
leaq 0x70(%rsp), %rdi
callq 0x4230
fldt 0x170(%rsp)
fmulp %st, %st(1)
fstpt 0x170(%rsp)
movq 0x240(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x5690
movsd 0x11bdd(%rip), %xmm0    # 0x15008
movsd %xmm0, 0x68(%rsp)
movq 0x238(%rsp), %rdi
movq 0x240(%rsp), %rsi
movq 0x248(%rsp), %rdx
callq 0x6b80
movq 0x240(%rsp), %rdi
movq 0x248(%rsp), %rsi
movq 0x240(%rsp), %rdx
callq 0x6b80
movq 0x238(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x52a0
movq 0x240(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x52a0
movq 0x248(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
jne 0x34cb
movq 0x240(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
jne 0x34cb
movq 0x238(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
je 0x34ef
xorl %edi, %edi
leaq 0x11d50(%rip), %rsi     # 0x15224
leaq 0x11ba3(%rip), %rdx     # 0x1507e
movb $0x0, %al
callq 0x10770
movb $0x1, 0x653(%rsp)
jmp 0x35a0
fldt 0x170(%rsp)
fstpl 0x28(%rsp)
movsd 0x28(%rsp), %xmm0
movsd 0x190(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
callq 0x4360
testb $0x1, %al
jne 0x351a
jmp 0x3543
fldt 0x170(%rsp)
fstpl 0x20(%rsp)
movsd 0x20(%rsp), %xmm0
movsd 0x188(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
callq 0x4360
testb $0x1, %al
jne 0x3588
leaq 0xf0(%rsp), %rcx
leaq 0x70(%rsp), %r8
fldt 0x170(%rsp)
movsd 0x190(%rsp), %xmm0
movsd 0x188(%rsp), %xmm1
movq %rsp, %rax
fstpt (%rax)
leaq 0x11caf(%rip), %rsi     # 0x15224
leaq 0x11cd4(%rip), %rdx     # 0x15250
movl $0x1, %edi
movb $0x2, %al
callq 0x10770
jmp 0x358a
movl 0x198(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x198(%rsp)
jmp 0x339e
movq 0x248(%rsp), %rdi
callq 0x47e0
movq 0x240(%rsp), %rdi
callq 0x47e0
movq 0x238(%rsp), %rdi
callq 0x47e0
testb $0x1, 0x653(%rsp)
je 0x35d6
jmp 0x37fd
leaq 0x11cb2(%rip), %rdi     # 0x1528f
movb $0x0, %al
callq 0x20c0
xorl %edi, %edi
callq 0x4660
movq %rax, 0x248(%rsp)
xorl %edi, %edi
callq 0x4660
movq %rax, 0x240(%rsp)
xorl %edi, %edi
callq 0x4660
movq %rax, 0x238(%rsp)
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
cmpl 0x654(%rsp), %eax
jge 0x37ca
movl $0x96, %edi
callq 0x44f0
movsd %xmm0, 0x58(%rsp)
movl $0x96, %edi
callq 0x44f0
movsd %xmm0, 0x50(%rsp)
movsd 0x119b6(%rip), %xmm0    # 0x15008
movsd %xmm0, 0x48(%rsp)
movq 0x248(%rsp), %rdi
movsd 0x58(%rsp), %xmm0
callq 0x4e10
movq 0x240(%rsp), %rdi
movsd 0x50(%rsp), %xmm0
callq 0x4e10
movq 0x238(%rsp), %rdi
movq 0x248(%rsp), %rsi
movq 0x240(%rsp), %rdx
callq 0x6b80
movq 0x248(%rsp), %rdi
movq 0x240(%rsp), %rsi
movq 0x248(%rsp), %rdx
callq 0x6b80
movq 0x248(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
jne 0x36ee
movq 0x240(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
jne 0x36ee
movq 0x238(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
je 0x3712
xorl %edi, %edi
leaq 0x11b2d(%rip), %rsi     # 0x15224
leaq 0x11980(%rip), %rdx     # 0x1507e
movb $0x0, %al
callq 0x10770
movb $0x1, 0x653(%rsp)
jmp 0x37ca
movq 0x238(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x52a0
movq 0x248(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x52a0
movsd 0x58(%rsp), %xmm0
mulsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x40(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
callq 0x4360
testb $0x1, %al
jne 0x3765
jmp 0x3780
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
callq 0x4360
testb $0x1, %al
jne 0x37b8
movsd 0x58(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
movsd 0x40(%rsp), %xmm3
movsd 0x38(%rsp), %xmm4
movl $0x1, %edi
leaq 0x11a7a(%rip), %rsi     # 0x15224
leaq 0x11aec(%rip), %rdx     # 0x1529d
movb $0x5, %al
callq 0x10770
jmp 0x37ba
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x3619
movq 0x248(%rsp), %rdi
callq 0x47e0
movq 0x240(%rsp), %rdi
callq 0x47e0
movq 0x238(%rsp), %rdi
callq 0x47e0
movl 0x234(%rsp), %edi
callq 0x10ac0
addq $0x658, %rsp            # imm = 0x658
retq
nopw %cs:(%rax,%rax)