#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 *, unsigned int const,
                           unsigned int const, unsigned int const);
scalar_t__ strlen(char *);
void UpnpResponse_ContentDirectory_Browse(const void *UPnPToken,
                                          const char *unescaped_Result,
                                          const unsigned int NumberReturned,
                                          const unsigned int TotalMatches,
                                          const unsigned int UpdateID) {
  char *body;
  char *Result = (char *)malloc(1 + ILibXmlEscapeLength(unescaped_Result));
  ILibXmlEscape(Result, unescaped_Result);
  body = (char *)malloc(134 + strlen(Result));
  sprintf(
      body,
      "<Result>%s</Result><NumberReturned>%u</NumberReturned><TotalMatches>%u</"
      "TotalMatches><UpdateID>%u</UpdateID>",
      Result, NumberReturned, TotalMatches, UpdateID);
  UpnpResponseGeneric(UPnPToken,
                      "urn:schemas-upnp-org:service:ContentDirectory:1",
                      "Browse", body);
  free(body);
  free(Result);
}


x86 assembly (clang, -O0):
<UpnpResponse_ContentDirectory_Browse>:
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    %r8d,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <ILibXmlEscapeLength@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <ILibXmlEscape@plt>
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x86,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe1a(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rcx
lea    0xe73(%rip),%rsi
lea    0xe9c(%rip),%rdx
call   1050 <UpnpResponseGeneric@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UpnpResponse_ContentDirectory_Browse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %rsi,%rbp
mov    %rdi,%r14
mov    %rsi,%rdi
call   1090 <ILibXmlEscapeLength@plt>
lea    0x1(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1040 <ILibXmlEscape@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x86(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,%rbp
lea    0xe39(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
mov    %r13d,%ecx
mov    %r12d,%r8d
mov    %r15d,%r9d
call   1080 <sprintf@plt>
lea    0xe8b(%rip),%rsi
lea    0xeb4(%rip),%rdx
mov    %r14,%rdi
mov    %rbp,%rcx
call   1050 <UpnpResponseGeneric@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [109 x i8] c"<Result>%s</Result><NumberReturned>%u</NumberReturned><TotalMatches>%u</TotalMatches><UpdateID>%u</UpdateID>\00"
@.str.1 = [48 x i8] c"urn:schemas-upnp-org:service:ContentDirectory:1\00"
@.str.2 = [7 x i8] c"Browse\00"
define void @UpnpResponse_ContentDirectory_Browse(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i8*, i8** %7
%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** %12
%18 = load i8*, i8** %12
%19 = load i8*, i8** %7
%20 = call i32 @ILibXmlEscape(i8* %18, i8* %19)
%21 = load i8*, i8** %12
%22 = call i64 @strlen(i8* %21)
%23 = add nsw i64 134, %22
%24 = call i64 @malloc(i64 %23)
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %11
%26 = load i8*, i8** %11
%27 = load i8*, i8** %12
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = load i32, i32* %10
%31 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i8* %27, i32 %28, i32 %29, i32 %30)
%32 = load i8*, i8** %6
%33 = load i8*, i8** %11
%34 = call i32 @UpnpResponseGeneric(i8* %32, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = load i8*, i8** %11
%36 = call i32 @free(i8* %35)
%37 = load i8*, i8** %12
%38 = call i32 @free(i8* %37)
ret void
}

LLVM IR (-O2):
@.str = [109 x i8] c"<Result>%s</Result><NumberReturned>%u</NumberReturned><TotalMatches>%u</TotalMatches><UpdateID>%u</UpdateID>\00"
@.str.1 = [48 x i8] c"urn:schemas-upnp-org:service:ContentDirectory:1\00"
@.str.2 = [7 x i8] c"Browse\00"
define void @UpnpResponse_ContentDirectory_Browse(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i64 @ILibXmlEscapeLength(i8* %1)
%7 = add nsw i64 %6, 1
%8 = tail call i64 @malloc(i64 %7)
%9 = inttoptr i64 %8 to i8*
%10 = tail call i32 @ILibXmlEscape(i8* %9, i8* %1)
%11 = tail call i64 @strlen(i8* dereferenceable(1) %9)
%12 = add nsw i64 %11, 134
%13 = tail call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %2, i32 %3, i32 %4)
%16 = tail call i32 @UpnpResponseGeneric(i8* %0, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%17 = tail call i32 @free(i8* %14)
%18 = tail call i32 @free(i8* %9)
ret void
}