// File: skyleaworlder[P]AES/src/main.cpp
// Function: aes(std::bitset<128ul>, std::bitset<128ul>, unsigned long)
vector<byte> aes(
    std::bitset<128> input,
    std::bitset<128> key,
    size_t round
) {
    vector<vector<byte>> key_expan { Key_Expansion(byte_to_vector(key), round) };
    vector<byte> vec { byte_to_vector(input) };
    assert(key_expan.size() == round+1);

    vec = AddRoundKey(vec, key_expan[0]);

    size_t index;
    for (index = 1; index < round; ++index) {
        vec = SubBytes(vec);
        vec = ShiftRows(vec);
        vec = MixColumns(vec);
        vec = AddRoundKey(vec, key_expan[index]);
    }

    vec = SubBytes(vec);
    vec = ShiftRows(vec);
    vec = AddRoundKey(vec, key_expan[index]);
    return vec;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x278(%rbp)
movq %rdi, %rax
movq %rax, -0x270(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x30(%rbp)
movups -0x28(%rbp), %xmm0
movaps %xmm0, -0x70(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
leaq -0x60(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x5970
movq -0x268(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x3420
jmp 0x74ca
leaq -0x60(%rbp), %rdi
callq 0x2840
movq -0x278(%rbp), %rdi
movb $0x0, -0x7d(%rbp)
movups -0x18(%rbp), %xmm0
movaps %xmm0, -0x90(%rbp)
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0x5970
jmp 0x74fe
leaq -0x48(%rbp), %rdi
callq 0x51e0
movq -0x30(%rbp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jne 0x7516
jmp 0x7560
leaq 0x25eb(%rip), %rdi      # 0x9b08
leaq 0x2600(%rip), %rsi      # 0x9b24
movl $0x11, %edx
leaq 0x2601(%rip), %rcx      # 0x9b31
callq 0x20e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x2840
jmp 0x7a7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x7a72
movq -0x278(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x3bc0
jmp 0x7575
xorl %eax, %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x3da0
movq %rax, %rsi
leaq -0xd8(%rbp), %rdi
callq 0x3bc0
jmp 0x7593
leaq -0xa8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
callq 0x2630
jmp 0x75af
movq -0x278(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x7d00
leaq -0xa8(%rbp), %rdi
callq 0x2840
leaq -0xd8(%rbp), %rdi
callq 0x2840
leaq -0xc0(%rbp), %rdi
callq 0x2840
movq $0x1, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x788c
movq -0x278(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x3bc0
jmp 0x7617
leaq -0xf8(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x7290
jmp 0x762c
movq -0x278(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
movq %rsi, -0x280(%rbp)
callq 0x7d00
movq -0x280(%rbp), %rdi
callq 0x2840
leaq -0x110(%rbp), %rdi
callq 0x2840
movq -0x278(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x3bc0
jmp 0x7673
leaq -0x128(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x7040
jmp 0x7688
movq -0x278(%rbp), %rdi
leaq -0x128(%rbp), %rsi
movq %rsi, -0x288(%rbp)
callq 0x7d00
movq -0x288(%rbp), %rdi
callq 0x2840
leaq -0x140(%rbp), %rdi
callq 0x2840
movq -0x278(%rbp), %rsi
leaq -0x170(%rbp), %rdi
callq 0x3bc0
jmp 0x76cf
leaq -0x158(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x6630
jmp 0x76e4
movq -0x278(%rbp), %rdi
leaq -0x158(%rbp), %rsi
movq %rsi, -0x290(%rbp)
callq 0x7d00
movq -0x290(%rbp), %rdi
callq 0x2840
leaq -0x170(%rbp), %rdi
callq 0x2840
movq -0x278(%rbp), %rsi
leaq -0x1a0(%rbp), %rdi
callq 0x3bc0
jmp 0x772b
movq -0xe0(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x3da0
movq %rax, %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3bc0
jmp 0x774c
leaq -0x188(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
leaq -0x1b8(%rbp), %rdx
callq 0x2630
jmp 0x7768
movq -0x278(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x7d00
leaq -0x188(%rbp), %rdi
callq 0x2840
leaq -0x1b8(%rbp), %rdi
callq 0x2840
leaq -0x1a0(%rbp), %rdi
callq 0x2840
movq -0xe0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0x75f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x7a66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x77ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x2840
leaq -0xc0(%rbp), %rdi
callq 0x2840
jmp 0x7a66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x2840
jmp 0x7a66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x2840
jmp 0x7a66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x2840
jmp 0x7a66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x787b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x2840
leaq -0x1a0(%rbp), %rdi
callq 0x2840
jmp 0x7a66
movq -0x278(%rbp), %rsi
leaq -0x1e8(%rbp), %rdi
callq 0x3bc0
jmp 0x78a1
leaq -0x1d0(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x7290
jmp 0x78b6
movq -0x278(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
movq %rsi, -0x298(%rbp)
callq 0x7d00
movq -0x298(%rbp), %rdi
callq 0x2840
leaq -0x1e8(%rbp), %rdi
callq 0x2840
movq -0x278(%rbp), %rsi
leaq -0x218(%rbp), %rdi
callq 0x3bc0
jmp 0x78fd
leaq -0x200(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x7040
jmp 0x7912
movq -0x278(%rbp), %rdi
leaq -0x200(%rbp), %rsi
movq %rsi, -0x2a0(%rbp)
callq 0x7d00
movq -0x2a0(%rbp), %rdi
callq 0x2840
leaq -0x218(%rbp), %rdi
callq 0x2840
movq -0x278(%rbp), %rsi
leaq -0x248(%rbp), %rdi
callq 0x3bc0
jmp 0x7959
movq -0xe0(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x3da0
movq %rax, %rsi
leaq -0x260(%rbp), %rdi
callq 0x3bc0
jmp 0x797a
leaq -0x230(%rbp), %rdi
leaq -0x248(%rbp), %rsi
leaq -0x260(%rbp), %rdx
callq 0x2630
jmp 0x7996
movq -0x278(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x7d00
leaq -0x230(%rbp), %rdi
callq 0x2840
leaq -0x260(%rbp), %rdi
callq 0x2840
leaq -0x248(%rbp), %rdi
callq 0x2840
movb $0x1, -0x7d(%rbp)
testb $0x1, -0x7d(%rbp)
jne 0x7a4d
jmp 0x7a41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x2840
jmp 0x7a66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x2840
jmp 0x7a66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x7a33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x2840
leaq -0x248(%rbp), %rdi
callq 0x2840
jmp 0x7a66
movq -0x278(%rbp), %rdi
callq 0x2840
leaq -0x48(%rbp), %rdi
callq 0x3dc0
movq -0x270(%rbp), %rax
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
movq -0x278(%rbp), %rdi
callq 0x2840
leaq -0x48(%rbp), %rdi
callq 0x3dc0
movq -0x78(%rbp), %rdi
callq 0x22b0
nopw %cs:(%rax,%rax)