LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/aes.c
// Function: aes_crypt_ctr
int aes_crypt_ctr(aes_context *ctx,
        size_t length,
        size_t *nc_off,
        unsigned char nonce_counter[16],
        unsigned char stream_block[16],
        const unsigned char *input,
        unsigned char *output) {
    int c, i, cb;
    size_t n = *nc_off;

    while (length--) {
        if (n == 0) {
            aes_crypt_ecb(ctx, AES_ENCRYPT, nonce_counter, stream_block);

            i = 15;
            do {
                nonce_counter[i]++;
                cb = nonce_counter[i] == 0;
            } while (i-- && cb);

        }
        c = *input++;
        *output++ = (unsigned char) (c ^ stream_block[n]);

        n = (n + 1) & 0x0F;
    }

    *nc_off = n;

    return ( 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq (%rdx), %rbx
testq %rsi, %rsi
je 0x1ff7
movq %r9, %r14
movq %r8, %r15
movq %rcx, %r12
movq %rsi, %r13
movq 0x50(%rsp), %rbp
testq %rbx, %rbx
jne 0x1fda
movq 0x10(%rsp), %rdi
movl $0x1, %esi
movq %r12, %rdx
movq %r15, %rcx
callq 0x16d4
movl $0xf, %eax
incb (%r12,%rax)
sete %cl
addq $-0x1, %rax
jae 0x1fda
testb %cl, %cl
jne 0x1fc9
decq %r13
movb (%r15,%rbx), %al
xorb (%r14), %al
incq %r14
movb %al, (%rbp)
incq %rbp
incl %ebx
andl $0xf, %ebx
testq %r13, %r13
jne 0x1faa
movq 0x8(%rsp), %rax
movq %rbx, (%rax)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/sha1.c
// Function: sha1_update
void sha1_update(sha1_context *ctx, const unsigned char *input, size_t ilen) {
    size_t fill;
    unsigned long left;

    if (ilen <= 0)
        return;

    left = ctx->total[0] & 0x3F;
    fill = 64 - left;

    ctx->total[0] += (unsigned long) ilen;
    ctx->total[0] &= 0xFFFFFFFF;

    if (ctx->total[0] < (unsigned long) ilen)
        ctx->total[1]++;

    if (left && ilen >= fill) {
        memcpy((void *) (ctx->buffer + left),
                (void *) input, fill);
        sha1_process(ctx, ctx->buffer);
        input += fill;
        ilen -= fill;
        left = 0;
    }

    while (ilen >= 64) {
        sha1_process(ctx, input);
        input += 64;
        ilen -= 64;
    }

    if (ilen > 0) {
        memcpy((void *) (ctx->buffer + left),
                (void *) input, ilen);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdx, %rdx
je 0x20f9
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rax
leal (%rdx,%rax), %ecx
andl $0x3f, %eax
movq %rcx, (%rdi)
cmpq %rdx, %rcx
jae 0x2072
incq 0x8(%r14)
testq %rax, %rax
je 0x208d
movl $0x40, %r12d
subq %rax, %r12
movq %rdx, %r15
subq %r12, %r15
jae 0x2092
movq %rdx, %r15
jmp 0x20dd
movq %rdx, %r15
jmp 0x20b7
leaq 0x38(%r14), %r13
leaq (%r14,%rax), %rdi
addq $0x38, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x10f0
movq %r14, %rdi
movq %r13, %rsi
callq 0x2103
addq %r12, %rbx
cmpq $0x40, %r15
jb 0x20d6
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2103
addq $0x40, %rbx
addq $-0x40, %r15
cmpq $0x3f, %r15
ja 0x20bd
testq %r15, %r15
je 0x20f9
xorl %eax, %eax
leaq (%r14,%rax), %rdi
addq $0x38, %rdi
movq %rbx, %rsi
movq %r15, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/sha1.c
// Function: sha1
void sha1(const unsigned char *input, size_t ilen, unsigned char output[20]) {
    sha1_context ctx;

    sha1_starts(&ctx);
    sha1_update(&ctx, input, ilen);
    sha1_finish(&ctx, output);

    memset(&ctx, 0, sizeof ( sha1_context));
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xf8, %rsp
movq %rdx, %rbx
movq %rsi, %rdx
movq %rdi, %rsi
xorps %xmm0, %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
movq $0x67452301, 0x10(%r14) # imm = 0x67452301
movl $0x98badcfe, %eax       # imm = 0x98BADCFE
leaq 0x5712ce8b(%rax), %rcx
movq %rcx, 0x18(%r14)
movq %rax, 0x20(%r14)
movq $0x10325476, 0x28(%r14) # imm = 0x10325476
addq $0x2b1804f2, %rax       # imm = 0x2B1804F2
movq %rax, 0x30(%r14)
movq %r14, %rdi
callq 0x2045
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3ca4
addq $0xf8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/sha1.c
// Function: sha1_hmac_starts
void sha1_hmac_starts(sha1_context *ctx, const unsigned char *key, size_t keylen) {
    size_t i;
    unsigned char sum[20];

    if (keylen > 64) {
        sha1(key, keylen, sum);
        keylen = 20;
        key = sum;
    }

    memset(ctx->ipad, 0x36, 64);
    memset(ctx->opad, 0x5C, 64);

    for (i = 0; i < keylen; i++) {
        ctx->ipad[i] = (unsigned char) (ctx->ipad[i] ^ key[i]);
        ctx->opad[i] = (unsigned char) (ctx->opad[i] ^ key[i]);
    }

    sha1_starts(ctx);
    sha1_update(ctx, ctx->ipad, 64);

    memset(sum, 0, sizeof ( sum));
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rax
movq %rdi, %rbx
cmpq $0x41, %rdx
jb 0x3eb1
movq %rsp, %r14
movq %rax, %rdi
movq %rdx, %rsi
movq %r14, %rdx
callq 0x3dd3
leaq 0x78(%rbx), %rsi
movaps 0x8415(%rip), %xmm0     # 0xc280
movups %xmm0, 0xa8(%rbx)
movups %xmm0, 0x98(%rbx)
movups %xmm0, 0x88(%rbx)
movups %xmm0, 0x78(%rbx)
movaps 0x8405(%rip), %xmm0     # 0xc290
movups %xmm0, 0xb8(%rbx)
movups %xmm0, 0xc8(%rbx)
movups %xmm0, 0xd8(%rbx)
movups %xmm0, 0xe8(%rbx)
movl $0x14, %edx
movq %r14, %rax
jmp 0x3efd
leaq 0x78(%rbx), %rsi
movaps 0x83c4(%rip), %xmm0     # 0xc280
movups %xmm0, 0xa8(%rbx)
movups %xmm0, 0x98(%rbx)
movups %xmm0, 0x88(%rbx)
movups %xmm0, 0x78(%rbx)
movaps 0x83b4(%rip), %xmm0     # 0xc290
movups %xmm0, 0xb8(%rbx)
movups %xmm0, 0xc8(%rbx)
movups %xmm0, 0xd8(%rbx)
movups %xmm0, 0xe8(%rbx)
testq %rdx, %rdx
je 0x3f1c
xorl %ecx, %ecx
movb (%rax,%rcx), %dil
xorb %dil, 0x78(%rbx,%rcx)
movb (%rax,%rcx), %dil
xorb %dil, 0xb8(%rbx,%rcx)
incq %rcx
cmpq %rcx, %rdx
jne 0x3eff
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x67452301, 0x10(%rbx) # imm = 0x67452301
movl $0x98badcfe, %eax       # imm = 0x98BADCFE
leaq 0x5712ce8b(%rax), %rcx
movq %rcx, 0x18(%rbx)
movq %rax, 0x20(%rbx)
movq $0x10325476, 0x28(%rbx) # imm = 0x10325476
addq $0x2b1804f2, %rax       # imm = 0x2B1804F2
movq %rax, 0x30(%rbx)
movl $0x40, %edx
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r14
jmp 0x2045
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/sha1.c
// Function: sha1_hmac_finish
void sha1_hmac_finish(sha1_context *ctx, unsigned char output[20]) {
    unsigned char tmpbuf[20];

    sha1_finish(ctx, tmpbuf);
    sha1_starts(ctx);
    sha1_update(ctx, ctx->opad, 64);
    sha1_update(ctx, tmpbuf, 20);
    sha1_finish(ctx, output);

    memset(tmpbuf, 0, sizeof ( tmpbuf));
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq %rsp, %r15
movq %r15, %rsi
callq 0x3ca4
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq $0x67452301, 0x10(%r14) # imm = 0x67452301
movl $0x98badcfe, %eax       # imm = 0x98BADCFE
leaq 0x5712ce8b(%rax), %rcx
movq %rcx, 0x18(%r14)
movq %rax, 0x20(%r14)
movq $0x10325476, 0x28(%r14) # imm = 0x10325476
addq $0x2b1804f2, %rax       # imm = 0x2B1804F2
movq %rax, 0x30(%r14)
leaq 0xb8(%r14), %rsi
movl $0x40, %edx
movq %r14, %rdi
callq 0x2045
movl $0x14, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2045
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3ca4
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/sha1.c
// Function: sha1_hmac
void sha1_hmac(const unsigned char *key, size_t keylen,
        const unsigned char *input, size_t ilen,
        unsigned char output[20]) {
    sha1_context ctx;

    sha1_hmac_starts(&ctx, key, keylen);
    sha1_hmac_update(&ctx, input, ilen);
    sha1_hmac_finish(&ctx, output);

    memset(&ctx, 0, sizeof ( sha1_context));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %rdx
movq %rdi, %rsi
movq %rsp, %r12
movq %r12, %rdi
callq 0x3e3c
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2045
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3f69
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/des.c
// Function: des_setkey_dec
int des_setkey_dec(des_context *ctx, const unsigned char key[DES_KEY_SIZE]) {
    int i;

    des_setkey(ctx->sk, key);

    for (i = 0; i < 16; i += 2) {
        SWAP(ctx->sk[i ], ctx->sk[30 - i]);
        SWAP(ctx->sk[i + 1], ctx->sk[31 - i]);
    }

    return ( 0);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
addq $0x4, %rdi
callq 0x4100
leaq 0x80(%rbx), %rax
movq $-0x2, %rcx
movl 0xc(%rbx,%rcx,4), %edx
movl -0x4(%rax), %esi
movl %esi, 0xc(%rbx,%rcx,4)
movl %edx, -0x4(%rax)
movl 0x10(%rbx,%rcx,4), %edx
movl (%rax), %esi
movl %esi, 0x10(%rbx,%rcx,4)
movl %edx, (%rax)
addq $0x2, %rcx
addq $-0x8, %rax
cmpq $0xe, %rcx
jb 0x4594
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/des.c
// Function: des3_set2key_enc
int des3_set2key_enc(des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2]) {
    uint32_t sk[96];

    des3_set2key(ctx->sk, sk, key);
    memset(sk, 0, sizeof ( sk));

    return ( 0);
}

// Assembly:
subq $0x188, %rsp            # imm = 0x188
movq %rsi, %rdx
addq $0x4, %rdi
movq %rsp, %rsi
callq 0x45e0
xorl %eax, %eax
addq $0x188, %rsp            # imm = 0x188
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/des.c
// Function: des3_set2key
static void des3_set2key(uint32_t esk[96],
        uint32_t dsk[96],
        const unsigned char key[DES_KEY_SIZE * 2]) {
    int i;

    des_setkey(esk, key);
    des_setkey(dsk + 32, key + 8);

    for (i = 0; i < 32; i += 2) {
        dsk[i ] = esk[30 - i];
        dsk[i + 1] = esk[31 - i];

        esk[i + 32] = dsk[62 - i];
        esk[i + 33] = dsk[63 - i];

        esk[i + 64] = esk[i ];
        esk[i + 65] = esk[i + 1];

        dsk[i + 64] = dsk[i ];
        dsk[i + 65] = dsk[i + 1];
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq %rdx, %rsi
callq 0x4100
leaq 0x80(%rbx), %rdi
addq $0x8, %r15
movq %r15, %rsi
callq 0x4100
movl $0x40, %ecx
movl $0x3f, %eax
movl -0x84(%r14,%rax,4), %edx
movl %edx, -0x100(%rbx,%rcx,4)
movl -0x80(%r14,%rax,4), %edx
movl %edx, -0xfc(%rbx,%rcx,4)
movl -0x4(%rbx,%rax,4), %edx
movl %edx, -0x80(%r14,%rcx,4)
movl (%rbx,%rax,4), %edx
movl %edx, -0x7c(%r14,%rcx,4)
movq -0x100(%r14,%rcx,4), %rdx
movq %rdx, (%r14,%rcx,4)
movq -0x100(%rbx,%rcx,4), %rdx
movq %rdx, (%rbx,%rcx,4)
leaq 0x2(%rcx), %rdx
addq $-0x40, %rcx
addq $-0x2, %rax
cmpq $0x1e, %rcx
movq %rdx, %rcx
jb 0x4613
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/des.c
// Function: des3_set3key_enc
int des3_set3key_enc(des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3]) {
    uint32_t sk[96];

    des3_set3key(ctx->sk, sk, key);
    memset(sk, 0, sizeof ( sk));

    return ( 0);
}

// Assembly:
subq $0x188, %rsp            # imm = 0x188
movq %rsi, %rdx
addq $0x4, %rdi
movq %rsp, %rsi
callq 0x46b2
xorl %eax, %eax
addq $0x188, %rsp            # imm = 0x188
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/des.c
// Function: des3_set3key
static void des3_set3key(uint32_t esk[96],
        uint32_t dsk[96],
        const unsigned char key[24]) {
    int i;

    des_setkey(esk, key);
    des_setkey(dsk + 32, key + 8);
    des_setkey(esk + 64, key + 16);

    for (i = 0; i < 32; i += 2) {
        dsk[i ] = esk[94 - i];
        dsk[i + 1] = esk[95 - i];

        esk[i + 32] = dsk[62 - i];
        esk[i + 33] = dsk[63 - i];

        dsk[i + 64] = esk[30 - i];
        dsk[i + 65] = esk[31 - i];
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq %rdx, %rsi
callq 0x4100
leaq 0x80(%rbx), %rdi
leaq 0x8(%r15), %rsi
callq 0x4100
leaq 0x100(%r14), %rdi
addq $0x10, %r15
movq %r15, %rsi
callq 0x4100
movq $-0x2, %rax
movl $0x3e, %ecx
movl 0x80(%r14,%rcx,4), %edx
movl %edx, 0x8(%rbx,%rax,4)
movl 0x84(%r14,%rcx,4), %edx
movl %edx, 0xc(%rbx,%rax,4)
movl (%rbx,%rcx,4), %edx
movl %edx, 0x88(%r14,%rax,4)
movl 0x4(%rbx,%rcx,4), %edx
movl %edx, 0x8c(%r14,%rax,4)
movl -0x80(%r14,%rcx,4), %edx
movl %edx, 0x108(%rbx,%rax,4)
movl -0x7c(%r14,%rcx,4), %edx
movl %edx, 0x10c(%rbx,%rax,4)
addq $0x2, %rax
addq $-0x2, %rcx
cmpq $0x1e, %rax
jb 0x46f7
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/des.c
// Function: des_crypt_cbc
int des_crypt_cbc(des_context *ctx,
        int mode,
        size_t length,
        unsigned char iv[8],
        const unsigned char *input,
        unsigned char *output) {
    int i;
    unsigned char temp[8];

    if (length % 8)
        return ( POLARSSL_ERR_DES_INVALID_INPUT_LENGTH);

    if (mode == DES_ENCRYPT) {
        while (length > 0) {
            for (i = 0; i < 8; i++)
                output[i] = (unsigned char) (input[i] ^ iv[i]);

            des_crypt_ecb(ctx, output, output);
            memcpy(iv, output, 8);

            input += 8;
            output += 8;
            length -= 8;
        }
    } else /* DES_DECRYPT */ {
        while (length > 0) {
            memcpy(temp, input, 8);
            des_crypt_ecb(ctx, input, output);

            for (i = 0; i < 8; i++)
                output[i] = (unsigned char) (output[i] ^ iv[i]);

            memcpy(iv, temp, 8);

            input += 8;
            output += 8;
            length -= 8;
        }
    }

    return ( 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movl $0xffffffce, %eax       # imm = 0xFFFFFFCE
testb $0x7, %r12b
jne 0x4a62
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq %rdi, %r13
cmpl $0x1, %esi
jne 0x4a27
testq %r12, %r12
je 0x4a60
xorl %eax, %eax
movb (%r15,%rax), %cl
xorb (%r14,%rax), %cl
movb %cl, (%rbx,%rax)
incq %rax
cmpq $0x8, %rax
jne 0x49ef
movq %r13, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x4772
movq (%rbx), %rax
movq %rax, (%r15)
addq $0x8, %r14
addq $0x8, %rbx
addq $-0x8, %r12
jne 0x49ed
jmp 0x4a60
testq %r12, %r12
je 0x4a60
movq (%r14), %rbp
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x4772
xorl %eax, %eax
movb (%r15,%rax), %cl
xorb %cl, (%rbx,%rax)
incq %rax
cmpq $0x8, %rax
jne 0x4a3f
movq %rbp, (%r15)
addq $0x8, %r14
addq $0x8, %rbx
addq $-0x8, %r12
jne 0x4a2c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/aes_omac.c
// Function: gf_mul
void _gf_mul(unsigned char *pad) {
    unsigned int i;
    unsigned cxor = (pad[0] & 0x80) ? 0x87 : 0;

    for (i = 0; i < 15; i++)
        pad[i] = (pad[i] << 1) | (pad[i + 1] >> 7);
    pad[15] = (pad[15] << 1) ^ cxor;
}

// Assembly:
movb (%rdi), %al
movl $0x1, %ecx
movl %eax, %edx
movb (%rdi,%rcx), %sil
movl %esi, %r8d
shrb $0x7, %r8b
addb %dl, %dl
orb %r8b, %dl
movb %dl, -0x1(%rdi,%rcx)
incq %rcx
movl %esi, %edx
cmpq $0x10, %rcx
jne 0x4fe1
sarb $0x7, %al
andb $-0x79, %al
movb 0xf(%rdi), %cl
addb %cl, %cl
xorb %al, %cl
movb %cl, 0xf(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/aes_omac.c
// Function: aes_omac1
void aes_omac1(u8 *digest, u8 *input, u32 length, u8 *key, u32 keybits) {
    u32 i, j;
    u32 overflow;
    aes_context ctxt;
    unsigned char buffer1[16], buffer2[16], dbuf[16];

    memset(buffer1, 0, 16);

    aes_setkey_enc(&ctxt, key, keybits);

    aes_crypt_ecb(&ctxt, AES_ENCRYPT, buffer1, buffer2);
    _gf_mul(buffer2);

    if (length > 16) {
        for (i = 0; i < length - 16; i += 16) {
            for (j = 0; j < 16; j++)
                dbuf[j] = buffer1[j] ^ input[i + j];
            aes_crypt_ecb(&ctxt, AES_ENCRYPT, dbuf, buffer1);
        }
    }

    overflow = length & 0xf;
    if (length % 16 == 0)
        overflow = 16;

    memset(dbuf, 0, 16);
    memcpy(dbuf, &(input[i]), overflow);

    if (overflow != 16) {
        dbuf[overflow] = 0x80;
        _gf_mul(buffer2);
    }

    for (i = 0; i < 16; i++)
        dbuf[i] ^= buffer1[i] ^ buffer2[i];

    aes_crypt_ecb(&ctxt, AES_ENCRYPT, dbuf, digest);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r12
movaps %xmm0, (%r12)
leaq 0x48(%rsp), %r13
movq %r13, %rdi
movq %rcx, %rsi
movl %r8d, %edx
callq 0x125c
movq %rsp, %rbp
movq %r13, %rdi
movl $0x1, %esi
movq %r12, %rdx
movq %rbp, %rcx
callq 0x16d4
movl $0x1, %ecx
movb (%rbp), %al
movl %eax, %edx
movb (%rsp,%rcx), %sil
addb %dl, %dl
movl %esi, %edi
shrb $0x7, %dil
orb %dl, %dil
movb %dil, -0x1(%rsp,%rcx)
incq %rcx
movl %esi, %edx
cmpq $0x10, %rcx
jne 0x5069
sarb $0x7, %al
andb $-0x79, %al
movb 0xf(%rsp), %cl
addb %cl, %cl
xorb %al, %cl
movb %cl, 0xf(%rsp)
cmpl $0x11, %ebx
movq %rbx, 0x40(%rsp)
jb 0x50f2
movq %r14, 0x38(%rsp)
leal -0x10(%rbx), %r14d
xorl %ebx, %ebx
leaq 0x48(%rsp), %r12
leaq 0x10(%rsp), %r13
leaq 0x20(%rsp), %rbp
movups (%r15,%rbx), %xmm0
xorps 0x20(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movq %r12, %rdi
movl $0x1, %esi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x16d4
addq $0x10, %rbx
cmpq %r14, %rbx
jb 0x50bd
andl $-0x10, %ebx
movq 0x38(%rsp), %r14
jmp 0x50f4
xorl %ebx, %ebx
movq 0x40(%rsp), %r13
andl $0xf, %r13d
movl $0x10, %r12d
cmovnel %r13d, %r12d
movl $0x10, %eax
subq %r12, %rax
xorl %edx, %edx
testl %r13d, %r13d
cmovneq %rax, %rdx
addq %rbx, %r15
leaq (%rsp,%r12), %rdi
addq $0x10, %rdi
xorl %esi, %esi
callq 0x10a0
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x10f0
testl %r13d, %r13d
je 0x517f
movb $-0x80, 0x10(%rsp,%r12)
movl $0x1, %ecx
movb (%rsp), %al
movl %eax, %edx
movb (%rsp,%rcx), %sil
addb %dl, %dl
movl %esi, %edi
shrb $0x7, %dil
orb %dl, %dil
movb %dil, -0x1(%rsp,%rcx)
incq %rcx
movl %esi, %edx
cmpq $0x10, %rcx
jne 0x514f
sarb $0x7, %al
andb $-0x79, %al
movb 0xf(%rsp), %cl
addb %cl, %cl
xorb %al, %cl
movb %cl, 0xf(%rsp)
movaps (%rsp), %xmm0
xorps 0x20(%rsp), %xmm0
leaq 0x10(%rsp), %rdx
xorps (%rdx), %xmm0
movaps %xmm0, (%rdx)
leaq 0x48(%rsp), %rdi
movl $0x1, %esi
movq %r14, %rcx
callq 0x16d4
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/kgen.c
// Function: generate_ata_keys
void generate_ata_keys(u8 *eid_root_key, u8 *eid_root_iv, u8 *data_key_dst, u8 *tweak_key_dst) {
    aes_context aes_ctxt;
    u8 iv[0x10];

    //Generate ATA data key.
    aes_setkey_enc(&aes_ctxt, eid_root_key, 0x100);
    memcpy(iv, eid_root_iv, 0x10);
    aes_crypt_cbc(&aes_ctxt, AES_ENCRYPT, 0x20, iv, sb_indiv_seed_00, data_key_dst);

    //Generate ATA tweak key.
    aes_setkey_enc(&aes_ctxt, eid_root_key, 0x100);
    memcpy(iv, eid_root_iv, 0x10);
    aes_crypt_cbc(&aes_ctxt, AES_ENCRYPT, 0x20, iv, sb_indiv_seed_20, tweak_key_dst);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rcx, %rbx
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbp
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x125c
movups (%r15), %xmm0
movq %rsp, %r12
movaps %xmm0, (%r12)
leaq 0xb373(%rip), %r8       # 0x10570
movl $0x20, %edx
movq %r14, %rdi
movl $0x1, %esi
movq %r12, %rcx
movq %r13, %r9
callq 0x1eab
movq %r14, %rdi
movq %rbp, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x125c
movups (%r15), %xmm0
movaps %xmm0, (%r12)
leaq 0xb35b(%rip), %r8       # 0x10590
movl $0x20, %edx
movq %r14, %rdi
movl $0x1, %esi
movq %r12, %rcx
movq %rbx, %r9
callq 0x1eab
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/kgen.c
// Function: generate_encdec_keys
void generate_encdec_keys(u8 *eid_root_key, u8 *eid_root_iv, u8 *data_key_dst, u8 *tweak_key_dst) {
    aes_context aes_ctxt;
    u8 iv[0x10];

    //Generate encdec_k1.
    aes_setkey_enc(&aes_ctxt, eid_root_key, 0x100);
    memcpy(iv, eid_root_iv, 0x10);
    aes_crypt_cbc(&aes_ctxt, AES_ENCRYPT, 0x20, iv, encdec_seed_00, data_key_dst);

    //Generate encdec_k3.
    aes_setkey_enc(&aes_ctxt, eid_root_key, 0x100);
    memcpy(iv, eid_root_iv, 0x10);
    aes_crypt_cbc(&aes_ctxt, AES_ENCRYPT, 0x20, iv, encdec_seed_20, tweak_key_dst);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rcx, %rbx
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbp
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x125c
movups (%r15), %xmm0
movq %rsp, %r12
movaps %xmm0, (%r12)
leaq 0xb28c(%rip), %r8       # 0x10530
movl $0x20, %edx
movq %r14, %rdi
movl $0x1, %esi
movq %r12, %rcx
movq %r13, %r9
callq 0x1eab
movq %r14, %rdi
movq %rbp, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x125c
movups (%r15), %xmm0
movaps %xmm0, (%r12)
leaq 0xb274(%rip), %r8       # 0x10550
movl $0x20, %edx
movq %r14, %rdi
movl $0x1, %esi
movq %r12, %rcx
movq %rbx, %r9
callq 0x1eab
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/aes_xts.c
// Function: aes_xts_init
int aes_xts_init(aes_xts_ctxt_t *ctxt, int mode, const u8 *data_key, const u8 *tweak_key, int keybits) {
    ctxt->mode = mode;
    ctxt->keybits = keybits;
    aes_setkey_enc(&ctxt->twk_ctxt, tweak_key, keybits);

    if (mode == AES_ENCRYPT)
        aes_setkey_enc(&ctxt->aes_ctxt, data_key, keybits);
    else if (mode == AES_DECRYPT)
        aes_setkey_dec(&ctxt->aes_ctxt, data_key, keybits);
    else
        return -1;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %r8d, %ebx
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r15
movl %esi, 0x460(%rdi)
movl %r8d, 0x464(%rdi)
movq %rcx, %rsi
movl %r8d, %edx
callq 0x125c
testl %ebp, %ebp
je 0x5356
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x1, %ebp
jne 0x536c
addq $0x230, %r15            # imm = 0x230
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x125c
jmp 0x536a
addq $0x230, %r15            # imm = 0x230
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x154d
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/aes_xts.c
// Function: aes_xts_crypt
int aes_xts_crypt(aes_xts_ctxt_t *ctxt, u64 seqno, u32 sector_size, const u8 *in, u8 *out) {
    u32 i = 0, j = 0;
    u8 tweak[0x10], buf[0x10];
    u8 carry_in, carry_out;

    //Check alignment.
    if (!(sector_size % 0x10 == 0))
        return -1;

    //Init tweak.
    ((u64 *) tweak)[0] = seqno; //_ES64(seqno);
    ((u64 *) tweak)[1] = 0;
    aes_crypt_ecb(&ctxt->twk_ctxt, AES_ENCRYPT, tweak, tweak);

    //En-/decrypt sector.
    for (i = 0; i < sector_size; i += 0x10) {
        for (j = 0; j < 0x10; j++)
            buf[j] = in[i + j] ^ tweak[j];

        //En-/decrypt 0x10 bytes.
        aes_crypt_ecb(&ctxt->aes_ctxt, ctxt->mode, buf, buf);

        for (j = 0; j < 0x10; j++)
            out[i + j] = buf[j] ^ tweak[j];

        //Update tweak (GF MUL).
        carry_in = 0;
        for (j = 0; j < 0x10; j++) {
            carry_out = (tweak[j] >> 7) & 1;
            tweak[j] = ((tweak[j] << 1) + carry_in) & 0xFF;
            carry_in = carry_out;
        }
        if (carry_out)
            tweak[0] ^= 0x87;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %ebp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0xf, %bpl
jne 0x5468
movq %r8, %rbx
movq %rcx, %r14
movq %rdi, %r15
movq %rsp, %rcx
movq %rsi, (%rcx)
movq $0x0, 0x8(%rcx)
movl $0x1, %esi
movq %rcx, %rdx
callq 0x16d4
testl %ebp, %ebp
je 0x5466
movq %r14, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movq %r15, %r12
addq $0x230, %r15            # imm = 0x230
xorl %ebx, %ebx
leaq 0x20(%rsp), %r13
movl %ebx, %r14d
movq 0x18(%rsp), %rax
movups (%rax,%r14), %xmm0
xorps (%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movl 0x460(%r12), %esi
movq %r15, %rdi
movq %r13, %rdx
movq %r13, %rcx
callq 0x16d4
movdqa (%rsp), %xmm0
movdqa 0x20(%rsp), %xmm1
pxor %xmm0, %xmm1
movq 0x10(%rsp), %rax
movdqu %xmm1, (%rax,%r14)
movdqa %xmm0, %xmm1
psrlw $0x7, %xmm1
pand 0x782c(%rip), %xmm1     # 0xcc60
pslldq $0x1, %xmm1             # xmm1 = zero,xmm1[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]
movdqa %xmm0, %xmm2
paddb %xmm0, %xmm2
por %xmm1, %xmm2
movdqa %xmm2, (%rsp)
movdqa %xmm0, 0x30(%rsp)
cmpb $0x0, 0x3f(%rsp)
jns 0x545b
xorb $-0x79, (%rsp)
addl $0x10, %ebx
cmpl %ebp, %ebx
jb 0x53dd
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/util.c
// Function: hexdump
void _hexdump(FILE *fp, const char *name, u32 offset, u8 *buf, int len, BOOL print_addr) {
    int i, j, align = strlen(name) + 1;

    fprintf(fp, "%s ", name);
    if (print_addr == TRUE)
        fprintf(fp, "%08x: ", offset);
    for (i = 0; i < len; i++) {
        if (i % 16 == 0 && i != 0) {
            fprintf(fp, "\n");
            for (j = 0; j < align; j++)
                putchar(' ');
            if (print_addr == TRUE)
                fprintf(fp, "%08X: ", offset + i);
        }
        fprintf(fp, "%02X ", buf[i]);
    }
    fprintf(fp, "\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %ebx
movl %r8d, %r12d
movq %rcx, %r14
movq %rdx, 0x8(%rsp)
movq %rsi, %rbp
movq %rdi, %r15
movq %rsi, %rdi
callq 0x1080
movq %rax, 0x10(%rsp)
leaq 0x77c2(%rip), %rsi      # 0xcc70
movq %r15, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x10d0
movl %ebx, 0x4(%rsp)
cmpl $0x1, %ebx
jne 0x54da
leaq 0x77a9(%rip), %rsi      # 0xcc74
movq %r15, %rdi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x10d0
testl %r12d, %r12d
jle 0x556d
movl %r12d, %r12d
movq 0x10(%rsp), %rax
incl %eax
movl %eax, (%rsp)
leaq 0x778b(%rip), %rbp      # 0xcc82
xorl %ebx, %ebx
testb $0xf, %bl
setne %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
jne 0x5553
movl $0xa, %edi
movq %r15, %rsi
callq 0x10b0
cmpl $0x7ffffffe, 0x10(%rsp) # imm = 0x7FFFFFFE
ja 0x5533
movl (%rsp), %r13d
movl $0x20, %edi
callq 0x1040
decl %r13d
jne 0x5524
cmpl $0x1, 0x4(%rsp)
jne 0x5553
movq 0x8(%rsp), %rax
leal (%rbx,%rax), %edx
movq %r15, %rdi
leaq 0x772f(%rip), %rsi      # 0xcc7b
xorl %eax, %eax
callq 0x10d0
movzbl (%r14,%rbx), %edx
movq %r15, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10d0
incq %rbx
cmpq %r12, %rbx
jne 0x54f9
movl $0xa, %edi
movq %r15, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/util.c
// Function: read_buffer
u8 *_read_buffer(s8 *file, u32 *length) {
    FILE *fp;
    u32 size;

    if ((fp = fopen(file, "rb")) == NULL)
        return NULL;

    fseek(fp, 0, SEEK_END);
    size = ftell(fp);
    fseek(fp, 0, SEEK_SET);

    u8 *buffer = (u8 *) malloc(sizeof (u8) * size);
    fread(buffer, sizeof (u8), size, fp);

    if (length != NULL)
        *length = size;

    fclose(fp);

    return buffer;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rbx
leaq 0x76ed(%rip), %rsi      # 0xcc88
callq 0x1120
testq %rax, %rax
je 0x5601
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1110
movq %r14, %rdi
callq 0x10e0
movq %rax, %r15
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1110
movl %r15d, %r13d
movq %r13, %rdi
callq 0x1100
movq %rax, %r12
movl $0x1, %esi
movq %rax, %rdi
movq %r13, %rdx
movq %r14, %rcx
callq 0x1060
testq %rbx, %rbx
je 0x55f7
movl %r15d, (%rbx)
movq %r14, %rdi
callq 0x1070
jmp 0x5604
xorl %r12d, %r12d
movq %r12, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/util.c
// Function: write_buffer
void _write_buffer(s8 *file, u8 *buffer, u32 length) {
    FILE *fp;

    if ((fp = fopen(file, "wb")) == NULL)
        return;

    fwrite(buffer, sizeof (u8), length, fp);
    fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rsi, %rbx
leaq 0x766a(%rip), %rsi      # 0xcc8b
callq 0x1120
testq %rax, %rax
je 0x564c
movq %rax, %r14
movl %ebp, %edx
movl $0x1, %esi
movq %rbx, %rdi
movq %rax, %rcx
callq 0x1150
movq %r14, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x1070
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/indiv.c
// Function: indiv_gen
void indiv_gen(u8 *seed0, u8 *seed1, u8 *seed2, u8 *seed3, u8 *indiv) {
    u32 i, rounds = INDIV_SIZE / INDIV_CHUNK_SIZE;
    u8 iv[0x10];
    aes_context aes_ctxt;

    memset(indiv, 0, INDIV_SIZE);

    //Copy seeds.
    if (seed0 != NULL)
        memcpy(indiv, seed0, INDIV_SEED_SIZE);
    if (seed1 != NULL)
        memcpy(indiv + INDIV_SEED_SIZE, seed1, INDIV_SEED_SIZE);
    if (seed2 != NULL)
        memcpy(indiv + INDIV_SEED_SIZE * 2, seed2, INDIV_SEED_SIZE);
    if (seed3 != NULL)
        memcpy(indiv + INDIV_SEED_SIZE * 3, seed3, INDIV_SEED_SIZE);

    //Generate.
    for (i = 0; i < rounds; i++, indiv += INDIV_CHUNK_SIZE) {
        //Set key and iv.
        aes_setkey_enc(&aes_ctxt, eid_root_key, KEY_BITS(ISO_ROOT_KEY_SIZE));
        memcpy(iv, eid_root_key + 0x20, ISO_ROOT_IV_SIZE);
        //Encrypt one chunk.
        aes_crypt_cbc(&aes_ctxt, AES_ENCRYPT, INDIV_CHUNK_SIZE, iv, indiv, indiv);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movl $0x100, %edx            # imm = 0x100
movq %r8, %rdi
xorl %esi, %esi
callq 0x10a0
testq %r13, %r13
je 0x56ab
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups 0x30(%r13), %xmm3
movups %xmm3, 0x30(%rbx)
movups %xmm2, 0x20(%rbx)
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
testq %r12, %r12
je 0x56d7
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups 0x20(%r12), %xmm2
movups 0x30(%r12), %xmm3
movups %xmm3, 0x70(%rbx)
movups %xmm2, 0x60(%rbx)
movups %xmm1, 0x50(%rbx)
movups %xmm0, 0x40(%rbx)
testq %r15, %r15
je 0x570b
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups 0x30(%r15), %xmm3
movups %xmm3, 0xb0(%rbx)
movups %xmm2, 0xa0(%rbx)
movups %xmm1, 0x90(%rbx)
movups %xmm0, 0x80(%rbx)
testq %r14, %r14
je 0x573f
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movups %xmm3, 0xf0(%rbx)
movups %xmm2, 0xe0(%rbx)
movups %xmm1, 0xd0(%rbx)
movups %xmm0, 0xc0(%rbx)
xorl %r13d, %r13d
leaq 0xae77(%rip), %rbp      # 0x105c0
leaq 0x18(%rsp), %r14
movq %rsp, %r15
leaq (%rbx,%r13), %r12
movq (%rbp), %rsi
movq %r14, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x125c
movq (%rbp), %rax
movups 0x20(%rax), %xmm0
movaps %xmm0, (%rsp)
movl $0x40, %edx
movq %r14, %rdi
movl $0x1, %esi
movq %r15, %rcx
movq %r12, %r8
movq %r12, %r9
callq 0x1eab
addq $0x40, %r13
cmpl $0x100, %r13d           # imm = 0x100
jne 0x5751
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid_unpack
void eid_unpack(s8 *file) {
    u32 i, length;
    u8 *eid = _read_buffer(file, &length);

    if (eid != NULL) {
        eid_header_t *h = (eid_header_t *) eid;

        //Fix header.
        _es_eid_header(h);

        eid_entry_t *e = (eid_entry_t *) (eid + sizeof (eid_header_t));
        for (i = 0; i < h->entcnt; i++, e++) {
            //Fix entry.
            _es_eid_entry(e);

            s8 fname[128];
            sprintf(fname, "%s%d", file, (u32) e->entnum);
            printf("writing entry @ offset 0x%08x (0x%08x bytes) to %s\n", e->offset, e->size, fname);
            _write_buffer(fname, eid + e->offset, e->size);
        }

        free(eid);
    } else
        printf("error: could not read %s\n", file);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
leaq 0xc(%rsp), %rsi
callq 0x5588
testq %rax, %rax
je 0x5867
movq %rax, %r14
movl (%rax), %eax
movl 0x4(%r14), %ecx
testl %eax, %eax
bswapl %eax
movl %eax, (%r14)
bswapl %ecx
movl %ecx, 0x4(%r14)
je 0x585d
leaq 0x10(%r14), %rbp
leaq 0x10(%rsp), %r12
leaq 0x74aa(%rip), %r13      # 0xcca5
xorl %r15d, %r15d
movl (%rbp), %eax
movl 0x4(%rbp), %ecx
bswapl %eax
movl %eax, (%rbp)
bswapl %ecx
movl %ecx, 0x4(%rbp)
movq 0x8(%rbp), %rcx
bswapq %rcx
movq %rcx, 0x8(%rbp)
movq %r12, %rdi
leaq 0x747d(%rip), %rsi      # 0xcca0
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1140
movl (%rbp), %esi
movl 0x4(%rbp), %edx
movq %r13, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x1090
movl (%rbp), %esi
movl 0x4(%rbp), %edx
addq %r14, %rsi
movq %r12, %rdi
callq 0x5611
incl %r15d
addq $0x10, %rbp
cmpl (%r14), %r15d
jb 0x57fe
movq %r14, %rdi
callq 0x1030
jmp 0x5878
leaq 0x746b(%rip), %rdi      # 0xccd9
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1090
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid_get_entry
u8 *eid_get_entry(s8 *file, u64 entnum) {
    u32 i, length;
    u8 *res = NULL;
    u8 *eid = _read_buffer(file, &length);

    if (eid != NULL) {
        eid_header_t *h = (eid_header_t *) eid;

        //Fix header.
        _es_eid_header(h);

        eid_entry_t *e = (eid_entry_t *) (eid + sizeof (eid_header_t));
        for (i = 0; i < h->entcnt; i++, e++) {
            //Fix entry.
            _es_eid_entry(e);

            if (e->entnum == entnum) {
                res = (u8 *) malloc(e->size);
                memcpy(res, eid + e->offset, e->size);
                break;
            }
        }

        free(eid);
    } else
        printf("error: could not read %s\n", file);

    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r15
movq %rdi, %r12
leaq 0xc(%rsp), %rsi
callq 0x5588
testq %rax, %rax
je 0x58f5
movq %rax, %rbx
movl (%rax), %eax
movl 0x4(%rbx), %ecx
testl %eax, %eax
bswapl %eax
movl %eax, (%rbx)
bswapl %ecx
movl %ecx, 0x4(%rbx)
je 0x590b
cmpl $0x1, %eax
adcl $0x0, %eax
leaq 0x18(%rbx), %rcx
xorl %r14d, %r14d
movl -0x8(%rcx), %ebp
movl -0x4(%rcx), %edx
bswapl %ebp
movl %ebp, -0x8(%rcx)
bswapl %edx
movl %edx, -0x4(%rcx)
movq (%rcx), %rsi
bswapq %rsi
movq %rsi, (%rcx)
cmpq %r15, %rsi
je 0x5910
addq $0x10, %rcx
decl %eax
jne 0x58cd
jmp 0x5931
leaq 0x73dd(%rip), %rdi      # 0xccd9
xorl %r14d, %r14d
movq %r12, %rsi
xorl %eax, %eax
callq 0x1090
jmp 0x5939
xorl %r14d, %r14d
jmp 0x5931
movl %edx, %r15d
movq %r15, %rdi
callq 0x1100
movq %rax, %r14
movl %ebp, %eax
movq %rbx, %rsi
addq %rax, %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x10f0
movq %rbx, %rdi
callq 0x1030
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid0_hash_encrypt_section_0
void eid0_hash_encrypt_section_0(u8 *section_in, u8 *section_out) {
    u8 indiv[INDIV_SIZE];
    u8 key[0x10];
    aes_context aes_ctxt;

    //Generate individuals.
    indiv_gen(eid0_indiv_seed, NULL, NULL, NULL, indiv);

    //Generate key.
	aes_setkey_enc(&aes_ctxt, indiv + INDIV_EID0_SEC_0_GENKEY_OFFSET, 0x100);
    aes_crypt_ecb(&aes_ctxt, AES_ENCRYPT, eid0_keyseed_0, key);

    //Calculate aes omac1.
    aes_omac1(section_in + 0xA8, section_in, 0xA8, key, 0x80);

    //Encrypt section 0 of eid0.
    aes_setkey_enc(&aes_ctxt, key, 0x80);
    aes_crypt_cbc(&aes_ctxt, AES_ENCRYPT, 0xC0, indiv + INDIV_EID0_SEC_0_IV_OFFSET, section_in, section_out);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xa8c1(%rip), %rdi      # 0x10360
leaq 0x10(%rsp), %r8
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x5654
leaq 0x30(%rsp), %rsi
leaq 0x118(%rsp), %r15
movq %r15, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x125c
leaq 0xa9f0(%rip), %rdx      # 0x104c0
movq %rsp, %r12
movq %r15, %rdi
movl $0x1, %esi
movq %r12, %rcx
callq 0x16d4
leaq 0xa8(%r14), %rdi
movq %r14, %rsi
movl $0xa8, %edx
movq %r12, %rcx
movl $0x80, %r8d
callq 0x5010
movq %r15, %rdi
movq %r12, %rsi
movl $0x80, %edx
callq 0x125c
leaq 0x20(%rsp), %rcx
movl $0xc0, %edx
movq %r15, %rdi
movl $0x1, %esi
movq %r14, %r8
movq %rbx, %r9
callq 0x1eab
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid0_hash_encrypt_section_6
void eid0_hash_encrypt_section_6(u8 *section_in, u8 *section_out) {
    u8 indiv[INDIV_SIZE];
    u8 key[0x10];
    aes_context aes_ctxt;

    //Generate individuals.
    indiv_gen(eid0_indiv_seed, NULL, NULL, NULL, indiv);

    //Generate key.
    aes_setkey_enc(&aes_ctxt, indiv + INDIV_EID0_SEC_6_GENKEY_OFFSET, 0x100);
    aes_crypt_ecb(&aes_ctxt, AES_ENCRYPT, eid0_keyseed_6, key);

    //Calculate aes omac1.
    aes_omac1(section_in + 0xA8, section_in, 0xA8, key, 0x80);

    //Encrypt section 0 of eid0.
    aes_setkey_enc(&aes_ctxt, key, 0x80);
    aes_crypt_cbc(&aes_ctxt, AES_ENCRYPT, 0xC0, indiv + INDIV_EID0_SEC_6_IV_OFFSET, section_in, section_out);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xa809(%rip), %rdi      # 0x10360
leaq 0x10(%rsp), %r8
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x5654
leaq 0x30(%rsp), %rsi
leaq 0x118(%rsp), %r15
movq %r15, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x125c
leaq 0xa948(%rip), %rdx      # 0x104d0
movq %rsp, %r12
movq %r15, %rdi
movl $0x1, %esi
movq %r12, %rcx
callq 0x16d4
leaq 0xa8(%r14), %rdi
movq %r14, %rsi
movl $0xa8, %edx
movq %r12, %rcx
movl $0x80, %r8d
callq 0x5010
movq %r15, %rdi
movq %r12, %rsi
movl $0x80, %edx
callq 0x125c
leaq 0x20(%rsp), %rcx
movl $0xc0, %edx
movq %r15, %rdi
movl $0x1, %esi
movq %r14, %r8
movq %rbx, %r9
callq 0x1eab
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid0_decrypt
void eid0_decrypt(s8 *file_in, s8 *file_out) {
    u32 length;
    u8 *eid0 = _read_buffer(file_in, &length);

    if (eid0 != NULL) {
        u8 section_0[EID0_SECTION_0_SIZE];
        eid0_decrypt_section(eid0, section_0, 0);

        u8 section_6[EID0_SECTION_0_SIZE];
        eid0_decrypt_section(eid0, section_6, 6);

        u8 section_A[EID0_SECTION_0_SIZE];
        eid0_decrypt_section(eid0, section_A, 10);

        s8 fname_0[128];
        sprintf(fname_0, "%s.section_0.bin", file_out);
        _write_buffer(fname_0, section_0, 0xC0);

        s8 fname_6[128];
        sprintf(fname_6, "%s.section_6.bin", file_out);
        _write_buffer(fname_6, section_6, 0xC0);

        s8 fname_A[128];
        sprintf(fname_A, "%s.section_A.bin", file_out);
        _write_buffer(fname_A, section_A, 0xC0);

        free(eid0);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
movq %rsi, %r14
leaq 0xc(%rsp), %rsi
callq 0x5588
testq %rax, %rax
je 0x5da4
movq %rax, %rbx
leaq 0x310(%rsp), %r13
movq %rax, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x5949
leaq 0x250(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
movl $0x6, %edx
callq 0x5949
leaq 0x190(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x5949
leaq 0x6fd1(%rip), %rsi      # 0xccf3
leaq 0x110(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1140
movq %rbp, %rdi
movq %r13, %rsi
movl $0xc0, %edx
callq 0x5611
leaq 0x6fb6(%rip), %rsi      # 0xcd04
leaq 0x90(%rsp), %r13
movq %r13, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1140
movq %r13, %rdi
movq %r12, %rsi
movl $0xc0, %edx
callq 0x5611
leaq 0x6f9b(%rip), %rsi      # 0xcd15
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1140
movq %r12, %rdi
movq %r15, %rsi
movl $0xc0, %edx
callq 0x5611
movq %rbx, %rdi
callq 0x1030
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid0_encrypt_section_0
void eid0_encrypt_section_0(s8 *file_in, s8 *file_out) {
    s8 fname_0_in[128];
    sprintf(fname_0_in, "%s.bin", file_in);

    u32 length;
    u8 *section_0_decrypted = _read_buffer(fname_0_in, &length);

    if (section_0_decrypted != NULL) {
        u8 section_0[EID0_SECTION_0_SIZE];
        eid0_hash_encrypt_section_0(section_0_decrypted, section_0);

        s8 fname_0[128];
        sprintf(fname_0, "%s.bin", file_out);
        _write_buffer(fname_0, section_0, 0xC0);

        free(section_0_decrypted);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rsi, %rbx
movq %rdi, %rdx
leaq 0x6f55(%rip), %rsi      # 0xcd26
leaq 0x90(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x5588
testq %rax, %rax
je 0x5e3c
movq %rax, %r14
leaq 0x110(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x5a84
leaq 0x6f14(%rip), %rsi      # 0xcd26
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1140
movq %r12, %rdi
movq %r15, %rsi
movl $0xc0, %edx
callq 0x5611
movq %r14, %rdi
callq 0x1030
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid0_encrypt_section_6
void eid0_encrypt_section_6(s8 *file_in, s8 *file_out) {
    s8 fname_6_in[128];
    sprintf(fname_6_in, "%s.bin", file_in);

    u32 length;
    u8 *section_6_decrypted = _read_buffer(fname_6_in, &length);

    if (section_6_decrypted != NULL) {
        u8 section_6[EID0_SECTION_6_SIZE];
        eid0_hash_encrypt_section_6(section_6_decrypted, section_6);

        s8 fname_6[128];
        sprintf(fname_6, "%s.bin", file_out);
        _write_buffer(fname_6, section_6, 0xC0);

        free(section_6_decrypted);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rsi, %rbx
movq %rdi, %rdx
leaq 0x6ec0(%rip), %rsi      # 0xcd26
leaq 0x90(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x5588
testq %rax, %rax
je 0x5ed1
movq %rax, %r14
leaq 0x110(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x5b3c
leaq 0x6e7f(%rip), %rsi      # 0xcd26
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1140
movq %r12, %rdi
movq %r15, %rsi
movl $0xc0, %edx
callq 0x5611
movq %r14, %rdi
callq 0x1030
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid0_encrypt_section_A
void eid0_encrypt_section_A(s8 *file_in, s8 *file_out) {
    s8 fname_A_in[128];
    sprintf(fname_A_in, "%s.bin", file_in);

    u32 length;
    u8 *section_A_decrypted = _read_buffer(fname_A_in, &length);

    if (section_A_decrypted != NULL) {
        u8 section_A[EID0_SECTION_A_SIZE];
        eid0_hash_encrypt_section_A(section_A_decrypted, section_A);

        s8 fname_A[128];
        sprintf(fname_A, "%s.bin", file_out);
        _write_buffer(fname_A, section_A, 0xC0);

        free(section_A_decrypted);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rsi, %rbx
movq %rdi, %rdx
leaq 0x6e2b(%rip), %rsi      # 0xcd26
leaq 0x90(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x5588
testq %rax, %rax
je 0x5f66
movq %rax, %r14
leaq 0x110(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x5bf4
leaq 0x6dea(%rip), %rsi      # 0xcd26
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1140
movq %r12, %rdi
movq %r15, %rsi
movl $0xc0, %edx
callq 0x5611
movq %r14, %rdi
callq 0x1030
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid1_decrypt
void eid1_decrypt(s8 *file_in, s8 *file_out) {
    u32 length;
    u8 *eid1 = _read_buffer(file_in, &length);

    if (eid1 != NULL) {
        eid1_decrypt_buffer(eid1);
		_write_buffer(file_out, eid1, 0x280);
		free(eid1);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
leaq 0x4(%rsp), %rsi
callq 0x5588
testq %rax, %rax
je 0x6330
movq %rax, %r14
movq %rax, %rdi
callq 0x618b
movq %rbx, %rdi
movq %r14, %rsi
movl $0x280, %edx            # imm = 0x280
callq 0x5611
movq %r14, %rdi
callq 0x1030
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid2_generate_block_buffer
u8 *eid2_generate_block_buffer(u8 *eid2, u32 blocktype) {
    u8 *res = NULL, indiv[INDIV_SIZE];
    aes_context aes_ctxt;

    //Generate individuals.
    indiv_gen(eid2_indiv_seed, NULL, NULL, NULL, indiv);

    switch (blocktype) {
        case EID2_BLOCKTYPE_P:
            res = (u8 *) malloc(0x80);
            aes_setkey_dec(&aes_ctxt, indiv + INDIV_EID2_KEY_OFFSET, 0x100);
            aes_crypt_cbc(&aes_ctxt, AES_DECRYPT, 0x80, indiv + INDIV_EID2_IV_OFFSET, eid2 + 0x20, res);
            break;
        case EID2_BLOCKTYPE_S:
            res = (u8 *) malloc(0x690);
            aes_setkey_dec(&aes_ctxt, indiv + INDIV_EID2_KEY_OFFSET, 0x100);
            aes_crypt_cbc(&aes_ctxt, AES_DECRYPT, 0x690, indiv + INDIV_EID2_IV_OFFSET, eid2 + 0x20 + 0x80, res);
            break;
    }

    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x338, %rsp            # imm = 0x338
movl %esi, %ebp
movq %rdi, %rbx
leaq 0xa0af(%rip), %rdi      # 0x10400
xorl %r14d, %r14d
movq %rsp, %r8
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x5654
cmpl $0x2, %ebp
je 0x63a3
cmpl $0x1, %ebp
jne 0x63eb
movl $0x80, %edi
callq 0x1100
movq %rax, %r14
leaq 0x20(%rsp), %rsi
leaq 0x108(%rsp), %r15
movq %r15, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x154d
leaq 0x10(%rsp), %rcx
addq $0x20, %rbx
movl $0x80, %edx
jmp 0x63db
movl $0x690, %edi            # imm = 0x690
callq 0x1100
movq %rax, %r14
leaq 0x20(%rsp), %rsi
leaq 0x108(%rsp), %r15
movq %r15, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x154d
leaq 0x10(%rsp), %rcx
addq $0xa0, %rbx
movl $0x690, %edx            # imm = 0x690
movq %r15, %rdi
xorl %esi, %esi
movq %rbx, %r8
movq %r14, %r9
callq 0x1eab
movq %r14, %rax
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r14
popq %r15
popq %rbp
retq