// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/riverkeyakv2/ref/Motorist.cpp
// Function: Piston::Piston(Permutation const*, unsigned int, unsigned int)
Piston::Piston(const Permutation *aF, unsigned int aRs, unsigned int aRa)
    : f(aF), Rs(aRs), Ra(aRa)
{
    unsigned int b = f->getWidth();
    if (Rs > Ra)
        throw Exception("Rs is larger than Ra.");
    if (Ra > ((b-32)/8))
        throw Exception("Ra is larger than (b-32)/8.");
    state.reset(new UINT8[(b+7)/8]);
    memset(state.get(), 0, (b+7)/8);
    EOM = Ra;
    CryptEnd = Ra+1;
    InjectStart = Ra+2;
    InjectEnd = Ra+3;
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movl %edx, 0xb4(%rsp)
movl %ecx, 0xb0(%rsp)
movq 0xc0(%rsp), %rdi
movq %rdi, 0x40(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, (%rdi)
addq $0x8, %rdi
movq %rdi, 0x38(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0xe970
movq 0x40(%rsp), %rax
movl 0xb4(%rsp), %ecx
movl %ecx, 0x10(%rax)
movl 0xb0(%rsp), %ecx
movl %ecx, 0x14(%rax)
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, 0x48(%rsp)
jmp 0x14f1a
movq 0x40(%rsp), %rcx
movl 0x48(%rsp), %eax
movl %eax, 0xac(%rsp)
movl 0x10(%rcx), %eax
cmpl 0x14(%rcx), %eax
jbe 0x15013
movb $0x1, 0x76(%rsp)
movl $0x20, %edi
callq 0xe570
movq %rax, 0x28(%rsp)
leaq 0x77(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xdce0
movq 0x30(%rsp), %rdx
leaq 0x6275(%rip), %rsi      # 0x1b1da
leaq 0x78(%rsp), %rdi
callq 0xe740
jmp 0x14f71
movq 0x28(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xde70
jmp 0x14f82
movq 0x28(%rsp), %rdi
movb $0x0, 0x76(%rsp)
movq 0xb02d(%rip), %rsi      # 0x1ffc0
movq 0xb01e(%rip), %rdx      # 0x1ffb8
callq 0xd8c0
jmp 0x1519a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x15183
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x14ff1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x78(%rsp), %rdi
callq 0xe450
leaq 0x77(%rsp), %rdi
callq 0xe050
testb $0x1, 0x76(%rsp)
jne 0x15004
jmp 0x1500e
movq 0x28(%rsp), %rdi
callq 0xdd30
jmp 0x15183
movq 0x40(%rsp), %rax
movl 0x14(%rax), %eax
movl 0xac(%rsp), %ecx
subl $0x20, %ecx
shrl $0x3, %ecx
cmpl %ecx, %eax
jbe 0x150f4
movb $0x1, 0x4e(%rsp)
movl $0x20, %edi
callq 0xe570
movq %rax, 0x18(%rsp)
leaq 0x4f(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0xdce0
movq 0x20(%rsp), %rdx
leaq 0x6191(%rip), %rsi      # 0x1b1f0
leaq 0x50(%rsp), %rdi
callq 0xe740
jmp 0x1506b
movq 0x18(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xde70
jmp 0x1507c
movq 0x18(%rsp), %rdi
movb $0x0, 0x4e(%rsp)
movq 0xaf33(%rip), %rsi      # 0x1ffc0
movq 0xaf24(%rip), %rdx      # 0x1ffb8
callq 0xd8c0
jmp 0x1519a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x150d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x50(%rsp), %rdi
callq 0xe450
leaq 0x4f(%rsp), %rdi
callq 0xe050
testb $0x1, 0x4e(%rsp)
jne 0x150e5
jmp 0x150ef
movq 0x18(%rsp), %rdi
callq 0xdd30
jmp 0x15183
movq 0x40(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movl 0xac(%rsp), %eax
addl $0x7, %eax
shrl $0x3, %eax
movl %eax, %edi
callq 0xe6a0
movq %rax, 0x10(%rsp)
jmp 0x1511d
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0xe170
movq 0x40(%rsp), %rdi
addq $0x8, %rdi
callq 0xd1d0
movq %rax, %rdi
movl 0xac(%rsp), %eax
addl $0x7, %eax
shrl $0x3, %eax
movl %eax, %eax
movl %eax, %edx
xorl %esi, %esi
callq 0xd7c0
movq 0x40(%rsp), %rax
movl 0x14(%rax), %ecx
movl %ecx, 0x18(%rax)
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c(%rax)
movl 0x14(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x20(%rax)
movl 0x14(%rax), %ecx
addl $0x3, %ecx
movl %ecx, 0x24(%rax)
addq $0xc8, %rsp
retq
movq 0x38(%rsp), %rdi
callq 0xd330
movq 0xa0(%rsp), %rdi
callq 0xe7c0
nopw (%rax,%rax)