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

/* Variables and functions */
int EVP_EncryptFinal_ex(int /*<<< orphan*/ *, unsigned char *, int *);
int EVP_EncryptUpdate(int /*<<< orphan*/ *, unsigned char *, int *,
                      unsigned char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
void randombuff(EVP_CIPHER_CTX *aes_ctx, unsigned char *buff, int length) {
  memset(buff, 0, length);
  if (1 != EVP_EncryptUpdate(aes_ctx, buff, &length, buff, length)) {
    fprintf(stderr, "EVP error\n");
  }
  if (1 != EVP_EncryptFinal_ex(aes_ctx, buff, &length)) {
    fprintf(stderr, "EVP error\n");
  }
}


x86 assembly (clang, -O0):
<randombuff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    -0x14(%rbp),%rdx
call   1050 <EVP_EncryptUpdate@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     119e <randombuff+0x5e>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <EVP_EncryptFinal_ex@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     11d3 <randombuff+0x93>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xe32(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randombuff>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %edx,0xc(%rsp)
mov    %rsi,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
lea    0xc(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbx,%rcx
mov    %ebp,%r8d
call   1050 <EVP_EncryptUpdate@plt>
cmp    $0x1,%eax
je     118e <randombuff+0x4e>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xc(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <EVP_EncryptFinal_ex@plt>
cmp    $0x1,%eax
je     11b8 <randombuff+0x78>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"EVP error\0A\00"
define void @randombuff(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %5
%8 = load i32, i32* %6
%9 = call i32 @memset(i8* %7, i32 0, i32 %8)
%10 = load i32*, i32** %4
%11 = load i8*, i8** %5
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = call i32 @EVP_EncryptUpdate(i32* %10, i8* %11, i32* %6, i8* %12, i32 %13)
%15 = icmp ne i32 1, %14
br i1 %15, label %16, label %19
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %16, %3
%20 = load i32*, i32** %4
%21 = load i8*, i8** %5
%22 = call i32 @EVP_EncryptFinal_ex(i32* %20, i8* %21, i32* %6)
%23 = icmp ne i32 1, %22
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %24, %19
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [11 x i8] c"EVP error\0A\00"
define void @randombuff(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
store i32 %2, i32* %4
%5 = tail call i32 @memset(i8* %1, i32 0, i32 %2)
%6 = call i32 @EVP_EncryptUpdate(i32* %0, i8* %1, i32* %4, i8* %1, i32 %2)
%7 = icmp eq i32 %6, 1
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %8, %3
%12 = call i32 @EVP_EncryptFinal_ex(i32* %0, i8* %1, i32* %4)
%13 = icmp eq i32 %12, 1
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14, %11
ret void
}