LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/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 0x75e6(%rip), %rsi      # 0xcc5b
callq 0x1120
testq %rax, %rax
je 0x56a0
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_O1/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 0x56ff
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 0x572b
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 0x575f
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 0x5793
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 0xae23(%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 0x1eae
addq $0x40, %r13
cmpl $0x100, %r13d           # imm = 0x100
jne 0x57a5
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x55dc
testq %rax, %rax
je 0x58be
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 0x58b4
leaq 0x18(%r14), %rbp
leaq 0x10(%rsp), %r12
leaq 0x7426(%rip), %r13      # 0xcc75
xorl %r15d, %r15d
movl -0x8(%rbp), %eax
movl -0x4(%rbp), %ecx
bswapl %eax
movl %eax, -0x8(%rbp)
bswapl %ecx
movl %ecx, -0x4(%rbp)
movq (%rbp), %rax
bswapq %rax
movq %rax, (%rbp)
movl (%rbp), %ecx
movq %r12, %rdi
leaq 0x73f6(%rip), %rsi      # 0xcc70
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1140
movl -0x8(%rbp), %esi
movl -0x4(%rbp), %edx
movq %r13, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x1090
movl -0x8(%rbp), %esi
movl -0x4(%rbp), %edx
addq %r14, %rsi
movq %r12, %rdi
callq 0x5665
incl %r15d
addq $0x10, %rbp
cmpl (%r14), %r15d
jb 0x5852
movq %r14, %rdi
callq 0x1030
jmp 0x58cf
leaq 0x73e4(%rip), %rdi      # 0xcca9
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_O1/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 0x55dc
testq %rax, %rax
je 0x594c
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 0x5962
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), %rdx
bswapq %rdx
movq %rdx, (%rcx)
cmpq %r15, %rdx
je 0x5967
addq $0x10, %rcx
decl %eax
jne 0x5924
jmp 0x5989
leaq 0x7356(%rip), %rdi      # 0xcca9
xorl %r14d, %r14d
movq %r12, %rsi
xorl %eax, %eax
callq 0x1090
jmp 0x5991
xorl %r14d, %r14d
jmp 0x5989
movl -0x4(%rcx), %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_O1/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 0xa869(%rip), %rdi      # 0x10360
leaq 0x10(%rsp), %r8
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x56a8
leaq 0x30(%rsp), %rsi
leaq 0x118(%rsp), %r15
movq %r15, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x125c
leaq 0xa998(%rip), %rdx      # 0x104c0
movq %rsp, %r12
movq %r15, %rdi
movl $0x1, %esi
movq %r12, %rcx
callq 0x16d7
leaq 0xa8(%r14), %rdi
movq %r14, %rsi
movl $0xa8, %edx
movq %r12, %rcx
movl $0x80, %r8d
callq 0x504d
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 0x1eae
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xa7b1(%rip), %rdi      # 0x10360
leaq 0x10(%rsp), %r8
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x56a8
leaq 0x30(%rsp), %rsi
leaq 0x118(%rsp), %r15
movq %r15, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x125c
leaq 0xa8f0(%rip), %rdx      # 0x104d0
movq %rsp, %r12
movq %r15, %rdi
movl $0x1, %esi
movq %r12, %rcx
callq 0x16d7
leaq 0xa8(%r14), %rdi
movq %r14, %rsi
movl $0xa8, %edx
movq %r12, %rcx
movl $0x80, %r8d
callq 0x504d
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 0x1eae
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x55dc
testq %rax, %rax
je 0x5dfc
movq %rax, %rbx
leaq 0x310(%rsp), %r13
movq %rax, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x59a1
leaq 0x250(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
movl $0x6, %edx
callq 0x59a1
leaq 0x190(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x59a1
leaq 0x6f49(%rip), %rsi      # 0xccc3
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 0x5665
leaq 0x6f2e(%rip), %rsi      # 0xccd4
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 0x5665
leaq 0x6f13(%rip), %rsi      # 0xcce5
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 0x5665
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_O1/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 0x6ecd(%rip), %rsi      # 0xccf6
leaq 0x90(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x55dc
testq %rax, %rax
je 0x5e94
movq %rax, %r14
leaq 0x110(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x5adc
leaq 0x6e8c(%rip), %rsi      # 0xccf6
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 0x5665
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_O1/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 0x6e38(%rip), %rsi      # 0xccf6
leaq 0x90(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x55dc
testq %rax, %rax
je 0x5f29
movq %rax, %r14
leaq 0x110(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x5b94
leaq 0x6df7(%rip), %rsi      # 0xccf6
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 0x5665
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_O1/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 0x6da3(%rip), %rsi      # 0xccf6
leaq 0x90(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x55dc
testq %rax, %rax
je 0x5fbe
movq %rax, %r14
leaq 0x110(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x5c4c
leaq 0x6d62(%rip), %rsi      # 0xccf6
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 0x5665
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_O1/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 0x55dc
testq %rax, %rax
je 0x6388
movq %rax, %r14
movq %rax, %rdi
callq 0x61e3
movq %rbx, %rdi
movq %r14, %rsi
movl $0x280, %edx            # imm = 0x280
callq 0x5665
movq %r14, %rdi
callq 0x1030
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xa057(%rip), %rdi      # 0x10400
xorl %r14d, %r14d
movq %rsp, %r8
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x56a8
cmpl $0x2, %ebp
je 0x63fb
cmpl $0x1, %ebp
jne 0x6443
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 0x153b
leaq 0x10(%rsp), %rcx
addq $0x20, %rbx
movl $0x80, %edx
jmp 0x6433
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 0x153b
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 0x1eae
movq %r14, %rax
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid2_generate_block
void eid2_generate_block(s8 *file_in, u32 blocktype, s8 *file_out) {
    u32 length;
    u8 *eid2 = _read_buffer(file_in, &length);

    if (eid2 != NULL) {
        u8 *block = eid2_generate_block_buffer(eid2, blocktype);
        if (block != NULL) {
            switch (blocktype) {
                case EID2_BLOCKTYPE_P:
                    _write_buffer(file_out, block, 0x80);
                    free(block);
                    break;
                case EID2_BLOCKTYPE_S:
                    _write_buffer(file_out, block, 0x690);
                    free(block);
                    break;
            }

        }

        free(eid2);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %esi, %ebp
leaq 0x4(%rsp), %rsi
callq 0x55dc
testq %rax, %rax
je 0x64b5
movq %rax, %rbx
movq %rax, %rdi
movl %ebp, %esi
callq 0x6390
testq %rax, %rax
je 0x64ad
movq %rax, %r15
cmpl $0x1, %ebp
je 0x6495
cmpl $0x2, %ebp
jne 0x64ad
movl $0x690, %edx            # imm = 0x690
jmp 0x649a
movl $0x80, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x5665
movq %r15, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid2_decrypt_block
void eid2_decrypt_block(u8 *block, u32 length) {
    u8 tmp[0x08], iv[0x08];
    int block_size = 8;
    int num_blocks = (int) (length / block_size);

    memcpy(iv, eid2_des_iv, 0x08);

    if (num_blocks > 0) {
        int i, j;
        des_context ctx;
        des_setkey_dec(&ctx, eid2_des_key);
        for (i = 0; i < num_blocks - 1; ++i) {
            u8 *ptr = block + i * block_size;
            memcpy(tmp, ptr, block_size);
            des_crypt_ecb(&ctx, ptr, ptr);
            if (i > 0) {
                for (j = 0; j < block_size; ++j)
                    ptr[j] = ptr[j] ^ iv[j];
            }
            memcpy(iv, tmp, block_size);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
leaq 0xa108(%rip), %rax      # 0x105e0
movq (%rax), %rax
movq %rax, 0x8(%rsp)
cmpl $0x8, %esi
jb 0x654c
movl %esi, %ebx
movq %rdi, %r14
leaq 0xa02f(%rip), %rsi      # 0x10520
leaq 0x14(%rsp), %rdi
callq 0x4565
cmpl $0x10, %ebx
jb 0x654c
shrl $0x3, %ebx
decl %ebx
xorl %r12d, %r12d
leaq 0x14(%rsp), %r15
movq %r14, %r13
leaq (%r14,%r12,8), %rdx
movq (%rdx), %rbp
movq %r15, %rdi
movq %rdx, %rsi
callq 0x47b3
testq %r12, %r12
je 0x653b
xorl %eax, %eax
movb 0x8(%rsp,%rax), %cl
xorb %cl, (%r13,%rax)
incq %rax
cmpq $0x8, %rax
jne 0x6529
movq %rbp, 0x8(%rsp)
incq %r12
addq $0x8, %r13
cmpq %rbx, %r12
jne 0x6510
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid3_decrypt_buffer
void eid3_decrypt_buffer(u8 *eid3) {
    u8 indiv[INDIV_SIZE];
    u8 key[0x10], iv[0x10];
    aes_context aes_ctxt;

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

    //Generate key.
    memset(iv, 0, 0x10);
    aes_setkey_enc(&aes_ctxt, indiv + 0x20, 0x100);
    aes_crypt_cbc(&aes_ctxt, AES_ENCRYPT, 0x10, iv, eid3_keyseed, key);

    //Calculate eid3 aes omac1.
    u8 digest[AES_OMAC1_DIGEST_SIZE];
    aes_omac1(digest, eid3, 0xF0, key, 0x80);



    if (memcmp(digest, eid3 + 0xF0, AES_OMAC1_DIGEST_SIZE) != 0)
        printf("warning: eid3 omac1 hash check failed!\n");

    //Decrypt eid3.
    aes_setkey_dec(&aes_ctxt, key, 0x80);
    memcpy(iv, eid3 + 0x10, 0x10);
    aes_crypt_cbc(&aes_ctxt, AES_DECRYPT, 0xD0, iv, eid3 + 0x20, eid3 + 0x20);

    //Decrypt second layer.
    memset(iv, 0, 0x10);
    aes_setkey_dec(&aes_ctxt, eid3_static_key, 0x80);
    aes_crypt_cbc(&aes_ctxt, AES_DECRYPT, 0xD0, iv, eid3 + 0x20, eid3 + 0x20);


    u8 sha1_digest[20];
    sha1(eid3 + 0x20, 0xB8, sha1_digest);



    if (memcmp(sha1_digest, eid3 + 0x20 + 0xB8, 20) != 0)
        printf("warning: eid3 sha1 hash check failed!\n");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x388, %rsp            # imm = 0x388
movq %rdi, %rbx
leaq 0x9eca(%rip), %rdi      # 0x10440
leaq 0x50(%rsp), %r8
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x56a8
xorps %xmm0, %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
leaq 0x70(%rsp), %rsi
leaq 0x158(%rsp), %r15
movq %r15, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x125c
leaq 0x9f4f(%rip), %r8       # 0x10500
leaq 0x10(%rsp), %r12
movl $0x10, %edx
movq %r15, %rdi
movl $0x1, %esi
movq %r14, %rcx
movq %r12, %r9
callq 0x1eae
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movl $0xf0, %edx
movq %r12, %rcx
movl $0x80, %r8d
callq 0x504d
movdqu 0xf0(%rbx), %xmm0
pcmpeqb (%r14), %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x6610
leaq 0x684b(%rip), %rdi      # 0xce56
callq 0x1050
leaq 0x158(%rsp), %r14
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
movl $0x80, %edx
callq 0x153b
movups 0x10(%rbx), %xmm0
movq %rsp, %r12
movaps %xmm0, (%r12)
leaq 0x20(%rbx), %r15
movl $0xd0, %edx
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %rcx
movq %r15, %r8
movq %r15, %r9
callq 0x1eae
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
leaq 0x9eaf(%rip), %rsi      # 0x10510
movq %r14, %rdi
movl $0x80, %edx
callq 0x153b
movl $0xd0, %edx
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %rcx
movq %r15, %r8
movq %r15, %r9
callq 0x1eae
leaq 0x30(%rsp), %r14
movl $0xb8, %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x3de7
movdqu 0xd8(%rbx), %xmm0
movd 0x10(%r14), %xmm1
movd 0xe8(%rbx), %xmm2
pcmpeqb (%r14), %xmm0
pcmpeqb %xmm1, %xmm2
pand %xmm2, %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x66d5
leaq 0x67ad(%rip), %rdi      # 0xce7d
callq 0x1050
addq $0x388, %rsp            # imm = 0x388
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid3_decrypt
void eid3_decrypt(s8 *file_in, s8 *file_out) {
    u32 length;
    u8 *eid3 = _read_buffer(file_in, &length);

    if (eid3 != NULL) {
        eid3_decrypt_buffer(eid3);
        _write_buffer(file_out, eid3, EID3_SIZE);
        free(eid3);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
leaq 0x4(%rsp), %rsi
callq 0x55dc
testq %rax, %rax
je 0x671d
movq %rax, %r14
movq %rax, %rdi
callq 0x655e
movq %rbx, %rdi
movq %r14, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x5665
movq %r14, %rdi
callq 0x1030
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid4_decrypt_buffer
void eid4_decrypt_buffer(u8 *eid4) {
    u8 indiv[INDIV_SIZE];
    aes_context aes_ctxt;

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

    //Calculate eid4 aes omac1.
    u8 digest[AES_OMAC1_DIGEST_SIZE];
    aes_omac1(digest, eid4, 0x20, indiv + INDIV_EID4_KEY_OFFSET, 0x100);

    if (memcmp(digest, eid4 + 0x20, AES_OMAC1_DIGEST_SIZE) != 0)
        printf("warning: eid4 hash check failed!\n");

    //Decrypt eid4.
    aes_setkey_dec(&aes_ctxt, indiv + INDIV_EID4_KEY_OFFSET, 0x100);
    aes_crypt_cbc(&aes_ctxt, AES_DECRYPT, 0x20, indiv + INDIV_EID4_IV_OFFSET, eid4, eid4);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x340, %rsp            # imm = 0x340
movq %rdi, %rbx
leaq 0x9d45(%rip), %rdi      # 0x10480
leaq 0x10(%rsp), %r8
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x56a8
leaq 0x30(%rsp), %r14
movq %rsp, %r15
movq %r15, %rdi
movq %rbx, %rsi
movl $0x20, %edx
movq %r14, %rcx
movl $0x100, %r8d            # imm = 0x100
callq 0x504d
movdqu 0x20(%rbx), %xmm0
pcmpeqb (%r15), %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x678d
leaq 0x671b(%rip), %rdi      # 0xcea3
callq 0x1050
leaq 0x110(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x153b
leaq 0x20(%rsp), %rcx
movl $0x20, %edx
movq %r15, %rdi
xorl %esi, %esi
movq %rbx, %r8
movq %rbx, %r9
callq 0x1eae
addq $0x340, %rsp            # imm = 0x340
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/eid.c
// Function: eid4_decrypt
void eid4_decrypt(s8 *file_in, s8 *file_out) {
    u32 length;
    u8 *eid4 = _read_buffer(file_in, &length);

    if (eid4 != NULL) {
        eid4_decrypt_buffer(eid4);
        _write_buffer(file_out, eid4, EID4_SIZE);
        free(eid4);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
leaq 0x4(%rsp), %rsi
callq 0x55dc
testq %rax, %rax
je 0x6805
movq %rax, %r14
movq %rax, %rdi
callq 0x6725
movq %rbx, %rdi
movq %r14, %rsi
movl $0x30, %edx
callq 0x5665
movq %r14, %rdi
callq 0x1030
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/main.c
// Function: generate_hdd_individuals
void generate_hdd_individuals() {
    u8 ata_k1[0x20], ata_k2[0x20], edec_k1[0x20], edec_k2[0x20];

    //fetching root_key
    eid_root_key = _read_buffer((s8*) "data/eid_root_key", NULL);

    //Generate keys.
    generate_ata_keys(eid_root_key, eid_root_key + 0x20, ata_k1, ata_k2);
    generate_encdec_keys(eid_root_key, eid_root_key + 0x20, edec_k1, edec_k2);

    _hexdump(stdout, "ATA-DATA-KEY    ", 0, ata_k1, 0x20, 0);
    _hexdump(stdout, "ATA-TWEAK-KEY   ", 0, ata_k2, 0x20, 0);
    _hexdump(stdout, "ENCDEC-DATA-KEY ", 0, edec_k1, 0x20, 0);
    _hexdump(stdout, "ENCDEC-TWEAK-KEY", 0, edec_k2, 0x20, 0);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x80, %rsp
leaq 0x66b9(%rip), %rdi      # 0xcee0
xorl %esi, %esi
callq 0x55dc
leaq 0x9d8b(%rip), %rbx      # 0x105c0
movq %rax, (%rbx)
leaq 0x20(%rax), %rsi
leaq 0x60(%rsp), %r12
leaq 0x40(%rsp), %r15
movq %rax, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x5210
movq (%rbx), %rdi
leaq 0x20(%rdi), %rsi
leaq 0x20(%rsp), %r14
movq %rsp, %rbx
movq %r14, %rdx
movq %rbx, %rcx
callq 0x52b7
movq 0x976b(%rip), %r13      # 0xffe0
movq (%r13), %rdi
leaq 0x6672(%rip), %rsi      # 0xcef2
xorl %edx, %edx
movq %r12, %rcx
movl $0x20, %r8d
xorl %r9d, %r9d
callq 0x54cc
movq (%r13), %rdi
leaq 0x6665(%rip), %rsi      # 0xcf03
xorl %edx, %edx
movq %r15, %rcx
movl $0x20, %r8d
xorl %r9d, %r9d
callq 0x54cc
movq (%r13), %rdi
leaq 0x6658(%rip), %rsi      # 0xcf14
xorl %edx, %edx
movq %r14, %rcx
movl $0x20, %r8d
xorl %r9d, %r9d
callq 0x54cc
movq (%r13), %rdi
leaq 0x664b(%rip), %rsi      # 0xcf25
xorl %edx, %edx
movq %rbx, %rcx
movl $0x20, %r8d
xorl %r9d, %r9d
callq 0x54cc
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/main.c
// Function: decrypt_eid
void decrypt_eid() {
    //fetching root_key
    eid_root_key = _read_buffer((s8*) "data/eid_root_key", NULL);

    //unpacking eid
    eid_unpack((s8*) "eid/eid");

    //decrypting
    eid0_decrypt((s8*) "eid/eid0", (s8*) "eid/eid0decrypted");
    eid1_decrypt((s8*) "eid/eid1", (s8*) "eid/eid1decrypted.bin");
    eid2_generate_block((s8*) "eid/eid2", EID2_BLOCKTYPE_P, (s8*) "eid/eid2pblock.bin");
    eid2_generate_block((s8*) "eid/eid2", EID2_BLOCKTYPE_S, (s8*) "eid/eid2sblock.bin");
    u8* pblock = _read_buffer("eid/eid2pblock.bin", NULL);
    eid2_decrypt_block(pblock, 0x80);
    memcpy(pblock, pblock + 0x10, 0x60);
    _write_buffer((s8*) "eid/pblockdec.bin", pblock, 0x60);
    u8* sblock = _read_buffer("eid/eid2sblock.bin", NULL);
    eid2_decrypt_block(sblock, 0x690);
    memcpy(sblock, sblock + 0x10, 0x670);
    _write_buffer((s8*) "eid/sblockdec.bin", sblock, 0x670);
    eid3_decrypt((s8*) "eid/eid3", (s8*) "eid/eid3decrypted.bin");
    eid4_decrypt((s8*) "eid/eid4", (s8*) "eid/eid4decrypted.bin");
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
leaq 0x65d6(%rip), %rdi      # 0xcee0
xorl %esi, %esi
callq 0x55dc
leaq 0x9ca8(%rip), %rcx      # 0x105c0
movq %rax, (%rcx)
leaq 0x6614(%rip), %rdi      # 0xcf36
callq 0x5800
leaq 0x6610(%rip), %rdi      # 0xcf3e
leaq 0x6612(%rip), %rsi      # 0xcf47
callq 0x5d04
leaq 0x6618(%rip), %rdi      # 0xcf59
leaq 0x661a(%rip), %rsi      # 0xcf62
callq 0x634f
leaq 0x6624(%rip), %r14      # 0xcf78
leaq 0x6626(%rip), %r15      # 0xcf81
movq %r14, %rdi
movl $0x1, %esi
movq %r15, %rdx
callq 0x6454
leaq 0x6622(%rip), %rbx      # 0xcf94
movq %r14, %rdi
movl $0x2, %esi
movq %rbx, %rdx
callq 0x6454
movq %r15, %rdi
xorl %esi, %esi
callq 0x55dc
movq %rax, %r14
movq %rax, %rdi
movl $0x80, %esi
callq 0x64c0
leaq 0x10(%r14), %rsi
movl $0x60, %edx
movq %r14, %rdi
callq 0x10f0
leaq 0x65f3(%rip), %rdi      # 0xcfa7
movq %r14, %rsi
movl $0x60, %edx
callq 0x5665
movq %rbx, %rdi
xorl %esi, %esi
callq 0x55dc
movq %rax, %rbx
movq %rax, %rdi
movl $0x690, %esi            # imm = 0x690
callq 0x64c0
leaq 0x10(%rbx), %rsi
movl $0x670, %edx            # imm = 0x670
movq %rbx, %rdi
callq 0x10f0
leaq 0x65c6(%rip), %rdi      # 0xcfb9
movq %rbx, %rsi
movl $0x670, %edx            # imm = 0x670
callq 0x5665
leaq 0x65c4(%rip), %rdi      # 0xcfcb
leaq 0x65c6(%rip), %rsi      # 0xcfd4
callq 0x66e4
leaq 0x65d0(%rip), %rdi      # 0xcfea
leaq 0x65d2(%rip), %rsi      # 0xcff3
popq %rbx
popq %r14
popq %r15
jmp 0x67cc
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/main.c
// Function: hexDump
void hexDump(const void *data, size_t size) {
  size_t i;
  for (i = 0; i < size; i++) {
    printf("%02hhX%c", ((char *)data)[i], (i + 1) % 16 ? ' ' : '\n');
  }
  printf("\n");
}

// Assembly:
testq %rsi, %rsi
je 0x6b0e
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
negq %rbx
movl $0x1, %r12d
movl $0xa, %ebp
leaq 0x65d7(%rip), %r15      # 0xd0b1
movsbl -0x1(%r14,%r12), %esi
testb $0xf, %r12b
movl $0x20, %edx
cmovel %ebp, %edx
movq %r15, %rdi
xorl %eax, %eax
callq 0x1090
leaq (%rbx,%r12), %rax
incq %rax
incq %r12
cmpq $0x1, %rax
jne 0x6ada
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
movl $0xa, %edi
jmp 0x1040
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/main.c
// Function: gen_vtrm
void gen_vtrm(){
	//fetching root_key
    eid_root_key = _read_buffer((s8*) "data/eid_root_key", NULL);
	
	aes_context aes_ctxt;
    u8 iv[0x10];
	u8 indiv[0x40];
	u8 key[0x10];
	u8 block_key[0x10];
	u8 block_iv[0x10]={0x0};
	
	
	indiv_gen(eid1_indiv_seed, NULL, NULL, NULL, indiv);
	
    //Generate VTRM Block Key.
	memcpy(key, indiv + 0x20, 0x10);
    aes_setkey_enc(&aes_ctxt, key, KEY_BITS(0x10));
    memcpy(iv, indiv + 0x10, 0x10);
    aes_crypt_cbc(&aes_ctxt, AES_ENCRYPT, 0x10, iv, keyseed_for_srk2, block_key);
	
	_hexdump(stdout, "Block Key:    ", 0, block_key, 0x10, 0);
	_hexdump(stdout, "Block Iv:    ", 0, block_iv, 0x10, 0);
	
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x2b0, %rsp            # imm = 0x2B0
leaq 0x610b(%rip), %rdi      # 0xcee0
xorl %esi, %esi
callq 0x55dc
leaq 0x97dd(%rip), %rcx      # 0x105c0
movq %rax, (%rcx)
xorps %xmm0, %xmm0
movq %rsp, %rbx
movaps %xmm0, (%rbx)
leaq 0x95aa(%rip), %rdi      # 0x103a0
leaq 0x40(%rsp), %r14
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
callq 0x56a8
movaps 0x20(%r14), %xmm0
leaq 0x20(%rsp), %rsi
movaps %xmm0, (%rsi)
leaq 0x80(%rsp), %r15
movq %r15, %rdi
movl $0x80, %edx
callq 0x125c
movaps 0x10(%r14), %xmm0
leaq 0x30(%rsp), %rcx
movaps %xmm0, (%rcx)
leaq 0x9281(%rip), %r8       # 0x100c0
leaq 0x10(%rsp), %r14
movl $0x10, %edx
movq %r15, %rdi
movl $0x1, %esi
movq %r14, %r9
callq 0x1eae
movq 0x9180(%rip), %r15      # 0xffe0
movq (%r15), %rdi
leaq 0x62c7(%rip), %rsi      # 0xd131
xorl %edx, %edx
movq %r14, %rcx
movl $0x10, %r8d
xorl %r9d, %r9d
callq 0x54cc
movq (%r15), %rdi
leaq 0x62b9(%rip), %rsi      # 0xd140
xorl %edx, %edx
movq %rbx, %rcx
movl $0x10, %r8d
xorl %r9d, %r9d
callq 0x54cc
addq $0x2b0, %rsp            # imm = 0x2B0
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/main.c
// Function: gen_backup
void gen_backup(){
	//fetching root_key
    eid_root_key = _read_buffer((s8*) "data/eid_root_key", NULL);
	
	aes_context aes_ctxt;
    u8 iv[0x10];
	u8 indiv[0x40];
	u8 key[0x10];
	u8 backup_key[0x10];
	
	
	indiv_gen(eid1_indiv_seed, NULL, NULL, NULL, indiv);
	
    //Generate Backup Key.
	memcpy(key, indiv + 0x20, 0x10);
    aes_setkey_enc(&aes_ctxt, key, KEY_BITS(0x10));
    memcpy(iv, indiv + 0x10, 0x10);
    aes_crypt_cbc(&aes_ctxt, AES_ENCRYPT, 0x10, iv, seed_for_backup, backup_key);
	memcpy(iv, indiv + 0x10, 0x10);
	
	_hexdump(stdout, "Backup Key:    ", 0, backup_key, 0x10, 0);
	_hexdump(stdout, "Backup Iv:    ", 0, iv, 0x10, 0);
	
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
leaq 0x6024(%rip), %rdi      # 0xcee0
xorl %esi, %esi
callq 0x55dc
leaq 0x96f6(%rip), %rcx      # 0x105c0
movq %rax, (%rcx)
leaq 0x94cc(%rip), %rdi      # 0x103a0
leaq 0x30(%rsp), %r14
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
callq 0x56a8
movaps 0x20(%r14), %xmm0
leaq 0x10(%rsp), %rsi
movaps %xmm0, (%rsi)
leaq 0x78(%rsp), %r15
movq %r15, %rdi
movl $0x80, %edx
callq 0x125c
movaps 0x10(%r14), %xmm0
leaq 0x20(%rsp), %rbx
movaps %xmm0, (%rbx)
leaq 0x91b6(%rip), %r8       # 0x100d0
movq %rsp, %r12
movl $0x10, %edx
movq %r15, %rdi
movl $0x1, %esi
movq %rbx, %rcx
movq %r12, %r9
callq 0x1eae
movaps 0x10(%r14), %xmm0
movaps %xmm0, (%rbx)
movq 0x909c(%rip), %r14      # 0xffe0
movq (%r14), %rdi
leaq 0x6200(%rip), %rsi      # 0xd14e
xorl %edx, %edx
movq %r12, %rcx
movl $0x10, %r8d
xorl %r9d, %r9d
callq 0x54cc
movq (%r14), %rdi
leaq 0x61f3(%rip), %rsi      # 0xd15e
xorl %edx, %edx
movq %rbx, %rcx
movl $0x10, %r8d
xorl %r9d, %r9d
callq 0x54cc
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/zecoxao[P]ps3_decrypt_tools/lib/main.c
// Function: main
int main() {
    int i;
    printf("Select an option\n1-Decrypt eEID(missing eid5)\n2-Encrypt All eEID0 sections \n3-Generate Syscon AUTH seeds(Acording to wiki)\n4-Generate HDD Keys\n5-Generate VTRM Keys\n6-Generate Backup Keys\n0-Exit\n");
    scanf("%d", &i);
    switch (i) {
        case 1:
            decrypt_eid();
			getchar();
            break;
        case 2:
			encrypt_eid0_section_0();
			encrypt_eid0_section_6();
            encrypt_eid0_section_A();
			//getchar();
            break;
        case 3:
            syscon_auth();
			getchar();
            break;
        case 4:
            generate_hdd_individuals();
			getchar();
            break;
		case 5:
            gen_vtrm();
			getchar();
            break;
		case 6:
            gen_backup();
			getchar();
        case 0:
            break;
        default:
            printf("Incorrect Option Selected! Try Again.");
            break;
    }
    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0x61fb(%rip), %rdi      # 0xd193
callq 0x1050
leaq 0x5cce(%rip), %rdi      # 0xcc72
leaq 0x4(%rsp), %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1130
movl (%rbx), %eax
cmpq $0x6, %rax
ja 0x705a
leaq 0x5efe(%rip), %rcx      # 0xcec4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
callq 0x68fe
jmp 0x7076
callq 0x6810
jmp 0x7076
leaq 0x5ef6(%rip), %rbx      # 0xcee0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x55dc
leaq 0x95c5(%rip), %r14      # 0x105c0
movq %rax, (%r14)
leaq 0x6004(%rip), %rdi      # 0xd009
leaq 0x6019(%rip), %rsi      # 0xd025
callq 0x5e0e
movq %rbx, %rdi
xorl %esi, %esi
callq 0x55dc
movq %rax, (%r14)
leaq 0x601c(%rip), %rdi      # 0xd041
leaq 0x6031(%rip), %rsi      # 0xd05d
callq 0x5ea3
movq %rbx, %rdi
xorl %esi, %esi
callq 0x55dc
movq %rax, (%r14)
leaq 0x6034(%rip), %rdi      # 0xd079
leaq 0x6049(%rip), %rsi      # 0xd095
callq 0x5f38
jmp 0x707b
callq 0x6b18
jmp 0x7076
leaq 0x610c(%rip), %rdi      # 0xd16d
xorl %eax, %eax
callq 0x1090
jmp 0x707b
callq 0x6dc2
jmp 0x7076
callq 0x6ea7
callq 0x10c0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/adelciotto[P]plasma/src/gl_rgb_plasma.c
// Function: InitSDL
int InitSDL(void) {
    SDL_Init(SDL_INIT_VIDEO);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
                        SDL_GL_CONTEXT_PROFILE_CORE);

    if (SDL_GetDesktopDisplayMode(0, &gDisplayMode) != 0) {
        return -1;
    }

    gWindow = SDL_CreateWindow(
        WINDOW_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, gWidth,
        gHeight, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
    if (gWindow == NULL) {
        return -1;
    }
    LogInfo("window created with size %dx%d", gWidth, gHeight);

    gContext = SDL_GL_CreateContext(gWindow);
    if (gContext == NULL) {
        return -1;
    }

    GLenum glewError = glewInit();
    if (glewError != GLEW_OK) {
        LogError("error initializing GLEW! %s", glewGetErrorString(glewError));
    }

    if (SDL_GL_SetSwapInterval(1) < 0) {
        LogInfo("warning: unable to set vsync. %s", SDL_GetError());
    }

    if (gFullscreen) {
        SDL_SetWindowFullscreen(gWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
    }

    SDL_ShowCursor(SDL_DISABLE);

    return 0;
}

// Assembly:
pushq %rbx
movl $0x20, %edi
callq 0x2260
movl $0x11, %edi
movl $0x3, %esi
callq 0x21e0
movl $0x12, %edi
movl $0x3, %esi
callq 0x21e0
movl $0x15, %edi
movl $0x1, %esi
callq 0x21e0
leaq 0x3c94(%rip), %rsi      # 0x6198
xorl %edi, %edi
callq 0x2150
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x2518
movl %ebx, %eax
popq %rbx
retq
movl 0x3c3e(%rip), %ecx      # 0x615c
movl 0x3c3b(%rip), %r8d      # 0x6160
leaq 0x1b1c(%rip), %rdi      # 0x4048
movl $0x2fff0000, %esi       # imm = 0x2FFF0000
movl $0x2fff0000, %edx       # imm = 0x2FFF0000
movl $0x26, %r9d
callq 0x2100
movq %rax, 0x3c28(%rip)      # 0x6170
testq %rax, %rax
je 0x2514
movl 0x3c09(%rip), %edx      # 0x615c
movl 0x3c07(%rip), %ecx      # 0x6160
leaq 0x1af6(%rip), %rsi      # 0x4056
xorl %edi, %edi
xorl %eax, %eax
callq 0x21b0
movq 0x3c00(%rip), %rdi      # 0x6170
callq 0x2180
movq %rax, 0x3bfc(%rip)      # 0x6178
testq %rax, %rax
je 0x2514
callq 0x2230
testl %eax, %eax
je 0x25a4
movl %eax, %edi
callq 0x20b0
leaq 0x1add(%rip), %rsi      # 0x4075
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2250
movl $0x1, %edi
callq 0x2140
testl %eax, %eax
jns 0x25ca
callq 0x21f0
leaq 0x1ad3(%rip), %rsi      # 0x4091
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x21b0
cmpl $0x0, 0x3bbf(%rip)      # 0x6190
je 0x25e4
movq 0x3b96(%rip), %rdi      # 0x6170
movl $0x1001, %esi           # imm = 0x1001
callq 0x2040
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x2190
jmp 0x2514
// File: /workspace/github_c_makefile_star2_O1/adelciotto[P]plasma/src/gl_rgb_plasma.c
// Function: LogShaderError
void LogShaderError(GLuint shader) {
    if (glIsShader(shader)) {
        int infoLogLength = 0;
        int maxLength = infoLogLength;

        glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength);

        char *infoLog = malloc(maxLength * sizeof(*infoLog));
        if (infoLog == NULL) {
            LogError("failed to malloc error log for gl shader %d of size %d",
                     shader, maxLength);
        }

        glGetShaderInfoLog(shader, maxLength, &infoLogLength, infoLog);
        if (infoLogLength > 0) {
            LogError("failed to compile shader %d:\n%s", shader, infoLog);
        }

        free(infoLog);
    } else {
        LogError("name shader %d is not a shader", shader);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movq 0x395e(%rip), %rax      # 0x5f60
callq *(%rax)
testb %al, %al
je 0x2699
xorl %eax, %eax
movl %eax, 0x4(%rsp)
movq %rsp, %r14
movl %eax, (%r14)
movq 0x3929(%rip), %rax      # 0x5f48
movl %ebx, %edi
movl $0x8b84, %esi           # imm = 0x8B84
movq %r14, %rdx
callq *(%rax)
movl (%r14), %ebp
movslq %ebp, %rdi
callq 0x21c0
movq %rax, %r14
testq %rax, %rax
jne 0x2652
leaq 0x1a6d(%rip), %rsi      # 0x40b2
xorl %edi, %edi
movl %ebx, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2250
movq 0x38b7(%rip), %rax      # 0x5f10
movl (%rsp), %esi
leaq 0x4(%rsp), %r15
movl %ebx, %edi
movq %r15, %rdx
movq %r14, %rcx
callq *(%rax)
cmpl $0x0, (%r15)
jle 0x2686
leaq 0x1a71(%rip), %rsi      # 0x40e9
xorl %edi, %edi
movl %ebx, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x2250
movq %r14, %rdi
callq 0x2070
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a69(%rip), %rsi      # 0x4109
xorl %edi, %edi
movl %ebx, %edx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2250
// File: /workspace/github_c_makefile_star2_O1/adelciotto[P]plasma/src/gl_rgb_plasma.c
// Function: LogProgramError
void LogProgramError(GLuint program) {
    if (glIsProgram(program)) {
        int infoLogLength = 0;
        int maxLength = infoLogLength;

        glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength);

        char *infoLog = malloc(maxLength * sizeof(*infoLog));
        if (infoLog == NULL) {
            LogError("failed to malloc error log for gl program %d of size %d",
                     program, maxLength);
        }

        glGetProgramInfoLog(program, maxLength, &infoLogLength, infoLog);
        if (infoLogLength > 0) {
            LogError("failed to link program %d:\n%s", program, infoLog);
        }

        free(infoLog);
    } else {
        LogError("name program %d is not a program", program);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movq 0x388b(%rip), %rax      # 0x5f50
callq *(%rax)
testb %al, %al
je 0x275c
xorl %eax, %eax
movl %eax, 0x4(%rsp)
movq %rsp, %r14
movl %eax, (%r14)
movq 0x3836(%rip), %rax      # 0x5f18
movl %ebx, %edi
movl $0x8b84, %esi           # imm = 0x8B84
movq %r14, %rdx
callq *(%rax)
movl (%r14), %ebp
movslq %ebp, %rdi
callq 0x21c0
movq %rax, %r14
testq %rax, %rax
jne 0x2715
leaq 0x1a20(%rip), %rsi      # 0x4128
xorl %edi, %edi
movl %ebx, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2250
movq 0x3874(%rip), %rax      # 0x5f90
movl (%rsp), %esi
leaq 0x4(%rsp), %r15
movl %ebx, %edi
movq %r15, %rdx
movq %r14, %rcx
callq *(%rax)
cmpl $0x0, (%r15)
jle 0x2749
leaq 0x1a25(%rip), %rsi      # 0x4160
xorl %edi, %edi
movl %ebx, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x2250
movq %r14, %rdi
callq 0x2070
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a1b(%rip), %rsi      # 0x417e
xorl %edi, %edi
movl %ebx, %edx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2250
// File: /workspace/github_c_makefile_star2_O1/adelciotto[P]plasma/src/gl_rgb_plasma.c
// Function: ReadFile
char *ReadFile(const char *filepath) {
    FILE *file = fopen(filepath, "rb");
    if (file == NULL) {
        return NULL;
    }

    fseek(file, 0, SEEK_END);
    long fileSize = ftell(file);
    rewind(file);

    char *buffer = malloc((fileSize + 1) * sizeof(*buffer));
    if (buffer == NULL) {
        return NULL;
    }

    size_t result = fread(buffer, 1, fileSize, file);
    if ((long)result != fileSize) {
        return NULL;
    }

    fclose(file);

    buffer[fileSize] = 0;
    return buffer;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
leaq 0x1a18(%rip), %rsi      # 0x419f
callq 0x2240
testq %rax, %rax
je 0x27f4
movq %rax, %rbx
xorl %r14d, %r14d
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2220
movq %rbx, %rdi
callq 0x20a0
movq %rax, %r15
movq %rbx, %rdi
callq 0x2270
leaq 0x1(%r15), %rdi
callq 0x21c0
testq %rax, %rax
je 0x27f7
movq %rax, %r12
movl $0x1, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x2130
cmpq %r15, %rax
jne 0x27f4
movq %rbx, %rdi
callq 0x2110
movb $0x0, (%r12,%r15)
movq %r12, %r14
jmp 0x27f7
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/adelciotto[P]plasma/src/gl_rgb_plasma.c
// Function: compileShader
GLboolean compileShader(GLenum type, const GLchar *source[],
                        GLuint *outShader) {
    GLuint shader = glCreateShader(type);
    glShaderSource(shader, 1, source, NULL);
    glCompileShader(shader);

    *outShader = shader;

    GLint shaderCompiled = GL_FALSE;
    glGetShaderiv(shader, GL_COMPILE_STATUS, &shaderCompiled);
    if (shaderCompiled != GL_TRUE) {
        return GL_FALSE;
    }

    return GL_TRUE;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq 0x37bd(%rip), %rax      # 0x5fd8
callq *(%rax)
movl %eax, %ebp
movq 0x3792(%rip), %rax      # 0x5fb8
movl %ebp, %edi
movl $0x1, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq *(%rax)
movq 0x373d(%rip), %rax      # 0x5f78
movl %ebp, %edi
callq *(%rax)
movl %ebp, (%rbx)
leaq 0xc(%rsp), %rbx
movl $0x0, (%rbx)
movq 0x36f5(%rip), %rax      # 0x5f48
movl %ebp, %edi
movl $0x8b81, %esi           # imm = 0x8B81
movq %rbx, %rdx
callq *(%rax)
cmpl $0x1, (%rbx)
sete %al
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq