LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/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 %r9, %rbx
movq %r8, %r14
movq %rcx, %r12
movq %rsi, %r13
movq %rdi, 0x10(%rsp)
movq 0x50(%rsp), %rbp
movq %rdx, 0x8(%rsp)
movq (%rdx), %r15
subq $0x1, %r13
jb 0x1f30
testq %r15, %r15
jne 0x1f18
movq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x169e
pushq $0xf
popq %rax
incb (%r12,%rax)
sete %cl
addq $-0x1, %rax
jae 0x1f18
testb %cl, %cl
jne 0x1f07
movb (%r14,%r15), %al
xorb (%rbx), %al
incq %rbx
movb %al, (%rbp)
incq %rbp
incl %r15d
andl $0xf, %r15d
jmp 0x1ee6
movq 0x8(%rsp), %rax
movq %r15, (%rax)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdx, %rdx
je 0x203a
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %r13
leal (%rdx,%r13), %eax
andl $0x3f, %r13d
movq %rax, (%rdi)
cmpq %rdx, %rax
jae 0x1fb5
incq 0x8(%r14)
testq %r13, %r13
je 0x1ff6
pushq $0x40
popq %r12
subq %r13, %r12
movq %r15, %rbp
subq %r12, %rbp
jb 0x200e
leaq 0x38(%r14), %r15
leaq (%r14,%r13), %rdi
addq $0x38, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x10f0
movq %r14, %rdi
movq %r15, %rsi
callq 0x2049
addq %r12, %rbx
xorl %r13d, %r13d
movq %rbp, %r15
jmp 0x200e
xorl %r13d, %r13d
jmp 0x200e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2049
addq $0x40, %rbx
addq $-0x40, %r15
cmpq $0x40, %r15
jae 0x1ffb
testq %r15, %r15
je 0x203a
leaq (%r14,%r13), %rdi
addq $0x38, %rdi
movq %rbx, %rsi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x1f81
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3bea
addq $0xf8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rdi, %rbx
cmpq $0x41, %rdx
jb 0x3da7
movq %rsp, %r14
movq %rsi, %rdi
movq %rdx, %rsi
movq %r14, %rdx
callq 0x3d17
pushq $0x14
popq %rdx
movq %r14, %rsi
leaq 0x78(%rbx), %rax
movaps 0x74ce(%rip), %xmm0     # 0xb280
movups %xmm0, 0xa8(%rbx)
movups %xmm0, 0x98(%rbx)
movups %xmm0, 0x88(%rbx)
movups %xmm0, 0x78(%rbx)
movaps 0x74be(%rip), %xmm0     # 0xb290
movups %xmm0, 0xb8(%rbx)
movups %xmm0, 0xc8(%rbx)
movups %xmm0, 0xd8(%rbx)
movups %xmm0, 0xe8(%rbx)
xorl %ecx, %ecx
cmpq %rcx, %rdx
je 0x3e0f
movb (%rsi,%rcx), %dil
xorb %dil, 0x78(%rbx,%rcx)
movb (%rsi,%rcx), %dil
xorb %dil, 0xb8(%rbx,%rcx)
incq %rcx
jmp 0x3df0
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x67452301, 0x10(%rbx) # imm = 0x67452301
movl $0x98badcfe, %ecx       # imm = 0x98BADCFE
leaq 0x5712ce8b(%rcx), %rdx
movq %rdx, 0x18(%rbx)
movq %rcx, 0x20(%rbx)
movq $0x10325476, 0x28(%rbx) # imm = 0x10325476
addq $0x2b1804f2, %rcx       # imm = 0x2B1804F2
movq %rcx, 0x30(%rbx)
pushq $0x40
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
addq $0x18, %rsp
popq %rbx
popq %r14
jmp 0x1f81
// File: /workspace/github_c_makefile_star2_O2/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 0x3bea
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
pushq $0x40
popq %rdx
movq %r14, %rdi
callq 0x1f81
pushq $0x14
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x1f81
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3bea
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x3d80
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1f81
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3e5e
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O2/zecoxao[P]ps3_decrypt_tools/lib/des.c
// Function: des_key_check_key_parity
int des_key_check_key_parity(const unsigned char key[DES_KEY_SIZE]) {
    int i;

    for (i = 0; i < DES_KEY_SIZE; i++)
        if (key[i] != odd_parity_table[key[i] / 2])
            return ( 1);

    return ( 0);
}

