// File: /workspace/github_cpp_makefile_star2_O1/renzibei[P]TSProxy/aes.cpp
// Function: aes(char*, char const*)
void aes(char *p, const char *key){

	int pArray[4][4];
	int i;

	extendKey(key);//扩展密钥

    // 开始加密
    strToArray(p, pArray);
    addKey(pArray, 0);//一开始的轮密钥加

    // 中间九轮
    for(i = 1; i < 10; i++){
        subBytes(pArray);//字节代换
        shiftRows(pArray);//行移位
        mixColumns(pArray);//列混合
        addKey(pArray, i);
    }

    // 最后一轮
    subBytes(pArray);//字节代换
    shiftRows(pArray);//行移位
    addKey(pArray, 10);

    arrayToStr(pArray, p);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, 0x18(%rsp)
xorl %ecx, %ecx
pxor %xmm0, %xmm0
movdqa 0x2c74(%rip), %xmm1     # 0x8f20
pshufd $0xf5, %xmm1, %xmm2     # xmm2 = xmm1[1,1,3,3]
leaq 0xb7a28(%rip), %rax     # 0xbdce0
movd (%rsi,%rcx), %xmm3
punpcklbw %xmm0, %xmm3    # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1],xmm3[2],xmm0[2],xmm3[3],xmm0[3],xmm3[4],xmm0[4],xmm3[5],xmm0[5],xmm3[6],xmm0[6],xmm3[7],xmm0[7]
punpcklwd %xmm0, %xmm3    # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1],xmm3[2],xmm0[2],xmm3[3],xmm0[3]
pshufd $0xf5, %xmm3, %xmm4     # xmm4 = xmm3[1,1,3,3]
pmuludq %xmm1, %xmm3
pshufd $0xe8, %xmm3, %xmm3     # xmm3 = xmm3[0,2,2,3]
pmuludq %xmm2, %xmm4
pshufd $0xe8, %xmm4, %xmm4     # xmm4 = xmm4[0,2,2,3]
punpckldq %xmm4, %xmm3    # xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1]
pshufd $0xee, %xmm3, %xmm4     # xmm4 = xmm3[2,3,2,3]
por %xmm3, %xmm4
pshufd $0x55, %xmm4, %xmm3     # xmm3 = xmm4[1,1,1,1]
por %xmm4, %xmm3
movd %xmm3, (%rcx,%rax)
addq $0x4, %rcx
cmpq $0x10, %rcx
jne 0x62b8
xorl %ecx, %ecx
movl $0x4, %edx
movl $0xff, %esi
leaq 0x2c5c(%rip), %rbx      # 0x8f70
leaq 0x3055(%rip), %rdi      # 0x9370
movl -0x10(%rax,%rdx,4), %r8d
movl -0x4(%rax,%rdx,4), %r9d
testb $0x3, %dl
je 0x6336
xorl %r8d, %r9d
movl %r9d, (%rax,%rdx,4)
jmp 0x63ca
movl %r9d, %r10d
shrl $0x18, %r10d
movl %r10d, 0x2c(%rsp)
movl %r9d, %r10d
shrl $0x10, %r10d
andl %esi, %r10d
movl %r10d, 0x20(%rsp)
movl %r9d, %r10d
shrl $0x8, %r10d
andl %esi, %r10d
movl %r10d, 0x24(%rsp)
andl %esi, %r9d
movl %r9d, 0x28(%rsp)
xorl %r9d, %r9d
movl 0x20(%rsp,%r9,4), %r10d
movl %r10d, %r11d
andl $0xf, %r11d
andl $0xf0, %r10d
leaq (%rbx,%r10,4), %r10
movl (%r10,%r11,4), %r10d
movl %r10d, 0x20(%rsp,%r9,4)
incq %r9
cmpq $0x4, %r9
jne 0x636b
movl 0x20(%rsp), %r9d
movl 0x24(%rsp), %r10d
shll $0x18, %r9d
shll $0x10, %r10d
orl %r9d, %r10d
movl 0x28(%rsp), %r9d
shll $0x8, %r9d
orl %r10d, %r9d
orl 0x2c(%rsp), %r9d
movslq %ecx, %rcx
xorl (%rdi,%rcx,4), %r9d
xorl %r8d, %r9d
movl %r9d, (%rax,%rdx,4)
incl %ecx
incq %rdx
cmpq $0x2c, %rdx
jne 0x631b
leaq 0x70(%rsp), %rax
xorl %ecx, %ecx
movq 0x18(%rsp), %rdx
movq %rax, %rsi
xorl %edi, %edi
movzbl (%rdx,%rdi), %r8d
movl %r8d, (%rsi)
incq %rdi
addq $0x10, %rsi
cmpq $0x4, %rdi
jne 0x63e8
incq %rcx
addq $0x4, %rdx
addq $0x4, %rax
cmpq $0x4, %rcx
jne 0x63e3
leaq 0x70(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x6675
movl $0x1, %ebp
leaq 0x80(%rsp), %r8
movq %r12, %rax
xorl %ecx, %ecx
xorl %edx, %edx
movl (%rax,%rdx,4), %esi
movl %esi, %edi
andl $0xf, %edi
andl $0xf0, %esi
leaq (%rbx,%rsi,4), %rsi
movl (%rsi,%rdi,4), %esi
movl %esi, (%rax,%rdx,4)
incq %rdx
cmpq $0x4, %rdx
jne 0x6431
incq %rcx
addq $0x10, %rax
cmpq $0x4, %rcx
jne 0x642f
movl $0x1, %eax
movq %r8, %rcx
xorl %edx, %edx
movq %rdx, %rsi
shlq $0x4, %rsi
movdqa (%r8,%rsi), %xmm0
movdqa %xmm0, 0x20(%rsp)
xorl %esi, %esi
leal (%rax,%rsi), %edi
andl $0x3, %edi
movl 0x20(%rsp,%rdi,4), %edi
movl %edi, (%rcx,%rsi,4)
incq %rsi
cmpq $0x4, %rsi
jne 0x647e
incq %rax
incq %rdx
addq $0x10, %rcx
cmpq $0x3, %rdx
jne 0x6469
movl %ebp, 0xc(%rsp)
movdqa 0x70(%rsp), %xmm0
movdqa 0x80(%rsp), %xmm1
movdqa 0x90(%rsp), %xmm2
movdqa 0xa0(%rsp), %xmm3
movdqa %xmm3, 0x50(%rsp)
movdqa %xmm2, 0x40(%rsp)
movdqa %xmm1, 0x30(%rsp)
movdqa %xmm0, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x68(%rsp)
shlq $0x4, %rax
leaq 0x2ead(%rip), %rcx      # 0x93a0
movl (%rax,%rcx), %esi
movl %esi, 0x14(%rsp)
movl 0x4(%rax,%rcx), %esi
movl %esi, 0x10(%rsp)
movl 0x8(%rax,%rcx), %r13d
movl 0xc(%rax,%rcx), %r14d
xorl %r15d, %r15d
movl 0x20(%rsp,%r15,4), %esi
movl 0x14(%rsp), %edi
callq 0x6f4c
movl %eax, %ebp
movl 0x30(%rsp,%r15,4), %esi
movl 0x10(%rsp), %edi
callq 0x6f4c
movl %eax, %ebx
xorl %ebp, %ebx
movl 0x40(%rsp,%r15,4), %esi
movl %r13d, %edi
callq 0x6f4c
movl %eax, %ebp
movl 0x50(%rsp,%r15,4), %esi
movl %r14d, %edi
callq 0x6f4c
xorl %ebp, %eax
xorl %ebx, %eax
movl %eax, (%r12,%r15,4)
incq %r15
cmpq $0x4, %r15
jne 0x650f
movq 0x68(%rsp), %rax
incq %rax
addq $0x10, %r12
cmpq $0x4, %rax
jne 0x64e3
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movl 0xc(%rsp), %ebp
movl %ebp, %esi
callq 0x6675
incl %ebp
cmpl $0xa, %ebp
leaq 0x29dd(%rip), %rbx      # 0x8f70
leaq 0x80(%rsp), %r8
jne 0x642a
leaq 0x70(%rsp), %rax
xorl %ecx, %ecx
xorl %edx, %edx
movl (%rax,%rdx,4), %esi
movl %esi, %edi
andl $0xf, %edi
andl $0xf0, %esi
leaq (%rbx,%rsi,4), %rsi
movl (%rsi,%rdi,4), %esi
movl %esi, (%rax,%rdx,4)
incq %rdx
cmpq $0x4, %rdx
jne 0x65aa
incq %rcx
addq $0x10, %rax
cmpq $0x4, %rcx
jne 0x65a8
movl $0x1, %eax
leaq 0x80(%rsp), %rcx
xorl %edx, %edx
movq %rcx, %rsi
movq %rdx, %rdi
shlq $0x4, %rdi
movdqa (%rcx,%rdi), %xmm0
movdqa %xmm0, 0x20(%rsp)
xorl %edi, %edi
leal (%rax,%rdi), %r8d
andl $0x3, %r8d
movl 0x20(%rsp,%r8,4), %r8d
movl %r8d, (%rsi,%rdi,4)
incq %rdi
cmpq $0x4, %rdi
jne 0x65fe
incq %rax
incq %rdx
addq $0x10, %rsi
cmpq $0x3, %rdx
jne 0x65ea
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x6675
xorl %eax, %eax
movq 0x18(%rsp), %rsi
xorl %ecx, %ecx
movb (%r14,%rcx), %dl
movb %dl, (%rsi)
incq %rsi
addq $0x10, %rcx
cmpq $0x40, %rcx
jne 0x6643
incq %rax
addq $0x4, %r14
cmpq $0x4, %rax
jne 0x6641
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq