#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*/ BN_bin2bn(unsigned char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ str2bin(unsigned char *, char *);
scalar_t__ strlen(char *);
unsigned char *unpack(unsigned char *, char *);
unsigned char *simpleUnpack(unsigned char *buffer_in, BIGNUM *bn_new) {
  char out[1024];
  memset(out, 0x00, 1024);
  unsigned char *ptr = unpack(buffer_in, out);
  unsigned char bytes_in[384];
  str2bin(bytes_in, out);
  BN_bin2bn(bytes_in, (int)strlen(out) / 2, bn_new);
  return ptr;
}


x86 assembly (clang, -O0):
<simpleUnpack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1070 <unpack@plt>
mov    %rax,-0x418(%rbp)
lea    -0x5a0(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <str2bin@plt>
lea    -0x5a0(%rbp),%rax
mov    %rax,-0x5a8(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5a8(%rbp),%rdi
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
call   1050 <BN_bin2bn@plt>
mov    -0x418(%rbp),%rax
add    $0x5b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simpleUnpack>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x588,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x180(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <unpack@plt>
mov    %rax,%rbx
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <str2bin@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
mov    %r12,%rdi
mov    %r14,%rdx
call   1050 <BN_bin2bn@plt>
mov    %rbx,%rax
add    $0x588,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @simpleUnpack(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [1024 x i8]
%6 = alloca i8*
%7 = alloca [384 x i8]
store i8* %0, i8** %3
store i32* %1, i32** %4
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 1024)
%10 = load i8*, i8** %3
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = call i8* @unpack(i8* %10, i8* %11)
store i8* %12, i8** %6
%13 = getelementptr inbounds [384 x i8], [384 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%15 = call i32 @str2bin(i8* %13, i8* %14)
%16 = getelementptr inbounds [384 x i8], [384 x i8]* %7, i64 0, i64 0
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%18 = call i64 @strlen(i8* %17)
%19 = trunc i64 %18 to i32
%20 = sdiv i32 %19, 2
%21 = load i32*, i32** %4
%22 = call i32 @BN_bin2bn(i8* %16, i32 %20, i32* %21)
%23 = load i8*, i8** %6
ret i8* %23
}

LLVM IR (-O2):
define i8* @simpleUnpack(i8* %0, i32* %1) {
%3 = alloca [1024 x i8]
%4 = alloca [384 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 1024)
%7 = call i8* @unpack(i8* %0, i8* %5)
%8 = getelementptr inbounds [384 x i8], [384 x i8]* %4, i64 0, i64 0
%9 = call i32 @str2bin(i8* %8, i8* %5)
%10 = call i64 @strlen(i8* %5)
%11 = trunc i64 %10 to i32
%12 = sdiv i32 %11, 2
%13 = call i32 @BN_bin2bn(i8* %8, i32 %12, i32* %1)
ret i8* %7
}