// File: /workspace/github_c_makefile_star2_O2/zecoxao[P]ps3_decrypt_tools/lib/aes.c
// Function: aes_crypt_ecb
int aes_crypt_ecb(aes_context *ctx,
        int mode,
        const unsigned char input[16],
        unsigned char output[16]) {
    int i;
    unsigned long *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;

    RK = ctx->rk;

    GET_ULONG_LE(X0, input, 0);
    X0 ^= *RK++;
    GET_ULONG_LE(X1, input, 4);
    X1 ^= *RK++;
    GET_ULONG_LE(X2, input, 8);
    X2 ^= *RK++;
    GET_ULONG_LE(X3, input, 12);
    X3 ^= *RK++;

    if (mode == AES_DECRYPT) {
        for (i = (ctx->nr >> 1) - 1; i > 0; i--) {
            AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);
            AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);
        }

        AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);

        X0 = *RK++ ^ \
                ((unsigned long) RSb[ (Y0) & 0xFF ]) ^
                ((unsigned long) RSb[ (Y3 >> 8) & 0xFF ] << 8) ^
                ((unsigned long) RSb[ (Y2 >> 16) & 0xFF ] << 16) ^
                ((unsigned long) RSb[ (Y1 >> 24) & 0xFF ] << 24);

        X1 = *RK++ ^ \
                ((unsigned long) RSb[ (Y1) & 0xFF ]) ^
                ((unsigned long) RSb[ (Y0 >> 8) & 0xFF ] << 8) ^
                ((unsigned long) RSb[ (Y3 >> 16) & 0xFF ] << 16) ^
                ((unsigned long) RSb[ (Y2 >> 24) & 0xFF ] << 24);

        X2 = *RK++ ^ \
                ((unsigned long) RSb[ (Y2) & 0xFF ]) ^
                ((unsigned long) RSb[ (Y1 >> 8) & 0xFF ] << 8) ^
                ((unsigned long) RSb[ (Y0 >> 16) & 0xFF ] << 16) ^
                ((unsigned long) RSb[ (Y3 >> 24) & 0xFF ] << 24);

        X3 = *RK++ ^ \
                ((unsigned long) RSb[ (Y3) & 0xFF ]) ^
                ((unsigned long) RSb[ (Y2 >> 8) & 0xFF ] << 8) ^
                ((unsigned long) RSb[ (Y1 >> 16) & 0xFF ] << 16) ^
                ((unsigned long) RSb[ (Y0 >> 24) & 0xFF ] << 24);
    } else /* AES_ENCRYPT */ {
        for (i = (ctx->nr >> 1) - 1; i > 0; i--) {
            AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);
            AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);
        }

        AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);

        X0 = *RK++ ^ \
                ((unsigned long) FSb[ (Y0) & 0xFF ]) ^
                ((unsigned long) FSb[ (Y1 >> 8) & 0xFF ] << 8) ^
                ((unsigned long) FSb[ (Y2 >> 16) & 0xFF ] << 16) ^
                ((unsigned long) FSb[ (Y3 >> 24) & 0xFF ] << 24);

        X1 = *RK++ ^ \
                ((unsigned long) FSb[ (Y1) & 0xFF ]) ^
                ((unsigned long) FSb[ (Y2 >> 8) & 0xFF ] << 8) ^
                ((unsigned long) FSb[ (Y3 >> 16) & 0xFF ] << 16) ^
                ((unsigned long) FSb[ (Y0 >> 24) & 0xFF ] << 24);

        X2 = *RK++ ^ \
                ((unsigned long) FSb[ (Y2) & 0xFF ]) ^
                ((unsigned long) FSb[ (Y3 >> 8) & 0xFF ] << 8) ^
                ((unsigned long) FSb[ (Y0 >> 16) & 0xFF ] << 16) ^
                ((unsigned long) FSb[ (Y1 >> 24) & 0xFF ] << 24);

        X3 = *RK++ ^ \
                ((unsigned long) FSb[ (Y3) & 0xFF ]) ^
                ((unsigned long) FSb[ (Y0 >> 8) & 0xFF ] << 8) ^
                ((unsigned long) FSb[ (Y1 >> 16) & 0xFF ] << 16) ^
                ((unsigned long) FSb[ (Y2 >> 24) & 0xFF ] << 24);
    }

    PUT_ULONG_LE(X0, output, 0);
    PUT_ULONG_LE(X1, output, 4);
    PUT_ULONG_LE(X2, output, 8);
    PUT_ULONG_LE(X3, output, 12);

    return ( 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x8(%rdi), %rax
movl (%rdx), %r8d
movl 0x4(%rdx), %ebx
xorq (%rax), %r8
xorq 0x8(%rax), %rbx
movq %rcx, -0x8(%rsp)
movl 0x8(%rdx), %r10d
xorq 0x10(%rax), %r10
movl 0xc(%rdx), %r14d
xorq 0x18(%rax), %r14
addq $0x20, %rax
movl (%rdi), %edx
sarl %edx
movl $0xff, %ebp
testl %esi, %esi
je 0x1987
leaq 0x7b96(%rip), %rcx      # 0x9280
leaq 0x838f(%rip), %r9       # 0x9a80
movl $0x7f8, %r15d           # imm = 0x7F8
leaq 0x8b82(%rip), %rdi      # 0xa280
leaq 0x937b(%rip), %rsi      # 0xaa80
cmpl $0x2, %edx
jl 0x18a0
movl %edx, -0x20(%rsp)
movl %r8d, %edx
andl %ebp, %edx
movl (%rcx,%rdx,8), %r12d
xorl (%rax), %r12d
movl %ebx, %edx
shrl $0x8, %edx
andl %ebp, %edx
xorl (%r9,%rdx,8), %r12d
movl %r10d, %edx
shrl $0xd, %edx
andl %r15d, %edx
xorl (%rdx,%rdi), %r12d
movl %r14d, %edx
shrl $0x18, %edx
xorl (%rsi,%rdx,8), %r12d
movl %ebx, %edx
andl %ebp, %edx
movl (%rcx,%rdx,8), %r13d
xorl 0x8(%rax), %r13d
movl %r10d, %edx
shrl $0x8, %edx
andl %ebp, %edx
xorl (%r9,%rdx,8), %r13d
movl %r14d, %edx
shrl $0xd, %edx
andl %r15d, %edx
xorl (%rdx,%rdi), %r13d
movl %r8d, %edx
shrl $0x18, %edx
xorl (%rsi,%rdx,8), %r13d
movl %r10d, %edx
andl %ebp, %edx
movl (%rcx,%rdx,8), %edx
xorl 0x10(%rax), %edx
movl %r14d, %r11d
shrl $0x8, %r11d
andl %ebp, %r11d
xorl (%r9,%r11,8), %edx
movl %r8d, %r11d
shrl $0xd, %r11d
andl %r15d, %r11d
xorl (%r11,%rdi), %edx
movl %ebx, %r11d
shrl $0x18, %r11d
xorl (%rsi,%r11,8), %edx
andl %ebp, %r14d
movl (%rcx,%r14,8), %r11d
xorl 0x18(%rax), %r11d
shrl $0x8, %r8d
andl %ebp, %r8d
xorl (%r9,%r8,8), %r11d
shrl $0xd, %ebx
andl %r15d, %ebx
xorl (%rbx,%rdi), %r11d
shrl $0x18, %r10d
xorl (%rsi,%r10,8), %r11d
movl %r12d, %r8d
andl %ebp, %r8d
movq (%rcx,%r8,8), %r8
xorq 0x20(%rax), %r8
movl %r13d, %r10d
shrl $0x8, %r10d
andl %ebp, %r10d
xorq (%r9,%r10,8), %r8
movl %edx, %r10d
shrl $0xd, %r10d
andl %r15d, %r10d
xorq (%r10,%rdi), %r8
movl %r11d, %r10d
shrl $0x18, %r10d
xorq (%rsi,%r10,8), %r8
movl %r13d, %r10d
andl %ebp, %r10d
movq (%rcx,%r10,8), %rbx
xorq 0x28(%rax), %rbx
movl %edx, %r10d
shrl $0x8, %r10d
andl %ebp, %r10d
xorq (%r9,%r10,8), %rbx
movl %r11d, %r10d
shrl $0xd, %r10d
andl %r15d, %r10d
xorq (%r10,%rdi), %rbx
movl %r12d, %r10d
shrl $0x18, %r10d
xorq (%rsi,%r10,8), %rbx
movl %edx, %r10d
andl %ebp, %r10d
movq (%rcx,%r10,8), %r10
xorq 0x30(%rax), %r10
movl %r11d, %r14d
shrl $0x8, %r14d
andl %ebp, %r14d
xorq (%r9,%r14,8), %r10
movl %r12d, %r14d
shrl $0xd, %r14d
andl %r15d, %r14d
xorq (%r14,%rdi), %r10
movl %r13d, %r14d
shrl $0x18, %r14d
xorq (%rsi,%r14,8), %r10
andl %ebp, %r11d
movq (%rcx,%r11,8), %r14
xorq 0x38(%rax), %r14
shrl $0x8, %r12d
andl %ebp, %r12d
xorq (%r9,%r12,8), %r14
shrl $0xd, %r13d
andl %r15d, %r13d
xorq (%r13,%rdi), %r14
shrl $0x18, %edx
xorq (%rsi,%rdx,8), %r14
movl -0x20(%rsp), %edx
decl %edx
addq $0x40, %rax
jmp 0x1705
movl $0xff, %r15d
movl %r8d, %edx
andl %r15d, %edx
movq (%rcx,%rdx,8), %r12
xorq (%rax), %r12
movl %ebx, %edx
shrl $0x8, %edx
andl %r15d, %edx
xorq (%r9,%rdx,8), %r12
movl %r10d, %edx
shrl $0xd, %edx
movl $0x7f8, %ebp            # imm = 0x7F8
andl %ebp, %edx
xorq (%rdx,%rdi), %r12
movl %r14d, %edx
shrl $0x18, %edx
xorq (%rsi,%rdx,8), %r12
movl %ebx, %edx
andl %r15d, %edx
movq (%rcx,%rdx,8), %rdx
xorq 0x8(%rax), %rdx
movl %r10d, %r11d
shrl $0x8, %r11d
andl %r15d, %r11d
xorq (%r9,%r11,8), %rdx
movl %r14d, %r11d
shrl $0xd, %r11d
andl %ebp, %r11d
xorq (%r11,%rdi), %rdx
movl %r8d, %r11d
shrl $0x18, %r11d
xorq (%rsi,%r11,8), %rdx
movl %r10d, %r11d
andl %r15d, %r11d
movq (%rcx,%r11,8), %r13
xorq 0x10(%rax), %r13
movl %r14d, %r11d
shrl $0x8, %r11d
andl %r15d, %r11d
xorq (%r9,%r11,8), %r13
movl %r8d, %r11d
shrl $0xd, %r11d
andl %ebp, %r11d
xorq (%r11,%rdi), %r13
movl %ebx, %r11d
shrl $0x18, %r11d
xorq (%rsi,%r11,8), %r13
movq %r12, %r11
andl %r15d, %r14d
movq (%rcx,%r14,8), %r12
xorq 0x18(%rax), %r12
shrl $0x8, %r8d
andl %r15d, %r8d
xorq (%r9,%r8,8), %r12
shrl $0xd, %ebx
andl %ebp, %ebx
xorq (%rbx,%rdi), %r12
shrl $0x18, %r10d
xorq (%rsi,%r10,8), %r12
leaq 0x570c(%rip), %rsi      # 0x7080
movq %rdx, %rbp
movq %r13, %rbx
movq %r12, %r15
movq %r11, -0x20(%rsp)
jmp 0x1c4b
leaq 0x57f2(%rip), %r15      # 0x7180
leaq 0x67eb(%rip), %rsi      # 0x8180
cmpl $0x2, %edx
jl 0x1b59
movl %edx, -0x20(%rsp)
movl %r8d, %edx
andl %ebp, %edx
movl (%r15,%rdx,8), %r12d
xorl (%rax), %r12d
movl %r14d, %edx
shrl $0x8, %edx
andl %ebp, %edx
leaq 0x5fc3(%rip), %rdi      # 0x7980
xorl (%rdi,%rdx,8), %r12d
movl %r10d, %edx
shrl $0xd, %edx
movl $0x7f8, %ecx            # imm = 0x7F8
andl %ecx, %edx
movl $0x7f8, %r11d           # imm = 0x7F8
xorl (%rdx,%rsi), %r12d
movl %ebx, %edx
shrl $0x18, %edx
leaq 0x6f9c(%rip), %rcx      # 0x8980
xorl (%rcx,%rdx,8), %r12d
movl %ebx, %edx
andl %ebp, %edx
movl (%r15,%rdx,8), %r13d
xorl 0x8(%rax), %r13d
movl %r8d, %edx
shrl $0x8, %edx
andl %ebp, %edx
xorl (%rdi,%rdx,8), %r13d
movl %r14d, %edx
shrl $0xd, %edx
andl %r11d, %edx
xorl (%rdx,%rsi), %r13d
movl %r10d, %edx
shrl $0x18, %edx
xorl (%rcx,%rdx,8), %r13d
movl %r10d, %edx
andl %ebp, %edx
movl (%r15,%rdx,8), %edx
xorl 0x10(%rax), %edx
movl %ebx, %r9d
shrl $0x8, %r9d
andl %ebp, %r9d
xorl (%rdi,%r9,8), %edx
movl %r8d, %r9d
shrl $0xd, %r9d
andl %r11d, %r9d
xorl (%r9,%rsi), %edx
movl %r14d, %r9d
shrl $0x18, %r9d
xorl (%rcx,%r9,8), %edx
andl %ebp, %r14d
movl (%r15,%r14,8), %r11d
xorl 0x18(%rax), %r11d
shrl $0x8, %r10d
andl %ebp, %r10d
xorl (%rdi,%r10,8), %r11d
shrl $0xd, %ebx
movl $0x7f8, %r10d           # imm = 0x7F8
andl %r10d, %ebx
xorl (%rbx,%rsi), %r11d
shrl $0x18, %r8d
xorl (%rcx,%r8,8), %r11d
movl %r12d, %r8d
andl %ebp, %r8d
movq (%r15,%r8,8), %r8
xorq 0x20(%rax), %r8
movl %r11d, %r9d
shrl $0x8, %r9d
andl %ebp, %r9d
xorq (%rdi,%r9,8), %r8
movl %edx, %r9d
shrl $0xd, %r9d
andl %r10d, %r9d
xorq (%r9,%rsi), %r8
movl %r13d, %r9d
shrl $0x18, %r9d
xorq (%rcx,%r9,8), %r8
movl %r13d, %r9d
andl %ebp, %r9d
movq (%r15,%r9,8), %rbx
xorq 0x28(%rax), %rbx
movl %r12d, %r9d
shrl $0x8, %r9d
andl %ebp, %r9d
xorq (%rdi,%r9,8), %rbx
movl %r11d, %r9d
shrl $0xd, %r9d
andl %r10d, %r9d
movl $0x7f8, %r14d           # imm = 0x7F8
xorq (%r9,%rsi), %rbx
movl %edx, %r9d
shrl $0x18, %r9d
xorq (%rcx,%r9,8), %rbx
movl %edx, %r9d
andl %ebp, %r9d
movq (%r15,%r9,8), %r10
xorq 0x30(%rax), %r10
movl %r13d, %r9d
shrl $0x8, %r9d
andl %ebp, %r9d
xorq (%rdi,%r9,8), %r10
movl %r12d, %r9d
shrl $0xd, %r9d
andl %r14d, %r9d
xorq (%r9,%rsi), %r10
movl %r11d, %r9d
shrl $0x18, %r9d
xorq (%rcx,%r9,8), %r10
andl %ebp, %r11d
movq (%r15,%r11,8), %r14
xorq 0x38(%rax), %r14
shrl $0x8, %edx
andl %ebp, %edx
xorq (%rdi,%rdx,8), %r14
movl -0x20(%rsp), %edx
shrl $0xd, %r13d
movl $0x7f8, %edi            # imm = 0x7F8
andl %edi, %r13d
xorq (%r13,%rsi), %r14
shrl $0x18, %r12d
xorq (%rcx,%r12,8), %r14
decl %edx
addq $0x40, %rax
jmp 0x1995
movl $0xff, %r15d
movl %r8d, %ecx
andl %r15d, %ecx
leaq 0x5614(%rip), %rdx      # 0x7180
movq (%rdx,%rcx,8), %r11
xorq (%rax), %r11
movl %r14d, %ecx
shrl $0x8, %ecx
andl %r15d, %ecx
leaq 0x5dfd(%rip), %rdi      # 0x7980
xorq (%rdi,%rcx,8), %r11
movl %r10d, %ecx
shrl $0xd, %ecx
movl $0x7f8, %ebp            # imm = 0x7F8
andl %ebp, %ecx
leaq 0x65e5(%rip), %rsi      # 0x8180
xorq (%rcx,%rsi), %r11
movl %ebx, %ecx
shrl $0x18, %ecx
leaq 0x6dd5(%rip), %r9       # 0x8980
xorq (%r9,%rcx,8), %r11
movl %ebx, %ecx
andl %r15d, %ecx
movq (%rdx,%rcx,8), %r12
xorq 0x8(%rax), %r12
movl %r8d, %ecx
shrl $0x8, %ecx
andl %r15d, %ecx
xorq (%rdi,%rcx,8), %r12
movl %r14d, %ecx
shrl $0xd, %ecx
andl %ebp, %ecx
xorq (%rcx,%rsi), %r12
movl %r10d, %ecx
shrl $0x18, %ecx
xorq (%r9,%rcx,8), %r12
movl %r10d, %ecx
andl %r15d, %ecx
movq (%rdx,%rcx,8), %r13
xorq 0x10(%rax), %r13
movl %ebx, %ecx
shrl $0x8, %ecx
andl %r15d, %ecx
xorq (%rdi,%rcx,8), %r13
movl %r8d, %ecx
shrl $0xd, %ecx
andl %ebp, %ecx
xorq (%rcx,%rsi), %r13
movl %r14d, %ecx
shrl $0x18, %ecx
xorq (%r9,%rcx,8), %r13
andl %r15d, %r14d
movq (%rdx,%r14,8), %rdx
xorq 0x18(%rax), %rdx
shrl $0x8, %r10d
andl %r15d, %r10d
xorq (%rdi,%r10,8), %rdx
shrl $0xd, %ebx
andl %ebp, %ebx
xorq (%rbx,%rsi), %rdx
shrl $0x18, %r8d
xorq (%r9,%r8,8), %rdx
leaq 0x7543(%rip), %rsi      # 0x9180
movq %r12, %rbp
movq %r11, %rbx
movq %rdx, %r15
movq %r13, -0x20(%rsp)
movl $0xff, %r14d
movl $0xff, %r9d
movl %r13d, %ecx
shrl $0x10, %ecx
andl %r9d, %ecx
movzbl (%rsi,%rcx), %ecx
shll $0x10, %ecx
movl %r12d, %r10d
shrl $0x18, %r10d
movzbl (%rsi,%r10), %r10d
shll $0x18, %r10d
orl %ecx, %r10d
movl %edx, %ecx
shrl $0x8, %ecx
andl %r9d, %ecx
movzbl (%rsi,%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %r10d
movq %r11, %rcx
andq %r14, %rcx
movzbl (%rsi,%rcx), %ecx
xorq 0x20(%rax), %rcx
movq %rcx, -0x10(%rsp)
movq %rbp, %rcx
andq %r14, %rcx
andq %r14, %r13
movq %r11, %rdi
movl %r15d, %r11d
andq %r14, %r15
movzbl (%rsi,%rcx), %r8d
xorq 0x28(%rax), %r8
movzbl (%rsi,%r13), %r14d
xorq 0x30(%rax), %r14
movzbl (%rsi,%r15), %ecx
xorq 0x38(%rax), %rcx
movq %rcx, -0x18(%rsp)
movl %ebx, %eax
shrl $0x8, %eax
andl %r9d, %eax
shrl $0x10, %r11d
andl %r9d, %r11d
shrl $0x8, %r12d
andl %r9d, %r12d
shrl $0x10, %edi
andl %r9d, %edi
movq -0x20(%rsp), %rcx
movl %ecx, %r13d
shrl $0x8, %ecx
andl %r9d, %ecx
shrl $0x10, %ebp
andl %r9d, %ebp
movzbl (%rsi,%rax), %r9d
movzbl (%rsi,%r11), %r15d
shrl $0x18, %r13d
movzbl (%rsi,%r13), %r13d
movzbl (%rsi,%r12), %r11d
movzbl (%rsi,%rdi), %r12d
shrl $0x18, %edx
movzbl (%rsi,%rdx), %eax
movzbl (%rsi,%rcx), %ecx
movzbl (%rsi,%rbp), %ebp
shrl $0x18, %ebx
movzbl (%rsi,%rbx), %edi
movq -0x8(%rsp), %rdx
movq -0x10(%rsp), %rsi
movb %sil, (%rdx)
movl %esi, %ebx
xorl %r10d, %ebx
shll $0x10, %r15d
shll $0x18, %r13d
orl %r15d, %r13d
shll $0x8, %r9d
orl %r9d, %r13d
movb %bh, 0x1(%rdx)
movl %ebx, %esi
shrl $0x10, %esi
movb %sil, 0x2(%rdx)
shrl $0x18, %ebx
movb %bl, 0x3(%rdx)
movb %r8b, 0x4(%rdx)
movl %r8d, %ebx
xorl %r13d, %ebx
shll $0x10, %r12d
shll $0x18, %eax
orl %r12d, %eax
shll $0x8, %r11d
orl %r11d, %eax
movb %bh, 0x5(%rdx)
movl %ebx, %esi
shrl $0x10, %esi
movb %sil, 0x6(%rdx)
shrl $0x18, %ebx
movb %bl, 0x7(%rdx)
movb %r14b, 0x8(%rdx)
movl %r14d, %ebx
xorl %eax, %ebx
shll $0x10, %ebp
shll $0x18, %edi
orl %ebp, %edi
shll $0x8, %ecx
orl %ecx, %edi
movb %bh, 0x9(%rdx)
movl %ebx, %ecx
shrl $0x10, %ecx
movb %cl, 0xa(%rdx)
shrl $0x18, %ebx
movb %bl, 0xb(%rdx)
movq -0x18(%rsp), %rax
movb %al, 0xc(%rdx)
movl %eax, %ecx
xorl %edi, %ecx
movb %ch, 0xd(%rdx)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0xe(%rdx)
shrl $0x18, %ecx
movb %cl, 0xf(%rdx)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq