#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ *getbnfrombuf(unsigned char *, int);
BIGNUM *hashsum2bn(const unsigned char *dgst) {
  unsigned char buf[32];
  int i;
  for (i = 0; i < 32; i++) {
    buf[31 - i] = dgst[i];
  }
  return getbnfrombuf(buf, 32);
}


x86 assembly (clang, -O0):
<hashsum2bn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x20,-0x34(%rbp)
jge    1154 <hashsum2bn+0x44>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    $0x1f,%eax
sub    -0x34(%rbp),%eax
cltq
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1123 <hashsum2bn+0x13>
lea    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   1030 <getbnfrombuf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hashsum2bn>:
sub    $0x28,%rsp
movdqu (%rdi),%xmm0
pxor   %xmm1,%xmm1
movdqa %xmm0,%xmm2
punpcklbw %xmm1,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
punpckhbw %xmm1,%xmm0
pshufd $0x4e,%xmm0,%xmm0
pshuflw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm0
packuswb %xmm2,%xmm0
movdqa %xmm0,0x10(%rsp)
movdqu 0x10(%rdi),%xmm0
movdqa %xmm0,%xmm2
punpcklbw %xmm1,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
punpckhbw %xmm1,%xmm0
pshufd $0x4e,%xmm0,%xmm0
pshuflw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm0
packuswb %xmm2,%xmm0
movdqa %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x20,%esi
call   1030 <getbnfrombuf@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32* @hashsum2bn(i8* %0) {
%2 = alloca i8*
%3 = alloca [32 x i8]
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
br label %5
5: ; preds = %18, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 32
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = load i8*, i8** %2
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = load i32, i32* %4
%15 = sub nsw i32 31, %14
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 %16
store i8 %13, i8* %17
br label %18
18: ; preds = %8
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %5
21: ; preds = %5
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%23 = call i32* @getbnfrombuf(i8* %22, i32 32)
ret i32* %23
}

LLVM IR (-O2):
define i32* @hashsum2bn(i8* nocapture %0) {
%2 = alloca [32 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%4 = bitcast i8* %0 to <16 x i8>*
%5 = load <16 x i8>, <16 x i8>* %4
%6 = shufflevector <16 x i8> %5, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 16
%8 = bitcast i8* %7 to <16 x i8>*
store <16 x i8> %6, <16 x i8>* %8
%9 = getelementptr inbounds i8, i8* %0, i64 16
%10 = bitcast i8* %9 to <16 x i8>*
%11 = load <16 x i8>, <16 x i8>* %10
%12 = shufflevector <16 x i8> %11, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%13 = bitcast [32 x i8]* %2 to <16 x i8>*
store <16 x i8> %12, <16 x i8>* %13
%14 = call i32* @getbnfrombuf(i8* %3, i32 32)
ret i32* %14
}