// File: /workspace/github_c_makefile_star2_O0/rpeepz[P]ft_ssl/srcs/rsa/genrsa.c
// Function: genrsa
__uint64_t		genrsa(t_rsa_out rsa)
{
	t_rsa		gg;
	char		buf[80];

	ft_bzero(buf, 80);
	ft_bzero(&gg, sizeof(gg));
	ft_sprintf(buf, "%s, %d bit long modulus\n", GEN_PRV, rsa.bits);
	ft_putstr_fd(buf, 2);
	while (1)
	{
		gg.p = genprime((rsa.bits / 2), (int)gg.n);
		gg.q = genprime((rsa.bits / 2) + 1, (int)gg.n);
		if ((gg.n = valid_modulus(gg, rsa.bits)) != 1)
			break ;
	}
	gg.e = 65537;
	gg.phi = (gg.p - 1) * (gg.q - 1);
	gg.d = mod_inverse(gg.e, gg.phi);
	gg.dmp1 = gg.d % (gg.p - 1);
	gg.dmq1 = gg.d % (gg.q - 1);
	gg.iqmp = mod_inverse(gg.q, gg.p);
	ft_bzero(buf, 80);
	ft_sprintf(buf, "e is %llu (%#x)\n", gg.e, gg.e);
	ft_putstr_fd(buf, 2);
	rsa_encode_out(rsa, gg);
	return (gg.n);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
leaq 0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
movl $0x50, %esi
callq 0xa600
leaq -0x48(%rbp), %rdi
movl $0x48, %esi
callq 0xa600
movq -0xa8(%rbp), %rax
leaq -0xa0(%rbp), %rdi
movl 0x8(%rax), %ecx
leaq 0x1063a(%rip), %rsi     # 0x13ce7
leaq 0x1064c(%rip), %rdx     # 0x13d00
movb $0x0, %al
callq 0xb3d0
leaq -0xa0(%rbp), %rdi
movl $0x2, %esi
callq 0xb230
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %edi
movq -0x38(%rbp), %rax
movl %eax, %esi
callq 0x34b0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movq %rcx, -0x48(%rbp)
movl 0x8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %edi
addl $0x1, %edi
movq -0x38(%rbp), %rax
movl %eax, %esi
callq 0x34b0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movq %rcx, -0x40(%rbp)
movl 0x8(%rax), %edi
movq -0x8(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x40(%rax)
movups -0x48(%rbp), %xmm0
movups -0x38(%rbp), %xmm1
movups -0x28(%rbp), %xmm2
movups -0x18(%rbp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x35c0
movq %rax, -0x38(%rbp)
cmpq $0x1, %rax
je 0x3760
jmp 0x3765
jmp 0x36cc
movq $0x10001, -0x10(%rbp)   # imm = 0x10001
movq -0x48(%rbp), %rax
subq $0x1, %rax
movq -0x40(%rbp), %rcx
subq $0x1, %rcx
imulq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x4ee0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq -0x48(%rbp), %rcx
subq $0x1, %rcx
xorl %edx, %edx
divq %rcx
movq %rdx, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq -0x40(%rbp), %rcx
subq $0x1, %rcx
xorl %edx, %edx
divq %rcx
movq %rdx, -0x20(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x4ee0
movq %rax, -0x18(%rbp)
leaq -0xa0(%rbp), %rdi
movl $0x50, %esi
callq 0xa600
leaq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rdx
movq -0x10(%rbp), %rcx
leaq 0x10523(%rip), %rsi     # 0x13d1b
movb $0x0, %al
callq 0xb3d0
leaq -0xa0(%rbp), %rdi
movl $0x2, %esi
callq 0xb230
movq -0xa8(%rbp), %rcx
movq -0x8(%rbp), %rdx
movq %rsp, %rax
movq %rdx, 0x58(%rax)
movups -0x48(%rbp), %xmm0
movups -0x38(%rbp), %xmm1
movups -0x28(%rbp), %xmm2
movups -0x18(%rbp), %xmm3
movups %xmm3, 0x48(%rax)
movups %xmm2, 0x38(%rax)
movups %xmm1, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movups (%rcx), %xmm0
movups %xmm0, (%rax)
callq 0x7730
movq -0x38(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)