// File: /workspace/github_c_makefile_star2_O2/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 $0x348, %rsp            # imm = 0x348
xorl %eax, %eax
cmpq $0x81, %rax
je 0x19d3
andw $0x0, 0x20(%rsp,%rax,2)
andw $0x0, 0x130(%rsp,%rax,2)
incq %rax
jmp 0x19b7
movq %rdi, 0x10(%rsp)
movw $0x1, %r13w
movw %r13w, 0x130(%rsp)
movw %r13w, 0x22(%rsp)
xorl %r12d, %r12d
xorl %r9d, %r9d
cmpq $0x100, %r12            # imm = 0x100
je 0x1b52
movq %r9, 0x8(%rsp)
movl $0x80, %eax
cmpl %eax, %r12d
movl $0x80, %r14d
cmovbl %r12d, %r14d
xorl %r15d, %r15d
movq %rsi, 0x18(%rsp)
movq %rsi, %rbp
xorl %ebx, %ebx
cmpq %r14, %r15
ja 0x1a45
movzwl 0x130(%rsp,%r15,2), %edi
movzwl (%rbp), %esi
callq 0x4ebc
xorl %eax, %ebx
incq %r15
addq $-0x2, %rbp
jmp 0x1a23
leal -0x1(%rbx), %eax
movzwl %ax, %r14d
shrl $0xf, %r14d
decl %r14d
movq 0x8(%rsp), %rax
addl %eax, %eax
movl %r12d, %r15d
subl %eax, %r15d
xorl %eax, %eax
cmpq $0x81, %rax
je 0x1a7f
movzwl 0x130(%rsp,%rax,2), %ecx
movw %cx, 0x240(%rsp,%rax,2)
incq %rax
jmp 0x1a62
movl %r13d, 0x4(%rsp)
movzwl %r13w, %edi
movzwl %bx, %esi
callq 0x4fcf
movzwl %ax, %ebp
xorl %r13d, %r13d
cmpq $0x81, %r13
je 0x1ac0
movzwl 0x20(%rsp,%r13,2), %esi
movl %ebp, %edi
callq 0x4ebc
movswl %r14w, %ecx
andl %eax, %ecx
xorw %cx, 0x130(%rsp,%r13,2)
incq %r13
jmp 0x1a96
testw %r15w, %r15w
movl $0x0, %eax
cmovsl %eax, %r14d
movzwl %r14w, %eax
incq %r12
movl %r12d, %ecx
movq 0x8(%rsp), %r9
subl %r9d, %ecx
andl %eax, %ecx
notl %eax
xorl %edx, %edx
movq 0x18(%rsp), %rsi
movl 0x4(%rsp), %r13d
cmpq $0x81, %rdx
je 0x1b1a
movzwl 0x240(%rsp,%rdx,2), %r8d
andw %r14w, %r8w
movzwl 0x20(%rsp,%rdx,2), %edi
andw %ax, %di
orl %r8d, %edi
movw %di, 0x20(%rsp,%rdx,2)
incq %rdx
jmp 0x1aef
andl %eax, %r9d
orl %ecx, %r9d
andl %eax, %r13d
movl $0x100, %eax            # imm = 0x100
testq %rax, %rax
je 0x1b3d
movzwl 0x1e(%rsp,%rax), %ecx
movw %cx, 0x20(%rsp,%rax)
addq $-0x2, %rax
jmp 0x1b28
andl %ebx, %r14d
orl %r14d, %r13d
andw $0x0, 0x20(%rsp)
addq $0x2, %rsi
jmp 0x19f2
movl $0x81, %eax
movq 0x10(%rsp), %rdx
subq $0x1, %rax
jb 0x1b73
movzwl 0x130(%rsp,%rax,2), %ecx
movw %cx, (%rdx)
addq $0x2, %rdx
jmp 0x1b5c
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)