// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/minalpherv11/ref/minalpher.c
// Function: TEM_ENC
static void TEM_ENC(
  const unsigned char     *_K,    /* I    Secret key              */
  unsigned char           _flag,  /* I    Flag for the padding    */
  const unsigned char     *_N,    /* I    Nonce                   */
  unsigned long long      _i,     /* I    an integer              */
  unsigned long long      _j,     /* I    an integer              */
  unsigned char           *_M,    /* I    Message                 */

  unsigned char           *C_     /* O    Ciphertext              */
  )
{
  int d;
  unsigned char L[BLOCK_SIZE];

  /*-- L=(K||flag||N) + P(K||flag||N) --*/
  Copy( L, _K, KEYBYTES );
  L[KEYBYTES]   = _flag;
  L[KEYBYTES+1] = 0x00;
  L[KEYBYTES+2] = 0x00;
  for( d=0; d<NONCEBYTES; d++ ) L[d+KEYBYTES+3] = _N[d];

  minalpher_P( L, FORWARD );

  Xor( L, _K, KEYBYTES );
  L[KEYBYTES]   ^= _flag;
  L[KEYBYTES+1] ^= 0x00;
  L[KEYBYTES+2] ^= 0x00;
  for( d=0; d<NONCEBYTES; d++ ) L[d+KEYBYTES+3] ^= _N[d];

  /* C=y^{i}(y+1)^{j}L + P(M+y^{i}(y+1)^{j}L) --*/
  Copy( C_, _M, BLOCK_SIZE );
  TweakGen( L, _i, _j );
  Xor(  C_,  L, BLOCK_SIZE );
  minalpher_P( C_, FORWARD );
  Xor(  C_,  L, BLOCK_SIZE );
}

// Assembly:
subq $0x78, %rsp
movb %sil, %al
movq 0x80(%rsp), %rsi
movq %rdi, 0x70(%rsp)
movb %al, 0x6f(%rsp)
movq %rdx, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq %r8, 0x50(%rsp)
movq %r9, 0x48(%rsp)
movl $0x0, 0x1c(%rsp)
cmpl $0x10, 0x1c(%rsp)
jge 0x25ce
movq 0x70(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movb (%rax,%rcx), %cl
movslq 0x1c(%rsp), %rax
movb %cl, 0x20(%rsp,%rax)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x25a4
jmp 0x25d0
movb 0x6f(%rsp), %al
movb %al, 0x30(%rsp)
movb $0x0, 0x31(%rsp)
movb $0x0, 0x32(%rsp)
movl $0x0, 0x44(%rsp)
cmpl $0xd, 0x44(%rsp)
jge 0x261b
movq 0x60(%rsp), %rax
movslq 0x44(%rsp), %rcx
movb (%rax,%rcx), %cl
movl 0x44(%rsp), %eax
addl $0x10, %eax
addl $0x3, %eax
cltq
movb %cl, 0x20(%rsp,%rax)
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x25ea
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x2ad0
movl $0x0, 0x18(%rsp)
cmpl $0x10, 0x18(%rsp)
jge 0x2661
movq 0x70(%rsp), %rax
movslq 0x18(%rsp), %rcx
movzbl (%rax,%rcx), %edx
movslq 0x18(%rsp), %rax
movzbl 0x20(%rsp,%rax), %ecx
xorl %edx, %ecx
movb %cl, 0x20(%rsp,%rax)
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x262f
jmp 0x2663
movzbl 0x6f(%rsp), %ecx
movzbl 0x30(%rsp), %eax
xorl %ecx, %eax
movb %al, 0x30(%rsp)
movzbl 0x31(%rsp), %eax
xorl $0x0, %eax
movb %al, 0x31(%rsp)
movzbl 0x32(%rsp), %eax
xorl $0x0, %eax
movb %al, 0x32(%rsp)
movl $0x0, 0x44(%rsp)
cmpl $0xd, 0x44(%rsp)
jge 0x26cc
movq 0x60(%rsp), %rax
movslq 0x44(%rsp), %rcx
movzbl (%rax,%rcx), %edx
movl 0x44(%rsp), %eax
addl $0x10, %eax
addl $0x3, %eax
cltq
movzbl 0x20(%rsp,%rax), %ecx
xorl %edx, %ecx
movb %cl, 0x20(%rsp,%rax)
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x2693
jmp 0x26ce
movl $0x0, 0x14(%rsp)
cmpl $0x20, 0x14(%rsp)
jge 0x2707
movq 0x48(%rsp), %rax
movslq 0x14(%rsp), %rcx
movb (%rax,%rcx), %dl
movq 0x80(%rsp), %rax
movslq 0x14(%rsp), %rcx
movb %dl, (%rax,%rcx)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x26d6
jmp 0x2709
leaq 0x20(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0x2c00
movl $0x0, 0x10(%rsp)
cmpl $0x20, 0x10(%rsp)
jge 0x2759
movslq 0x10(%rsp), %rax
movzbl 0x20(%rsp,%rax), %esi
movq 0x80(%rsp), %rax
movslq 0x10(%rsp), %rcx
movzbl (%rax,%rcx), %edx
xorl %esi, %edx
movb %dl, (%rax,%rcx)
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x2725
jmp 0x275b
movq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x2ad0
movl $0x0, 0xc(%rsp)
cmpl $0x20, 0xc(%rsp)
jge 0x27a6
movslq 0xc(%rsp), %rax
movzbl 0x20(%rsp,%rax), %esi
movq 0x80(%rsp), %rax
movslq 0xc(%rsp), %rcx
movzbl (%rax,%rcx), %edx
xorl %esi, %edx
movb %dl, (%rax,%rcx)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x2772
jmp 0x27a8
addq $0x78, %rsp
retq
nopl (%rax)