#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 */

/* Variables and functions */
int /*<<< orphan*/ memory_free(char *);
int /*<<< orphan*/ send(int, char *, size_t, int /*<<< orphan*/);
void send_free(int client, char **buffer, int bytes) {
  if (NULL != buffer) {
    if (bytes > 0) {
      send(client, *buffer, (size_t)bytes, 0);
    }
    if (*buffer) {
      memory_free(*buffer);
      *buffer = NULL;
    }
  }
}


x86 assembly (clang, -O0):
<send_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1187 <send_free+0x67>
cmpl   $0x0,-0x14(%rbp)
jle    115d <send_free+0x3d>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
movslq -0x14(%rbp),%rdx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1182 <send_free+0x62>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <memory_free@plt>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
jmp    1187 <send_free+0x67>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_free>:
push   %rbx
test   %rsi,%rsi
je     114d <send_free+0x2d>
mov    %rsi,%rbx
test   %edx,%edx
jle    1139 <send_free+0x19>
mov    (%rbx),%rsi
mov    %edx,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     114d <send_free+0x2d>
call   1030 <memory_free@plt>
movq   $0x0,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @send_free(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%7 = load i8**, i8*** %5
%8 = icmp ne i8** null, %7
br i1 %8, label %9, label %29
9: ; preds = %3
%10 = load i32, i32* %6
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = load i8*, i8** %14
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = call i32 @send(i32 %13, i8* %15, i64 %17, i32 0)
br label %19
19: ; preds = %12, %9
%20 = load i8**, i8*** %5
%21 = load i8*, i8** %20
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8**, i8*** %5
%25 = load i8*, i8** %24
%26 = call i32 @memory_free(i8* %25)
%27 = load i8**, i8*** %5
store i8* null, i8** %27
br label %28
28: ; preds = %23, %19
br label %29
29: ; preds = %28, %3
ret void
}

LLVM IR (-O2):
define void @send_free(i32 %0, i8** %1, i32 %2) {
%4 = icmp eq i8** %1, null
br i1 %4, label %16, label %5
5: ; preds = %3
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %11
7: ; preds = %5
%8 = load i8*, i8** %1
%9 = zext i32 %2 to i64
%10 = tail call i32 @send(i32 %0, i8* %8, i64 %9, i32 0)
br label %11
11: ; preds = %7, %5
%12 = load i8*, i8** %1
%13 = icmp eq i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @memory_free(i8* %12)
store i8* null, i8** %1
br label %16
16: ; preds = %11, %14, %3
ret void
}