// File: /workspace/github_c_makefile_star2_O0/blasphemy[P]mmc-utils/3rdparty/hmac_sha/hmac_sha2.c
// Function: hmac_sha512_init
void hmac_sha512_init(hmac_sha512_ctx *ctx, const unsigned char *key,
                      unsigned int key_size)
{
    unsigned int fill;
    unsigned int num;

    const unsigned char *key_used;
    unsigned char key_temp[SHA512_DIGEST_SIZE];
    int i;

    if (key_size == SHA512_BLOCK_SIZE) {
        key_used = key;
        num = SHA512_BLOCK_SIZE;
    } else {
        if (key_size > SHA512_BLOCK_SIZE){
            num = SHA512_DIGEST_SIZE;
            sha512(key, key_size, key_temp);
            key_used = key_temp;
        } else { /* key_size > SHA512_BLOCK_SIZE */
            key_used = key;
            num = key_size;
        }
        fill = SHA512_BLOCK_SIZE - num;

        memset(ctx->block_ipad + num, 0x36, fill);
        memset(ctx->block_opad + num, 0x5c, fill);
    }

    for (i = 0; i < (int) num; i++) {
        ctx->block_ipad[i] = key_used[i] ^ 0x36;
        ctx->block_opad[i] = key_used[i] ^ 0x5c;
    }

    sha512_init(&ctx->ctx_inside);
    sha512_update(&ctx->ctx_inside, ctx->block_ipad, SHA512_BLOCK_SIZE);

    sha512_init(&ctx->ctx_outside);
    sha512_update(&ctx->ctx_outside, ctx->block_opad,
                  SHA512_BLOCK_SIZE);

    /* for hmac_reinit */
    memcpy(&ctx->ctx_inside_reinit, &ctx->ctx_inside,
           sizeof(sha512_ctx));
    memcpy(&ctx->ctx_outside_reinit, &ctx->ctx_outside,
           sizeof(sha512_ctx));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpl $0x80, -0x14(%rbp)
jne 0x103e3
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x80, -0x1c(%rbp)
jmp 0x10466
cmpl $0x80, -0x14(%rbp)
jbe 0x1040d
movl $0x40, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x70(%rbp), %rdx
callq 0x11420
leaq -0x70(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x1041b
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl $0x80, %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
addq $0x520, %rdi            # imm = 0x520
movl -0x1c(%rbp), %eax
addq %rax, %rdi
movl -0x18(%rbp), %eax
movl %eax, %edx
movl $0x36, %esi
callq 0x30f0
movq -0x8(%rbp), %rdi
addq $0x5a0, %rdi            # imm = 0x5A0
movl -0x1c(%rbp), %eax
addq %rax, %rdi
movl -0x18(%rbp), %eax
movl %eax, %edx
movl $0x5c, %esi
callq 0x30f0
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x104c0
movq -0x28(%rbp), %rax
movslq -0x74(%rbp), %rcx
movzbl (%rax,%rcx), %eax
xorl $0x36, %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movslq -0x74(%rbp), %rcx
movb %dl, 0x520(%rax,%rcx)
movq -0x28(%rbp), %rax
movslq -0x74(%rbp), %rcx
movzbl (%rax,%rcx), %eax
xorl $0x5c, %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movslq -0x74(%rbp), %rcx
movb %dl, 0x5a0(%rax,%rcx)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x1046d
movq -0x8(%rbp), %rdi
callq 0x11470
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x520, %rsi            # imm = 0x520
movl $0x80, %edx
callq 0x114d0
movq -0x8(%rbp), %rdi
addq $0x148, %rdi            # imm = 0x148
callq 0x11470
movq -0x8(%rbp), %rdi
addq $0x148, %rdi            # imm = 0x148
movq -0x8(%rbp), %rsi
addq $0x5a0, %rsi            # imm = 0x5A0
movl $0x80, %edx
callq 0x114d0
movq -0x8(%rbp), %rdi
addq $0x290, %rdi            # imm = 0x290
movq -0x8(%rbp), %rsi
movl $0x148, %edx            # imm = 0x148
callq 0x31b0
movq -0x8(%rbp), %rdi
addq $0x3d8, %rdi            # imm = 0x3D8
movq -0x8(%rbp), %rsi
addq $0x148, %rsi            # imm = 0x148
movl $0x148, %edx            # imm = 0x148
callq 0x31b0
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)