#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 upnphttp {
  int dummy;
};
typedef int /*<<< orphan*/ body;

/* Variables and functions */
int /*<<< orphan*/ BuildResp2_upnphttp(struct upnphttp *, int, char *, char *,
                                       int);
int /*<<< orphan*/ CloseSocket_upnphttp(struct upnphttp *);
int /*<<< orphan*/ SendResp_upnphttp(struct upnphttp *);
int snprintf(char *, int, char const *, int, char const *);
void SoapError(struct upnphttp *h, int errCode, const char *errDesc) {
  static const char resp[] =
      "<s:Envelope "
      "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
      "s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
      "<s:Body>"
      "<s:Fault>"
      "<faultcode>s:Client</faultcode>"
      "<faultstring>UPnPError</faultstring>"
      "<detail>"
      "<UPnPError xmlns=\"urn:schemas-upnp-org:control-1-0\">"
      "<errorCode>%d</errorCode>"
      "<errorDescription>%s</errorDescription>"
      "</UPnPError>"
      "</detail>"
      "</s:Fault>"
      "</s:Body>"
      "</s:Envelope>";
  char body[2048];
  int bodylen;
  ;
  bodylen = snprintf(body, sizeof(body), resp, errCode, errDesc);
  BuildResp2_upnphttp(h, 500, "Internal Server Error", body, bodylen);
  SendResp_upnphttp(h);
  CloseSocket_upnphttp(h);
}


x86 assembly (clang, -O0):
<SoapError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x820(%rbp),%rdi
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    $0x800,%esi
lea    0xe90(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,-0x824(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x820(%rbp),%rcx
mov    -0x824(%rbp),%r8d
mov    $0x1f4,%esi
lea    0xfe9(%rip),%rdx
call   1050 <BuildResp2_upnphttp@plt>
mov    -0x8(%rbp),%rdi
call   1030 <SendResp_upnphttp@plt>
mov    -0x8(%rbp),%rdi
call   1060 <CloseSocket_upnphttp@plt>
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SoapError>:
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rdx,%r8
mov    %esi,%ecx
mov    %rdi,%rbx
lea    0xea7(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x800,%esi
call   1040 <snprintf@plt>
lea    0x1012(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1f4,%esi
mov    %r14,%rcx
mov    %eax,%r8d
call   1050 <BuildResp2_upnphttp@plt>
mov    %rbx,%rdi
call   1030 <SendResp_upnphttp@plt>
mov    %rbx,%rdi
call   1060 <CloseSocket_upnphttp@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.upnphttp = type { i32 }
@SoapError.resp = internal constant [386 x i8] c"<s:Envelope xmlns:s=\22http://schemas.xmlsoap.org/soap/envelope/\22 s:encodingStyle=\22http://schemas.xmlsoap.org/soap/encoding/\22><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring>UPnPError</faultstring><detail><UPnPError xmlns=\22urn:schemas-upnp-org:control-1-0\22><errorCode>%d</errorCode><errorDescription>%s</errorDescription></UPnPError></detail></s:Fault></s:Body></s:Envelope>\00"
@.str = [22 x i8] c"Internal Server Error\00"
define void @SoapError(%struct.upnphttp* %0, i32 %1, i8* %2) {
%4 = alloca %struct.upnphttp*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [2048 x i8]
%8 = alloca i32
store %struct.upnphttp* %0, %struct.upnphttp** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%10 = load i32, i32* %5
%11 = load i8*, i8** %6
%12 = call i32 @snprintf(i8* %9, i32 2048, i8* getelementptr inbounds ([386 x i8], [386 x i8]* @SoapError.resp, i64 0, i64 0), i32 %10, i8* %11)
store i32 %12, i32* %8
%13 = load %struct.upnphttp*, %struct.upnphttp** %4
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%15 = load i32, i32* %8
%16 = call i32 @BuildResp2_upnphttp(%struct.upnphttp* %13, i32 500, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %15)
%17 = load %struct.upnphttp*, %struct.upnphttp** %4
%18 = call i32 @SendResp_upnphttp(%struct.upnphttp* %17)
%19 = load %struct.upnphttp*, %struct.upnphttp** %4
%20 = call i32 @CloseSocket_upnphttp(%struct.upnphttp* %19)
ret void
}

LLVM IR (-O2):
%struct.upnphttp = type { i32 }
@SoapError.resp = internal constant [386 x i8] c"<s:Envelope xmlns:s=\22http://schemas.xmlsoap.org/soap/envelope/\22 s:encodingStyle=\22http://schemas.xmlsoap.org/soap/encoding/\22><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring>UPnPError</faultstring><detail><UPnPError xmlns=\22urn:schemas-upnp-org:control-1-0\22><errorCode>%d</errorCode><errorDescription>%s</errorDescription></UPnPError></detail></s:Fault></s:Body></s:Envelope>\00"
@.str = [22 x i8] c"Internal Server Error\00"
define void @SoapError(%struct.upnphttp* %0, i32 %1, i8* %2) {
%4 = alloca [2048 x i8]
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 2048, i8* getelementptr inbounds ([386 x i8], [386 x i8]* @SoapError.resp, i64 0, i64 0), i32 %1, i8* %2)
%7 = call i32 @BuildResp2_upnphttp(%struct.upnphttp* %0, i32 500, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %6)
%8 = call i32 @SendResp_upnphttp(%struct.upnphttp* %0)
%9 = call i32 @CloseSocket_upnphttp(%struct.upnphttp* %0)
ret void
}