// File: /workspace/github_c_makefile_star2_O0/bloomsource[P]dns_update/aes.c
// Function: aes_setkey_dec
int aes_setkey_dec( aes_context *ctx, const unsigned char *key, int keysize )
{
    int i, j;
    aes_context cty;
    unsigned long *RK;
    unsigned long *SK;
    int ret;

    switch( keysize )
    {
        case 128: ctx->nr = 10; break;
        case 192: ctx->nr = 12; break;
        case 256: ctx->nr = 14; break;
        default : return( ERR_AES_INVALID_KEY_LENGTH );
    }


    ctx->rk = RK = ctx->buf;

    ret = aes_setkey_enc( &cty, key, keysize );
    if( ret != 0 )
        return( ret );

    SK = cty.rk + cty.nr * 4;

    *RK++ = *SK++;
    *RK++ = *SK++;
    *RK++ = *SK++;
    *RK++ = *SK++;

    for( i = ctx->nr - 1, SK -= 8; i > 0; i--, SK -= 8 )
    {
        for( j = 0; j < 4; j++, SK++ )
        {
            *RK++ = RT0[ FSb[ ( *SK       ) & 0xFF ] ] ^
                    RT1[ FSb[ ( *SK >>  8 ) & 0xFF ] ] ^
                    RT2[ FSb[ ( *SK >> 16 ) & 0xFF ] ] ^
                    RT3[ FSb[ ( *SK >> 24 ) & 0xFF ] ];
        }
    }

    *RK++ = *SK++;
    *RK++ = *SK++;
    *RK++ = *SK++;
    *RK++ = *SK++;

    memset( &cty, 0, sizeof( aes_context ) );

    return( 0 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x270(%rbp)
subl $0x80, %eax
je 0xa976
jmp 0xa958
movl -0x270(%rbp), %eax
subl $0xc0, %eax
je 0xa982
jmp 0xa967
movl -0x270(%rbp), %eax
subl $0x100, %eax            # imm = 0x100
je 0xa98e
jmp 0xa99a
movq -0x10(%rbp), %rax
movl $0xa, (%rax)
jmp 0xa9a6
movq -0x10(%rbp), %rax
movl $0xc, (%rax)
jmp 0xa9a6
movq -0x10(%rbp), %rax
movl $0xe, (%rax)
jmp 0xa9a6
movl $0xfffff800, -0x4(%rbp) # imm = 0xFFFFF800
jmp 0xaceb
movq -0x10(%rbp), %rcx
addq $0x10, %rcx
movq %rcx, -0x260(%rbp)
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
leaq -0x258(%rbp), %rdi
callq 0xa370
movl %eax, -0x26c(%rbp)
cmpl $0x0, -0x26c(%rbp)
je 0xa9ed
movl -0x26c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xaceb
movq -0x250(%rbp), %rax
movl -0x258(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x268(%rbp)
movq -0x268(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x268(%rbp)
movq (%rax), %rcx
movq -0x260(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x260(%rbp)
movq %rcx, (%rax)
movq -0x268(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x268(%rbp)
movq (%rax), %rcx
movq -0x260(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x260(%rbp)
movq %rcx, (%rax)
movq -0x268(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x268(%rbp)
movq (%rax), %rcx
movq -0x260(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x260(%rbp)
movq %rcx, (%rax)
movq -0x268(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x268(%rbp)
movq (%rax), %rcx
movq -0x260(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x260(%rbp)
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x268(%rbp), %rax
addq $-0x40, %rax
movq %rax, -0x268(%rbp)
cmpl $0x0, -0x20(%rbp)
jle 0xac11
movl $0x0, -0x24(%rbp)
cmpl $0x4, -0x24(%rbp)
jge 0xabef
movq -0x268(%rbp), %rax
movq (%rax), %rcx
andq $0xff, %rcx
leaq 0x2b71(%rip), %rax      # 0xd690
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x2c64(%rip), %rax      # 0xd790
movq (%rax,%rcx,8), %rcx
movq -0x268(%rbp), %rax
movq (%rax), %rdx
shrq $0x8, %rdx
andq $0xff, %rdx
leaq 0x2b44(%rip), %rax      # 0xd690
movzbl (%rax,%rdx), %eax
movl %eax, %edx
leaq 0x3437(%rip), %rax      # 0xdf90
xorq (%rax,%rdx,8), %rcx
movq -0x268(%rbp), %rax
movq (%rax), %rdx
shrq $0x10, %rdx
andq $0xff, %rdx
leaq 0x2b17(%rip), %rax      # 0xd690
movzbl (%rax,%rdx), %eax
movl %eax, %edx
leaq 0x3c0a(%rip), %rax      # 0xe790
xorq (%rax,%rdx,8), %rcx
movq -0x268(%rbp), %rax
movq (%rax), %rdx
shrq $0x18, %rdx
andq $0xff, %rdx
leaq 0x2aea(%rip), %rax      # 0xd690
movzbl (%rax,%rdx), %eax
movl %eax, %edx
leaq 0x43dd(%rip), %rax      # 0xef90
xorq (%rax,%rdx,8), %rcx
movq -0x260(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x260(%rbp)
movq %rcx, (%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x268(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x268(%rbp)
jmp 0xaafd
jmp 0xabf1
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x268(%rbp), %rax
addq $-0x40, %rax
movq %rax, -0x268(%rbp)
jmp 0xaaec
movq -0x268(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x268(%rbp)
movq (%rax), %rcx
movq -0x260(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x260(%rbp)
movq %rcx, (%rax)
movq -0x268(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x268(%rbp)
movq (%rax), %rcx
movq -0x260(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x260(%rbp)
movq %rcx, (%rax)
movq -0x268(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x268(%rbp)
movq (%rax), %rcx
movq -0x260(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x260(%rbp)
movq %rcx, (%rax)
movq -0x268(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x268(%rbp)
movq (%rax), %rcx
movq -0x260(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x260(%rbp)
movq %rcx, (%rax)
leaq -0x258(%rbp), %rdi
xorl %esi, %esi
movl $0x230, %edx            # imm = 0x230
callq 0x2140
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
nopw (%rax,%rax)