#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;

/* Variables and functions */
int EVP_DecryptUpdate(void *, int /*<<< orphan*/ *, int *, int /*<<< orphan*/ *,
                      int);
int /*<<< orphan*/ msg_print_va(int, char *, int, int, int);
int AES128_CBC_DecryptUpdate(void *ctx, uint8_t *plaintext, uint8_t *ciphertext,
                             int in_size) {
  int out_size = 0;
  int ret = 1;
  if (in_size > 0) {
    ret = EVP_DecryptUpdate(ctx, plaintext, &out_size, ciphertext, in_size);
    if (1 != ret || in_size != out_size) {
      msg_print_va(
          0x01,
          "AES128_CBC_DecryptUpdate failed: %d, in_size: %d, out_size: %d\n",
          ret, in_size, out_size);
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<AES128_CBC_DecryptUpdate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11a5 <AES128_CBC_DecryptUpdate+0x85>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
lea    -0x20(%rbp),%rdx
call   1040 <EVP_DecryptUpdate@plt>
mov    %eax,-0x24(%rbp)
mov    $0x1,%eax
cmp    -0x24(%rbp),%eax
jne    1185 <AES128_CBC_DecryptUpdate+0x65>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     11a0 <AES128_CBC_DecryptUpdate+0x80>
mov    -0x24(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    $0x1,%edi
lea    0xe65(%rip),%rsi
call   1030 <msg_print_va@plt>
jmp    11a5 <AES128_CBC_DecryptUpdate+0x85>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AES128_CBC_DecryptUpdate>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebx
movl   $0x0,0xc(%rsp)
mov    $0x1,%ebp
test   %ecx,%ecx
jle    1176 <AES128_CBC_DecryptUpdate+0x56>
mov    %rdx,%rcx
lea    0xc(%rsp),%rdx
mov    %ebx,%r8d
call   1040 <EVP_DecryptUpdate@plt>
mov    %eax,%r14d
mov    0xc(%rsp),%r8d
cmp    $0x1,%eax
jne    115d <AES128_CBC_DecryptUpdate+0x3d>
cmp    %ebx,%r8d
je     1176 <AES128_CBC_DecryptUpdate+0x56>
lea    0xe9c(%rip),%rsi
mov    $0x1,%edi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1030 <msg_print_va@plt>
mov    %r14d,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [64 x i8] c"AES128_CBC_DecryptUpdate failed: %d, in_size: %d, out_size: %d\0A\00"
define i32 @AES128_CBC_DecryptUpdate(i8* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 1, i32* %10
%11 = load i32, i32* %8
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %31
13: ; preds = %4
%14 = load i8*, i8** %5
%15 = load i32*, i32** %6
%16 = load i32*, i32** %7
%17 = load i32, i32* %8
%18 = call i32 @EVP_DecryptUpdate(i8* %14, i32* %15, i32* %9, i32* %16, i32 %17)
store i32 %18, i32* %10
%19 = load i32, i32* %10
%20 = icmp ne i32 1, %19
br i1 %20, label %25, label %21
21: ; preds = %13
%22 = load i32, i32* %8
%23 = load i32, i32* %9
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21, %13
%26 = load i32, i32* %10
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = call i32 @msg_print_va(i32 1, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27, i32 %28)
br label %30
30: ; preds = %25, %21
br label %31
31: ; preds = %30, %4
%32 = load i32, i32* %10
ret i32 %32
}

LLVM IR (-O2):
@.str = [64 x i8] c"AES128_CBC_DecryptUpdate failed: %d, in_size: %d, out_size: %d\0A\00"
define i32 @AES128_CBC_DecryptUpdate(i8* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %16
8: ; preds = %4
%9 = call i32 @EVP_DecryptUpdate(i8* %0, i32* %1, i32* %5, i32* %2, i32 %3)
%10 = icmp eq i32 %9, 1
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, %3
%13 = select i1 %10, i1 %12, i1 false
br i1 %13, label %16, label %14
14: ; preds = %8
%15 = call i32 @msg_print_va(i32 1, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %3, i32 %11)
br label %16
16: ; preds = %8, %14, %4
%17 = phi i32 [ %9, %14 ], [ 1, %4 ], [ 1, %8 ]
ret i32 %17
}