// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/ascon128v11/ref/ascon.c
// Function: permutation
void permutation(u8* S, int rounds) {
  int i;
  u64 x0, x1, x2, x3, x4;
  u64 t0, t1, t2, t3, t4;
  load64(&x0, S + 0);
  load64(&x1, S + 8);
  load64(&x2, S + 16);
  load64(&x3, S + 24);
  load64(&x4, S + 32);
  printwords(" permutation input:", x0, x1, x2, x3, x4);
  for (i = 0; i < rounds; ++i) {
    // addition of round constant
    x2 ^= ((0xfull - i) << 4) | i;
    printwords(" addition of round constant:", x0, x1, x2, x3, x4);
    // substitution layer
    x0 ^= x4;    x4 ^= x3;    x2 ^= x1;
    t0  = x0;    t1  = x1;    t2  = x2;    t3  = x3;    t4  = x4;
    t0 =~ t0;    t1 =~ t1;    t2 =~ t2;    t3 =~ t3;    t4 =~ t4;
    t0 &= x1;    t1 &= x2;    t2 &= x3;    t3 &= x4;    t4 &= x0;
    x0 ^= t1;    x1 ^= t2;    x2 ^= t3;    x3 ^= t4;    x4 ^= t0;
    x1 ^= x0;    x0 ^= x4;    x3 ^= x2;    x2 =~ x2;
    printwords(" substitution layer:", x0, x1, x2, x3, x4);
    // linear diffusion layer
    x0 ^= ROTR(x0, 19) ^ ROTR(x0, 28);
    x1 ^= ROTR(x1, 61) ^ ROTR(x1, 39);
    x2 ^= ROTR(x2,  1) ^ ROTR(x2,  6);
    x3 ^= ROTR(x3, 10) ^ ROTR(x3, 17);
    x4 ^= ROTR(x4,  7) ^ ROTR(x4, 41);
    printwords(" linear diffusion layer:", x0, x1, x2, x3, x4);
  }
  store64(S + 0, x0);
  store64(S + 8, x1);
  store64(S + 16, x2);
  store64(S + 24, x3);
  store64(S + 32, x4);
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movl %esi, 0x5c(%rsp)
movq 0x60(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x1040
movq 0x60(%rsp), %rsi
addq $0x8, %rsi
leaq 0x48(%rsp), %rdi
callq 0x1040
movq 0x60(%rsp), %rsi
addq $0x10, %rsi
leaq 0x40(%rsp), %rdi
callq 0x1040
movq 0x60(%rsp), %rsi
addq $0x18, %rsi
leaq 0x38(%rsp), %rdi
callq 0x1040
movq 0x60(%rsp), %rsi
addq $0x20, %rsi
leaq 0x30(%rsp), %rdi
callq 0x1040
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r9
leaq 0x1cf8(%rip), %rdi      # 0x3000
callq 0x1080
movl $0x0, 0x58(%rsp)
movl 0x58(%rsp), %eax
cmpl 0x5c(%rsp), %eax
jge 0x164d
movslq 0x58(%rsp), %rcx
movl $0xf, %eax
subq %rcx, %rax
shlq $0x4, %rax
movslq 0x58(%rsp), %rcx
orq %rcx, %rax
xorq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r9
leaq 0x1cae(%rip), %rdi      # 0x3014
callq 0x1080
movq 0x30(%rsp), %rax
xorq 0x50(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x38(%rsp), %rax
xorq 0x30(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x48(%rsp), %rax
xorq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rax
xorq $-0x1, %rax
movq %rax, 0x28(%rsp)
movq 0x20(%rsp), %rax
xorq $-0x1, %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
xorq $-0x1, %rax
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %rax
xorq $-0x1, %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rax
xorq $-0x1, %rax
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rax
andq 0x28(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x40(%rsp), %rax
andq 0x20(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
andq 0x18(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
andq 0x10(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x50(%rsp), %rax
andq 0x8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%rsp), %rax
xorq 0x50(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x18(%rsp), %rax
xorq 0x48(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x10(%rsp), %rax
xorq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x8(%rsp), %rax
xorq 0x38(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x28(%rsp), %rax
xorq 0x30(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x50(%rsp), %rax
xorq 0x48(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x30(%rsp), %rax
xorq 0x50(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x40(%rsp), %rax
xorq 0x38(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rax
xorq $-0x1, %rax
movq %rax, 0x40(%rsp)
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r9
leaq 0x1b30(%rip), %rdi      # 0x3031
callq 0x1080
movq 0x50(%rsp), %rax
shrq $0x13, %rax
movq 0x50(%rsp), %rcx
shlq $0x2d, %rcx
orq %rcx, %rax
movq 0x50(%rsp), %rcx
shrq $0x1c, %rcx
movq 0x50(%rsp), %rdx
shlq $0x24, %rdx
orq %rdx, %rcx
xorq %rcx, %rax
xorq 0x50(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x48(%rsp), %rax
shrq $0x3d, %rax
movq 0x48(%rsp), %rcx
shlq $0x3, %rcx
orq %rcx, %rax
movq 0x48(%rsp), %rcx
shrq $0x27, %rcx
movq 0x48(%rsp), %rdx
shlq $0x19, %rdx
orq %rdx, %rcx
xorq %rcx, %rax
xorq 0x48(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x40(%rsp), %rax
shrq %rax
movq 0x40(%rsp), %rcx
shlq $0x3f, %rcx
orq %rcx, %rax
movq 0x40(%rsp), %rcx
shrq $0x6, %rcx
movq 0x40(%rsp), %rdx
shlq $0x3a, %rdx
orq %rdx, %rcx
xorq %rcx, %rax
xorq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x38(%rsp), %rax
shrq $0xa, %rax
movq 0x38(%rsp), %rcx
shlq $0x36, %rcx
orq %rcx, %rax
movq 0x38(%rsp), %rcx
shrq $0x11, %rcx
movq 0x38(%rsp), %rdx
shlq $0x2f, %rdx
orq %rdx, %rcx
xorq %rcx, %rax
xorq 0x38(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %rax
shrq $0x7, %rax
movq 0x30(%rsp), %rcx
shlq $0x39, %rcx
orq %rcx, %rax
movq 0x30(%rsp), %rcx
shrq $0x29, %rcx
movq 0x30(%rsp), %rdx
shlq $0x17, %rdx
orq %rdx, %rcx
xorq %rcx, %rax
xorq 0x30(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r9
leaq 0x1a0e(%rip), %rdi      # 0x3046
callq 0x1080
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x1315
movq 0x60(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x10a0
movq 0x60(%rsp), %rdi
addq $0x8, %rdi
movq 0x48(%rsp), %rsi
callq 0x10a0
movq 0x60(%rsp), %rdi
addq $0x10, %rdi
movq 0x40(%rsp), %rsi
callq 0x10a0
movq 0x60(%rsp), %rdi
addq $0x18, %rdi
movq 0x38(%rsp), %rsi
callq 0x10a0
movq 0x60(%rsp), %rdi
addq $0x20, %rdi
movq 0x30(%rsp), %rsi
callq 0x10a0
addq $0x68, %rsp
retq
nopl (%rax)