// File: /workspace/github_c_makefile_star2_O1/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), %ebp
xorq 0x18(%rax), %rbp
addq $0x20, %rax
movl (%rdi), %edi
sarl %edi
testl %esi, %esi
je 0x1a18
leaq 0x8b43(%rip), %r14      # 0xa260
leaq 0x933c(%rip), %rdx      # 0xaa60
cmpl $0x2, %edi
jl 0x1917
incl %edi
movl $0xff, %esi
movl %r8d, %r11d
andl %esi, %r11d
leaq 0x8b1f(%rip), %rcx      # 0xa260
movl (%rcx,%r11,8), %r12d
movq %rcx, %r9
xorl (%rax), %r12d
movl %ebx, %r11d
shrl $0x8, %r11d
andl %esi, %r11d
xorl (%rdx,%r11,8), %r12d
movl %r10d, %r11d
shrl $0xd, %r11d
movl $0x7f8, %ecx            # imm = 0x7F8
andl %ecx, %r11d
movl $0x7f8, %r14d           # imm = 0x7F8
leaq 0x9aeb(%rip), %r15      # 0xb260
xorl (%r11,%r15), %r12d
movl %ebp, %r11d
shrl $0x18, %r11d
leaq 0xa2d9(%rip), %rcx      # 0xba60
xorl (%rcx,%r11,8), %r12d
movl %ebx, %r11d
andl %esi, %r11d
movl (%r9,%r11,8), %r13d
xorl 0x8(%rax), %r13d
movl %r10d, %r11d
shrl $0x8, %r11d
andl %esi, %r11d
xorl (%rdx,%r11,8), %r13d
movl %ebp, %r11d
shrl $0xd, %r11d
andl %r14d, %r11d
xorl (%r11,%r15), %r13d
movl %r8d, %r11d
shrl $0x18, %r11d
xorl (%rcx,%r11,8), %r13d
movl %r10d, %r11d
andl %esi, %r11d
movl (%r9,%r11,8), %r11d
movq %r9, %r14
xorl 0x10(%rax), %r11d
movq %rdx, %r9
movl %ebp, %edx
shrl $0x8, %edx
andl %esi, %edx
xorl (%r9,%rdx,8), %r11d
movl %r8d, %edx
shrl $0xd, %edx
movl $0x7f8, %r15d           # imm = 0x7F8
andl %r15d, %edx
leaq 0x9a6b(%rip), %r15      # 0xb260
xorl (%rdx,%r15), %r11d
movl %ebx, %edx
shrl $0x18, %edx
xorl (%rcx,%rdx,8), %r11d
andl %esi, %ebp
movl (%r14,%rbp,8), %edx
xorl 0x18(%rax), %edx
shrl $0x8, %r8d
andl %esi, %r8d
xorl (%r9,%r8,8), %edx
shrl $0xd, %ebx
movl $0x7f8, %ebp            # imm = 0x7F8
andl %ebp, %ebx
xorl (%rbx,%r15), %edx
shrl $0x18, %r10d
xorl (%rcx,%r10,8), %edx
movl %r12d, %r8d
andl %esi, %r8d
movq (%r14,%r8,8), %r8
xorq 0x20(%rax), %r8
movl %r13d, %r10d
shrl $0x8, %r10d
andl %esi, %r10d
xorq (%r9,%r10,8), %r8
movl %r11d, %r10d
shrl $0xd, %r10d
andl %ebp, %r10d
xorq (%r10,%r15), %r8
movl %edx, %r10d
shrl $0x18, %r10d
xorq (%rcx,%r10,8), %r8
movl %r13d, %r10d
andl %esi, %r10d
movq (%r14,%r10,8), %rbx
xorq 0x28(%rax), %rbx
movl %r11d, %r10d
shrl $0x8, %r10d
andl %esi, %r10d
xorq (%r9,%r10,8), %rbx
movl %edx, %r10d
shrl $0xd, %r10d
andl %ebp, %r10d
xorq (%r10,%r15), %rbx
movl %r12d, %r10d
shrl $0x18, %r10d
xorq (%rcx,%r10,8), %rbx
movl %r11d, %r10d
andl %esi, %r10d
movq (%r14,%r10,8), %r10
xorq 0x30(%rax), %r10
movl %edx, %ebp
shrl $0x8, %ebp
andl %esi, %ebp
xorq (%r9,%rbp,8), %r10
movl %r12d, %ebp
shrl $0xd, %ebp
movl $0x7f8, %r14d           # imm = 0x7F8
andl %r14d, %ebp
xorq (%rbp,%r15), %r10
movl %r13d, %ebp
shrl $0x18, %ebp
xorq (%rcx,%rbp,8), %r10
andl %esi, %edx
leaq 0x898a(%rip), %rbp      # 0xa260
movq (%rbp,%rdx,8), %rbp
movq %r9, %rdx
xorq 0x38(%rax), %rbp
shrl $0x8, %r12d
andl %esi, %r12d
xorq (%r9,%r12,8), %rbp
shrl $0xd, %r13d
andl %r14d, %r13d
xorq (%r13,%r15), %rbp
shrl $0x18, %r11d
xorq (%rcx,%r11,8), %rbp
addq $0x40, %rax
decl %edi
cmpl $0x2, %edi
jg 0x1734
leaq 0x8949(%rip), %r14      # 0xa260
movl $0xff, %r11d
movl %r8d, %ecx
andl %r11d, %ecx
movq (%r14,%rcx,8), %r12
xorq (%rax), %r12
movl %ebx, %ecx
shrl $0x8, %ecx
andl %r11d, %ecx
xorq (%rdx,%rcx,8), %r12
movq %rdx, %r9
movl %r10d, %edx
shrl $0xd, %edx
movl $0x7f8, %ecx            # imm = 0x7F8
andl %ecx, %edx
movl $0x7f8, %r15d           # imm = 0x7F8
leaq 0x990d(%rip), %rdi      # 0xb260
xorq (%rdx,%rdi), %r12
movl %ebp, %edx
shrl $0x18, %edx
leaq 0xa0fd(%rip), %rcx      # 0xba60
xorq (%rcx,%rdx,8), %r12
movl %ebx, %edx
andl %r11d, %edx
movq (%r14,%rdx,8), %rsi
xorq 0x8(%rax), %rsi
movl %r10d, %edx
shrl $0x8, %edx
andl %r11d, %edx
xorq (%r9,%rdx,8), %rsi
movl %ebp, %edx
shrl $0xd, %edx
andl %r15d, %edx
movl $0x7f8, %r13d           # imm = 0x7F8
xorq (%rdx,%rdi), %rsi
movl %r8d, %edx
shrl $0x18, %edx
xorq (%rcx,%rdx,8), %rsi
movl %r10d, %edx
andl %r11d, %edx
movq (%r14,%rdx,8), %r15
xorq 0x10(%rax), %r15
movl %ebp, %edx
shrl $0x8, %edx
andl %r11d, %edx
xorq (%r9,%rdx,8), %r15
movl %r8d, %edx
shrl $0xd, %edx
andl %r13d, %edx
xorq (%rdx,%rdi), %r15
movl %ebx, %edx
shrl $0x18, %edx
xorq (%rcx,%rdx,8), %r15
andl %r11d, %ebp
movq (%r14,%rbp,8), %r13
xorq 0x18(%rax), %r13
shrl $0x8, %r8d
andl %r11d, %r8d
xorq (%r9,%r8,8), %r13
shrl $0xd, %ebx
movl $0x7f8, %edx            # imm = 0x7F8
andl %edx, %ebx
xorq (%rbx,%rdi), %r13
shrl $0x18, %r10d
xorq (%rcx,%r10,8), %r13
leaq 0x6660(%rip), %rdx      # 0x8060
movq %rsi, %rdi
movq %r15, -0x20(%rsp)
movq %r13, %rcx
movq %r12, %r8
movq %r12, -0x28(%rsp)
jmp 0x1cff
leaq 0x6741(%rip), %r11      # 0x8160
leaq 0x6f3a(%rip), %r9       # 0x8960
cmpl $0x2, %edi
jl 0x1c17
incl %edi
movl $0xff, %esi
movl %r8d, %ecx
andl %esi, %ecx
movl (%r11,%rcx,8), %r12d
xorl (%rax), %r12d
movl %ebp, %ecx
shrl $0x8, %ecx
andl %esi, %ecx
xorl (%r9,%rcx,8), %r12d
movl %r10d, %ecx
shrl $0xd, %ecx
movl $0x7f8, %edx            # imm = 0x7F8
andl %edx, %ecx
leaq 0x76ff(%rip), %r15      # 0x9160
xorl (%rcx,%r15), %r12d
movq %r15, %r14
movl %ebx, %ecx
shrl $0x18, %ecx
leaq 0x7eec(%rip), %r15      # 0x9960
xorl (%r15,%rcx,8), %r12d
movl %ebx, %ecx
andl %esi, %ecx
movl (%r11,%rcx,8), %r13d
xorl 0x8(%rax), %r13d
movl %r8d, %ecx
shrl $0x8, %ecx
andl %esi, %ecx
xorl (%r9,%rcx,8), %r13d
movl %ebp, %ecx
shrl $0xd, %ecx
andl %edx, %ecx
xorl (%rcx,%r14), %r13d
movl %r10d, %ecx
shrl $0x18, %ecx
xorl (%r15,%rcx,8), %r13d
movl %r10d, %ecx
andl %esi, %ecx
movl (%r11,%rcx,8), %ecx
xorl 0x10(%rax), %ecx
movq %r11, %r14
movq %r9, %r11
movl %ebx, %r9d
shrl $0x8, %r9d
andl %esi, %r9d
xorl (%r11,%r9,8), %ecx
movl %r8d, %r9d
shrl $0xd, %r9d
andl %edx, %r9d
leaq 0x768a(%rip), %rdx      # 0x9160
xorl (%r9,%rdx), %ecx
movl %ebp, %r9d
shrl $0x18, %r9d
xorl (%r15,%r9,8), %ecx
andl %esi, %ebp
movl (%r14,%rbp,8), %edx
xorl 0x18(%rax), %edx
shrl $0x8, %r10d
andl %esi, %r10d
xorl (%r11,%r10,8), %edx
shrl $0xd, %ebx
movl $0x7f8, %r10d           # imm = 0x7F8
andl %r10d, %ebx
leaq 0x7654(%rip), %rbp      # 0x9160
xorl (%rbx,%rbp), %edx
shrl $0x18, %r8d
xorl (%r15,%r8,8), %edx
movl %r12d, %r8d
andl %esi, %r8d
movq (%r14,%r8,8), %r8
xorq 0x20(%rax), %r8
movl %edx, %r9d
shrl $0x8, %r9d
andl %esi, %r9d
xorq (%r11,%r9,8), %r8
movl %ecx, %r9d
shrl $0xd, %r9d
andl %r10d, %r9d
xorq (%r9,%rbp), %r8
movl %r13d, %r9d
shrl $0x18, %r9d
xorq (%r15,%r9,8), %r8
movq %r15, %r10
movl %r13d, %r9d
andl %esi, %r9d
movq (%r14,%r9,8), %rbx
xorq 0x28(%rax), %rbx
movl %r12d, %r9d
shrl $0x8, %r9d
andl %esi, %r9d
xorq (%r11,%r9,8), %rbx
movl %edx, %r9d
shrl $0xd, %r9d
movl $0x7f8, %r15d           # imm = 0x7F8
andl %r15d, %r9d
xorq (%r9,%rbp), %rbx
movq %rbp, %r15
movl %ecx, %r9d
shrl $0x18, %r9d
xorq (%r10,%r9,8), %rbx
movl %ecx, %r9d
andl %esi, %r9d
movq (%r14,%r9,8), %r10
xorq 0x30(%rax), %r10
movl %r13d, %r9d
shrl $0x8, %r9d
andl %esi, %r9d
xorq (%r11,%r9,8), %r10
movl %r12d, %r9d
shrl $0xd, %r9d
movl $0x7f8, %ebp            # imm = 0x7F8
andl %ebp, %r9d
xorq (%r9,%r15), %r10
movl %edx, %r9d
shrl $0x18, %r9d
leaq 0x7d96(%rip), %rbp      # 0x9960
xorq (%rbp,%r9,8), %r10
movq %r11, %r9
movq %r14, %r11
andl %esi, %edx
movq (%r14,%rdx,8), %rbp
xorq 0x38(%rax), %rbp
shrl $0x8, %ecx
andl %esi, %ecx
xorq (%r9,%rcx,8), %rbp
shrl $0xd, %r13d
movl $0x7f8, %ecx            # imm = 0x7F8
andl %ecx, %r13d
xorq (%r13,%r15), %rbp
shrl $0x18, %r12d
leaq 0x7d5c(%rip), %rcx      # 0x9960
xorq (%rcx,%r12,8), %rbp
addq $0x40, %rax
decl %edi
cmpl $0x2, %edi
jg 0x1a36
movl $0xff, %ecx
movl %r8d, %esi
andl %ecx, %esi
movq (%r11,%rsi,8), %r12
xorq (%rax), %r12
movl %ebp, %edi
shrl $0x8, %edi
andl %ecx, %edi
xorq (%r9,%rdi,8), %r12
movl %r10d, %edi
shrl $0xd, %edi
movl $0x7f8, %edx            # imm = 0x7F8
andl %edx, %edi
movl $0x7f8, %esi            # imm = 0x7F8
leaq 0x7514(%rip), %rdx      # 0x9160
xorq (%rdi,%rdx), %r12
movl %ebx, %edi
shrl $0x18, %edi
leaq 0x7d04(%rip), %r14      # 0x9960
xorq (%r14,%rdi,8), %r12
movl %ebx, %edi
andl %ecx, %edi
movq (%r11,%rdi,8), %r13
xorq 0x8(%rax), %r13
movl %r8d, %edi
shrl $0x8, %edi
andl %ecx, %edi
xorq (%r9,%rdi,8), %r13
movl %ebp, %edi
shrl $0xd, %edi
andl %esi, %edi
xorq (%rdi,%rdx), %r13
movl %r10d, %edi
shrl $0x18, %edi
xorq (%r14,%rdi,8), %r13
movl %r10d, %edi
andl %ecx, %edi
movq (%r11,%rdi,8), %r15
xorq 0x10(%rax), %r15
movl %ebx, %edi
shrl $0x8, %edi
andl %ecx, %edi
xorq (%r9,%rdi,8), %r15
movl %r8d, %edi
shrl $0xd, %edi
andl %esi, %edi
xorq (%rdi,%rdx), %r15
movl %ebp, %edi
shrl $0x18, %edi
xorq (%r14,%rdi,8), %r15
andl %ecx, %ebp
movq (%r11,%rbp,8), %rsi
xorq 0x18(%rax), %rsi
shrl $0x8, %r10d
andl %ecx, %r10d
xorq (%r9,%r10,8), %rsi
shrl $0xd, %ebx
movl $0x7f8, %ecx            # imm = 0x7F8
andl %ecx, %ebx
xorq (%rbx,%rdx), %rsi
shrl $0x18, %r8d
xorq (%r14,%r8,8), %rsi
leaq 0x8474(%rip), %rdx      # 0xa160
movq %r13, %rdi
movq %r12, %r8
movq %r12, -0x20(%rsp)
movq %rsi, %rcx
movq %r15, -0x28(%rsp)
movl $0xff, %r14d
movl $0xff, %r9d
movl %r15d, %r10d
shrl $0x10, %r10d
andl %r9d, %r10d
movzbl (%rdx,%r10), %r10d
shll $0x10, %r10d
movl %r13d, %r11d
shrl $0x18, %r11d
movzbl (%rdx,%r11), %r11d
shll $0x18, %r11d
orl %r10d, %r11d
movl %esi, %r10d
shrl $0x8, %r10d
andl %r9d, %r10d
movzbl (%rdx,%r10), %r10d
shll $0x8, %r10d
orl %r10d, %r11d
movl %r11d, -0x2c(%rsp)
movq %r8, %r10
andq %r14, %r10
movzbl (%rdx,%r10), %r10d
xorq 0x20(%rax), %r10
movq %r10, -0x10(%rsp)
movq %rdi, %rbp
andq %r14, %rbp
andq %r14, %r15
movl %ecx, %ebx
andq %r14, %rcx
movzbl (%rdx,%rbp), %r11d
xorq 0x28(%rax), %r11
movzbl (%rdx,%r15), %r15d
xorq 0x30(%rax), %r15
movzbl (%rdx,%rcx), %ecx
xorq 0x38(%rax), %rcx
movq %rcx, -0x18(%rsp)
movq -0x20(%rsp), %r12
movl %r12d, %eax
shrl $0x8, %eax
andl %r9d, %eax
shrl $0x10, %ebx
andl %r9d, %ebx
shrl $0x8, %r13d
andl %r9d, %r13d
shrl $0x10, %r8d
andl %r9d, %r8d
movq -0x28(%rsp), %rbp
movq %rsi, %r14
movl %ebp, %esi
shrl $0x8, %ebp
andl %r9d, %ebp
shrl $0x10, %edi
andl %r9d, %edi
movzbl (%rdx,%rax), %ecx
movzbl (%rdx,%rbx), %r10d
shrl $0x18, %esi
movzbl (%rdx,%rsi), %r9d
movzbl (%rdx,%r13), %ebx
movzbl (%rdx,%r8), %r8d
shrl $0x18, %r14d
movzbl (%rdx,%r14), %esi
movzbl (%rdx,%rbp), %ebp
movzbl (%rdx,%rdi), %r14d
shrl $0x18, %r12d
movzbl (%rdx,%r12), %eax
movq -0x8(%rsp), %rdi
movq -0x10(%rsp), %rdx
movb %dl, (%rdi)
xorl -0x2c(%rsp), %edx
shll $0x10, %r10d
shll $0x18, %r9d
orl %r10d, %r9d
shll $0x8, %ecx
orl %ecx, %r9d
movb %dh, 0x1(%rdi)
movl %edx, %r10d
shrl $0x10, %r10d
movb %r10b, 0x2(%rdi)
shrl $0x18, %edx
movb %dl, 0x3(%rdi)
movb %r11b, 0x4(%rdi)
movl %r11d, %edx
xorl %r9d, %edx
shll $0x10, %r8d
shll $0x18, %esi
orl %r8d, %esi
shll $0x8, %ebx
orl %ebx, %esi
movb %dh, 0x5(%rdi)
movl %edx, %r9d
shrl $0x10, %r9d
movb %r9b, 0x6(%rdi)
shrl $0x18, %edx
movb %dl, 0x7(%rdi)
movb %r15b, 0x8(%rdi)
movl %r15d, %edx
xorl %esi, %edx
shll $0x10, %r14d
shll $0x18, %eax
orl %r14d, %eax
shll $0x8, %ebp
orl %ebp, %eax
movb %dh, 0x9(%rdi)
movl %edx, %ecx
shrl $0x10, %ecx
movb %cl, 0xa(%rdi)
shrl $0x18, %edx
movb %dl, 0xb(%rdi)
movq -0x18(%rsp), %rcx
movb %cl, 0xc(%rdi)
xorl %eax, %ecx
movb %ch, 0xd(%rdi)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0xe(%rdi)
shrl $0x18, %ecx
movb %cl, 0xf(%rdi)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq