// File: /workspace/github_c_makefile_star2_O1/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, 0x20(%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, 0x8(%rsp)
movw %dx, (%rax)
xorl %ecx, %ecx
movl $0x0, 0xc(%rsp)
xorl %ebx, %ebx
movl $0x80, %eax
cmpq %rax, %rcx
movl $0x80, %r15d
movq %rcx, 0x10(%rsp)
cmovbq %rcx, %r15
incq %r15
xorl %r13d, %r13d
movq %r14, 0x28(%rsp)
xorl %r12d, %r12d
movzwl 0x140(%rsp,%r13,2), %edi
movzwl (%r14), %esi
callq 0x4f64
xorl %eax, %r12d
incq %r13
addq $-0x2, %r14
cmpq %r13, %r15
jne 0x1a45
leal -0x1(%r12), %eax
movzwl %ax, %r13d
shrl $0xf, %r13d
decl %r13d
movl 0xc(%rsp), %ecx
subl %ebx, %ecx
subl %ebx, %ecx
movl %ecx, 0x1c(%rsp)
movl $0x102, %edx            # imm = 0x102
leaq 0x250(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x10a0
movzwl 0x8(%rsp), %edi
movzwl %r12w, %esi
callq 0x5077
movzwl %ax, %r15d
movswl %r13w, %r14d
xorl %ebp, %ebp
movzwl 0x30(%rsp,%rbp,2), %esi
movl %r15d, %edi
callq 0x4f64
andl %r14d, %eax
xorw %ax, 0x140(%rsp,%rbp,2)
incq %rbp
cmpq $0x81, %rbp
jne 0x1ab4
cmpw $0x0, 0x1c(%rsp)
movl $0x0, %eax
cmovsl %eax, %r13d
movzwl %r13w, %r15d
movq 0x10(%rsp), %rax
incq %rax
movq %rax, 0x10(%rsp)
movl %eax, %ebp
subl %ebx, %ebp
andl %r15d, %ebp
notl %r15d
xorl %eax, %eax
movzwl 0x250(%rsp,%rax,2), %ecx
andw %r13w, %cx
movzwl 0x30(%rsp,%rax,2), %edx
andw %r15w, %dx
orl %ecx, %edx
movw %dx, 0x30(%rsp,%rax,2)
incq %rax
cmpq $0x81, %rax
jne 0x1b04
movl $0x100, %edx            # imm = 0x100
leaq 0x32(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x10e0
movl 0x8(%rsp), %eax
andl %r15d, %eax
andl %r15d, %ebx
orl %ebp, %ebx
andl %r12d, %r13d
orl %eax, %r13d
movw $0x0, 0x30(%rsp)
incl 0xc(%rsp)
movq 0x28(%rsp), %r14
addq $0x2, %r14
movl %r13d, 0x8(%rsp)
movq 0x10(%rsp), %rcx
cmpq $0x100, %rcx            # imm = 0x100
jne 0x1a20
movl $0x80, %eax
movq 0x20(%rsp), %rdx
movzwl 0x140(%rsp,%rax,2), %ecx
movw %cx, (%rdx)
addq $0x2, %rdx
addq $-0x1, %rax
jb 0x1b86
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)