// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/riverkeyakv2/ref/Motorist.cpp
// Function: Motorist::Wrap(std::istream&, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>>&, std::istream&, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>>&, bool, bool)
bool Motorist::Wrap(istream& I, stringstream& O, istream& A, stringstream& T, bool unwrapFlag, bool forgetFlag)
{
    if (phase != riding)
        throw Exception("The phase must be riding to call Motorist::Wrap().");
    if ((!hasMore(I)) && (!hasMore(A)))
        engine.Inject(A);
    while(hasMore(I)) {
        engine.Crypt(I, O, unwrapFlag);
        engine.Inject(A);
    }
    while(hasMore(A))
        engine.Inject(A);
    if ((Pi > 1) || forgetFlag)
        MakeKnot();
    bool res = HandleTag(true, T, unwrapFlag);
    if (!res)
        O.str(string(""));
    return res;
}

// Assembly:
subq $0xd8, %rsp
movl %r9d, %eax
movq %rcx, 0x28(%rsp)
movq %rdx, %rcx
movq 0x28(%rsp), %rdx
movq %rcx, 0x30(%rsp)
movq %rsi, %rcx
movq 0x30(%rsp), %rsi
movq %rcx, 0x38(%rsp)
movq %rdi, %r9
movq 0x38(%rsp), %rdi
movb %al, %cl
movb 0xe0(%rsp), %al
movq %r9, 0xd0(%rsp)
movq %rdi, 0xc8(%rsp)
movq %rsi, 0xc0(%rsp)
movq %rdx, 0xb8(%rsp)
movq %r8, 0xb0(%rsp)
andb $0x1, %cl
movb %cl, 0xaf(%rsp)
andb $0x1, %al
movb %al, 0xae(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x40(%rsp)
cmpl $0x1, 0x60(%rax)
je 0x16ff3
movb $0x1, 0x73(%rsp)
movl $0x20, %edi
callq 0xe570
movq %rax, 0x18(%rsp)
leaq 0x87(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0xdce0
movq 0x20(%rsp), %rdx
leaq 0x4417(%rip), %rsi      # 0x1b375
leaq 0x88(%rsp), %rdi
callq 0xe740
jmp 0x16f6d
movq 0x18(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xde70
jmp 0x16f81
movq 0x18(%rsp), %rdi
movb $0x0, 0x73(%rsp)
movq 0x902e(%rip), %rsi      # 0x1ffc0
movq 0x901f(%rip), %rdx      # 0x1ffb8
callq 0xd8c0
jmp 0x171ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
jmp 0x16fce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x88(%rsp), %rdi
callq 0xe450
leaq 0x87(%rsp), %rdi
callq 0xe050
testb $0x1, 0x73(%rsp)
jne 0x16fe4
jmp 0x16fee
movq 0x18(%rsp), %rdi
callq 0xdd30
jmp 0x171a2
movq 0xc8(%rsp), %rdi
callq 0xd250
testb $0x1, %al
jne 0x1702b
movq 0xb8(%rsp), %rdi
callq 0xd250
testb $0x1, %al
jne 0x1702b
movq 0x40(%rsp), %rdi
addq $0x20, %rdi
movq 0xb8(%rsp), %rsi
callq 0xe9e0
jmp 0x1702d
movq 0xc8(%rsp), %rdi
callq 0xd250
testb $0x1, %al
jne 0x17040
jmp 0x17086
movq 0x40(%rsp), %rdi
addq $0x20, %rdi
movq 0xc8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
addq $0x10, %rdx
movb 0xaf(%rsp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0xdc00
movq 0x40(%rsp), %rdi
addq $0x20, %rdi
movq 0xb8(%rsp), %rsi
callq 0xe9e0
jmp 0x1702d
jmp 0x17088
movq 0xb8(%rsp), %rdi
callq 0xd250
testb $0x1, %al
jne 0x1709b
jmp 0x170b3
movq 0x40(%rsp), %rdi
addq $0x20, %rdi
movq 0xb8(%rsp), %rsi
callq 0xe9e0
jmp 0x17088
movq 0x40(%rsp), %rax
cmpl $0x1, (%rax)
ja 0x170c7
testb $0x1, 0xae(%rsp)
je 0x170d1
movq 0x40(%rsp), %rdi
callq 0xe4c0
movq 0x40(%rsp), %rdi
movq 0xb0(%rsp), %rdx
movb 0xaf(%rsp), %al
movl $0x1, %esi
andb $0x1, %al
movzbl %al, %ecx
callq 0xdcc0
andb $0x1, %al
movb %al, 0x72(%rsp)
testb $0x1, 0x72(%rsp)
jne 0x17194
movq 0xc0(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x4f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0xdce0
movq 0x10(%rsp), %rdx
leaq 0x3f25(%rip), %rsi      # 0x1b052
leaq 0x50(%rsp), %rdi
callq 0xe740
jmp 0x17139
movq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xd160
jmp 0x1714a
leaq 0x50(%rsp), %rdi
callq 0xe450
leaq 0x4f(%rsp), %rdi
callq 0xe050
jmp 0x17194
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
jmp 0x17188
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x50(%rsp), %rdi
callq 0xe450
leaq 0x4f(%rsp), %rdi
callq 0xe050
jmp 0x171a2
movb 0x72(%rsp), %al
andb $0x1, %al
addq $0xd8, %rsp
retq
movq 0x78(%rsp), %rdi
callq 0xe7c0
nopl (%rax)