#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 */

/* Variables and functions */
int EVP_BytesToKey(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/ *,
                   unsigned char const *, int /*<<< orphan*/, int,
                   unsigned char *, unsigned char *);
int /*<<< orphan*/ EVP_aes_256_cbc();
int /*<<< orphan*/ EVP_sha256();
int /*<<< orphan*/ strlen(char *);
int el_aes256_create_key(const unsigned char *key_data, unsigned char *key) {
  int ret, nrounds = 5;
  unsigned char iv[32];
  ret = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha256(), NULL, key_data,
                       strlen((char *)key_data), nrounds, key, iv);
  return -(ret != 32);
}


x86 assembly (clang, -O0):
<el_aes256_create_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x18(%rbp)
mov    $0x0,%al
call   1040 <EVP_aes_256_cbc@plt>
mov    %eax,-0x50(%rbp)
mov    $0x0,%al
call   1060 <EVP_sha256@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x50(%rbp),%edi
mov    -0x4c(%rbp),%esi
mov    -0x48(%rbp),%rcx
mov    %eax,%r8d
mov    -0x18(%rbp),%r9d
mov    -0x10(%rbp),%r10
lea    -0x40(%rbp),%rax
xor    %edx,%edx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <EVP_BytesToKey@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%ecx
xor    %eax,%eax
sub    %ecx,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<el_aes256_create_key>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <EVP_aes_256_cbc@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1060 <EVP_sha256@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rsp,%r10
mov    %r15d,%edi
mov    %ebp,%esi
xor    %edx,%edx
mov    %rbx,%rcx
mov    %eax,%r8d
mov    $0x5,%r9d
push   %r10
push   %r14
call   1030 <EVP_BytesToKey@plt>
add    $0x10,%rsp
xor    %ecx,%ecx
cmp    $0x20,%eax
setne  %cl
neg    %ecx
mov    %ecx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @el_aes256_create_key(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [32 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 5, i32* %6
%8 = call i32 (...) @EVP_aes_256_cbc()
%9 = call i32 (...) @EVP_sha256()
%10 = load i8*, i8** %3
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = load i32, i32* %6
%14 = load i8*, i8** %4
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%16 = call i32 @EVP_BytesToKey(i32 %8, i32 %9, i32* null, i8* %10, i32 %12, i32 %13, i8* %14, i8* %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 32
%19 = zext i1 %18 to i32
%20 = sub nsw i32 0, %19
ret i32 %20
}

LLVM IR (-O2):
define i32 @el_aes256_create_key(i8* %0, i8* %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @EVP_aes_256_cbc()
%6 = tail call i32 (...) @EVP_sha256()
%7 = tail call i32 @strlen(i8* %0)
%8 = call i32 @EVP_BytesToKey(i32 %5, i32 %6, i32* null, i8* %0, i32 %7, i32 5, i8* %1, i8* %4)
%9 = icmp ne i32 %8, 32
%10 = sext i1 %9 to i32
ret i32 %10
}