// File: /workspace/github_c_makefile_star2_O0/janmojzis[P]mcencrypt/sk_gen.c
// Function: irr_gen
static int irr_gen(gf *out, gf *f)
{
	int i, j, k, c;

	gf mat[ SYS_T+1 ][ SYS_T ];
	gf mask, inv, t;

	/* // */

	mat[0][0] = 1;

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

	for (i = 0; i < SYS_T; i++)
		mat[1][i] = f[i];

	for (j = 2; j <= SYS_T; j++)
		GF_mul(mat[j], mat[j-1], f);

	/* // */

	for (j = 0; j < SYS_T; j++)
	{
		for (k = j + 1; k < SYS_T; k++)
		{
			mask = gf_iszero(mat[ j ][ j ]);

			for (c = j; c < SYS_T + 1; c++)
				mat[ c ][ j ] ^= mat[ c ][ k ] & mask;

		}

		if ( mat[ j ][ j ] == 0 ) /* // return if not systematic */
		{
			return -1;
		}

		inv = gf_inv(mat[j][j]);

		for (c = j; c < SYS_T + 1; c++)
			mat[ c ][ j ] = gf_mul(mat[ c ][ j ], inv) ;

		for (k = 0; k < SYS_T; k++)
		{
			if (k != j)
			{
				t = mat[ j ][ k ];

				for (c = j; c < SYS_T + 1; c++)
					mat[ c ][ k ] ^= gf_mul(mat[ c ][ j ], t);
			}
		}
	}

	for (i = 0; i < SYS_T; i++)
		out[i] = mat[ SYS_T ][ i ];

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x8140, %rsp           # imm = 0x8140
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movw $0x1, -0x8130(%rbp)
movl $0x1, -0x1c(%rbp)
cmpl $0x80, -0x1c(%rbp)
jge 0xd785
movslq -0x1c(%rbp), %rax
movw $0x0, -0x8130(%rbp,%rax,2)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd763
movl $0x0, -0x1c(%rbp)
cmpl $0x80, -0x1c(%rbp)
jge 0xd7b8
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movw (%rax,%rcx,2), %cx
movslq -0x1c(%rbp), %rax
movw %cx, -0x8030(%rbp,%rax,2)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd78c
movl $0x2, -0x20(%rbp)
cmpl $0x80, -0x20(%rbp)
jg 0xd804
movslq -0x20(%rbp), %rax
leaq -0x8130(%rbp), %rdi
shlq $0x8, %rax
addq %rax, %rdi
movl -0x20(%rbp), %eax
subl $0x1, %eax
cltq
leaq -0x8130(%rbp), %rsi
shlq $0x8, %rax
addq %rax, %rsi
movq -0x18(%rbp), %rdx
callq 0xb9d0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xd7bf
movl $0x0, -0x20(%rbp)
cmpl $0x80, -0x20(%rbp)
jge 0xda3b
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x80, -0x24(%rbp)
jge 0xd8c1
movslq -0x20(%rbp), %rcx
leaq -0x8130(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movzwl (%rax,%rcx,2), %edi
callq 0xb1e0
movw %ax, -0x8132(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x81, -0x28(%rbp)
jge 0xd8b1
movslq -0x28(%rbp), %rcx
leaq -0x8130(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movzwl (%rax,%rcx,2), %esi
movzwl -0x8132(%rbp), %eax
andl %eax, %esi
movslq -0x28(%rbp), %rcx
leaq -0x8130(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movzwl (%rax,%rcx,2), %edx
xorl %esi, %edx
movw %dx, (%rax,%rcx,2)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xd85a
jmp 0xd8b3
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xd821
movslq -0x20(%rbp), %rcx
leaq -0x8130(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jne 0xd8ec
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xda75
movslq -0x20(%rbp), %rcx
leaq -0x8130(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movzwl (%rax,%rcx,2), %edi
callq 0xb9a0
movw %ax, -0x8134(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x81, -0x28(%rbp)
jge 0xd972
movslq -0x28(%rbp), %rcx
leaq -0x8130(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movzwl %ax, %edi
movzwl -0x8134(%rbp), %esi
callq 0xb230
movw %ax, %dx
movslq -0x28(%rbp), %rcx
leaq -0x8130(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xd918
movl $0x0, -0x24(%rbp)
cmpl $0x80, -0x24(%rbp)
jge 0xda2b
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
je 0xda1b
movslq -0x20(%rbp), %rcx
leaq -0x8130(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movw %ax, -0x8136(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x81, -0x28(%rbp)
jge 0xda19
movslq -0x28(%rbp), %rcx
leaq -0x8130(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movzwl %ax, %edi
movzwl -0x8136(%rbp), %esi
callq 0xb230
movzwl %ax, %esi
movslq -0x28(%rbp), %rcx
leaq -0x8130(%rbp), %rax
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movzwl (%rax,%rcx,2), %edx
xorl %esi, %edx
movw %dx, (%rax,%rcx,2)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xd9b9
jmp 0xda1b
jmp 0xda1d
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xd979
jmp 0xda2d
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xd80b
movl $0x0, -0x1c(%rbp)
cmpl $0x80, -0x1c(%rbp)
jge 0xda6e
movslq -0x1c(%rbp), %rax
movw -0x130(%rbp,%rax,2), %dx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xda42
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x8140, %rsp           # imm = 0x8140
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)