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

/* Variables and functions */
size_t ece_aes128gcm_max_decrypted_length(int /*<<< orphan*/, size_t);
int ece_aes128gcm_payload_extract_params(int /*<<< orphan*/ const *, size_t,
                                         int /*<<< orphan*/ const **, size_t *,
                                         int /*<<< orphan*/ const **, size_t *,
                                         int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ const **, size_t *);
size_t ece_aes128gcm_plaintext_max_length(const uint8_t *payload,
                                          size_t payloadLen) {
  const uint8_t *salt;
  size_t saltLen;
  const uint8_t *keyId;
  size_t keyIdLen;
  uint32_t rs;
  const uint8_t *ciphertext;
  size_t ciphertextLen;
  int err = ece_aes128gcm_payload_extract_params(
      payload, payloadLen, &salt, &saltLen, &keyId, &keyIdLen, &rs, &ciphertext,
      &ciphertextLen);
  if (err) {
    return 0;
  }
  return ece_aes128gcm_max_decrypted_length(rs, ciphertextLen);
}


x86 assembly (clang, -O0):
<ece_aes128gcm_plaintext_max_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
lea    -0x38(%rbp),%r9
lea    -0x3c(%rbp),%r11
lea    -0x48(%rbp),%r10
lea    -0x50(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <ece_aes128gcm_payload_extract_params@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     1181 <ece_aes128gcm_plaintext_max_length+0x61>
movq   $0x0,-0x8(%rbp)
jmp    1191 <ece_aes128gcm_plaintext_max_length+0x71>
mov    -0x3c(%rbp),%edi
mov    -0x50(%rbp),%rsi
call   1030 <ece_aes128gcm_max_decrypted_length@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ece_aes128gcm_plaintext_max_length>:
sub    $0x40,%rsp
lea    0x10(%rsp),%rax
lea    0x18(%rsp),%r10
lea    0xc(%rsp),%r11
lea    0x38(%rsp),%rdx
lea    0x30(%rsp),%rcx
lea    0x28(%rsp),%r8
lea    0x20(%rsp),%r9
push   %rax
push   %r10
push   %r11
call   1040 <ece_aes128gcm_payload_extract_params@plt>
add    $0x20,%rsp
test   %eax,%eax
je     1160 <ece_aes128gcm_plaintext_max_length+0x40>
xor    %eax,%eax
add    $0x38,%rsp
ret
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%rsi
call   1030 <ece_aes128gcm_max_decrypted_length@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
define i64 @ece_aes128gcm_plaintext_max_length(i32* %0, i64 %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i64
%13 = alloca i32
store i32* %0, i32** %4
store i64 %1, i64* %5
%14 = load i32*, i32** %4
%15 = load i64, i64* %5
%16 = call i32 @ece_aes128gcm_payload_extract_params(i32* %14, i64 %15, i32** %6, i64* %7, i32** %8, i64* %9, i32* %10, i32** %11, i64* %12)
store i32 %16, i32* %13
%17 = load i32, i32* %13
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %2
store i64 0, i64* %3
br label %24
20: ; preds = %2
%21 = load i32, i32* %10
%22 = load i64, i64* %12
%23 = call i64 @ece_aes128gcm_max_decrypted_length(i32 %21, i64 %22)
store i64 %23, i64* %3
br label %24
24: ; preds = %20, %19
%25 = load i64, i64* %3
ret i64 %25
}

LLVM IR (-O2):
define i64 @ece_aes128gcm_plaintext_max_length(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i64
%10 = bitcast i32** %3 to i8*
%11 = bitcast i64* %4 to i8*
%12 = bitcast i32** %5 to i8*
%13 = bitcast i64* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = bitcast i32** %8 to i8*
%16 = bitcast i64* %9 to i8*
%17 = call i32 @ece_aes128gcm_payload_extract_params(i32* %0, i64 %1, i32** %3, i64* %4, i32** %5, i64* %6, i32* %7, i32** %8, i64* %9)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %2
%20 = load i32, i32* %7
%21 = load i64, i64* %9
%22 = call i64 @ece_aes128gcm_max_decrypted_length(i32 %20, i64 %21)
br label %23
23: ; preds = %2, %19
%24 = phi i64 [ %22, %19 ], [ 0, %2 ]
ret i64 %24
}