#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 ILibXmlEscape(char *, char const *);
scalar_t__ ILibXmlEscapeLength(char const *);
int /*<<< orphan*/ UpnpSendData(void const *, char *, int, int const);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
void UpnpSendDataXmlEscaped(const void *UPnPToken, const char *Data,
                            const int DataLength, const int Terminate) {
  int escsize;
  char *buf;
  escsize = (int)ILibXmlEscapeLength(Data);
  buf = (char *)malloc(escsize);
  if (buf != NULL) {
    escsize = ILibXmlEscape(buf, Data);
    UpnpSendData(UPnPToken, buf, escsize, Terminate);
    free(buf);
  }
}


x86 assembly (clang, -O0):
<UpnpSendDataXmlEscaped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <ILibXmlEscapeLength@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11b5 <UpnpSendDataXmlEscaped+0x65>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <ILibXmlEscape@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1050 <UpnpSendData@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UpnpSendDataXmlEscaped>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %rsi,%rdi
call   1070 <ILibXmlEscapeLength@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11a4 <UpnpSendDataXmlEscaped+0x54>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1040 <ILibXmlEscape@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
mov    %r14d,%ecx
call   1050 <UpnpSendData@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @UpnpSendDataXmlEscaped(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i64 @ILibXmlEscapeLength(i8* %1)
%6 = trunc i64 %5 to i32
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i64 %7, 0
br i1 %9, label %14, label %10
10: ; preds = %4
%11 = tail call i32 @ILibXmlEscape(i8* %8, i8* %1)
%12 = tail call i32 @UpnpSendData(i8* %0, i8* %8, i32 %11, i32 %3)
%13 = tail call i32 @free(i8* %8)
br label %14
14: ; preds = %10, %4
ret void
}