#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 *, char *);
scalar_t__ strlen(char *);
void UpnpResponse_MediaRenderer_AVTransport_GetDeviceCapabilities(
    const void *UPnPToken, const char *unescaped_PlayMedia,
    const char *unescaped_RecMedia, const char *unescaped_RecQualityModes) {
  char *body;
  char *PlayMedia =
      (char *)malloc(1 + ILibXmlEscapeLength(unescaped_PlayMedia));
  char *RecMedia = (char *)malloc(1 + ILibXmlEscapeLength(unescaped_RecMedia));
  char *RecQualityModes =
      (char *)malloc(1 + ILibXmlEscapeLength(unescaped_RecQualityModes));
  ILibXmlEscape(PlayMedia, unescaped_PlayMedia);
  ILibXmlEscape(RecMedia, unescaped_RecMedia);
  ILibXmlEscape(RecQualityModes, unescaped_RecQualityModes);
  body = (char *)malloc(80 + strlen(PlayMedia) + strlen(RecMedia) +
                        strlen(RecQualityModes));
  sprintf(body,
          "<PlayMedia>%s</PlayMedia><RecMedia>%s</"
          "RecMedia><RecQualityModes>%s</RecQualityModes>",
          PlayMedia, RecMedia, RecQualityModes);
  UpnpResponseGeneric(UPnPToken, "urn:schemas-upnp-org:service:AVTransport:1",
                      "GetDeviceCapabilities", body);
  free(body);
  free(PlayMedia);
  free(RecMedia);
  free(RecQualityModes);
}


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

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

LLVM IR (-O0):
@.str = [86 x i8] c"<PlayMedia>%s</PlayMedia><RecMedia>%s</RecMedia><RecQualityModes>%s</RecQualityModes>\00"
@.str.1 = [43 x i8] c"urn:schemas-upnp-org:service:AVTransport:1\00"
@.str.2 = [22 x i8] c"GetDeviceCapabilities\00"
define void @UpnpResponse_MediaRenderer_AVTransport_GetDeviceCapabilities(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%13 = load i8*, i8** %6
%14 = call i64 @ILibXmlEscapeLength(i8* %13)
%15 = add nsw i64 1, %14
%16 = call i64 @malloc(i64 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %10
%18 = load i8*, i8** %7
%19 = call i64 @ILibXmlEscapeLength(i8* %18)
%20 = add nsw i64 1, %19
%21 = call i64 @malloc(i64 %20)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %11
%23 = load i8*, i8** %8
%24 = call i64 @ILibXmlEscapeLength(i8* %23)
%25 = add nsw i64 1, %24
%26 = call i64 @malloc(i64 %25)
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %12
%28 = load i8*, i8** %10
%29 = load i8*, i8** %6
%30 = call i32 @ILibXmlEscape(i8* %28, i8* %29)
%31 = load i8*, i8** %11
%32 = load i8*, i8** %7
%33 = call i32 @ILibXmlEscape(i8* %31, i8* %32)
%34 = load i8*, i8** %12
%35 = load i8*, i8** %8
%36 = call i32 @ILibXmlEscape(i8* %34, i8* %35)
%37 = load i8*, i8** %10
%38 = call i64 @strlen(i8* %37)
%39 = add nsw i64 80, %38
%40 = load i8*, i8** %11
%41 = call i64 @strlen(i8* %40)
%42 = add nsw i64 %39, %41
%43 = load i8*, i8** %12
%44 = call i64 @strlen(i8* %43)
%45 = add nsw i64 %42, %44
%46 = call i64 @malloc(i64 %45)
%47 = inttoptr i64 %46 to i8*
store i8* %47, i8** %9
%48 = load i8*, i8** %9
%49 = load i8*, i8** %10
%50 = load i8*, i8** %11
%51 = load i8*, i8** %12
%52 = call i32 @sprintf(i8* %48, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str, i64 0, i64 0), i8* %49, i8* %50, i8* %51)
%53 = load i8*, i8** %5
%54 = load i8*, i8** %9
%55 = call i32 @UpnpResponseGeneric(i8* %53, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %54)
%56 = load i8*, i8** %9
%57 = call i32 @free(i8* %56)
%58 = load i8*, i8** %10
%59 = call i32 @free(i8* %58)
%60 = load i8*, i8** %11
%61 = call i32 @free(i8* %60)
%62 = load i8*, i8** %12
%63 = call i32 @free(i8* %62)
ret void
}

LLVM IR (-O2):
@.str = [86 x i8] c"<PlayMedia>%s</PlayMedia><RecMedia>%s</RecMedia><RecQualityModes>%s</RecQualityModes>\00"
@.str.1 = [43 x i8] c"urn:schemas-upnp-org:service:AVTransport:1\00"
@.str.2 = [22 x i8] c"GetDeviceCapabilities\00"
define void @UpnpResponse_MediaRenderer_AVTransport_GetDeviceCapabilities(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i64 @ILibXmlEscapeLength(i8* %1)
%6 = add nsw i64 %5, 1
%7 = tail call i64 @malloc(i64 %6)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i64 @ILibXmlEscapeLength(i8* %2)
%10 = add nsw i64 %9, 1
%11 = tail call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i8*
%13 = tail call i64 @ILibXmlEscapeLength(i8* %3)
%14 = add nsw i64 %13, 1
%15 = tail call i64 @malloc(i64 %14)
%16 = inttoptr i64 %15 to i8*
%17 = tail call i32 @ILibXmlEscape(i8* %8, i8* %1)
%18 = tail call i32 @ILibXmlEscape(i8* %12, i8* %2)
%19 = tail call i32 @ILibXmlEscape(i8* %16, i8* %3)
%20 = tail call i64 @strlen(i8* dereferenceable(1) %8)
%21 = add nsw i64 %20, 80
%22 = tail call i64 @strlen(i8* dereferenceable(1) %12)
%23 = add nsw i64 %21, %22
%24 = tail call i64 @strlen(i8* dereferenceable(1) %16)
%25 = add nsw i64 %23, %24
%26 = tail call i64 @malloc(i64 %25)
%27 = inttoptr i64 %26 to i8*
%28 = tail call i32 @sprintf(i8* dereferenceable(1) %27, i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %12, i8* %16)
%29 = tail call i32 @UpnpResponseGeneric(i8* %0, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%30 = tail call i32 @free(i8* %27)
%31 = tail call i32 @free(i8* %8)
%32 = tail call i32 @free(i8* %12)
%33 = tail call i32 @free(i8* %16)
ret void
}