#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 */
struct ILibWebServer_Session {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ILibWebServer_StreamBody(struct ILibWebServer_Session *,
                                            char *, int, int /*<<< orphan*/,
                                            int);
scalar_t__ malloc(int);
int sprintf(char *, char *, char const *);
scalar_t__ strlen(char const *);
void UpnpAsyncResponse_DONE(const void *UPnPToken, const char *actionName) {
  char *RESPONSE_FOOTER = "</u:%sResponse>\r\n   </s:Body>\r\n</s:Envelope>";
  int footSize = (int)strlen(RESPONSE_FOOTER) + (int)strlen(actionName);
  char *footer = (char *)malloc(footSize);
  struct ILibWebServer_Session *session =
      (struct ILibWebServer_Session *)UPnPToken;
  int footLength = sprintf(footer, RESPONSE_FOOTER, actionName);
  ILibWebServer_StreamBody(session, footer, footLength, 0, 1);
}


x86 assembly (clang, -O0):
<UpnpAsyncResponse_DONE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1060 <sprintf@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x34(%rbp),%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1050 <ILibWebServer_StreamBody@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UpnpAsyncResponse_DONE>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
lea    0x2c(%rax),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xe9b(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <ILibWebServer_StreamBody@plt>

LLVM IR (-O0):
%struct.ILibWebServer_Session = type { i32 }
@.str = [45 x i8] c"</u:%sResponse>\0D\0A </s:Body>\0D\0A</s:Envelope>\00"
define void @UpnpAsyncResponse_DONE(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca %struct.ILibWebServer_Session*
%9 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8** %5
%10 = load i8*, i8** %5
%11 = call i64 @strlen(i8* %10)
%12 = trunc i64 %11 to i32
%13 = load i8*, i8** %4
%14 = call i64 @strlen(i8* %13)
%15 = trunc i64 %14 to i32
%16 = add nsw i32 %12, %15
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %7
%20 = load i8*, i8** %3
%21 = bitcast i8* %20 to %struct.ILibWebServer_Session*
store %struct.ILibWebServer_Session* %21, %struct.ILibWebServer_Session** %8
%22 = load i8*, i8** %7
%23 = load i8*, i8** %5
%24 = load i8*, i8** %4
%25 = call i32 @sprintf(i8* %22, i8* %23, i8* %24)
store i32 %25, i32* %9
%26 = load %struct.ILibWebServer_Session*, %struct.ILibWebServer_Session** %8
%27 = load i8*, i8** %7
%28 = load i32, i32* %9
%29 = call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %26, i8* %27, i32 %28, i32 0, i32 1)
ret void
}

LLVM IR (-O2):
%struct.ILibWebServer_Session = type { i32 }
@.str = [45 x i8] c"</u:%sResponse>\0D\0A </s:Body>\0D\0A</s:Envelope>\00"
define void @UpnpAsyncResponse_DONE(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = trunc i64 %3 to i32
%5 = add nsw i32 %4, 44
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = bitcast i8* %0 to %struct.ILibWebServer_Session*
%9 = tail call i32 @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %1)
%10 = tail call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %8, i8* %7, i32 %9, i32 0, i32 1)
ret void
}