#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*/ uint8_t;
typedef int /*<<< orphan*/ uint32_t;
struct CRYPTO_CIPHER_CTX {
  int dummy;
};
typedef int /*<<< orphan*/ EVP_CIPHER_CTX;

/* Variables and functions */
scalar_t__ EVP_Cipher(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                      int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ ssh_set_error(char *);
int crypto_aes_crypt(struct CRYPTO_CIPHER_CTX *cipher_ctx, uint8_t *out,
                     uint8_t *data, uint32_t len) {
  EVP_CIPHER_CTX *ctx = ((EVP_CIPHER_CTX *)(cipher_ctx));
  if (EVP_Cipher(ctx, out, data, len) == 0) {
    ssh_set_error("cipher error");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<crypto_aes_crypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1030 <EVP_Cipher@plt>
cmp    $0x0,%rax
jne    1175 <crypto_aes_crypt+0x55>
lea    0xe9c(%rip),%rdi
call   1040 <ssh_set_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    117c <crypto_aes_crypt+0x5c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypto_aes_crypt>:
push   %rax
call   1030 <EVP_Cipher@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     1132 <crypto_aes_crypt+0x12>
pop    %rcx
ret
lea    0xec7(%rip),%rdi
call   1040 <ssh_set_error@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.CRYPTO_CIPHER_CTX = type { i32 }
@.str = [13 x i8] c"cipher error\00"
define i32 @crypto_aes_crypt(%struct.CRYPTO_CIPHER_CTX* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.CRYPTO_CIPHER_CTX*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32*
store %struct.CRYPTO_CIPHER_CTX* %0, %struct.CRYPTO_CIPHER_CTX** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32 %3, i32* %9
%11 = load %struct.CRYPTO_CIPHER_CTX*, %struct.CRYPTO_CIPHER_CTX** %6
%12 = bitcast %struct.CRYPTO_CIPHER_CTX* %11 to i32*
store i32* %12, i32** %10
%13 = load i32*, i32** %10
%14 = load i32*, i32** %7
%15 = load i32*, i32** %8
%16 = load i32, i32* %9
%17 = call i64 @EVP_Cipher(i32* %13, i32* %14, i32* %15, i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = call i32 @ssh_set_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %22
21: ; preds = %4
store i32 0, i32* %5
br label %22
22: ; preds = %21, %19
%23 = load i32, i32* %5
ret i32 %23
}

LLVM IR (-O2):
%struct.CRYPTO_CIPHER_CTX = type { i32 }
@.str = [13 x i8] c"cipher error\00"
define i32 @crypto_aes_crypt(%struct.CRYPTO_CIPHER_CTX* %0, i32* %1, i32* %2, i32 %3) {
%5 = getelementptr %struct.CRYPTO_CIPHER_CTX, %struct.CRYPTO_CIPHER_CTX* %0, i64 0, i32 0
%6 = tail call i64 @EVP_Cipher(i32* %5, i32* %1, i32* %2, i32 %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @ssh_set_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %4, %8
%11 = phi i32 [ -1, %8 ], [ 0, %4 ]
ret i32 %11
}