// File: /workspace/github_c_makefile_star2_O1/sbp[P]tweetnacl-tools/tweetnacl.c
// Function: core
sv core(u8 *out,const u8 *in,const u8 *k,const u8 *c,int h)
{
  u32 w[16],x[16],y[16],t[4];
  int i,j,m;

  FOR(i,4) {
    x[5*i] = ld32(c+4*i);
    x[1+i] = ld32(k+4*i);
    x[6+i] = ld32(in+4*i);
    x[11+i] = ld32(k+16+4*i);
  }

  FOR(i,16) y[i] = x[i];

  FOR(i,20) {
    FOR(j,4) {
      FOR(m,4) t[m] = x[(5*j+4*m)%16];
      t[1] ^= L32(t[0]+t[3], 7);
      t[2] ^= L32(t[1]+t[0], 9);
      t[3] ^= L32(t[2]+t[1],13);
      t[0] ^= L32(t[3]+t[2],18);
      FOR(m,4) w[4*j+(j+m)%4] = t[m];
    }
    FOR(m,16) x[m] = w[m];
  }

  if (h) {
    FOR(i,16) x[i] += y[i];
    FOR(i,4) {
      x[5*i] -= ld32(c+4*i);
      x[6+i] -= ld32(in+4*i);
    }
    FOR(i,4) {
      st32(out+4*i,x[5*i]);
      st32(out+16+4*i,x[6+i]);
    }
  } else
    FOR(i,16) st32(out + 4 * i,x[i] + y[i]);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movq %rcx, %r9
movq %rsi, %rbx
movq %rdi, %rax
leaq -0x60(%rsp), %r10
movq $-0x28, %rcx
xorl %esi, %esi
movl (%r9,%rsi), %edi
movq %rdi, 0x40(%rsp,%rcx,4)
movl (%rdx,%rsi), %edi
movq %rdi, -0x58(%rsp,%rsi,2)
movl (%rbx,%rsi), %edi
movq %rdi, -0x30(%rsp,%rsi,2)
movl 0x10(%rdx,%rsi), %edi
movq %rdi, -0x8(%rsp,%rsi,2)
addq $0x4, %rsi
addq $0xa, %rcx
cmpq $0x10, %rsi
jne 0x160e
leaq 0x20(%rsp), %rdi
leaq -0x60(%rsp), %rsi
movl $0x10, %ecx
rep  movsq (%rsi), %es:(%rdi)
xorl %edx, %edx
leaq 0xa0(%rsp), %r11
xorl %ecx, %ecx
xorl %esi, %esi
xorl %edi, %edi
leal (%rcx,%rdi), %r14d
andl $0xf, %r14d
movq -0x60(%rsp,%r14,8), %r14
movq %r14, -0x80(%rsp,%rdi,2)
addq $0x4, %rdi
cmpq $0x10, %rdi
jne 0x1660
movq -0x80(%rsp), %rdi
movq -0x68(%rsp), %r15
leaq (%r15,%rdi), %r14
movq %r14, %r12
shlq $0x7, %r12
shrl $0x19, %r14d
orq %r12, %r14
xorq -0x78(%rsp), %r14
movq %r14, -0x78(%rsp)
leaq (%r14,%rdi), %r12
movq %r12, %r13
shlq $0x9, %r13
shrl $0x17, %r12d
orq %r13, %r12
xorq -0x70(%rsp), %r12
movq %r12, -0x70(%rsp)
addq %r12, %r14
movq %r14, %r13
shlq $0xd, %r13
shrl $0x13, %r14d
orq %r13, %r14
xorq %r15, %r14
movq %r14, -0x68(%rsp)
addq %r12, %r14
movq %r14, %r15
shlq $0x12, %r15
shrl $0xe, %r14d
orq %r15, %r14
xorq %rdi, %r14
movq %r14, -0x80(%rsp)
leal (,%rsi,4), %edi
xorl %r14d, %r14d
movq -0x80(%rsp,%r14,8), %r15
leal (%rsi,%r14), %r12d
andl $0x3, %r12d
orq %rdi, %r12
movq %r15, 0xa0(%rsp,%r12,8)
incq %r14
cmpq $0x4, %r14
jne 0x16fa
incq %rsi
addq $0x5, %rcx
cmpq $0x4, %rsi
jne 0x165e
movl $0x10, %ecx
movq %r10, %rdi
movq %r11, %rsi
rep  movsq (%rsi), %es:(%rdi)
incl %edx
cmpl $0x14, %edx
jne 0x165a
xorl %ecx, %ecx
testl %r8d, %r8d
je 0x17d1
movq 0x20(%rsp,%rcx,8), %rdx
addq %rdx, -0x60(%rsp,%rcx,8)
incq %rcx
cmpq $0x10, %rcx
jne 0x1750
movq $-0x28, %rcx
xorl %edx, %edx
movl (%r9,%rdx), %esi
subq %rsi, 0x40(%rsp,%rcx,4)
movl (%rbx,%rdx), %esi
subq %rsi, -0x30(%rsp,%rdx,2)
addq $0x4, %rdx
addq $0xa, %rcx
cmpq $0x10, %rdx
jne 0x176c
xorl %ecx, %ecx
leaq (%rcx,%rcx,4), %rdx
movq -0x60(%rsp,%rdx,8), %rdx
xorl %esi, %esi
movb %dl, (%rax,%rsi)
shrq $0x8, %rdx
incq %rsi
cmpq $0x4, %rsi
jne 0x1798
movq -0x30(%rsp,%rcx,8), %rdx
movl $0x10, %esi
movb %dl, (%rax,%rsi)
shrq $0x8, %rdx
incq %rsi
cmpq $0x14, %rsi
jne 0x17b2
incq %rcx
addq $0x4, %rax
cmpq $0x4, %rcx
jne 0x178d
jmp 0x17fa
movq 0x20(%rsp,%rcx,8), %rdx
addq -0x60(%rsp,%rcx,8), %rdx
xorl %esi, %esi
movb %dl, (%rax,%rsi)
shrq $0x8, %rdx
incq %rsi
cmpq $0x4, %rsi
jne 0x17dd
incq %rcx
addq $0x4, %rax
cmpq $0x10, %rcx
jne 0x17d1
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq