// File: /workspace/github_c_makefile_star2_O0/zecoxao[P]ps3_decrypt_tools/lib/des.c
// Function: des_setkey
static void des_setkey(uint32_t SK[32], const unsigned char key[DES_KEY_SIZE]) {
    int i;
    uint32_t X, Y, T;

    GET_UINT32_BE(X, key, 0);
    GET_UINT32_BE(Y, key, 4);

    /*
     * Permuted Choice 1
     */
    T = ((Y >> 4) ^ X) & 0x0F0F0F0F;
    X ^= T;
    Y ^= (T << 4);
    T = ((Y) ^ X) & 0x10101010;
    X ^= T;
    Y ^= (T);

    X = (LHs[ (X) & 0xF] << 3) | (LHs[ (X >> 8) & 0xF ] << 2)
            | (LHs[ (X >> 16) & 0xF] << 1) | (LHs[ (X >> 24) & 0xF ])
            | (LHs[ (X >> 5) & 0xF] << 7) | (LHs[ (X >> 13) & 0xF ] << 6)
            | (LHs[ (X >> 21) & 0xF] << 5) | (LHs[ (X >> 29) & 0xF ] << 4);

    Y = (RHs[ (Y >> 1) & 0xF] << 3) | (RHs[ (Y >> 9) & 0xF ] << 2)
            | (RHs[ (Y >> 17) & 0xF] << 1) | (RHs[ (Y >> 25) & 0xF ])
            | (RHs[ (Y >> 4) & 0xF] << 7) | (RHs[ (Y >> 12) & 0xF ] << 6)
            | (RHs[ (Y >> 20) & 0xF] << 5) | (RHs[ (Y >> 28) & 0xF ] << 4);

    X &= 0x0FFFFFFF;
    Y &= 0x0FFFFFFF;

    /*
     * calculate subkeys
     */
    for (i = 0; i < 16; i++) {
        if (i < 2 || i == 8 || i == 15) {
            X = ((X << 1) | (X >> 27)) & 0x0FFFFFFF;
            Y = ((Y << 1) | (Y >> 27)) & 0x0FFFFFFF;
        } else {
            X = ((X << 2) | (X >> 26)) & 0x0FFFFFFF;
            Y = ((Y << 2) | (Y >> 26)) & 0x0FFFFFFF;
        }

        *SK++ = ((X << 4) & 0x24000000) | ((X << 28) & 0x10000000)
                | ((X << 14) & 0x08000000) | ((X << 18) & 0x02080000)
                | ((X << 6) & 0x01000000) | ((X << 9) & 0x00200000)
                | ((X >> 1) & 0x00100000) | ((X << 10) & 0x00040000)
                | ((X << 2) & 0x00020000) | ((X >> 10) & 0x00010000)
                | ((Y >> 13) & 0x00002000) | ((Y >> 4) & 0x00001000)
                | ((Y << 6) & 0x00000800) | ((Y >> 1) & 0x00000400)
                | ((Y >> 14) & 0x00000200) | ((Y) & 0x00000100)
                | ((Y >> 5) & 0x00000020) | ((Y >> 10) & 0x00000010)
                | ((Y >> 3) & 0x00000008) | ((Y >> 18) & 0x00000004)
                | ((Y >> 26) & 0x00000002) | ((Y >> 24) & 0x00000001);

        *SK++ = ((X << 15) & 0x20000000) | ((X << 17) & 0x10000000)
                | ((X << 10) & 0x08000000) | ((X << 22) & 0x04000000)
                | ((X >> 2) & 0x02000000) | ((X << 1) & 0x01000000)
                | ((X << 16) & 0x00200000) | ((X << 11) & 0x00100000)
                | ((X << 3) & 0x00080000) | ((X >> 6) & 0x00040000)
                | ((X << 15) & 0x00020000) | ((X >> 4) & 0x00010000)
                | ((Y >> 2) & 0x00002000) | ((Y << 8) & 0x00001000)
                | ((Y >> 14) & 0x00000808) | ((Y >> 9) & 0x00000400)
                | ((Y) & 0x00000200) | ((Y << 7) & 0x00000100)
                | ((Y >> 7) & 0x00000020) | ((Y >> 3) & 0x00000011)
                | ((Y << 2) & 0x00000004) | ((Y >> 21) & 0x00000002);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x5(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x6(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x7(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x4, %eax
xorl -0x18(%rbp), %eax
andl $0xf0f0f0f, %eax        # imm = 0xF0F0F0F
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
xorl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x20(%rbp), %eax
shll $0x4, %eax
xorl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
xorl -0x18(%rbp), %eax
andl $0x10101010, %eax       # imm = 0x10101010
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
xorl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x20(%rbp), %eax
xorl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
andl $0xf, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x93ea(%rip), %rax      # 0x10ba0
movl (%rax,%rcx,4), %eax
shll $0x3, %eax
movl -0x18(%rbp), %ecx
shrl $0x8, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x93d0(%rip), %rcx      # 0x10ba0
movl (%rcx,%rdx,4), %ecx
shll $0x2, %ecx
orl %ecx, %eax
movl -0x18(%rbp), %ecx
shrl $0x10, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x93b4(%rip), %rcx      # 0x10ba0
movl (%rcx,%rdx,4), %ecx
shll %ecx
orl %ecx, %eax
movl -0x18(%rbp), %ecx
shrl $0x18, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x9399(%rip), %rcx      # 0x10ba0
orl (%rcx,%rdx,4), %eax
movl -0x18(%rbp), %ecx
shrl $0x5, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x9382(%rip), %rcx      # 0x10ba0
movl (%rcx,%rdx,4), %ecx
shll $0x7, %ecx
orl %ecx, %eax
movl -0x18(%rbp), %ecx
shrl $0xd, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x9366(%rip), %rcx      # 0x10ba0
movl (%rcx,%rdx,4), %ecx
shll $0x6, %ecx
orl %ecx, %eax
movl -0x18(%rbp), %ecx
shrl $0x15, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x934a(%rip), %rcx      # 0x10ba0
movl (%rcx,%rdx,4), %ecx
shll $0x5, %ecx
orl %ecx, %eax
movl -0x18(%rbp), %ecx
shrl $0x1d, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x932e(%rip), %rcx      # 0x10ba0
movl (%rcx,%rdx,4), %ecx
shll $0x4, %ecx
orl %ecx, %eax
movl %eax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
shrl %eax
andl $0xf, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x9350(%rip), %rax      # 0x10be0
movl (%rax,%rcx,4), %eax
shll $0x3, %eax
movl -0x1c(%rbp), %ecx
shrl $0x9, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x9336(%rip), %rcx      # 0x10be0
movl (%rcx,%rdx,4), %ecx
shll $0x2, %ecx
orl %ecx, %eax
movl -0x1c(%rbp), %ecx
shrl $0x11, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x931a(%rip), %rcx      # 0x10be0
movl (%rcx,%rdx,4), %ecx
shll %ecx
orl %ecx, %eax
movl -0x1c(%rbp), %ecx
shrl $0x19, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x92ff(%rip), %rcx      # 0x10be0
orl (%rcx,%rdx,4), %eax
movl -0x1c(%rbp), %ecx
shrl $0x4, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x92e8(%rip), %rcx      # 0x10be0
movl (%rcx,%rdx,4), %ecx
shll $0x7, %ecx
orl %ecx, %eax
movl -0x1c(%rbp), %ecx
shrl $0xc, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x92cc(%rip), %rcx      # 0x10be0
movl (%rcx,%rdx,4), %ecx
shll $0x6, %ecx
orl %ecx, %eax
movl -0x1c(%rbp), %ecx
shrl $0x14, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x92b0(%rip), %rcx      # 0x10be0
movl (%rcx,%rdx,4), %ecx
shll $0x5, %ecx
orl %ecx, %eax
movl -0x1c(%rbp), %ecx
shrl $0x1c, %ecx
andl $0xf, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x9294(%rip), %rcx      # 0x10be0
movl (%rcx,%rdx,4), %ecx
shll $0x4, %ecx
orl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
movl %eax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
movl %eax, -0x1c(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x10, -0x14(%rbp)
jge 0x7c35
cmpl $0x2, -0x14(%rbp)
jl 0x7990
cmpl $0x8, -0x14(%rbp)
je 0x7990
cmpl $0xf, -0x14(%rbp)
jne 0x79bc
movl -0x18(%rbp), %eax
shll %eax
movl -0x18(%rbp), %ecx
shrl $0x1b, %ecx
orl %ecx, %eax
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
movl %eax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
shll %eax
movl -0x1c(%rbp), %ecx
shrl $0x1b, %ecx
orl %ecx, %eax
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
movl %eax, -0x1c(%rbp)
jmp 0x79e8
movl -0x18(%rbp), %eax
shll $0x2, %eax
movl -0x18(%rbp), %ecx
shrl $0x1a, %ecx
orl %ecx, %eax
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
movl %eax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
shll $0x2, %eax
movl -0x1c(%rbp), %ecx
shrl $0x1a, %ecx
orl %ecx, %eax
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %ecx
shll $0x4, %ecx
andl $0x24000000, %ecx       # imm = 0x24000000
movl -0x18(%rbp), %eax
shll $0x1c, %eax
andl $0x10000000, %eax       # imm = 0x10000000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0xe, %eax
andl $0x8000000, %eax        # imm = 0x8000000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0x12, %eax
andl $0x2080000, %eax        # imm = 0x2080000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0x6, %eax
andl $0x1000000, %eax        # imm = 0x1000000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0x9, %eax
andl $0x200000, %eax         # imm = 0x200000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shrl %eax
andl $0x100000, %eax         # imm = 0x100000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0xa, %eax
andl $0x40000, %eax          # imm = 0x40000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0x2, %eax
andl $0x20000, %eax          # imm = 0x20000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shrl $0xa, %eax
andl $0x10000, %eax          # imm = 0x10000
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0xd, %eax
andl $0x2000, %eax           # imm = 0x2000
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0x4, %eax
andl $0x1000, %eax           # imm = 0x1000
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shll $0x6, %eax
andl $0x800, %eax            # imm = 0x800
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl %eax
andl $0x400, %eax            # imm = 0x400
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0xe, %eax
andl $0x200, %eax            # imm = 0x200
orl %eax, %ecx
movl -0x1c(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0x5, %eax
andl $0x20, %eax
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0xa, %eax
andl $0x10, %eax
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0x3, %eax
andl $0x8, %eax
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0x12, %eax
andl $0x4, %eax
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0x1a, %eax
andl $0x2, %eax
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0x18, %eax
andl $0x1, %eax
orl %eax, %ecx
movq -0x8(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x8(%rbp)
movl %ecx, (%rax)
movl -0x18(%rbp), %ecx
shll $0xf, %ecx
andl $0x20000000, %ecx       # imm = 0x20000000
movl -0x18(%rbp), %eax
shll $0x11, %eax
andl $0x10000000, %eax       # imm = 0x10000000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0xa, %eax
andl $0x8000000, %eax        # imm = 0x8000000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0x16, %eax
andl $0x4000000, %eax        # imm = 0x4000000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shrl $0x2, %eax
andl $0x2000000, %eax        # imm = 0x2000000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll %eax
andl $0x1000000, %eax        # imm = 0x1000000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0x10, %eax
andl $0x200000, %eax         # imm = 0x200000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0xb, %eax
andl $0x100000, %eax         # imm = 0x100000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0x3, %eax
andl $0x80000, %eax          # imm = 0x80000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shrl $0x6, %eax
andl $0x40000, %eax          # imm = 0x40000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shll $0xf, %eax
andl $0x20000, %eax          # imm = 0x20000
orl %eax, %ecx
movl -0x18(%rbp), %eax
shrl $0x4, %eax
andl $0x10000, %eax          # imm = 0x10000
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0x2, %eax
andl $0x2000, %eax           # imm = 0x2000
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shll $0x8, %eax
andl $0x1000, %eax           # imm = 0x1000
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0xe, %eax
andl $0x808, %eax            # imm = 0x808
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0x9, %eax
andl $0x400, %eax            # imm = 0x400
orl %eax, %ecx
movl -0x1c(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shll $0x7, %eax
andl $0x100, %eax            # imm = 0x100
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0x7, %eax
andl $0x20, %eax
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0x3, %eax
andl $0x11, %eax
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shll $0x2, %eax
andl $0x4, %eax
orl %eax, %ecx
movl -0x1c(%rbp), %eax
shrl $0x15, %eax
andl $0x2, %eax
orl %eax, %ecx
movq -0x8(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x8(%rbp)
movl %ecx, (%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7974
popq %rbp
retq
nopw (%rax,%rax)