#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;
typedef int /*<<< orphan*/ key_array;

/* Variables and functions */
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ xxtea_to_key_array(char const *, int /*<<< orphan*/,
                                      int /*<<< orphan*/ *, int);
size_t xxtea_ubyte_encrypt(int /*<<< orphan*/ const *, size_t,
                           int /*<<< orphan*/ *, size_t, int /*<<< orphan*/ *);
size_t xxtea_encrypt(const void *data, size_t len, uint8_t *out,
                     size_t out_size, const char *key) {
  uint32_t key_array[64];
  xxtea_to_key_array(key, strlen(key), key_array, sizeof(key_array));
  return xxtea_ubyte_encrypt((const uint8_t *)data, len, out, out_size,
                             key_array);
}


x86 assembly (clang, -O0):
<xxtea_encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x138(%rbp),%rdi
mov    %eax,%esi
lea    -0x130(%rbp),%rdx
mov    $0x100,%ecx
call   1050 <xxtea_to_key_array@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x130(%rbp),%r8
call   1040 <xxtea_ubyte_encrypt@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xxtea_encrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
mov    %r8,%rdi
call   1030 <strlen@plt>
mov    %rsp,%rbp
mov    %rbx,%rdi
mov    %eax,%esi
mov    %rbp,%rdx
mov    $0x100,%ecx
call   1050 <xxtea_to_key_array@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %rbp,%r8
call   1040 <xxtea_ubyte_encrypt@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @xxtea_encrypt(i8* %0, i64 %1, i32* %2, i64 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca [64 x i32]
store i8* %0, i8** %6
store i64 %1, i64* %7
store i32* %2, i32** %8
store i64 %3, i64* %9
store i8* %4, i8** %10
%12 = load i8*, i8** %10
%13 = load i8*, i8** %10
%14 = call i32 @strlen(i8* %13)
%15 = getelementptr inbounds [64 x i32], [64 x i32]* %11, i64 0, i64 0
%16 = call i32 @xxtea_to_key_array(i8* %12, i32 %14, i32* %15, i32 256)
%17 = load i8*, i8** %6
%18 = bitcast i8* %17 to i32*
%19 = load i64, i64* %7
%20 = load i32*, i32** %8
%21 = load i64, i64* %9
%22 = getelementptr inbounds [64 x i32], [64 x i32]* %11, i64 0, i64 0
%23 = call i64 @xxtea_ubyte_encrypt(i32* %18, i64 %19, i32* %20, i64 %21, i32* %22)
ret i64 %23
}

LLVM IR (-O2):
define i64 @xxtea_encrypt(i8* %0, i64 %1, i32* %2, i64 %3, i8* %4) {
%6 = alloca [64 x i32]
%7 = bitcast [64 x i32]* %6 to i8*
%8 = tail call i32 @strlen(i8* %4)
%9 = getelementptr inbounds [64 x i32], [64 x i32]* %6, i64 0, i64 0
%10 = call i32 @xxtea_to_key_array(i8* %4, i32 %8, i32* %9, i32 256)
%11 = bitcast i8* %0 to i32*
%12 = call i64 @xxtea_ubyte_encrypt(i32* %11, i64 %1, i32* %2, i64 %3, i32* %9)
ret i64 %12
}