// File: /workspace/github_c_makefile_star2_O0/cyb70289[P]tt/tests/decimal.c
// Function: verify_div
static void verify_div(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", "NaN", },
		{ "0.0", "1E-2000", "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_div(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("Div 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_div(dec3, dec1, dec2);
		tt_dec_div(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 div 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("Div 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_div(dec3, dec1, dec2);
		tt_dec_div(dec1, dec1, dec2);

		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 div 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 $0x5f8, %rsp            # imm = 0x5F8
movl %edi, 0x5f4(%rsp)
movb $0x0, 0x5f3(%rsp)
movl $0x1, %edi
callq 0x10ac0
movl %eax, 0x1d4(%rsp)
xorl %edi, %edi
callq 0x4660
movq %rax, 0x1e8(%rsp)
xorl %edi, %edi
callq 0x4660
movq %rax, 0x1e0(%rsp)
xorl %edi, %edi
callq 0x4660
movq %rax, 0x1d8(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0x213fd(%rip), %rsi     # 0x24c70
movl $0x30, %edx
callq 0x2150
movl $0x0, 0x19c(%rsp)
movslq 0x19c(%rsp), %rax
cmpq $0x2, %rax
jae 0x39f9
movq 0x1e8(%rsp), %rdi
movslq 0x19c(%rsp), %rcx
leaq 0x1a0(%rsp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x5690
movq 0x1e0(%rsp), %rdi
movslq 0x19c(%rsp), %rcx
leaq 0x1a0(%rsp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x5690
movq 0x1d8(%rsp), %rdi
movq 0x1e8(%rsp), %rsi
movq 0x1e0(%rsp), %rdx
callq 0x7970
movq 0x1d8(%rsp), %rdi
leaq 0x1f0(%rsp), %rsi
movl $0x168, %edx            # imm = 0x168
callq 0x5dc0
movq 0x1d8(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
je 0x3956
xorl %edi, %edi
leaq 0x119ac(%rip), %rsi     # 0x152e7
leaq 0x1173c(%rip), %rdx     # 0x1507e
movb $0x0, %al
callq 0x10770
movb $0x1, 0x5f3(%rsp)
jmp 0x39f9
leaq 0x1f0(%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 0x39e1
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 0x1f0(%rsp), %r9
xorl %edi, %edi
leaq 0x1191e(%rip), %rsi     # 0x152e7
leaq 0x11922(%rip), %rdx     # 0x152f2
movb $0x0, %al
callq 0x10770
movb $0x1, 0x5f3(%rsp)
jmp 0x39f9
jmp 0x39e3
movl 0x19c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x19c(%rsp)
jmp 0x3888
movq 0x1e8(%rsp), %rdi
callq 0x47e0
movq 0x1e0(%rsp), %rdi
callq 0x47e0
movq 0x1d8(%rsp), %rdi
callq 0x47e0
testb $0x1, 0x5f3(%rsp)
je 0x3a2f
jmp 0x3edd
leaq 0x118ca(%rip), %rdi     # 0x15300
movb $0x0, %al
callq 0x20c0
movl $0x1e, %edi
callq 0x4660
movq %rax, 0x1e8(%rsp)
movl $0x32, %edi
callq 0x4660
movq %rax, 0x1e0(%rsp)
movl $0x28, %edi
callq 0x4660
movq %rax, 0x1d8(%rsp)
movl $0x0, 0x198(%rsp)
movl 0x198(%rsp), %eax
cmpl 0x5f4(%rsp), %eax
jge 0x3c80
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 0x1e8(%rsp), %rdi
callq 0x5690
movl 0x18(%rsp), %esi
movl 0x1c(%rsp), %edx
leaq 0x70(%rsp), %rdi
callq 0x4230
fldt 0x170(%rsp)
fdivp %st, %st(1)
fstpt 0x170(%rsp)
movq 0x1e0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x5690
movsd 0x114fd(%rip), %xmm0    # 0x15008
movsd %xmm0, 0x68(%rsp)
movq 0x1d8(%rsp), %rdi
movq 0x1e8(%rsp), %rsi
movq 0x1e0(%rsp), %rdx
callq 0x7970
movq 0x1e0(%rsp), %rdi
movq 0x1e8(%rsp), %rsi
movq 0x1e0(%rsp), %rdx
callq 0x7970
movq 0x1d8(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x52a0
movq 0x1e0(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x52a0
movq 0x1e8(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
jne 0x3bab
movq 0x1e0(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
jne 0x3bab
movq 0x1d8(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
je 0x3bcf
xorl %edi, %edi
leaq 0x11733(%rip), %rsi     # 0x152e7
leaq 0x114c3(%rip), %rdx     # 0x1507e
movb $0x0, %al
callq 0x10770
movb $0x1, 0x5f3(%rsp)
jmp 0x3c80
fldt 0x170(%rsp)
fstpl 0x28(%rsp)
movsd 0x28(%rsp), %xmm0
movsd 0x190(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
callq 0x4360
testb $0x1, %al
jne 0x3bfa
jmp 0x3c23
fldt 0x170(%rsp)
fstpl 0x20(%rsp)
movsd 0x20(%rsp), %xmm0
movsd 0x188(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
callq 0x4360
testb $0x1, %al
jne 0x3c68
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 0x11692(%rip), %rsi     # 0x152e7
leaq 0x116b7(%rip), %rdx     # 0x15313
movl $0x1, %edi
movb $0x2, %al
callq 0x10770
jmp 0x3c6a
movl 0x198(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x198(%rsp)
jmp 0x3a7e
movq 0x1e8(%rsp), %rdi
callq 0x47e0
movq 0x1e0(%rsp), %rdi
callq 0x47e0
movq 0x1d8(%rsp), %rdi
callq 0x47e0
testb $0x1, 0x5f3(%rsp)
je 0x3cb6
jmp 0x3edd
leaq 0x11695(%rip), %rdi     # 0x15352
movb $0x0, %al
callq 0x20c0
xorl %edi, %edi
callq 0x4660
movq %rax, 0x1e8(%rsp)
xorl %edi, %edi
callq 0x4660
movq %rax, 0x1e0(%rsp)
xorl %edi, %edi
callq 0x4660
movq %rax, 0x1d8(%rsp)
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
cmpl 0x5f4(%rsp), %eax
jge 0x3eaa
movl $0x96, %edi
callq 0x44f0
movsd %xmm0, 0x58(%rsp)
movl $0x96, %edi
callq 0x44f0
movsd %xmm0, 0x50(%rsp)
movsd 0x112d6(%rip), %xmm0    # 0x15008
movsd %xmm0, 0x48(%rsp)
movq 0x1e8(%rsp), %rdi
movsd 0x58(%rsp), %xmm0
callq 0x4e10
movq 0x1e0(%rsp), %rdi
movsd 0x50(%rsp), %xmm0
callq 0x4e10
movq 0x1d8(%rsp), %rdi
movq 0x1e8(%rsp), %rsi
movq 0x1e0(%rsp), %rdx
callq 0x7970
movq 0x1e8(%rsp), %rdi
movq 0x1e8(%rsp), %rsi
movq 0x1e0(%rsp), %rdx
callq 0x7970
movq 0x1e8(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
jne 0x3dce
movq 0x1e0(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
jne 0x3dce
movq 0x1d8(%rsp), %rdi
callq 0x4850
cmpl $0x0, %eax
je 0x3df2
xorl %edi, %edi
leaq 0x11510(%rip), %rsi     # 0x152e7
leaq 0x112a0(%rip), %rdx     # 0x1507e
movb $0x0, %al
callq 0x10770
movb $0x1, 0x5f3(%rsp)
jmp 0x3eaa
movq 0x1d8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x52a0
movq 0x1e8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x52a0
movsd 0x58(%rsp), %xmm0
divsd 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 0x3e45
jmp 0x3e60
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
callq 0x4360
testb $0x1, %al
jne 0x3e98
movsd 0x58(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
movsd 0x40(%rsp), %xmm3
movsd 0x38(%rsp), %xmm4
movl $0x1, %edi
leaq 0x1145d(%rip), %rsi     # 0x152e7
leaq 0x114cf(%rip), %rdx     # 0x15360
movb $0x5, %al
callq 0x10770
jmp 0x3e9a
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x3cf9
movq 0x1e8(%rsp), %rdi
callq 0x47e0
movq 0x1e0(%rsp), %rdi
callq 0x47e0
movq 0x1d8(%rsp), %rdi
callq 0x47e0
movl 0x1d4(%rsp), %edi
callq 0x10ac0
addq $0x5f8, %rsp            # imm = 0x5F8
retq
nopw %cs:(%rax,%rax)