// Assembly:
xorl %eax, %eax
leaq 0x7342(%rip), %rdx      # 0xb2e0
pushq $0x1
popq %rcx
xorl %esi, %esi
cmpq $0x8, %rsi
je 0x3fbf
movzbl (%rdi,%rsi), %r8d
movl %r8d, %r9d
shrl %r9d
incq %rsi
cmpb (%r9,%rdx), %r8b
je 0x3fa3
movl %ecx, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x3ff8
leaq 0x80(%rbx), %rax
xorl %ecx, %ecx
cmpq $0xf, %rcx
ja 0x44a2
movl 0x4(%rbx,%rcx,4), %edx
movl -0x4(%rax), %esi
movl %esi, 0x4(%rbx,%rcx,4)
movl %edx, -0x4(%rax)
movl 0x8(%rbx,%rcx,4), %edx
movl (%rax), %esi
movl %esi, 0x8(%rbx,%rcx,4)
movl %edx, (%rax)
addq $0x2, %rcx
addq $-0x8, %rax
jmp 0x4478
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x44c6
xorl %eax, %eax
addq $0x188, %rsp            # imm = 0x188
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x3ff8
leaq 0x80(%rbx), %rdi
addq $0x8, %r15
movq %r15, %rsi
callq 0x3ff8
pushq $0x40
popq %rax
pushq $0x1f
popq %rcx
leaq -0x40(%rax), %rdx
cmpq $0x1f, %rdx
ja 0x454d
movl -0x4(%r14,%rcx,4), %edx
movl %edx, -0x100(%rbx,%rax,4)
movl (%r14,%rcx,4), %edx
movl %edx, -0xfc(%rbx,%rax,4)
movl 0x7c(%rbx,%rcx,4), %edx
movl %edx, -0x80(%r14,%rax,4)
movl 0x80(%rbx,%rcx,4), %edx
movl %edx, -0x7c(%r14,%rax,4)
movq -0x100(%r14,%rax,4), %rdx
movq %rdx, (%r14,%rax,4)
movq -0x100(%rbx,%rax,4), %rdx
movq %rdx, (%rbx,%rax,4)
addq $0x2, %rax
addq $-0x2, %rcx
jmp 0x44f5
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x4593
xorl %eax, %eax
addq $0x188, %rsp            # imm = 0x188
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x3ff8
leaq 0x80(%rbx), %rdi
leaq 0x8(%r15), %rsi
callq 0x3ff8
leaq 0x100(%r14), %rdi
addq $0x10, %r15
movq %r15, %rsi
callq 0x3ff8
xorl %eax, %eax
xorl %ecx, %ecx
cmpq $0x1f, %rcx
ja 0x462d
movl 0x178(%r14,%rax), %edx
movl %edx, (%rbx,%rcx,4)
movl 0x17c(%r14,%rax), %edx
movl %edx, 0x4(%rbx,%rcx,4)
movl 0xf8(%rbx,%rax), %edx
movl %edx, 0x80(%r14,%rcx,4)
movl 0xfc(%rbx,%rax), %edx
movl %edx, 0x84(%r14,%rcx,4)
movl 0x78(%r14,%rax), %edx
movl %edx, 0x100(%rbx,%rcx,4)
movl 0x7c(%r14,%rax), %edx
movl %edx, 0x104(%rbx,%rcx,4)
addq $0x2, %rcx
addq $-0x8, %rax
jmp 0x45d0
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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
testb $0x7, %r12b
je 0x48c2
pushq $-0x32
popq %rax
jmp 0x494f
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq %rdi, %rbp
cmpl $0x1, %esi
jne 0x4912
testq %r12, %r12
je 0x494d
xorl %eax, %eax
cmpq $0x8, %rax
je 0x48f0
movb (%r15,%rax), %cl
xorb (%r14,%rax), %cl
movb %cl, (%rbx,%rax)
incq %rax
jmp 0x48da
movq %rbp, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x4653
movq (%rbx), %rax
movq %rax, (%r15)
addq $0x8, %r14
addq $0x8, %rbx
addq $-0x8, %r12
jmp 0x48d3
testq %r12, %r12
je 0x494d
movq (%r14), %r13
movq %rbp, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x4653
xorl %eax, %eax
cmpq $0x8, %rax
je 0x493c
movb (%r15,%rax), %cl
xorb %cl, (%rbx,%rax)
incq %rax
jmp 0x492a
movq %r13, (%r15)
addq $0x8, %r14
addq $0x8, %rbx
addq $-0x8, %r12
jmp 0x4912
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_O2/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
pushq $0x1
popq %rcx
movl %eax, %edx
cmpq $0x10, %rcx
je 0x4ed8
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
jmp 0x4eb7
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_O2/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 $0x288, %rsp            # imm = 0x288
movl %edx, %ebp
movq %rsi, 0x8(%rsp)
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rbx
movaps %xmm0, (%rbx)
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %rcx, %rsi
movl %r8d, %edx
callq 0x126c
pushq $0x1
popq %rsi
leaq 0x40(%rsp), %r13
movq %r12, %rdi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x169e
movq %r13, %rdi
callq 0x4eb0
cmpl $0x11, %ebp
jb 0x4fa1
movq %r14, 0x38(%rsp)
movq %rbp, 0x30(%rsp)
leal -0x10(%rbp), %r14d
xorl %r15d, %r15d
pushq $0x1
popq %rbp
leaq 0x10(%rsp), %r13
leaq 0x20(%rsp), %rbx
movq 0x8(%rsp), %r12
cmpq %r14, %r15
jae 0x4fa6
xorl %eax, %eax
cmpq $0x10, %rax
je 0x4f85
movb (%r12,%rax), %cl
xorb 0x20(%rsp,%rax), %cl
movb %cl, 0x10(%rsp,%rax)
incq %rax
jmp 0x4f6e
leaq 0x58(%rsp), %rdi
movl %ebp, %esi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x169e
addq $0x10, %r15
addq $0x10, %r12
jmp 0x4f67
xorl %r15d, %r15d
jmp 0x4fb4
andl $-0x10, %r15d
movq 0x38(%rsp), %r14
movq 0x30(%rsp), %rbp
movq 0x8(%rsp), %r12
andl $0xf, %ebp
pushq $0x10
popq %rbx
cmovnel %ebp, %ebx
pushq $0x10
popq %rax
subq %rbx, %rax
xorl %edx, %edx
testl %ebp, %ebp
cmovneq %rax, %rdx
addq %r15, %r12
leaq (%rsp,%rbx), %rdi
addq $0x10, %rdi
xorl %esi, %esi
callq 0x10a0
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x10f0
testl %ebp, %ebp
je 0x5005
movb $-0x80, 0x10(%rsp,%rbx)
leaq 0x40(%rsp), %rdi
callq 0x4eb0
xorl %eax, %eax
cmpq $0x10, %rax
je 0x501e
movb 0x40(%rsp,%rax), %cl
xorb 0x20(%rsp,%rax), %cl
xorb %cl, 0x10(%rsp,%rax)
incq %rax
jmp 0x5007
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rcx
callq 0x169e
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/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 $0x258, %rsp            # imm = 0x258
movq %rcx, 0x8(%rsp)
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x126c
movups (%r15), %xmm0
leaq 0x10(%rsp), %rbp
movaps %xmm0, (%rbp)
leaq 0xa4f0(%rip), %r8       # 0xf580
pushq $0x1
popq %rbx
pushq $0x20
popq %rdx
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rcx
movq %r12, %r9
callq 0x1de8
movq %r14, %rdi
movq %r13, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x126c
movups (%r15), %xmm0
movaps %xmm0, (%rbp)
leaq 0xa4db(%rip), %r8       # 0xf5a0
movq %r14, %rdi
movl %ebx, %esi
pushq $0x20
popq %rdx
movq %rbp, %rcx
movq 0x8(%rsp), %r9
callq 0x1de8
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 $0x258, %rsp            # imm = 0x258
movq %rcx, 0x8(%rsp)
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x126c
movups (%r15), %xmm0
leaq 0x10(%rsp), %rbp
movaps %xmm0, (%rbp)
leaq 0xa40c(%rip), %r8       # 0xf540
pushq $0x1
popq %rbx
pushq $0x20
popq %rdx
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rcx
movq %r12, %r9
callq 0x1de8
movq %r14, %rdi
movq %r13, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x126c
movups (%r15), %xmm0
movaps %xmm0, (%rbp)
leaq 0xa3f7(%rip), %r8       # 0xf560
movq %r14, %rdi
movl %ebx, %esi
pushq $0x20
popq %rdx
movq %rbp, %rcx
movq 0x8(%rsp), %r9
callq 0x1de8
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x126c
testl %ebp, %ebp
je 0x51d9
cmpl $0x1, %ebp
jne 0x51f1
addq $0x230, %r15            # imm = 0x230
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x126c
jmp 0x51ed
addq $0x230, %r15            # imm = 0x230
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x1541
xorl %eax, %eax
jmp 0x51f4
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
testb $0xf, %bpl
je 0x521d
pushq $-0x1
popq %rax
jmp 0x52ee
movq %r8, %r15
movq %rdi, %rbx
movq %rcx, 0x28(%rsp)
movq %rsp, %rcx
movq %rsi, (%rcx)
andq $0x0, 0x8(%rcx)
pushq $0x1
popq %rsi
movq %rcx, %rdx
callq 0x169e
movq %rbx, 0x20(%rsp)
leaq 0x230(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x30(%rsp), %r12
xorl %ebx, %ebx
cmpl %ebp, %ebx
jae 0x52ec
movl %ebx, %eax
movq %r15, %r13
addq %rax, %r15
addq 0x28(%rsp), %rax
xorl %ecx, %ecx
cmpq $0x10, %rcx
je 0x5282
movb (%rsp,%rcx), %dl
xorb (%rax,%rcx), %dl
movb %dl, 0x30(%rsp,%rcx)
incq %rcx
jmp 0x526d
movq 0x20(%rsp), %rax
movl 0x460(%rax), %esi
movq 0x18(%rsp), %rdi
movq %r12, %rdx
movq %r12, %rcx
callq 0x169e
xorl %eax, %eax
cmpq $0x10, %rax
je 0x52b5
movb (%rsp,%rax), %cl
xorb 0x30(%rsp,%rax), %cl
movb %cl, (%r15,%rax)
incq %rax
jmp 0x529f
xorl %eax, %eax
xorl %ecx, %ecx
movq %r13, %r15
cmpq $0x10, %rax
je 0x52db
movb (%rsp,%rax), %dl
movl %edx, %r14d
shrb $0x7, %r14b
addb %dl, %dl
orb %cl, %dl
movb %dl, (%rsp,%rax)
incq %rax
movl %r14d, %ecx
jmp 0x52bc
testb %r14b, %r14b
je 0x52e4
xorb $-0x79, (%rsp)
addl $0x10, %ebx
jmp 0x5256
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movl %r9d, %ebp
movl %r8d, %r14d
movq %rcx, %r12
movq %rdx, 0x18(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
movq %rsi, %rdi
callq 0x1080
movq %rax, %r13
incl %r13d
leaq 0x6929(%rip), %rsi      # 0xbc60
movq %r15, 0x8(%rsp)
movq %r15, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x10d0
movl %ebp, 0x14(%rsp)
cmpl $0x1, %ebp
jne 0x536a
leaq 0x690b(%rip), %rsi      # 0xbc64
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rdx
xorl %eax, %eax
callq 0x10d0
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
movq %r13, 0x20(%rsp)
testl %r14d, %r14d
cmovlel %eax, %r14d
pushq $0x20
popq %r13
leaq 0x68e5(%rip), %rbx      # 0xbc72
xorl %ebp, %ebp
cmpq %r14, %rbp
je 0x541c
testb $0xf, %bpl
setne %al
testq %rbp, %rbp
sete %cl
orb %al, %cl
jne 0x5400
movq %r14, %r15
movq %r12, %r14
movq %rbx, %r12
pushq $0xa
popq %rdi
movq 0x8(%rsp), %rsi
callq 0x10b0
movq 0x20(%rsp), %rax
movl %eax, %ebx
subl $0x1, %ebx
jb 0x53d5
movl %r13d, %edi
callq 0x1040
jmp 0x53c6
cmpl $0x1, 0x14(%rsp)
movq %r12, %rbx
movq %r14, %r12
movq %r15, %r14
jne 0x5400
movq 0x18(%rsp), %rax
leal (%rax,%rbp), %edx
movq 0x8(%rsp), %rdi
leaq 0x6872(%rip), %rsi      # 0xbc6b
xorl %eax, %eax
callq 0x10d0
movzbl (%r12,%rbp), %edx
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10d0
incq %rbp
jmp 0x538f
pushq $0xa
popq %rdi
movq 0x8(%rsp), %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
// File: /workspace/github_c_makefile_star2_O2/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 0x682e(%rip), %rsi      # 0xbc78
callq 0x1130
testq %rax, %rax
je 0x54ac
movq %rax, %r14
pushq $0x2
popq %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x1120
movq %r14, %rdi
callq 0x10e0
movq %rax, %r15
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1120
movl %r15d, %r13d
movq %r13, %rdi
callq 0x1100
movq %rax, %r12
pushq $0x1
popq %rsi
movq %rax, %rdi
movq %r13, %rdx
movq %r14, %rcx
callq 0x1060
testq %rbx, %rbx
je 0x54a2
movl %r15d, (%rbx)
movq %r14, %rdi
callq 0x1070
jmp 0x54af
xorl %r12d, %r12d
movq %r12, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x67af(%rip), %rsi      # 0xbc7b
callq 0x1130
testq %rax, %rax
je 0x54f5
movq %rax, %r14
movl %ebp, %edx
pushq $0x1
popq %rsi
movq %rbx, %rdi
movq %rax, %rcx
callq 0x1160
movq %r14, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x1070
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/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 0x5553
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 0x557f
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 0x55b3
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 0x55e7
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 %ebp, %ebp
leaq 0x9fe0(%rip), %r15      # 0xf5d0
leaq 0x18(%rsp), %r14
movq %rsp, %r12
cmpl $0x100, %ebp            # imm = 0x100
je 0x563c
leaq (%rbx,%rbp), %r13
movq (%r15), %rsi
movq %r14, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x126c
movq (%r15), %rax
movups 0x20(%rax), %xmm0
movaps %xmm0, (%rsp)
movq %r14, %rdi
pushq $0x1
popq %rsi
pushq $0x40
popq %rdx
movq %r12, %rcx
movq %r13, %r8
movq %r13, %r9
callq 0x1de8
addq $0x40, %rbp
jmp 0x55f8
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_O2/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 0x5437
testq %rax, %rax
je 0x56ff
movq %rax, %r14
movl (%rax), %eax
movl 0x4(%r14), %ecx
bswapl %eax
movl %eax, (%r14)
bswapl %ecx
movl %ecx, 0x4(%r14)
leaq 0x10(%r14), %r15
leaq 0x10(%rsp), %r13
leaq 0x65fa(%rip), %rbp      # 0xbc95
xorl %r12d, %r12d
cmpl %eax, %r12d
jae 0x56f5
movq %r15, %rdi
callq 0x5722
movl 0x8(%r15), %ecx
movq %r13, %rdi
leaq 0x65d7(%rip), %rsi      # 0xbc90
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1150
movl (%r15), %esi
movl 0x4(%r15), %edx
movq %rbp, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x1090
movl (%r15), %esi
movl 0x4(%r15), %edx
addq %r14, %rsi
movq %r13, %rdi
callq 0x54bc
incl %r12d
movl (%r14), %eax
addq $0x10, %r15
jmp 0x569e
movq %r14, %rdi
callq 0x1030
jmp 0x5710
leaq 0x65c3(%rip), %rdi      # 0xbcc9
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_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r12
leaq 0x4(%rsp), %rsi
callq 0x5437
testq %rax, %rax
je 0x57c2
movq %rax, %rbx
movl (%rax), %eax
movl 0x4(%rbx), %ecx
bswapl %eax
movl %eax, (%rbx)
bswapl %ecx
movl %ecx, 0x4(%rbx)
leaq 0x10(%rbx), %r12
pushq $-0x1
popq %rbp
xorl %r14d, %r14d
incl %ebp
cmpl (%rbx), %ebp
jae 0x57b8
leaq 0x10(%r12), %r13
movq %r12, %rdi
callq 0x5722
cmpq %r15, 0x8(%r12)
movq %r13, %r12
jne 0x5777
movl -0xc(%r13), %r15d
movq %r15, %rdi
callq 0x1100
movq %rax, %r14
movl -0x10(%r13), %eax
movq %rbx, %rsi
addq %rax, %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x10f0
movq %rbx, %rdi
callq 0x1030
jmp 0x57d6
leaq 0x6500(%rip), %rdi      # 0xbcc9
xorl %r14d, %r14d
movq %r12, %rsi
xorl %eax, %eax
callq 0x1090
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x340, %rsp            # imm = 0x340
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x9a35(%rip), %rdi      # 0xf370
leaq 0x10(%rsp), %r8
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x54fc
leaq 0x30(%rsp), %rsi
leaq 0x110(%rsp), %r15
movq %r15, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x126c
leaq 0x9b64(%rip), %rdx      # 0xf4d0
pushq $0x1
popq %rbp
movq %rsp, %r12
movq %r15, %rdi
movl %ebp, %esi
movq %r12, %rcx
callq 0x169e
leaq 0xa8(%r14), %rdi
movq %r14, %rsi
movl $0xa8, %edx
movq %r12, %rcx
movl $0x80, %r8d
callq 0x4ee8
movq %r15, %rdi
movq %r12, %rsi
movl $0x80, %edx
callq 0x126c
leaq 0x20(%rsp), %rcx
movl $0xc0, %edx
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %r8
movq %rbx, %r9
callq 0x1de8
addq $0x340, %rsp            # imm = 0x340
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x5437
testq %rax, %rax
je 0x5c38
movq %rax, %rbx
leaq 0x310(%rsp), %r13
movq %rax, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x57e8
leaq 0x250(%rsp), %r12
pushq $0x6
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x57e8
leaq 0x190(%rsp), %r15
pushq $0xa
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x57e8
leaq 0x612d(%rip), %rsi      # 0xbce3
leaq 0x110(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1150
movq %rbp, %rdi
movq %r13, %rsi
movl $0xc0, %edx
callq 0x54bc
leaq 0x6112(%rip), %rsi      # 0xbcf4
leaq 0x90(%rsp), %r13
movq %r13, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1150
movq %r13, %rdi
movq %r12, %rsi
movl $0xc0, %edx
callq 0x54bc
leaq 0x60f7(%rip), %rsi      # 0xbd05
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1150
movq %r12, %rdi
movq %r15, %rsi
movl $0xc0, %edx
callq 0x54bc
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_O2/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 0x60b1(%rip), %rsi      # 0xbd16
leaq 0x90(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1150
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x5437
testq %rax, %rax
je 0x5cd0
movq %rax, %r14
leaq 0x110(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x591f
leaq 0x6070(%rip), %rsi      # 0xbd16
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1150
movq %r12, %rdi
movq %r15, %rsi
movl $0xc0, %edx
callq 0x54bc
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_O2/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 0x601c(%rip), %rsi      # 0xbd16
leaq 0x90(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1150
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x5437
testq %rax, %rax
je 0x5d65
movq %rax, %r14
leaq 0x110(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x59d6
leaq 0x5fdb(%rip), %rsi      # 0xbd16
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1150
movq %r12, %rdi
movq %r15, %rsi
movl $0xc0, %edx
callq 0x54bc
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_O2/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 0x5f87(%rip), %rsi      # 0xbd16
leaq 0x90(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1150
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x5437
testq %rax, %rax
je 0x5dfa
movq %rax, %r14
leaq 0x110(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x5a8d
leaq 0x5f46(%rip), %rsi      # 0xbd16
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1150
movq %r12, %rdi
movq %r15, %rsi
movl $0xc0, %edx
callq 0x54bc
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_O2/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 0x5437
testq %rax, %rax
je 0x61b2
movq %rax, %r14
movq %rax, %rdi
callq 0x6004
movq %rbx, %rdi
movq %r14, %rsi
movl $0x280, %edx            # imm = 0x280
callq 0x54bc
movq %r14, %rdi
callq 0x1030
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x923d(%rip), %rdi      # 0xf410
xorl %r14d, %r14d
movq %rsp, %r8
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x54fc
cmpl $0x2, %ebp
je 0x6225
cmpl $0x1, %ebp
jne 0x626d
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 0x1541
leaq 0x10(%rsp), %rcx
addq $0x20, %rbx
movl $0x80, %edx
jmp 0x625d
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 0x1541
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 0x1de8
movq %r14, %rax
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x5437
testq %rax, %rax
je 0x62df
movq %rax, %rbx
movq %rax, %rdi
movl %ebp, %esi
callq 0x61ba
testq %rax, %rax
je 0x62d7
movq %rax, %r15
cmpl $0x1, %ebp
je 0x62bf
cmpl $0x2, %ebp
jne 0x62d7
movl $0x690, %edx            # imm = 0x690
jmp 0x62c4
movl $0x80, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x54bc
movq %r15, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq