// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/joltikeq6464v13/ref/tweakableBC.c
// Function: aesTweakDecrypt
void aesTweakDecrypt(uint32_t tweakey_size,
                     const uint8_t ct[8],
                     const uint8_t key[],
                     uint8_t pt[8])
{

    int i;
    int Nr;    
    uint64_t s;

    uint32_t s0;
    uint32_t s1;
    uint32_t s2;
    uint32_t s3;
    uint32_t s4;
    uint32_t s5;
    uint32_t s6;
    uint32_t s7;

    uint64_t rk[33];

    /* Produce the round tweakeys */
    Nr=joltikKeySetupDec128 (rk, key, tweakey_size/64);

    /* Get the ciphertext + key/tweak prewhitening */
    s=GETU64(ct) ^ rk[0];

    s0 = (s>>56ULL)&0xff;
    s1 = (s>>48ULL)&0xff;
    s2 = (s>>40ULL)&0xff;
    s3 = (s>>32ULL)&0xff;
    s4 = (s>>24ULL)&0xff;
    s5 = (s>>16ULL)&0xff;
    s6 = (s>> 8ULL)&0xff;
    s7 = (s>> 0ULL)&0xff;

    s  = (((uint64_t)(TmcH[s0]^TmcL[s1]))<<48ULL) ^ 
         (((uint64_t)(TmcH[s2]^TmcL[s3]))<<32ULL) ^ 
         (((uint64_t)(TmcH[s4]^TmcL[s5]))<<16ULL) ^ 
         (((uint64_t)(TmcH[s6]^TmcL[s7]))<< 0ULL);

    for(i=1; i<=Nr; ++i) {

        /* round i: */
        s0 = (((s>>56ULL)&0xf0))^((s>> 8ULL)&0xf); 
        s1 = (((s>>16ULL)&0xf0))^((s>>32ULL)&0xf);
        s2 = (((s>>40ULL)&0xf0))^((s>>56ULL)&0xf); 
        s3 = (((s>> 0ULL)&0xf0))^((s>>16ULL)&0xf);
        s4 = (((s>>24ULL)&0xf0))^((s>>40ULL)&0xf); 
        s5 = (((s>>48ULL)&0xf0))^((s>> 0ULL)&0xf);
        s6 = (((s>> 8ULL)&0xf0))^((s>>24ULL)&0xf); 
        s7 = (((s>>32ULL)&0xf0))^((s>>48ULL)&0xf);

        s  = (((uint64_t)(TdH[s0]^TdL[s1]))<<48ULL) ^ 
             (((uint64_t)(TdH[s2]^TdL[s3]))<<32ULL) ^ 
             (((uint64_t)(TdH[s4]^TdL[s5]))<<16ULL) ^ 
             (((uint64_t)(TdH[s6]^TdL[s7]))<< 0ULL) ^ rk[i];
    }

    /* Apply the MixColum to invert the last one performed in the Td table */
    s0 = (s>>56ULL)&0xff;
    s1 = (s>>48ULL)&0xff;
    s2 = (s>>40ULL)&0xff;
    s3 = (s>>32ULL)&0xff;
    s4 = (s>>24ULL)&0xff;
    s5 = (s>>16ULL)&0xff;
    s6 = (s>> 8ULL)&0xff;
    s7 = (s>> 0ULL)&0xff;

    s  = (((uint64_t)(TmcH[s0]^TmcL[s1]))<<48ULL) ^ 
         (((uint64_t)(TmcH[s2]^TmcL[s3]))<<32ULL) ^ 
         (((uint64_t)(TmcH[s4]^TmcL[s5]))<<16ULL) ^ 
         (((uint64_t)(TmcH[s6]^TmcL[s7]))<< 0ULL);

    /* Put the state into the plaintext */
    PUTU64(pt, s);
}

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movl %edi, 0x154(%rsp)
movq %rsi, 0x148(%rsp)
movq %rdx, 0x140(%rsp)
movq %rcx, 0x138(%rsp)
movq %rsp, %rdi
movq 0x140(%rsp), %rsi
movl 0x154(%rsp), %edx
shrl $0x6, %edx
callq 0x1060
movl %eax, 0x130(%rsp)
movq 0x148(%rsp), %rax
movzbl (%rax), %eax
shlq $0x38, %rax
movq 0x148(%rsp), %rcx
movzbl 0x1(%rcx), %ecx
shlq $0x30, %rcx
xorq %rcx, %rax
movq 0x148(%rsp), %rcx
movzbl 0x2(%rcx), %ecx
shlq $0x28, %rcx
xorq %rcx, %rax
movq 0x148(%rsp), %rcx
movzbl 0x3(%rcx), %ecx
shlq $0x20, %rcx
xorq %rcx, %rax
movq 0x148(%rsp), %rcx
movzbl 0x4(%rcx), %ecx
shlq $0x18, %rcx
xorq %rcx, %rax
movq 0x148(%rsp), %rcx
movzbl 0x5(%rcx), %ecx
shlq $0x10, %rcx
xorq %rcx, %rax
movq 0x148(%rsp), %rcx
movzbl 0x6(%rcx), %ecx
shlq $0x8, %rcx
xorq %rcx, %rax
movq 0x148(%rsp), %rcx
movzbl 0x7(%rcx), %ecx
xorq %rcx, %rax
xorq (%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x128(%rsp), %rax
shrq $0x38, %rax
andq $0xff, %rax
movl %eax, 0x124(%rsp)
movq 0x128(%rsp), %rax
shrq $0x30, %rax
andq $0xff, %rax
movl %eax, 0x120(%rsp)
movq 0x128(%rsp), %rax
shrq $0x28, %rax
andq $0xff, %rax
movl %eax, 0x11c(%rsp)
movq 0x128(%rsp), %rax
shrq $0x20, %rax
andq $0xff, %rax
movl %eax, 0x118(%rsp)
movq 0x128(%rsp), %rax
shrq $0x18, %rax
andq $0xff, %rax
movl %eax, 0x114(%rsp)
movq 0x128(%rsp), %rax
shrq $0x10, %rax
andq $0xff, %rax
movl %eax, 0x110(%rsp)
movq 0x128(%rsp), %rax
shrq $0x8, %rax
andq $0xff, %rax
movl %eax, 0x10c(%rsp)
movq 0x128(%rsp), %rax
shrq $0x0, %rax
andq $0xff, %rax
movl %eax, 0x108(%rsp)
movl 0x124(%rsp), %eax
movl %eax, %ecx
leaq 0x1155(%rip), %rax      # 0x4140
movl (%rax,%rcx,4), %eax
movl 0x120(%rsp), %ecx
movl %ecx, %edx
leaq 0x1542(%rip), %rcx      # 0x4540
xorl (%rcx,%rdx,4), %eax
movl %eax, %eax
shlq $0x30, %rax
movl 0x11c(%rsp), %ecx
movl %ecx, %edx
leaq 0x1129(%rip), %rcx      # 0x4140
movl (%rcx,%rdx,4), %ecx
movl 0x118(%rsp), %edx
movl %edx, %esi
leaq 0x1516(%rip), %rdx      # 0x4540
xorl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
shlq $0x20, %rcx
xorq %rcx, %rax
movl 0x114(%rsp), %ecx
movl %ecx, %edx
leaq 0x10fa(%rip), %rcx      # 0x4140
movl (%rcx,%rdx,4), %ecx
movl 0x110(%rsp), %edx
movl %edx, %esi
leaq 0x14e7(%rip), %rdx      # 0x4540
xorl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
shlq $0x10, %rcx
xorq %rcx, %rax
movl 0x10c(%rsp), %ecx
movl %ecx, %edx
leaq 0x10cb(%rip), %rcx      # 0x4140
movl (%rcx,%rdx,4), %ecx
movl 0x108(%rsp), %edx
movl %edx, %esi
leaq 0x14b8(%rip), %rdx      # 0x4540
xorl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
shlq $0x0, %rcx
xorq %rcx, %rax
movq %rax, 0x128(%rsp)
movl $0x1, 0x134(%rsp)
movl 0x134(%rsp), %eax
cmpl 0x130(%rsp), %eax
jg 0x32fe
movq 0x128(%rsp), %rax
shrq $0x38, %rax
andq $0xf0, %rax
movq 0x128(%rsp), %rcx
shrq $0x8, %rcx
andq $0xf, %rcx
xorq %rcx, %rax
movl %eax, 0x124(%rsp)
movq 0x128(%rsp), %rax
shrq $0x10, %rax
andq $0xf0, %rax
movq 0x128(%rsp), %rcx
shrq $0x20, %rcx
andq $0xf, %rcx
xorq %rcx, %rax
movl %eax, 0x120(%rsp)
movq 0x128(%rsp), %rax
shrq $0x28, %rax
andq $0xf0, %rax
movq 0x128(%rsp), %rcx
shrq $0x38, %rcx
andq $0xf, %rcx
xorq %rcx, %rax
movl %eax, 0x11c(%rsp)
movq 0x128(%rsp), %rax
shrq $0x0, %rax
andq $0xf0, %rax
movq 0x128(%rsp), %rcx
shrq $0x10, %rcx
andq $0xf, %rcx
xorq %rcx, %rax
movl %eax, 0x118(%rsp)
movq 0x128(%rsp), %rax
shrq $0x18, %rax
andq $0xf0, %rax
movq 0x128(%rsp), %rcx
shrq $0x28, %rcx
andq $0xf, %rcx
xorq %rcx, %rax
movl %eax, 0x114(%rsp)
movq 0x128(%rsp), %rax
shrq $0x30, %rax
andq $0xf0, %rax
movq 0x128(%rsp), %rcx
shrq $0x0, %rcx
andq $0xf, %rcx
xorq %rcx, %rax
movl %eax, 0x110(%rsp)
movq 0x128(%rsp), %rax
shrq $0x8, %rax
andq $0xf0, %rax
movq 0x128(%rsp), %rcx
shrq $0x18, %rcx
andq $0xf, %rcx
xorq %rcx, %rax
movl %eax, 0x10c(%rsp)
movq 0x128(%rsp), %rax
shrq $0x20, %rax
andq $0xf0, %rax
movq 0x128(%rsp), %rcx
shrq $0x30, %rcx
andq $0xf, %rcx
xorq %rcx, %rax
movl %eax, 0x108(%rsp)
movl 0x124(%rsp), %eax
movl %eax, %ecx
leaq 0x1f15(%rip), %rax      # 0x5140
movl (%rax,%rcx,4), %eax
movl 0x120(%rsp), %ecx
movl %ecx, %edx
leaq 0x2302(%rip), %rcx      # 0x5540
xorl (%rcx,%rdx,4), %eax
movl %eax, %eax
shlq $0x30, %rax
movl 0x11c(%rsp), %ecx
movl %ecx, %edx
leaq 0x1ee9(%rip), %rcx      # 0x5140
movl (%rcx,%rdx,4), %ecx
movl 0x118(%rsp), %edx
movl %edx, %esi
leaq 0x22d6(%rip), %rdx      # 0x5540
xorl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
shlq $0x20, %rcx
xorq %rcx, %rax
movl 0x114(%rsp), %ecx
movl %ecx, %edx
leaq 0x1eba(%rip), %rcx      # 0x5140
movl (%rcx,%rdx,4), %ecx
movl 0x110(%rsp), %edx
movl %edx, %esi
leaq 0x22a7(%rip), %rdx      # 0x5540
xorl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
shlq $0x10, %rcx
xorq %rcx, %rax
movl 0x10c(%rsp), %ecx
movl %ecx, %edx
leaq 0x1e8b(%rip), %rcx      # 0x5140
movl (%rcx,%rdx,4), %ecx
movl 0x108(%rsp), %edx
movl %edx, %esi
leaq 0x2278(%rip), %rdx      # 0x5540
xorl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
shlq $0x0, %rcx
xorq %rcx, %rax
movslq 0x134(%rsp), %rcx
xorq (%rsp,%rcx,8), %rax
movq %rax, 0x128(%rsp)
movl 0x134(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x134(%rsp)
jmp 0x30a7
movq 0x128(%rsp), %rax
shrq $0x38, %rax
andq $0xff, %rax
movl %eax, 0x124(%rsp)
movq 0x128(%rsp), %rax
shrq $0x30, %rax
andq $0xff, %rax
movl %eax, 0x120(%rsp)
movq 0x128(%rsp), %rax
shrq $0x28, %rax
andq $0xff, %rax
movl %eax, 0x11c(%rsp)
movq 0x128(%rsp), %rax
shrq $0x20, %rax
andq $0xff, %rax
movl %eax, 0x118(%rsp)
movq 0x128(%rsp), %rax
shrq $0x18, %rax
andq $0xff, %rax
movl %eax, 0x114(%rsp)
movq 0x128(%rsp), %rax
shrq $0x10, %rax
andq $0xff, %rax
movl %eax, 0x110(%rsp)
movq 0x128(%rsp), %rax
shrq $0x8, %rax
andq $0xff, %rax
movl %eax, 0x10c(%rsp)
movq 0x128(%rsp), %rax
shrq $0x0, %rax
andq $0xff, %rax
movl %eax, 0x108(%rsp)
movl 0x124(%rsp), %eax
movl %eax, %ecx
leaq 0xd6a(%rip), %rax       # 0x4140
movl (%rax,%rcx,4), %eax
movl 0x120(%rsp), %ecx
movl %ecx, %edx
leaq 0x1157(%rip), %rcx      # 0x4540
xorl (%rcx,%rdx,4), %eax
movl %eax, %eax
shlq $0x30, %rax
movl 0x11c(%rsp), %ecx
movl %ecx, %edx
leaq 0xd3e(%rip), %rcx       # 0x4140
movl (%rcx,%rdx,4), %ecx
movl 0x118(%rsp), %edx
movl %edx, %esi
leaq 0x112b(%rip), %rdx      # 0x4540
xorl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
shlq $0x20, %rcx
xorq %rcx, %rax
movl 0x114(%rsp), %ecx
movl %ecx, %edx
leaq 0xd0f(%rip), %rcx       # 0x4140
movl (%rcx,%rdx,4), %ecx
movl 0x110(%rsp), %edx
movl %edx, %esi
leaq 0x10fc(%rip), %rdx      # 0x4540
xorl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
shlq $0x10, %rcx
xorq %rcx, %rax
movl 0x10c(%rsp), %ecx
movl %ecx, %edx
leaq 0xce0(%rip), %rcx       # 0x4140
movl (%rcx,%rdx,4), %ecx
movl 0x108(%rsp), %edx
movl %edx, %esi
leaq 0x10cd(%rip), %rdx      # 0x4540
xorl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
shlq $0x0, %rcx
xorq %rcx, %rax
movq %rax, 0x128(%rsp)
movq 0x128(%rsp), %rax
shrq $0x38, %rax
movb %al, %cl
movq 0x138(%rsp), %rax
movb %cl, (%rax)
movq 0x128(%rsp), %rax
shrq $0x30, %rax
movb %al, %cl
movq 0x138(%rsp), %rax
movb %cl, 0x1(%rax)
movq 0x128(%rsp), %rax
shrq $0x28, %rax
movb %al, %cl
movq 0x138(%rsp), %rax
movb %cl, 0x2(%rax)
movq 0x128(%rsp), %rax
shrq $0x20, %rax
movb %al, %cl
movq 0x138(%rsp), %rax
movb %cl, 0x3(%rax)
movq 0x128(%rsp), %rax
shrq $0x18, %rax
movb %al, %cl
movq 0x138(%rsp), %rax
movb %cl, 0x4(%rax)
movq 0x128(%rsp), %rax
shrq $0x10, %rax
movb %al, %cl
movq 0x138(%rsp), %rax
movb %cl, 0x5(%rax)
movq 0x128(%rsp), %rax
shrq $0x8, %rax
movb %al, %cl
movq 0x138(%rsp), %rax
movb %cl, 0x6(%rax)
movq 0x128(%rsp), %rax
movb %al, %cl
movq 0x138(%rsp), %rax
movb %cl, 0x7(%rax)
addq $0x158, %rsp            # imm = 0x158
retq
nopw %cs:(%rax,%rax)
nopl (%rax)