#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*/ LOG_INFO;
int /*<<< orphan*/ SendResp_upnphttp(struct upnphttp *);
int snprintf(char *, int, char const *, int, char const *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, 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;
  syslog(LOG_INFO, "Returning UPnPError %d: %s", errCode, errDesc);
  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)
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0x1005(%rip),%rsi
call   1060 <syslog@plt>
lea    -0x820(%rbp),%rdi
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    $0x800,%esi
lea    0xe64(%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    0xfd8(%rip),%rdx
call   1050 <BuildResp2_upnphttp@plt>
mov    -0x8(%rbp),%rdi
call   1030 <SendResp_upnphttp@plt>
mov    -0x8(%rbp),%rdi
call   1070 <CloseSocket_upnphttp@plt>
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SoapError>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0x100d(%rip),%rsi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1060 <syslog@plt>
lea    0xe7a(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x800,%esi
mov    %ebp,%ecx
mov    %rbx,%r8
call   1040 <snprintf@plt>
lea    0xffb(%rip),%rdx
mov    %r14,%rdi
mov    $0x1f4,%esi
mov    %r15,%rcx
mov    %eax,%r8d
call   1050 <BuildResp2_upnphttp@plt>
mov    %r14,%rdi
call   1030 <SendResp_upnphttp@plt>
mov    %r14,%rdi
call   1070 <CloseSocket_upnphttp@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
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"
@LOG_INFO = global i32 0
@.str = [27 x i8] c"Returning UPnPError %d: %s\00"
@.str.1 = [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 = load i32, i32* @LOG_INFO
%10 = load i32, i32* %5
%11 = load i8*, i8** %6
%12 = call i32 @syslog(i32 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %11)
%13 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%14 = load i32, i32* %5
%15 = load i8*, i8** %6
%16 = call i32 @snprintf(i8* %13, i32 2048, i8* getelementptr inbounds ([386 x i8], [386 x i8]* @SoapError.resp, i64 0, i64 0), i32 %14, i8* %15)
store i32 %16, i32* %8
%17 = load %struct.upnphttp*, %struct.upnphttp** %4
%18 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%19 = load i32, i32* %8
%20 = call i32 @BuildResp2_upnphttp(%struct.upnphttp* %17, i32 500, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %19)
%21 = load %struct.upnphttp*, %struct.upnphttp** %4
%22 = call i32 @SendResp_upnphttp(%struct.upnphttp* %21)
%23 = load %struct.upnphttp*, %struct.upnphttp** %4
%24 = call i32 @CloseSocket_upnphttp(%struct.upnphttp* %23)
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"
@LOG_INFO = global i32 0
@.str = [27 x i8] c"Returning UPnPError %d: %s\00"
@.str.1 = [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 = load i32, i32* @LOG_INFO
%7 = tail call i32 @syslog(i32 %6, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %1, i8* %2)
%8 = 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)
%9 = call i32 @BuildResp2_upnphttp(%struct.upnphttp* %0, i32 500, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 %8)
%10 = call i32 @SendResp_upnphttp(%struct.upnphttp* %0)
%11 = call i32 @CloseSocket_upnphttp(%struct.upnphttp* %0)
ret void
}