// File: permutationlock[P]aes_math/lib/aes.cpp
// Function: keyExpandCore(std::vector<GaloisPolynomial, std::allocator<GaloisPolynomial>>&, int)
vector<GaloisPolynomial>& keyExpandCore(vector<GaloisPolynomial> & word, int iteration){
    // Do a simple left rotate of bytes
    GaloisPolynomial temp(word[0]);
    word[0] = word[1];
    word[1] = word[2];
    word[2] = word[3];
    word[3] = temp;
    
    // Apply S-Box to each byte
    for(int i=0; i<4; i++){
        sBox(word[i]);
    }
    
    // Apply Rcon operation (add 2^(iteration-1) to word[0])
    vector<Modular<int>> v;
    for(int i=0; i<iteration-2; i++){
        v.push_back(0);
    }
    v.push_back(1);
    word[0] += GaloisPolynomial(v);
    
    return word;
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movl %esi, 0xac(%rsp)
movq 0xb0(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movq %rsi, 0x18(%rsp)
callq 0xc4a0
movq %rax, %rsi
leaq 0x88(%rsp), %rdi
callq 0xca90
movq 0xb0(%rsp), %rdi
movl $0x1, %esi
callq 0xc4a0
movq 0x18(%rsp), %rsi
movq %rax, 0x20(%rsp)
movq 0xb0(%rsp), %rdi
callq 0xc4a0
movq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0xc4c0
jmp 0xadd4
movq 0xb0(%rsp), %rdi
movl $0x2, %esi
callq 0xc4a0
movq %rax, 0x10(%rsp)
movq 0xb0(%rsp), %rdi
movl $0x1, %esi
callq 0xc4a0
movq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0xc4c0
jmp 0xae0c
movq 0xb0(%rsp), %rdi
movl $0x3, %esi
callq 0xc4a0
movq %rax, 0x8(%rsp)
movq 0xb0(%rsp), %rdi
movl $0x2, %esi
callq 0xc4a0
movq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0xc4c0
jmp 0xae44
movq 0xb0(%rsp), %rdi
movl $0x3, %esi
callq 0xc4a0
movq %rax, %rdi
leaq 0x88(%rsp), %rsi
callq 0xc4c0
jmp 0xae68
movl $0x0, 0x78(%rsp)
cmpl $0x4, 0x78(%rsp)
jge 0xaeb8
movq 0xb0(%rsp), %rdi
movslq 0x78(%rsp), %rsi
callq 0xc4a0
movq %rax, %rdi
callq 0xa2f0
jmp 0xae93
jmp 0xae95
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0xae70
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
jmp 0xafe9
leaq 0x60(%rsp), %rdi
callq 0x6720
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movl 0xac(%rsp), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jge 0xaf2b
movl $0x0, 0x54(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x54(%rsp), %rsi
callq 0x6760
jmp 0xaef5
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x6730
jmp 0xaf06
jmp 0xaf08
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0xaeca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
jmp 0xafdf
movl $0x1, 0x4c(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x4c(%rsp), %rsi
callq 0x6760
jmp 0xaf44
leaq 0x60(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x6730
jmp 0xaf55
leaq 0x28(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movl $0x2, %edx
callq 0x5c70
jmp 0xaf6b
movq 0xb0(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xc4a0
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x5d40
jmp 0xaf8b
leaq 0x28(%rsp), %rdi
callq 0x6f00
movq 0xb0(%rsp), %rax
movq %rax, (%rsp)
leaq 0x60(%rsp), %rdi
callq 0x67e0
leaq 0x88(%rsp), %rdi
callq 0x6f00
movq (%rsp), %rax
addq $0xb8, %rsp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x6f00
leaq 0x60(%rsp), %rdi
callq 0x67e0
leaq 0x88(%rsp), %rdi
callq 0x6f00
movq 0x80(%rsp), %rdi
callq 0x22b0
nopw %cs:(%rax,%rax)