#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*/ ILibXmlEscape(char *, char const *);
scalar_t__ ILibXmlEscapeLength(char const *);
int /*<<< orphan*/ UpnpResponseGeneric(void const *, char *, char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
scalar_t__ strlen(char *);
void UpnpResponse_MediaRenderer_ConnectionManager_GetProtocolInfo(
    const void *UPnPToken, const char *unescaped_Source,
    const char *unescaped_Sink) {
  char *body;
  char *Source = (char *)malloc(1 + ILibXmlEscapeLength(unescaped_Source));
  char *Sink = (char *)malloc(1 + ILibXmlEscapeLength(unescaped_Sink));
  ILibXmlEscape(Source, unescaped_Source);
  ILibXmlEscape(Sink, unescaped_Sink);
  body = (char *)malloc(31 + strlen(Source) + strlen(Sink));
  sprintf(body, "<Source>%s</Source><Sink>%s</Sink>", Source, Sink);
  UpnpResponseGeneric(UPnPToken,
                      "urn:schemas-upnp-org:service:ConnectionManager:1",
                      "GetProtocolInfo", body);
  free(body);
  free(Source);
  free(Sink);
}


x86 assembly (clang, -O0):
<UpnpResponse_MediaRenderer_ConnectionManager_GetProtocolInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <ILibXmlEscapeLength@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <ILibXmlEscapeLength@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <ILibXmlEscape@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <ILibXmlEscape@plt>
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1f,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x38(%rbp),%rdi
add    %rax,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xdf3(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rcx
lea    0xe02(%rip),%rsi
lea    0xe2c(%rip),%rdx
call   1050 <UpnpResponseGeneric@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UpnpResponse_MediaRenderer_ConnectionManager_GetProtocolInfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%r14
mov    %rsi,%rdi
call   1090 <ILibXmlEscapeLength@plt>
lea    0x1(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    %r12,%rdi
call   1090 <ILibXmlEscapeLength@plt>
lea    0x1(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,%rbp
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <ILibXmlEscape@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <ILibXmlEscape@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rax,%r12
mov    %rbp,%rdi
call   1060 <strlen@plt>
lea    (%r12,%rax,1),%rdi
add    $0x1f,%rdi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe14(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
mov    %rbp,%rcx
call   1080 <sprintf@plt>
lea    0xe22(%rip),%rsi
lea    0xe4c(%rip),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1050 <UpnpResponseGeneric@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"<Source>%s</Source><Sink>%s</Sink>\00"
@.str.1 = [49 x i8] c"urn:schemas-upnp-org:service:ConnectionManager:1\00"
@.str.2 = [16 x i8] c"GetProtocolInfo\00"
define void @UpnpResponse_MediaRenderer_ConnectionManager_GetProtocolInfo(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = load i8*, i8** %5
%11 = call i64 @ILibXmlEscapeLength(i8* %10)
%12 = add nsw i64 1, %11
%13 = call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %8
%15 = load i8*, i8** %6
%16 = call i64 @ILibXmlEscapeLength(i8* %15)
%17 = add nsw i64 1, %16
%18 = call i64 @malloc(i64 %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %9
%20 = load i8*, i8** %8
%21 = load i8*, i8** %5
%22 = call i32 @ILibXmlEscape(i8* %20, i8* %21)
%23 = load i8*, i8** %9
%24 = load i8*, i8** %6
%25 = call i32 @ILibXmlEscape(i8* %23, i8* %24)
%26 = load i8*, i8** %8
%27 = call i64 @strlen(i8* %26)
%28 = add nsw i64 31, %27
%29 = load i8*, i8** %9
%30 = call i64 @strlen(i8* %29)
%31 = add nsw i64 %28, %30
%32 = call i64 @malloc(i64 %31)
%33 = inttoptr i64 %32 to i8*
store i8* %33, i8** %7
%34 = load i8*, i8** %7
%35 = load i8*, i8** %8
%36 = load i8*, i8** %9
%37 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %35, i8* %36)
%38 = load i8*, i8** %4
%39 = load i8*, i8** %7
%40 = call i32 @UpnpResponseGeneric(i8* %38, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = load i8*, i8** %7
%42 = call i32 @free(i8* %41)
%43 = load i8*, i8** %8
%44 = call i32 @free(i8* %43)
%45 = load i8*, i8** %9
%46 = call i32 @free(i8* %45)
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"<Source>%s</Source><Sink>%s</Sink>\00"
@.str.1 = [49 x i8] c"urn:schemas-upnp-org:service:ConnectionManager:1\00"
@.str.2 = [16 x i8] c"GetProtocolInfo\00"
define void @UpnpResponse_MediaRenderer_ConnectionManager_GetProtocolInfo(i8* %0, i8* %1, i8* %2) {
%4 = tail call i64 @ILibXmlEscapeLength(i8* %1)
%5 = add nsw i64 %4, 1
%6 = tail call i64 @malloc(i64 %5)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i64 @ILibXmlEscapeLength(i8* %2)
%9 = add nsw i64 %8, 1
%10 = tail call i64 @malloc(i64 %9)
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 @ILibXmlEscape(i8* %7, i8* %1)
%13 = tail call i32 @ILibXmlEscape(i8* %11, i8* %2)
%14 = tail call i64 @strlen(i8* dereferenceable(1) %7)
%15 = add nsw i64 %14, 31
%16 = tail call i64 @strlen(i8* dereferenceable(1) %11)
%17 = add nsw i64 %15, %16
%18 = tail call i64 @malloc(i64 %17)
%19 = inttoptr i64 %18 to i8*
%20 = tail call i32 @sprintf(i8* dereferenceable(1) %19, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %11)
%21 = tail call i32 @UpnpResponseGeneric(i8* %0, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%22 = tail call i32 @free(i8* %19)
%23 = tail call i32 @free(i8* %7)
%24 = tail call i32 @free(i8* %11)
ret void
}