// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/deoxyseq256128v13/ref/tweakableBC.c
// Function: deoxysKeySetupEnc256
int deoxysKeySetupEnc256(uint32_t* rtweakey,
                         const uint8_t* TweakKey,
                         const int no_tweakeys)
{

  int r;
  uint8_t tweakey[3][16];
  uint8_t alpha[3];
  const uint32_t rcon_row1 = 0x01020408;
  int Nr;

  memcpy (tweakey[0], TweakKey +  0, 16);
  memcpy (tweakey[1], TweakKey + 16, 16);

  if( 2 == no_tweakeys ){
    alpha[0] = 2;
    alpha[1] = 1;

    /* Number of rounds is 14 */
    Nr=14;

  } else if( 3 == no_tweakeys ){
    memcpy (tweakey[2], TweakKey + 32, 16);
    alpha[0] = 4;
    alpha[1] = 2;
    alpha[2] = 1;

    /* Number of rounds is 16 */
    Nr=16;

  } else {
    printf("The #tweakeys is %d, and it should be either 2 or 3. Exiting...\n", no_tweakeys);
    exit(1);
  }

  /* For each rounds */
  for(r=0; r<=Nr; r++) {

    /* Produce the round tweakey */
    rtweakey[ 4*r + 0] = GETU32( tweakey[0] +  0 ) ^ GETU32( tweakey[1] +  0 ) ^ ((3==no_tweakeys)* GETU32( tweakey[2] +  0 )) ^ rcon_row1 ;
    rtweakey[ 4*r + 1] = GETU32( tweakey[0] +  4 ) ^ GETU32( tweakey[1] +  4 ) ^ ((3==no_tweakeys)* GETU32( tweakey[2] +  4 )) ^ GETRCON( r);
    rtweakey[ 4*r + 2] = GETU32( tweakey[0] +  8 ) ^ GETU32( tweakey[1] +  8 ) ^ ((3==no_tweakeys)* GETU32( tweakey[2] +  8 ));
    rtweakey[ 4*r + 3] = GETU32( tweakey[0] + 12 ) ^ GETU32( tweakey[1] + 12 ) ^ ((3==no_tweakeys)* GETU32( tweakey[2] + 12 ));

    /* Apply H and G functions */
    H (tweakey[0]);
    G (tweakey[0], alpha[0]);

    H (tweakey[1]);
    G (tweakey[1], alpha[1]);

    if (3 == no_tweakeys) {
      H (tweakey[2]);
      G (tweakey[2], alpha[2]);
    }

  }/*r*/

  return Nr;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movl %edx, 0x44(%rsp)
movl $0x1020408, 0x8(%rsp)   # imm = 0x1020408
movq 0x48(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x28(%rsp)
movl $0x2, %eax
cmpl 0x44(%rsp), %eax
jne 0x27c6
movb $0x2, 0xd(%rsp)
movb $0x1, 0xe(%rsp)
movl $0xe, 0x4(%rsp)
jmp 0x281f
movl $0x3, %eax
cmpl 0x44(%rsp), %eax
jne 0x2801
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq 0x28(%rax), %rax
movq %rax, 0x38(%rsp)
movb $0x4, 0xd(%rsp)
movb $0x2, 0xe(%rsp)
movb $0x1, 0xf(%rsp)
movl $0x10, 0x4(%rsp)
jmp 0x281d
movl 0x44(%rsp), %esi
leaq 0x8177(%rip), %rdi      # 0xa983
movb $0x0, %al
callq 0x1040
movl $0x1, %edi
callq 0x1070
jmp 0x281f
movl $0x0, 0x40(%rsp)
movl 0x40(%rsp), %eax
cmpl 0x4(%rsp), %eax
jg 0x2b5f
movzbl 0x10(%rsp), %edx
shll $0x18, %edx
movzbl 0x11(%rsp), %eax
shll $0x10, %eax
xorl %eax, %edx
movzbl 0x12(%rsp), %eax
shll $0x8, %eax
xorl %eax, %edx
movzbl 0x13(%rsp), %eax
xorl %eax, %edx
movzbl 0x20(%rsp), %eax
shll $0x18, %eax
movzbl 0x21(%rsp), %ecx
shll $0x10, %ecx
xorl %ecx, %eax
movzbl 0x22(%rsp), %ecx
shll $0x8, %ecx
xorl %ecx, %eax
movzbl 0x23(%rsp), %ecx
xorl %ecx, %eax
xorl %eax, %edx
movl $0x3, %eax
cmpl 0x44(%rsp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movzbl 0x30(%rsp), %ecx
shll $0x18, %ecx
movzbl 0x31(%rsp), %esi
shll $0x10, %esi
xorl %esi, %ecx
movzbl 0x32(%rsp), %esi
shll $0x8, %esi
xorl %esi, %ecx
movzbl 0x33(%rsp), %esi
xorl %esi, %ecx
imull %ecx, %eax
xorl %eax, %edx
xorl $0x1020408, %edx        # imm = 0x1020408
movq 0x50(%rsp), %rax
movl 0x40(%rsp), %ecx
shll $0x2, %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movzbl 0x14(%rsp), %edx
shll $0x18, %edx
movzbl 0x15(%rsp), %eax
shll $0x10, %eax
xorl %eax, %edx
movzbl 0x16(%rsp), %eax
shll $0x8, %eax
xorl %eax, %edx
movzbl 0x17(%rsp), %eax
xorl %eax, %edx
movzbl 0x24(%rsp), %eax
shll $0x18, %eax
movzbl 0x25(%rsp), %ecx
shll $0x10, %ecx
xorl %ecx, %eax
movzbl 0x26(%rsp), %ecx
shll $0x8, %ecx
xorl %ecx, %eax
movzbl 0x27(%rsp), %ecx
xorl %ecx, %eax
xorl %eax, %edx
movl $0x3, %eax
cmpl 0x44(%rsp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movzbl 0x34(%rsp), %ecx
shll $0x18, %ecx
movzbl 0x35(%rsp), %esi
shll $0x10, %esi
xorl %esi, %ecx
movzbl 0x36(%rsp), %esi
shll $0x8, %esi
xorl %esi, %ecx
movzbl 0x37(%rsp), %esi
xorl %esi, %ecx
imull %ecx, %eax
xorl %eax, %edx
movslq 0x40(%rsp), %rcx
leaq 0x57b2(%rip), %rax      # 0x8110
movzbl (%rax,%rcx), %eax
shll $0x18, %eax
movslq 0x40(%rsp), %rsi
leaq 0x579f(%rip), %rcx      # 0x8110
movzbl (%rcx,%rsi), %ecx
shll $0x10, %ecx
xorl %ecx, %eax
movslq 0x40(%rsp), %rsi
leaq 0x578a(%rip), %rcx      # 0x8110
movzbl (%rcx,%rsi), %ecx
shll $0x8, %ecx
xorl %ecx, %eax
movslq 0x40(%rsp), %rsi
leaq 0x5775(%rip), %rcx      # 0x8110
movzbl (%rcx,%rsi), %ecx
shll $0x0, %ecx
xorl %ecx, %eax
xorl %eax, %edx
movq 0x50(%rsp), %rax
movl 0x40(%rsp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movzbl 0x18(%rsp), %edx
shll $0x18, %edx
movzbl 0x19(%rsp), %eax
shll $0x10, %eax
xorl %eax, %edx
movzbl 0x1a(%rsp), %eax
shll $0x8, %eax
xorl %eax, %edx
movzbl 0x1b(%rsp), %eax
xorl %eax, %edx
movzbl 0x28(%rsp), %eax
shll $0x18, %eax
movzbl 0x29(%rsp), %ecx
shll $0x10, %ecx
xorl %ecx, %eax
movzbl 0x2a(%rsp), %ecx
shll $0x8, %ecx
xorl %ecx, %eax
movzbl 0x2b(%rsp), %ecx
xorl %ecx, %eax
xorl %eax, %edx
movl $0x3, %eax
cmpl 0x44(%rsp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movzbl 0x38(%rsp), %ecx
shll $0x18, %ecx
movzbl 0x39(%rsp), %esi
shll $0x10, %esi
xorl %esi, %ecx
movzbl 0x3a(%rsp), %esi
shll $0x8, %esi
xorl %esi, %ecx
movzbl 0x3b(%rsp), %esi
xorl %esi, %ecx
imull %ecx, %eax
xorl %eax, %edx
movq 0x50(%rsp), %rax
movl 0x40(%rsp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movzbl 0x1c(%rsp), %edx
shll $0x18, %edx
movzbl 0x1d(%rsp), %eax
shll $0x10, %eax
xorl %eax, %edx
movzbl 0x1e(%rsp), %eax
shll $0x8, %eax
xorl %eax, %edx
movzbl 0x1f(%rsp), %eax
xorl %eax, %edx
movzbl 0x2c(%rsp), %eax
shll $0x18, %eax
movzbl 0x2d(%rsp), %ecx
shll $0x10, %ecx
xorl %ecx, %eax
movzbl 0x2e(%rsp), %ecx
shll $0x8, %ecx
xorl %ecx, %eax
movzbl 0x2f(%rsp), %ecx
xorl %ecx, %eax
xorl %eax, %edx
movl $0x3, %eax
cmpl 0x44(%rsp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movzbl 0x3c(%rsp), %ecx
shll $0x18, %ecx
movzbl 0x3d(%rsp), %esi
shll $0x10, %esi
xorl %esi, %ecx
movzbl 0x3e(%rsp), %esi
shll $0x8, %esi
xorl %esi, %ecx
movzbl 0x3f(%rsp), %esi
xorl %esi, %ecx
imull %ecx, %eax
xorl %eax, %edx
movq 0x50(%rsp), %rax
movl 0x40(%rsp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
leaq 0x10(%rsp), %rdi
callq 0x1080
leaq 0x10(%rsp), %rdi
movzbl 0xd(%rsp), %esi
callq 0x1100
leaq 0x10(%rsp), %rdi
addq $0x10, %rdi
callq 0x1080
leaq 0x10(%rsp), %rdi
addq $0x10, %rdi
movzbl 0xe(%rsp), %esi
callq 0x1100
movl $0x3, %eax
cmpl 0x44(%rsp), %eax
jne 0x2b4d
leaq 0x10(%rsp), %rdi
addq $0x20, %rdi
callq 0x1080
leaq 0x10(%rsp), %rdi
addq $0x20, %rdi
movzbl 0xf(%rsp), %esi
callq 0x1100
jmp 0x2b4f
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x2827
movl 0x4(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax,%rax)