// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
leaq -0x270(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %edx
leaq -0x260(%rbp), %rdi
callq 0x1250
leaq -0x270(%rbp), %rdx
leaq -0x280(%rbp), %rcx
leaq -0x260(%rbp), %rdi
movl $0x1, %esi
callq 0x1be0
leaq -0x280(%rbp), %rdi
callq 0x91f0
cmpl $0x10, -0x14(%rbp)
jbe 0x937a
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl -0x14(%rbp), %ecx
subl $0x10, %ecx
cmpl %ecx, %eax
jae 0x9378
movl $0x0, -0x2c(%rbp)
cmpl $0x10, -0x2c(%rbp)
jae 0x934e
movl -0x2c(%rbp), %eax
movzbl -0x270(%rbp,%rax), %eax
movq -0x10(%rbp), %rcx
movl -0x28(%rbp), %edx
addl -0x2c(%rbp), %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
xorl %ecx, %eax
movb %al, %cl
movl -0x2c(%rbp), %eax
movb %cl, -0x290(%rbp,%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9314
leaq -0x290(%rbp), %rdx
leaq -0x270(%rbp), %rcx
leaq -0x260(%rbp), %rdi
movl $0x1, %esi
callq 0x1be0
movl -0x28(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x28(%rbp)
jmp 0x9300
jmp 0x937a
movl -0x14(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x30(%rbp)
movl -0x14(%rbp), %eax
andl $0xf, %eax
cmpl $0x0, %eax
jne 0x9395
movl $0x10, -0x30(%rbp)
leaq -0x290(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0x290(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x28(%rbp), %eax
addq %rax, %rsi
movl -0x30(%rbp), %eax
movl %eax, %edx
callq 0x10e0
cmpl $0x10, -0x30(%rbp)
je 0x93e0
movl -0x30(%rbp), %eax
movb $-0x80, -0x290(%rbp,%rax)
leaq -0x280(%rbp), %rdi
callq 0x91f0
movl $0x0, -0x28(%rbp)
cmpl $0x10, -0x28(%rbp)
jae 0x9424
movl -0x28(%rbp), %eax
movzbl -0x270(%rbp,%rax), %edx
movl -0x28(%rbp), %eax
movzbl -0x280(%rbp,%rax), %eax
xorl %eax, %edx
movl -0x28(%rbp), %eax
movzbl -0x290(%rbp,%rax), %ecx
xorl %edx, %ecx
movb %cl, -0x290(%rbp,%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x93e7
leaq -0x290(%rbp), %rdx
movq -0x8(%rbp), %rcx
leaq -0x260(%rbp), %rdi
movl $0x1, %esi
callq 0x1be0
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
nopl (%rax)
nopl (%rax)