#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 const, int,
                                            int /*<<< orphan*/);
scalar_t__ strlen(char const *);
void UpnpAsyncResponse_OUT(const void *UPnPToken, const char *outArgName,
                           const char *bytes, const int byteLength,
                           const int startArg, const int endArg) {
  struct ILibWebServer_Session *session =
      (struct ILibWebServer_Session *)UPnPToken;
  if (startArg != 0) {
    ILibWebServer_StreamBody(session, "<", 1, 1, 0);
    ILibWebServer_StreamBody(session, (char *)outArgName,
                             (int)strlen(outArgName), 1, 0);
    ILibWebServer_StreamBody(session, ">", 1, 1, 0);
  }
  if (byteLength > 0) {
    ILibWebServer_StreamBody(session, (char *)bytes, byteLength, 1, 0);
  }
  if (endArg != 0) {
    ILibWebServer_StreamBody(session, "</", 2, 1, 0);
    ILibWebServer_StreamBody(session, (char *)outArgName,
                             (int)strlen(outArgName), 1, 0);
    ILibWebServer_StreamBody(session, ">\r\n", 3, 1, 0);
  }
}


x86 assembly (clang, -O0):
<UpnpAsyncResponse_OUT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11b5 <UpnpAsyncResponse_OUT+0x95>
mov    -0x30(%rbp),%rdi
lea    0xea4(%rip),%rsi
mov    $0x1,%ecx
xor    %r8d,%r8d
mov    %ecx,%edx
call   1040 <ILibWebServer_StreamBody@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <ILibWebServer_StreamBody@plt>
mov    -0x30(%rbp),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x1,%ecx
xor    %r8d,%r8d
mov    %ecx,%edx
call   1040 <ILibWebServer_StreamBody@plt>
cmpl   $0x0,-0x1c(%rbp)
jle    11d7 <UpnpAsyncResponse_OUT+0xb7>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <ILibWebServer_StreamBody@plt>
cmpl   $0x0,-0x24(%rbp)
je     124b <UpnpAsyncResponse_OUT+0x12b>
mov    -0x30(%rbp),%rdi
lea    0xe18(%rip),%rsi
mov    $0x2,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <ILibWebServer_StreamBody@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <ILibWebServer_StreamBody@plt>
mov    -0x30(%rbp),%rdi
lea    0xdce(%rip),%rsi
mov    $0x3,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <ILibWebServer_StreamBody@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UpnpAsyncResponse_OUT>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%r15d
mov    %ecx,%ebp
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%rbx
test   %r8d,%r8d
je     1190 <UpnpAsyncResponse_OUT+0x70>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <ILibWebServer_StreamBody@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <ILibWebServer_StreamBody@plt>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <ILibWebServer_StreamBody@plt>
test   %ebp,%ebp
jle    11a9 <UpnpAsyncResponse_OUT+0x89>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <ILibWebServer_StreamBody@plt>
test   %r15d,%r15d
je     120b <UpnpAsyncResponse_OUT+0xeb>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <ILibWebServer_StreamBody@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <ILibWebServer_StreamBody@plt>
lea    0xe19(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ILibWebServer_StreamBody@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ILibWebServer_Session = type { i32 }
@.str = [2 x i8] c"<\00"
@.str.1 = [2 x i8] c">\00"
@.str.2 = [3 x i8] c"</\00"
@.str.3 = [4 x i8] c">\0D\0A\00"
define void @UpnpAsyncResponse_OUT(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.ILibWebServer_Session*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%14 = load i8*, i8** %7
%15 = bitcast i8* %14 to %struct.ILibWebServer_Session*
store %struct.ILibWebServer_Session* %15, %struct.ILibWebServer_Session** %13
%16 = load i32, i32* %11
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %6
%19 = load %struct.ILibWebServer_Session*, %struct.ILibWebServer_Session** %13
%20 = call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1, i32 1, i32 0)
%21 = load %struct.ILibWebServer_Session*, %struct.ILibWebServer_Session** %13
%22 = load i8*, i8** %8
%23 = load i8*, i8** %8
%24 = call i64 @strlen(i8* %23)
%25 = trunc i64 %24 to i32
%26 = call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %21, i8* %22, i32 %25, i32 1, i32 0)
%27 = load %struct.ILibWebServer_Session*, %struct.ILibWebServer_Session** %13
%28 = call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 1, i32 0)
br label %29
29: ; preds = %18, %6
%30 = load i32, i32* %10
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load %struct.ILibWebServer_Session*, %struct.ILibWebServer_Session** %13
%34 = load i8*, i8** %9
%35 = load i32, i32* %10
%36 = call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %33, i8* %34, i32 %35, i32 1, i32 0)
br label %37
37: ; preds = %32, %29
%38 = load i32, i32* %12
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %51
40: ; preds = %37
%41 = load %struct.ILibWebServer_Session*, %struct.ILibWebServer_Session** %13
%42 = call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 1, i32 0)
%43 = load %struct.ILibWebServer_Session*, %struct.ILibWebServer_Session** %13
%44 = load i8*, i8** %8
%45 = load i8*, i8** %8
%46 = call i64 @strlen(i8* %45)
%47 = trunc i64 %46 to i32
%48 = call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %43, i8* %44, i32 %47, i32 1, i32 0)
%49 = load %struct.ILibWebServer_Session*, %struct.ILibWebServer_Session** %13
%50 = call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 1, i32 0)
br label %51
51: ; preds = %40, %37
ret void
}

LLVM IR (-O2):
%struct.ILibWebServer_Session = type { i32 }
@.str = [2 x i8] c"<\00"
@.str.1 = [2 x i8] c">\00"
@.str.2 = [3 x i8] c"</\00"
@.str.3 = [4 x i8] c">\0D\0A\00"
define void @UpnpAsyncResponse_OUT(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5) {
%7 = bitcast i8* %0 to %struct.ILibWebServer_Session*
%8 = icmp eq i32 %4, 0
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = tail call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1, i32 1, i32 0)
%11 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%12 = trunc i64 %11 to i32
%13 = tail call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %7, i8* %1, i32 %12, i32 1, i32 0)
%14 = tail call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 1, i32 0)
br label %15
15: ; preds = %9, %6
%16 = icmp sgt i32 %3, 0
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %7, i8* %2, i32 %3, i32 1, i32 0)
br label %19
19: ; preds = %17, %15
%20 = icmp eq i32 %5, 0
br i1 %20, label %27, label %21
21: ; preds = %19
%22 = tail call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 1, i32 0)
%23 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%24 = trunc i64 %23 to i32
%25 = tail call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %7, i8* %1, i32 %24, i32 1, i32 0)
%26 = tail call i32 @ILibWebServer_StreamBody(%struct.ILibWebServer_Session* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 1, i32 0)
br label %27
27: ; preds = %21, %19
ret void
}