// File: /workspace/github_c_makefile_star2_O0/janmojzis[P]mcencrypt/controlbits.c
// Function: controlbitsfrompermutation
static void controlbitsfrompermutation(int w, int n, int step, int off, unsigned char *c, uint32_t pi[n])
{
  int i;
  int j;
  int k;
  int t;
  uint32_t ip[n];
  uint32_t I[2 * n];
  uint32_t P[2 * n];
  uint32_t PI[2 * n];
  uint32_t T[2 * n];
  uint32_t piflip[n];
  uint32_t subpi[2][n / 2];

  if (w == 1) c[ off/8 ] |= (pi[0] & 1) << (off%8);
  if (w <= 1) return;

  invert(n,ip,pi);

  for (i = 0;i < n;++i) 
  {
    I[i] = ip[i] | (1 << w);
    I[n + i] = pi[i];
  }

  for (i = 0;i < 2 * n;++i)
      P[i] = (i >> w) + (i & ((1<<w)-2)) + ((i & 1) << w);

  for (t = 0;t < w;++t) 
  {
    composeinv(2 * n,PI,P,I);

    for (i = 0;i < 2 * n;++i)
      flow(w,&P[i],&PI[i],t);

    for (i = 0;i < 2 * n;++i)
	T[i] = I[i ^ 1];

    composeinv(2 * n,I,I,T);

    for (i = 0;i < 2 * n;++i)
	T[i] = P[i ^ 1];

    for (i = 0;i < 2 * n;++i)
      flow(w,&P[i],&T[i],1);
  }

  for (i = 0;i < n;++i)
    for (j = 0;j < w;++j)
      piflip[i] = pi[i];

  for (i = 0;i < n / 2;++i) c[ (off + i * step)/8 ] |= ((P[i * 2] >> w) & 1) << ((off + i * step)%8);
  for (i = 0;i < n / 2;++i) c[ (off + ((w-1)*n + i) * step)/8 ] |= ((P[n + i * 2] >> w) & 1) << ((off + ((w-1)*n + i) * step)%8);

  for (i = 0;i < n / 2;++i)
    cswap(&piflip[i * 2], &piflip[i * 2 + 1], (P[n + i * 2] >> w) & 1);

  for (k = 0;k < 2;++k)
    for (i = 0;i < n / 2;++i)
        subpi[k][i] = piflip[i * 2 + k] >> 1;

  for (k = 0;k < 2;++k)
    controlbitsfrompermutation(w - 1, n / 2, step * 2, off + step * (n/2 + k), c, subpi[k]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movq %r8, -0x18(%rbp)
movq %r9, -0x20(%rbp)
movl -0x8(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x38(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xb8(%rbp)
movq %rcx, %rsp
movq %rax, -0x40(%rbp)
movl -0x8(%rbp), %eax
addl %eax, %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xb0(%rbp)
movq %rcx, %rsp
movq %rax, -0x48(%rbp)
movl -0x8(%rbp), %eax
addl %eax, %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xa8(%rbp)
movq %rcx, %rsp
movq %rax, -0x50(%rbp)
movl -0x8(%rbp), %eax
addl %eax, %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xa0(%rbp)
movq %rcx, %rsp
movq %rax, -0x58(%rbp)
movl -0x8(%rbp), %eax
addl %eax, %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x98(%rbp)
movq %rcx, %rsp
movq %rax, -0x60(%rbp)
movl -0x8(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x90(%rbp)
movq %rcx, %rsp
movq %rax, -0x68(%rbp)
movl -0x8(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
sarl %eax
movq %rax, -0x88(%rbp)
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x80(%rbp)
movq %rcx, %rsp
movq %rax, -0x70(%rbp)
cmpl $0x1, -0x4(%rbp)
jne 0x8b59
movq -0x20(%rbp), %rax
movl (%rax), %esi
andl $0x1, %esi
movl -0x10(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %edx, %ecx
shll %cl, %esi
movq -0x18(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl -0x10(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xc0(%rbp), %rax
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edx
orl %esi, %edx
movb %dl, (%rax,%rcx)
cmpl $0x1, -0x4(%rbp)
jg 0x8b6b
movl $0x1, -0x74(%rbp)
jmp 0x90f6
movq -0xb8(%rbp), %rsi
movl -0x8(%rbp), %edi
movq -0x20(%rbp), %rdx
callq 0x9360
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8bd9
movq -0xb0(%rbp), %rax
movq -0xb8(%rbp), %rcx
movslq -0x24(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
movl -0x4(%rbp), %ecx
movl $0x1, %esi
shll %cl, %esi
movl %esi, %ecx
orl %ecx, %edx
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rcx
movslq -0x24(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
movl -0x8(%rbp), %ecx
addl -0x24(%rbp), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8b85
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x8(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x8c3c
movq -0xa8(%rbp), %rax
movl -0x24(%rbp), %edx
movl -0x4(%rbp), %ecx
sarl %cl, %edx
movl -0x24(%rbp), %ecx
movl %ecx, -0xc4(%rbp)
movl -0x4(%rbp), %ecx
movl $0x1, %esi
shll %cl, %esi
movl -0xc4(%rbp), %ecx
subl $0x2, %esi
andl %esi, %ecx
addl %ecx, %edx
movl -0x24(%rbp), %esi
andl $0x1, %esi
movl -0x4(%rbp), %ecx
shll %cl, %esi
movl %esi, %ecx
addl %ecx, %edx
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8be0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x8db3
movq -0xb0(%rbp), %rcx
movq -0xa8(%rbp), %rdx
movq -0xa0(%rbp), %rsi
movl -0x8(%rbp), %edi
shll %edi
callq 0x93c0
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x8(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x8cbb
movq -0xa0(%rbp), %rdx
movq -0xa8(%rbp), %rsi
movl -0x4(%rbp), %edi
movslq -0x24(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rsi
movslq -0x24(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movl -0x30(%rbp), %ecx
callq 0x9490
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8c75
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x8(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x8cfa
movq -0x98(%rbp), %rax
movq -0xb0(%rbp), %rcx
movl -0x24(%rbp), %edx
xorl $0x1, %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %edx
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8cc2
movq -0x98(%rbp), %rcx
movq -0xb0(%rbp), %rdx
movl -0x8(%rbp), %edi
shll %edi
movq %rdx, %rsi
callq 0x93c0
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x8(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x8d54
movq -0x98(%rbp), %rax
movq -0xa8(%rbp), %rcx
movl -0x24(%rbp), %edx
xorl $0x1, %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %edx
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8d1c
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x8(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x8da3
movq -0x98(%rbp), %rdx
movq -0xa8(%rbp), %rsi
movl -0x4(%rbp), %edi
movslq -0x24(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rsi
movslq -0x24(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movl $0x1, %ecx
callq 0x9490
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8d5b
jmp 0x8da5
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x8c43
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8e02
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x8df5
movq -0x90(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq -0x24(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x8dc9
jmp 0x8df7
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8dba
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0xc8(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xc8(%rbp), %eax
cmpl %ecx, %eax
jge 0x8e9d
movq -0xa8(%rbp), %rax
movl -0x24(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %esi
movl -0x4(%rbp), %ecx
shrl %cl, %esi
andl $0x1, %esi
movl -0x10(%rbp), %eax
movl -0x24(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl %ecx, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %edx, %ecx
shll %cl, %esi
movq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl -0x10(%rbp), %eax
movl -0x24(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl %ecx, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xd0(%rbp), %rax
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edx
orl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8e09
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0xd4(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xd4(%rbp), %eax
cmpl %ecx, %eax
jge 0x8f55
movq -0xa8(%rbp), %rax
movl -0x8(%rbp), %ecx
movl -0x24(%rbp), %edx
shll %edx
addl %edx, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %esi
movl -0x4(%rbp), %ecx
shrl %cl, %esi
andl $0x1, %esi
movl -0x10(%rbp), %eax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
imull -0x8(%rbp), %ecx
addl -0x24(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl %ecx, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %edx, %ecx
shll %cl, %esi
movq -0x18(%rbp), %rax
movq %rax, -0xe0(%rbp)
movl -0x10(%rbp), %eax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
imull -0x8(%rbp), %ecx
addl -0x24(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl %ecx, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xe0(%rbp), %rax
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edx
orl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8ea4
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0xe4(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xe4(%rbp), %eax
cmpl %ecx, %eax
jge 0x8fd9
movq -0xa8(%rbp), %rax
movq -0x90(%rbp), %rsi
movl -0x24(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
movq %rsi, %rdi
addq %rcx, %rdi
movl -0x24(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rsi
movl -0x8(%rbp), %ecx
movl -0x24(%rbp), %edx
shll %edx
addl %edx, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl -0x4(%rbp), %ecx
shrl %cl, %eax
andl $0x1, %eax
movsbl %al, %edx
callq 0x9530
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8f5c
movl $0x0, -0x2c(%rbp)
cmpl $0x2, -0x2c(%rbp)
jge 0x905d
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0xe8(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xe8(%rbp), %eax
cmpl %ecx, %eax
jge 0x9050
movq -0x80(%rbp), %rax
movq -0x88(%rbp), %rsi
movq -0x90(%rbp), %rcx
movl -0x24(%rbp), %edx
shll %edx
addl -0x2c(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %edx
shrl %edx
movslq -0x2c(%rbp), %rcx
imulq %rsi, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8fed
jmp 0x9052
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8fe0
movl $0x0, -0x2c(%rbp)
cmpl $0x2, -0x2c(%rbp)
jge 0x90ef
movq -0x80(%rbp), %r9
movq -0x88(%rbp), %r10
movl -0x4(%rbp), %edi
subl $0x1, %edi
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %esi
movl -0xc(%rbp), %eax
shll %eax
movl %eax, -0xf0(%rbp)
movl -0x10(%rbp), %ecx
movl -0xc(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %r8d
cltd
idivl %r8d
movl -0xf0(%rbp), %edx
movl %eax, %r8d
movl -0xec(%rbp), %eax
addl -0x2c(%rbp), %r8d
imull %r8d, %eax
addl %eax, %ecx
movq -0x18(%rbp), %r8
movslq -0x2c(%rbp), %rax
imulq %r10, %rax
shlq $0x2, %rax
addq %rax, %r9
callq 0x89e0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9064
movl $0x0, -0x74(%rbp)
movq -0x38(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)