#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 /*<<< orphan*/ *calloc(size_t, int);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, size_t);
int send_all(int, int /*<<< orphan*/ *, size_t);
int /*<<< orphan*/ txencrypt(int /*<<< orphan*/ *, size_t);
int send_enc(int fd, uint8_t *b, size_t n) {
  uint8_t *ebuf;
  int ret;
  ebuf = calloc(n, sizeof(uint8_t));
  memcpy(ebuf, b, n);
  txencrypt(ebuf, n);
  ret = send_all(fd, ebuf, n);
  free(ebuf);
  return ret;
}


x86 assembly (clang, -O0):
<send_enc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <txencrypt@plt>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <send_all@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_enc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%r15d
mov    %rdx,%rdi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <memcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <txencrypt@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1070 <send_all@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @send_enc(i32 %0, i32* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i64 %2, i64* %6
%9 = load i64, i64* %6
%10 = call i32* @calloc(i64 %9, i32 4)
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = load i32*, i32** %5
%13 = load i64, i64* %6
%14 = call i32 @memcpy(i32* %11, i32* %12, i64 %13)
%15 = load i32*, i32** %7
%16 = load i64, i64* %6
%17 = call i32 @txencrypt(i32* %15, i64 %16)
%18 = load i32, i32* %4
%19 = load i32*, i32** %7
%20 = load i64, i64* %6
%21 = call i32 @send_all(i32 %18, i32* %19, i64 %20)
store i32 %21, i32* %8
%22 = load i32*, i32** %7
%23 = call i32 @free(i32* %22)
%24 = load i32, i32* %8
ret i32 %24
}

LLVM IR (-O2):
define i32 @send_enc(i32 %0, i32* %1, i64 %2) {
%4 = tail call i32* @calloc(i64 %2, i32 4)
%5 = tail call i32 @memcpy(i32* %4, i32* %1, i64 %2)
%6 = tail call i32 @txencrypt(i32* %4, i64 %2)
%7 = tail call i32 @send_all(i32 %0, i32* %4, i64 %2)
%8 = tail call i32 @free(i32* %4)
ret i32 %7
}