// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/joltikeq6464v13/ref/tweakableBC.c
// Function: aesTweakEncrypt
void aesTweakEncrypt(uint32_t tweakey_size,
                     const uint8_t pt[8],
                     uint8_t key[],
                     uint8_t ct[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=joltikKeySetupEnc128 (rk, key, tweakey_size/64);

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


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

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

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

    }

    /* Put the state into the ciphertext */
    PUTU64(ct, 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 0x10e0
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)
movl $0x1, 0x134(%rsp)
movl 0x134(%rsp), %eax
cmpl 0x130(%rsp), %eax
jg 0x2d55
movq 0x128(%rsp), %rax
shrq $0x38, %rax
andq $0xf0, %rax
movq 0x128(%rsp), %rcx
shrq $0x28, %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 $0x0, %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 $0x18, %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 $0x30, %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 $0x8, %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 $0x20, %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 $0x38, %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 $0x10, %rcx
andq $0xf, %rcx
xorq %rcx, %rax
movl %eax, 0x108(%rsp)
movl 0x124(%rsp), %eax
movl %eax, %ecx
leaq 0x1cbe(%rip), %rax      # 0x4940
movl (%rax,%rcx,4), %eax
movl 0x120(%rsp), %ecx
movl %ecx, %edx
leaq 0x20ab(%rip), %rcx      # 0x4d40
xorl (%rcx,%rdx,4), %eax
movl %eax, %eax
shlq $0x30, %rax
movl 0x11c(%rsp), %ecx
movl %ecx, %edx
leaq 0x1c92(%rip), %rcx      # 0x4940
movl (%rcx,%rdx,4), %ecx
movl 0x118(%rsp), %edx
movl %edx, %esi
leaq 0x207f(%rip), %rdx      # 0x4d40
xorl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
shlq $0x20, %rcx
xorq %rcx, %rax
movl 0x114(%rsp), %ecx
movl %ecx, %edx
leaq 0x1c63(%rip), %rcx      # 0x4940
movl (%rcx,%rdx,4), %ecx
movl 0x110(%rsp), %edx
movl %edx, %esi
leaq 0x2050(%rip), %rdx      # 0x4d40
xorl (%rdx,%rsi,4), %ecx
movl %ecx, %ecx
shlq $0x10, %rcx
xorq %rcx, %rax
movl 0x10c(%rsp), %ecx
movl %ecx, %edx
leaq 0x1c34(%rip), %rcx      # 0x4940
movl (%rcx,%rdx,4), %ecx
movl 0x108(%rsp), %edx
movl %edx, %esi
leaq 0x2021(%rip), %rdx      # 0x4d40
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 0x2afe
jmp 0x2d57
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)