// File: /workspace/github_c_makefile_star2_O3/janmojzis[P]mcencrypt/bm.c
// Function: bm
void bm(gf *out, gf *s)
{
	int i;

	uint16_t N = 0;
	uint16_t L = 0;
	uint16_t mle;
	uint16_t mne;

	gf T[ SYS_T+1  ];
	gf C[ SYS_T+1 ];
	gf B[ SYS_T+1 ];

	gf b = 1, d, f;

	/* // */

	for (i = 0; i < SYS_T+1; i++)
		C[i] = B[i] = 0;

	B[1] = C[0] = 1;

	/* // */

	for (N = 0; N < 2 * SYS_T; N++)
	{
		d = 0;

		for (i = 0; i <= min(N, SYS_T); i++)
			d ^= gf_mul(C[i], s[ N-i]);
	
		mne = d; mne -= 1;   mne >>= 15; mne -= 1;
		mle = N; mle -= 2*L; mle >>= 15; mle -= 1;
		mle &= mne;

		for (i = 0; i <= SYS_T; i++)			
			T[i] = C[i];

		f = gf_frac(b, d);

		for (i = 0; i <= SYS_T; i++)			
			C[i] ^= gf_mul(f, B[i]) & mne;

		L = (L & ~mle) | ((N+1-L) & mle);

		for (i = 0; i <= SYS_T; i++)			
			B[i] = (B[i] & ~mle) | (T[i] & mle);

		b = (b & ~mle) | (d & mle);

		for (i = SYS_T; i >= 1; i--)
			B[i] = B[i-1];
		B[0] = 0;
	}

	for (i = 0; i <= SYS_T; i++)
		out[i] = C[ SYS_T-i ];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x358, %rsp            # imm = 0x358
movq %rsi, %r14
movq %rdi, 0x18(%rsp)
leaq 0x30(%rsp), %rdi
movl $0x102, %edx            # imm = 0x102
xorl %esi, %esi
callq 0x1070
leaq 0x140(%rsp), %rbx
movl $0x102, %edx            # imm = 0x102
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1070
movw $0x1, %dx
movw %dx, (%rbx)
leaq 0x32(%rsp), %rax
movw $0x1, %cx
movl %ecx, 0xc(%rsp)
movw %dx, (%rax)
xorl %ebp, %ebp
movl $0x0, 0x10(%rsp)
xorl %ebx, %ebx
movl $0x80, %eax
cmpq %rax, %rbp
movl $0x80, %r15d
movq %rbp, 0x20(%rsp)
cmovbq %rbp, %r15
incq %r15
xorl %r13d, %r13d
movq %r14, 0x28(%rsp)
xorl %r12d, %r12d
movzwl 0x140(%rsp,%r13,2), %edi
movzwl (%r14), %esi
callq 0x52b4
xorl %eax, %r12d
incq %r13
addq $-0x2, %r14
cmpq %r13, %r15
jne 0x1a15
leal -0x1(%r12), %eax
movzwl %ax, %r13d
shrl $0xf, %r13d
decl %r13d
movl 0x10(%rsp), %ecx
subl %ebx, %ecx
subl %ebx, %ecx
movl %ecx, 0x14(%rsp)
movl $0x102, %edx            # imm = 0x102
leaq 0x250(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x10a0
movzwl 0xc(%rsp), %edi
movzwl %r12w, %esi
callq 0x53c2
movzwl %ax, %r15d
movswl %r13w, %r14d
xorl %ebp, %ebp
movzwl 0x30(%rsp,%rbp,2), %esi
movl %r15d, %edi
callq 0x52b4
andl %r14d, %eax
xorw %ax, 0x140(%rsp,%rbp,2)
incq %rbp
cmpq $0x81, %rbp
jne 0x1a84
cmpw $0x0, 0x14(%rsp)
movl $0x0, %eax
cmovsl %eax, %r13d
movzwl %r13w, %eax
movq 0x20(%rsp), %rbp
incq %rbp
movl %ebp, %ecx
subl %ebx, %ecx
andl %eax, %ecx
notl %eax
xorl %edx, %edx
movzwl 0x250(%rsp,%rdx,2), %esi
andw %r13w, %si
movzwl 0x30(%rsp,%rdx,2), %edi
andw %ax, %di
orl %esi, %edi
movw %di, 0x30(%rsp,%rdx,2)
incq %rdx
cmpq $0x81, %rdx
jne 0x1acd
andl %eax, %ebx
orl %ecx, %ebx
movl 0xc(%rsp), %r14d
andl %eax, %r14d
movl $0x100, %edx            # imm = 0x100
leaq 0x32(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x10e0
andl %r12d, %r13d
orl %r14d, %r13d
movw $0x0, 0x30(%rsp)
incl 0x10(%rsp)
movq 0x28(%rsp), %r14
addq $0x2, %r14
movl %r13d, 0xc(%rsp)
cmpq $0x100, %rbp            # imm = 0x100
jne 0x19f0
movl $0x80, %eax
movq 0x18(%rsp), %rdx
movzwl 0x140(%rsp,%rax,2), %ecx
movw %cx, (%rdx)
addq $0x2, %rdx
addq $-0x1, %rax
jb 0x1b4a
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)