// File: /workspace/github_c_makefile_star2_O0/cyb70289[P]tt/tests/number.c
// Function: gen_prime
int gen_prime(int bits, _tt_word **pp)
{
	int msb = (bits+_tt_word_bits-1)/_tt_word_bits;
	tt_assert(msb >= 2);

	bits %= _tt_word_bits;
	*pp = malloc(msb*_tt_word_sz);
	_tt_word *p = *pp;

	while (1) {
		for (int i = 0; i < msb; i++) {
			p[i] = _tt_rand() & ~BIT(31);
#ifdef _TT_LP64_
			p[i] <<= 32;
			p[i] |= _tt_rand();
#endif
		}
		/* Set highest two bits and lowest bit */
		p[0] |= 0x1;
		if (bits == 0) {
			p[msb-1] |= (_tt_word_top_bit >> 1) |
				(_tt_word_top_bit >> 2);
		} else if (bits == 1) {
			p[msb-1] = 1;
			p[msb-2] |= _tt_word_top_bit >> 1;
		} else {
			p[msb-1] |= 0x3ULL << (bits-2);
			p[msb-1] &= (1ULL << bits) - 1;
		}

		if (_tt_int_isprime_buf(p, msb))
			break;
	}

	return msb;
}

// Assembly:
subq $0x28, %rsp
movl %edi, 0x24(%rsp)
movq %rsi, 0x18(%rsp)
movl 0x24(%rsp), %eax
addl $0x3f, %eax
subl $0x1, %eax
movl $0x3f, %ecx
cltd
idivl %ecx
movl %eax, 0x14(%rsp)
cmpl $0x2, 0x14(%rsp)
setge %al
xorb $-0x1, %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x1d27
xorl %edi, %edi
leaq 0x103cd(%rip), %rsi     # 0x120d4
leaq 0x103d0(%rip), %rdx     # 0x120de
leaq 0x103e3(%rip), %rcx     # 0x120f8
movl $0x12d, %r8d            # imm = 0x12D
movb $0x0, %al
callq 0xe010
callq 0x1060
jmp 0x1d29
movl 0x24(%rsp), %eax
movl $0x3f, %ecx
cltd
idivl %ecx
movl %edx, 0x24(%rsp)
movl 0x14(%rsp), %eax
shll $0x3, %eax
movslq %eax, %rdi
callq 0x1160
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
cmpl 0x14(%rsp), %eax
jge 0x1dcc
callq 0xeb40
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
movq 0x8(%rsp), %rax
movslq 0x4(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x8(%rsp), %rax
movslq 0x4(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
shlq $0x20, %rdx
movq %rdx, (%rax,%rcx,8)
callq 0xeb40
movl %eax, %eax
movl %eax, %edx
movq 0x8(%rsp), %rax
movslq 0x4(%rsp), %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x1d68
movq 0x8(%rsp), %rax
movq (%rax), %rcx
orq $0x1, %rcx
movq %rcx, (%rax)
cmpl $0x0, 0x24(%rsp)
jne 0x1e08
movq 0x8(%rsp), %rax
movl 0x14(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movabsq $0x6000000000000000, %rdx # imm = 0x6000000000000000
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1e9e
cmpl $0x1, 0x24(%rsp)
jne 0x1e49
movq 0x8(%rsp), %rax
movl 0x14(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq $0x1, (%rax,%rcx,8)
movq 0x8(%rsp), %rax
movl 0x14(%rsp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movabsq $0x4000000000000000, %rdx # imm = 0x4000000000000000
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1e9c
movl 0x24(%rsp), %eax
subl $0x2, %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x3, %edx
shlq %cl, %rdx
movq 0x8(%rsp), %rax
movl 0x14(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl 0x24(%rsp), %eax
movl %eax, %ecx
movl $0x1, %edx
shlq %cl, %rdx
subq $0x1, %rdx
movq 0x8(%rsp), %rax
movl 0x14(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
andq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1e9e
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0xcf00
testb $0x1, %al
jne 0x1eb2
jmp 0x1eb4
jmp 0x1eb9
jmp 0x1d60
movl 0x14(%rsp), %eax
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)