// File: /workspace/github_c_makefile_star2_O0/ataradov[P]edbg/utils.c
// Function: sha256
void sha256(uint8_t *data, int size, uint8_t *hash)
{
  uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
  uint64_t bit_size = size * 8;
  uint8_t buf[64];

  while (size >= 64)
  {
    sha256_process(H, data);
    data += 64;
    size -= 64;
  }

  memset(buf, 0, sizeof(buf));
  memcpy(buf, data, size);

  buf[size] = 0x80;

  if (size >= 56)
  {
    sha256_process(H, buf);
    memset(buf, 0, sizeof(buf));
  }

  buf[56] = bit_size >> 56;
  buf[57] = bit_size >> 48;
  buf[58] = bit_size >> 40;
  buf[59] = bit_size >> 32;
  buf[60] = bit_size >> 24;
  buf[61] = bit_size >> 16;
  buf[62] = bit_size >> 8;
  buf[63] = bit_size;

  sha256_process(H, buf);

  for (int i = 0; i < 8; i++)
  {
    hash[i*4+0] = H[i] >> 24;
    hash[i*4+1] = H[i] >> 16;
    hash[i*4+2] = H[i] >> 8;
    hash[i*4+3] = H[i];
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq 0xb7a3(%rip), %rax      # 0x153e0
movq %rax, -0x40(%rbp)
movq 0xb7a0(%rip), %rax      # 0x153e8
movq %rax, -0x38(%rbp)
movq 0xb79d(%rip), %rax      # 0x153f0
movq %rax, -0x30(%rbp)
movq 0xb79a(%rip), %rax      # 0x153f8
movq %rax, -0x28(%rbp)
movl -0xc(%rbp), %eax
shll $0x3, %eax
cltq
movq %rax, -0x48(%rbp)
cmpl $0x40, -0xc(%rbp)
jl 0x9c98
leaq -0x40(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x9e30
movq -0x8(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x8(%rbp)
movl -0xc(%rbp), %eax
subl $0x40, %eax
movl %eax, -0xc(%rbp)
jmp 0x9c6e
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x60f0
leaq -0x90(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0xc(%rbp), %rdx
callq 0x61a0
movslq -0xc(%rbp), %rax
movb $-0x80, -0x90(%rbp,%rax)
cmpl $0x38, -0xc(%rbp)
jl 0x9cf4
leaq -0x40(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x9e30
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x60f0
movq -0x48(%rbp), %rax
shrq $0x38, %rax
movb %al, -0x58(%rbp)
movq -0x48(%rbp), %rax
shrq $0x30, %rax
movb %al, -0x57(%rbp)
movq -0x48(%rbp), %rax
shrq $0x28, %rax
movb %al, -0x56(%rbp)
movq -0x48(%rbp), %rax
shrq $0x20, %rax
movb %al, -0x55(%rbp)
movq -0x48(%rbp), %rax
shrq $0x18, %rax
movb %al, -0x54(%rbp)
movq -0x48(%rbp), %rax
shrq $0x10, %rax
movb %al, -0x53(%rbp)
movq -0x48(%rbp), %rax
shrq $0x8, %rax
movb %al, -0x52(%rbp)
movq -0x48(%rbp), %rax
movb %al, -0x51(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x9e30
movl $0x0, -0x94(%rbp)
cmpl $0x8, -0x94(%rbp)
jge 0x9e18
movslq -0x94(%rbp), %rax
movl -0x40(%rbp,%rax,4), %eax
shrl $0x18, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x94(%rbp), %ecx
shll $0x2, %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movslq -0x94(%rbp), %rax
movl -0x40(%rbp,%rax,4), %eax
shrl $0x10, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x94(%rbp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movslq -0x94(%rbp), %rax
movl -0x40(%rbp,%rax,4), %eax
shrl $0x8, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x94(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movslq -0x94(%rbp), %rax
movl -0x40(%rbp,%rax,4), %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x94(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x9d62
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)