// File: /workspace/github_c_makefile_star2_O2/cyb70289[P]tt/tests/integer.c
// Function: main
int main(void)
{
	srand(time(NULL));

#if 0
	char *s = NULL;
	struct tt_int *ti = tt_int_alloc();
	struct tt_int *ti1 = tt_int_alloc();
	struct tt_int *ti2 = tt_int_alloc();
	tt_int_from_string(ti1, "-1111111111111111111111111111111111111111111");
	tt_int_from_string(ti2, "99999999999999999999999999999");
	tt_int_sub(ti1, ti1, ti2);
	tt_int_to_string(ti1, &s, 10);
	printf("%s\n", s);
	free(s);
	s = NULL;

	tt_int_from_string(ti1, "0x1000000000000000000000000000000000000000");
	tt_int_from_string(ti2, "0x20000000000000000000000000000000000");
	tt_int_mul(ti, ti1, ti2);
	assert(_tt_int_sanity(ti) == 0);
	tt_int_to_string(ti, &s, 16);
	printf("%s\n", s);
	free(s);
	s = NULL;

	tt_int_from_string(ti1, "1111111111111111111111111111111111111111111");
	tt_int_from_string(ti2, "1111111111111111111111111111");
	tt_int_div(ti, ti1, ti1, ti2);
	assert(_tt_int_sanity(ti) == 0);
	assert(_tt_int_sanity(ti1) == 0);
	tt_int_to_string(ti, &s, 10);
	printf("%s\n", s);
	free(s);
	s = NULL;
	tt_int_to_string(ti1, &s, 10);
	printf("%s\n", s);
	free(s);
	s = NULL;

	tt_int_free(ti);
	tt_int_free(ti1);
	tt_int_free(ti2);

	return 0;
#endif

#if 0
	int old_level = tt_log_set_level(TT_LOG_INFO);
	tt_info("Calculating...");
	struct tt_int *ti = tt_int_alloc();
	tt_int_factorial(ti, 1000000);
	char *s = NULL;
	tt_info("Converting...");
	tt_int_to_string(ti, &s, 10);
	printf("%s\n", s);
	free(s);
	tt_int_free(ti);
	tt_log_set_level(old_level);
	return 0;
#endif

#if 0
	#define MSB1	3000000
	#define MSB2	300
	#define LOOPS	1

	tt_log_set_level(TT_LOG_WARN);

	struct tt_int *ti1 = rand_int(MSB1);
	struct tt_int *ti2 = rand_int(MSB2);
	struct tt_int *ti3 = tt_int_alloc();

	for (int i = 0; i < LOOPS; i++)
		tt_int_mul(ti3, ti1, ti2);

	return 0;
#endif

#if 0
	tt_log_set_level(TT_LOG_WARN);
	for (int i = 1; i <= 4096; i *= 2)
		gen_exp10(i*9);
	return 0;
#endif

	tt_log_set_level(TT_LOG_WARN);

	const int count = 10000;
	verify_conv(count);
	verify_add_sub(count);
	verify_mul_div(count);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorl %edi, %edi
callq 0x2170
movl %eax, %edi
callq 0x2120
pushq $0x1
popq %rdi
callq 0x9338
leaq 0x8d87(%rip), %rdi      # 0xb29c
callq 0x2070
callq 0x5178
movq %rsp, %rcx
andq $0x0, (%rcx)
movq %rax, %rbx
pushq $0x10
popq %rbp
leaq 0x1964d(%rip), %r14     # 0x1bb80
cmpq $0xa0, %rbp
je 0x25ab
movq -0x10(%rbp,%r14), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x55d8
testl %eax, %eax
jne 0x2aee
movq %rbx, %rdi
callq 0x531e
testl %eax, %eax
jne 0x2aee
movl -0x8(%rbp,%r14), %edx
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x592b
testl %eax, %eax
jne 0x2bfc
movq (%rsp), %r12
movq (%rbp,%r14), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x2140
testl %eax, %eax
jne 0x2632
movq %r12, %rdi
callq 0x2030
andq $0x0, (%rsp)
addq $0x18, %rbp
jmp 0x2533
movl $0xffffd8f0, %ebp       # imm = 0xFFFFD8F0
leaq 0x24(%rsp), %r14
movq %rsp, %r15
testl %ebp, %ebp
je 0x2671
movq %r14, %rdi
callq 0x2c32
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x55d8
testl %eax, %eax
jne 0x2be3
movq %rbx, %rdi
callq 0x531e
testl %eax, %eax
jne 0x2be3
movl 0x24(%rsp), %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x592b
testl %eax, %eax
jne 0x2c15
movq (%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x2140
testl %eax, %eax
jne 0x2654
movq %r12, %rdi
callq 0x2030
movq (%rsp), %rdi
callq 0x2030
andq $0x0, (%rsp)
incl %ebp
jmp 0x25b8
leaq 0x8aee(%rip), %rsi      # 0xb127
leaq 0x8af3(%rip), %rdx      # 0xb133
xorl %edi, %edi
movq %r15, %rcx
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x9110
jmp 0x2679
leaq 0x8acc(%rip), %rsi      # 0xb127
leaq 0x8adf(%rip), %rdx      # 0xb141
xorl %edi, %edi
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x9110
movq %rbx, %rdi
callq 0x51d2
leaq 0x8c27(%rip), %rdi      # 0xb2a7
callq 0x2070
callq 0x5178
movq %rax, %rbx
callq 0x5178
movq %rax, %r14
callq 0x5178
movq %rax, %r13
callq 0x5178
movq %rax, %rbp
movl $0x2710, %r12d          # imm = 0x2710
callq 0x5178
movw $0x1, %si
movw $0xffff, %cx            # imm = 0xFFFF
movq %rax, %r15
movl %esi, %eax
xorl %edx, %edx
movw $0x64, %di
divw %di
subl $0x1, %r12d
jb 0x28b9
movl %esi, 0x8(%rsp)
imull $0x64, %eax, %eax
movl %ecx, 0xc(%rsp)
addl %ecx, %eax
testw %ax, %ax
movl %r12d, 0x18(%rsp)
je 0x26f1
movq %r15, 0x10(%rsp)
movq %rbp, %r15
jmp 0x2743
movq %rbx, %rdi
callq 0x51d2
movq %r14, %rdi
callq 0x51d2
movq %r13, %rdi
callq 0x51d2
movq %rbp, %rdi
callq 0x51d2
movq %r15, %rdi
callq 0x51d2
callq 0x5178
movq %rax, %rbx
callq 0x5178
movq %rax, %r14
callq 0x5178
movq %rax, %r13
callq 0x5178
movq %rax, %r15
callq 0x5178
movq %rax, 0x10(%rsp)
movq %rsp, %r12
movq %r12, %rdi
callq 0x2c32
movq %rax, %rbp
movq %rbx, %rdi
movq %rax, %rsi
callq 0x55d8
movq %rbp, %rdi
callq 0x2030
movq %r12, %rdi
callq 0x2c32
movq %rax, %rbp
movq %r14, %rdi
movq %rax, %rsi
callq 0x55d8
movq %rbp, %rdi
callq 0x2030
movq %r13, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x7397
testl %eax, %eax
jne 0x2ba5
movq %r13, %rdi
callq 0x531e
testl %eax, %eax
jne 0x2ba5
movq %r15, %rbp
movq %r15, %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x7397
testl %eax, %eax
jne 0x2b86
movq %rbp, %rdi
callq 0x531e
testl %eax, %eax
jne 0x2b86
movq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x7397
testl %eax, %eax
movl 0x18(%rsp), %r12d
jne 0x2b67
movq %r15, %rdi
callq 0x531e
testl %eax, %eax
jne 0x2b67
movq %rbx, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x7527
testl %eax, %eax
jne 0x2b48
movq %rbx, %rdi
callq 0x531e
testl %eax, %eax
jne 0x2b48
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x7527
testl %eax, %eax
jne 0x2b29
movq %r14, %rdi
callq 0x531e
testl %eax, %eax
jne 0x2b29
movq %rbx, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x7397
testl %eax, %eax
jne 0x2bc4
movq %rbx, %rdi
callq 0x531e
testl %eax, %eax
jne 0x2bc4
movq %rbx, %rdi
movq %r13, %rsi
callq 0x79b3
testl %eax, %eax
jne 0x28a2
movq %r14, %rdi
movq %rbp, %rsi
callq 0x79b3
testl %eax, %eax
jne 0x28a2
movl 0xc(%rsp), %ecx
decl %ecx
movl 0x8(%rsp), %esi
incl %esi
jmp 0x26bb
leaq 0x8971(%rip), %rsi      # 0xb21a
leaq 0x8979(%rip), %rdx      # 0xb229
xorl %edi, %edi
xorl %eax, %eax
callq 0x9110
movq %rbx, %rdi
callq 0x51d2
movq %r14, %rdi
callq 0x51d2
movq %r13, %rdi
callq 0x51d2
movq %rbp, %rdi
callq 0x51d2
movq %r15, %rdi
callq 0x51d2
leaq 0x89cc(%rip), %rdi      # 0xb2b4
callq 0x2070
callq 0x5178
movq %rax, %rbx
callq 0x5178
movq %rax, %r13
callq 0x5178
movq %rax, %r14
movw $0xffff, %r15w          # imm = 0xFFFF
movw $0x1, %r12w
movl $0x2710, 0x10(%rsp)     # imm = 0x2710
callq 0x5178
movq %rax, %rbp
movl %r12d, %eax
xorl %edx, %edx
movw $0x32, %cx
divw %cx
movl 0x10(%rsp), %ecx
subl $0x1, %ecx
jb 0x2a9e
movl %ecx, 0x10(%rsp)
movl %r12d, 0x8(%rsp)
imull $0x32, %eax, %eax
movl %r15d, 0xc(%rsp)
addl %r15d, %eax
testw %ax, %ax
je 0x295b
movq %r14, 0x18(%rsp)
movq %rbp, %r15
jmp 0x299d
movq %rbx, %rdi
callq 0x51d2
movq %r13, %rdi
callq 0x51d2
movq %r14, %rdi
callq 0x51d2
movq %rbp, %rdi
callq 0x51d2
callq 0x5178
movq %rax, %rbx
callq 0x5178
movq %rax, %r13
callq 0x5178
movq %rax, 0x18(%rsp)
callq 0x5178
movq %rax, %r15
movq %r13, %r14
movq %rsp, %r12
movq %r12, %rdi
callq 0x2c32
movq %rax, %rbp
movq %rbx, %rdi
movq %rax, %rsi
callq 0x55d8
movq %rbp, %rdi
callq 0x2030
movq %r12, %rdi
callq 0x2c32
movq %rax, %rbp
movq %r13, %rdi
movq %rax, %rsi
callq 0x55d8
movq %rbp, %rdi
callq 0x2030
movl 0x8(%rbx), %eax
cmpl 0x8(%r13), %eax
cmovlq %rbx, %r13
cmovlq %r14, %rbx
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x7639
testl %eax, %eax
jne 0x2acf
movq %r15, %rbp
movq %r14, %rdi
callq 0x531e
testl %eax, %eax
jne 0x2acf
movq %rbp, %rdi
callq 0x531e
testl %eax, %eax
jne 0x2acf
movq %r13, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x752f
testl %eax, %eax
movl 0xc(%rsp), %r15d
movl 0x8(%rsp), %r12d
jne 0x2b0a
movq %r13, %rdi
callq 0x531e
testl %eax, %eax
jne 0x2b0a
movq %r13, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x7397
movq %rbx, %rdi
movq %r13, %rsi
callq 0x79b3
testl %eax, %eax
jne 0x2a87
decl %r15d
incl %r12d
jmp 0x291f
leaq 0x87fa(%rip), %rsi      # 0xb288
leaq 0x8794(%rip), %rdx      # 0xb229
xorl %edi, %edi
xorl %eax, %eax
callq 0x9110
movq %rbx, %rdi
callq 0x51d2
movq %r13, %rdi
callq 0x51d2
movq %r14, %rdi
callq 0x51d2
movq %rbp, %rdi
callq 0x51d2
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x875c(%rip), %rdi      # 0xb232
leaq 0x861b(%rip), %rsi      # 0xb0f8
leaq 0x878b(%rip), %rcx      # 0xb26f
movl $0xe3, %edx
callq 0x20f0
leaq 0x85df(%rip), %rdi      # 0xb0d4
leaq 0x85fc(%rip), %rsi      # 0xb0f8
leaq 0x8605(%rip), %rcx      # 0xb108
pushq $0x4a
jmp 0x2c2c
leaq 0x86e6(%rip), %rdi      # 0xb1f7
leaq 0x85e0(%rip), %rsi      # 0xb0f8
leaq 0x8750(%rip), %rcx      # 0xb26f
movl $0xe7, %edx
callq 0x20f0
leaq 0x86c7(%rip), %rdi      # 0xb1f7
leaq 0x85c1(%rip), %rsi      # 0xb0f8
leaq 0x8636(%rip), %rcx      # 0xb174
movl $0xa1, %edx
callq 0x20f0
leaq 0x8685(%rip), %rdi      # 0xb1d4
leaq 0x85a2(%rip), %rsi      # 0xb0f8
leaq 0x8617(%rip), %rcx      # 0xb174
movl $0x9d, %edx
callq 0x20f0
leaq 0x8643(%rip), %rdi      # 0xb1b1
leaq 0x8583(%rip), %rsi      # 0xb0f8
leaq 0x85f8(%rip), %rcx      # 0xb174
movl $0x99, %edx
callq 0x20f0
leaq 0x8600(%rip), %rdi      # 0xb18d
leaq 0x8564(%rip), %rsi      # 0xb0f8
leaq 0x85d9(%rip), %rcx      # 0xb174
movl $0x95, %edx
callq 0x20f0
leaq 0x85a4(%rip), %rdi      # 0xb150
leaq 0x8545(%rip), %rsi      # 0xb0f8
leaq 0x85ba(%rip), %rcx      # 0xb174
movl $0x93, %edx
callq 0x20f0
leaq 0x8609(%rip), %rdi      # 0xb1d4
leaq 0x8526(%rip), %rsi      # 0xb0f8
leaq 0x859b(%rip), %rcx      # 0xb174
movl $0xa5, %edx
callq 0x20f0
leaq 0x84ea(%rip), %rdi      # 0xb0d4
leaq 0x8507(%rip), %rsi      # 0xb0f8
leaq 0x8510(%rip), %rcx      # 0xb108
pushq $0x5c
jmp 0x2c2c
leaq 0x851b(%rip), %rdi      # 0xb11e
leaq 0x84ee(%rip), %rsi      # 0xb0f8
leaq 0x84f7(%rip), %rcx      # 0xb108
pushq $0x4d
jmp 0x2c2c
leaq 0x8502(%rip), %rdi      # 0xb11e
leaq 0x84d5(%rip), %rsi      # 0xb0f8
leaq 0x84de(%rip), %rcx      # 0xb108
pushq $0x5e
popq %rdx
callq 0x20f0