// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x350, %rsp            # imm = 0x350
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movw $0x0, -0x16(%rbp)
movw $0x0, -0x18(%rbp)
movw $0x1, -0x342(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x81, -0x14(%rbp)
jge 0x1e8f
movslq -0x14(%rbp), %rax
movw $0x0, -0x340(%rbp,%rax,2)
movslq -0x14(%rbp), %rax
movw $0x0, -0x230(%rbp,%rax,2)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1e5f
movw $0x1, -0x230(%rbp)
movw $0x1, -0x33e(%rbp)
movw $0x0, -0x16(%rbp)
movzwl -0x16(%rbp), %eax
cmpl $0x100, %eax            # imm = 0x100
jge 0x2144
movw $0x0, -0x344(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x34c(%rbp)
movzwl -0x16(%rbp), %eax
cmpl $0x80, %eax
jge 0x1ee6
movzwl -0x16(%rbp), %eax
movl %eax, -0x350(%rbp)
jmp 0x1ef3
movl $0x80, %eax
movl %eax, -0x350(%rbp)
jmp 0x1ef3
movl -0x34c(%rbp), %eax
movl -0x350(%rbp), %ecx
cmpl %ecx, %eax
jg 0x1f4a
movslq -0x14(%rbp), %rax
movw -0x230(%rbp,%rax,2), %dx
movq -0x10(%rbp), %rax
movzwl -0x16(%rbp), %ecx
subl -0x14(%rbp), %ecx
movslq %ecx, %rcx
movzwl %dx, %edi
movzwl (%rax,%rcx,2), %esi
callq 0xb230
movzwl %ax, %ecx
movzwl -0x344(%rbp), %eax
xorl %ecx, %eax
movw %ax, -0x344(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1ec6
movw -0x344(%rbp), %ax
movw %ax, -0x1c(%rbp)
movzwl -0x1c(%rbp), %eax
subl $0x1, %eax
movw %ax, -0x1c(%rbp)
movzwl -0x1c(%rbp), %eax
sarl $0xf, %eax
movw %ax, -0x1c(%rbp)
movzwl -0x1c(%rbp), %eax
subl $0x1, %eax
movw %ax, -0x1c(%rbp)
movw -0x16(%rbp), %ax
movw %ax, -0x1a(%rbp)
movzwl -0x18(%rbp), %ecx
shll %ecx
movzwl -0x1a(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x1a(%rbp)
movzwl -0x1a(%rbp), %eax
sarl $0xf, %eax
movw %ax, -0x1a(%rbp)
movzwl -0x1a(%rbp), %eax
subl $0x1, %eax
movw %ax, -0x1a(%rbp)
movzwl -0x1c(%rbp), %ecx
movzwl -0x1a(%rbp), %eax
andl %ecx, %eax
movw %ax, -0x1a(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x80, -0x14(%rbp)
jg 0x1fe5
movslq -0x14(%rbp), %rax
movw -0x230(%rbp,%rax,2), %cx
movslq -0x14(%rbp), %rax
movw %cx, -0x120(%rbp,%rax,2)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1fb9
movw -0x342(%rbp), %ax
movzwl %ax, %edi
movzwl -0x344(%rbp), %esi
callq 0xb470
movw %ax, -0x346(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x80, -0x14(%rbp)
jg 0x2057
movw -0x346(%rbp), %cx
movslq -0x14(%rbp), %rax
movzwl %cx, %edi
movzwl -0x340(%rbp,%rax,2), %esi
callq 0xb230
movzwl %ax, %edx
movzwl -0x1c(%rbp), %eax
andl %eax, %edx
movslq -0x14(%rbp), %rax
movzwl -0x230(%rbp,%rax,2), %ecx
xorl %edx, %ecx
movw %cx, -0x230(%rbp,%rax,2)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2009
movzwl -0x18(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movzwl -0x16(%rbp), %ecx
addl $0x1, %ecx
movzwl -0x18(%rbp), %edx
subl %edx, %ecx
movzwl -0x1a(%rbp), %edx
andl %edx, %ecx
orl %ecx, %eax
movw %ax, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x80, -0x14(%rbp)
jg 0x20d0
movslq -0x14(%rbp), %rax
movzwl -0x340(%rbp,%rax,2), %eax
movzwl -0x1a(%rbp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movslq -0x14(%rbp), %rcx
movzwl -0x120(%rbp,%rcx,2), %ecx
movzwl -0x1a(%rbp), %edx
andl %edx, %ecx
orl %ecx, %eax
movw %ax, %cx
movslq -0x14(%rbp), %rax
movw %cx, -0x340(%rbp,%rax,2)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2084
movzwl -0x342(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movzwl -0x344(%rbp), %ecx
movzwl -0x1a(%rbp), %edx
andl %edx, %ecx
orl %ecx, %eax
movw %ax, -0x342(%rbp)
movl $0x80, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
jl 0x212a
movl -0x14(%rbp), %eax
subl $0x1, %eax
cltq
movw -0x340(%rbp,%rax,2), %cx
movslq -0x14(%rbp), %rax
movw %cx, -0x340(%rbp,%rax,2)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x20fd
movw $0x0, -0x340(%rbp)
movw -0x16(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x16(%rbp)
jmp 0x1ea7
movl $0x0, -0x14(%rbp)
cmpl $0x80, -0x14(%rbp)
jg 0x217d
movl $0x80, %eax
subl -0x14(%rbp), %eax
cltq
movw -0x230(%rbp,%rax,2), %dx
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x214b
addq $0x350, %rsp            # imm = 0x350
popq %rbp
retq
nopw %cs:(%rax,%rax)