#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;
};

/* Variables and functions */
int /*<<< orphan*/ BuildResp_upnphttp(struct upnphttp *, char *, int);
int /*<<< orphan*/ CloseSocket_upnphttp(struct upnphttp *);
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ SendResp_upnphttp(struct upnphttp *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
void sendXMLdesc(struct upnphttp *h, char *(f)(int *)) {
  char *desc;
  int len;
  desc = f(&len);
  if (!desc) {
    syslog(LOG_ERR, "Failed to generate XML description");
    return;
  }
  BuildResp_upnphttp(h, desc, len);
  SendResp_upnphttp(h);
  CloseSocket_upnphttp(h);
  free(desc);
}


x86 assembly (clang, -O0):
<sendXMLdesc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1c(%rbp),%rdi
call   *-0x10(%rbp)
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1190 <sendXMLdesc+0x40>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1060 <syslog@plt>
jmp    11bb <sendXMLdesc+0x6b>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <BuildResp_upnphttp@plt>
mov    -0x8(%rbp),%rdi
call   1040 <SendResp_upnphttp@plt>
mov    -0x8(%rbp),%rdi
call   1070 <CloseSocket_upnphttp@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendXMLdesc>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x4(%rsp),%rdi
call   *%rsi
test   %rax,%rax
je     118f <sendXMLdesc+0x3f>
mov    %rax,%rbx
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <BuildResp_upnphttp@plt>
mov    %r14,%rdi
call   1040 <SendResp_upnphttp@plt>
mov    %r14,%rdi
call   1070 <CloseSocket_upnphttp@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11a4 <sendXMLdesc+0x54>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1060 <syslog@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.upnphttp = type { i32 }
@LOG_ERR = global i32 0
@.str = [35 x i8] c"Failed to generate XML description\00"
define void @sendXMLdesc(%struct.upnphttp* %0, i8* (i32*)* %1) {
%3 = alloca %struct.upnphttp*
%4 = alloca i8* (i32*)*
%5 = alloca i8*
%6 = alloca i32
store %struct.upnphttp* %0, %struct.upnphttp** %3
store i8* (i32*)* %1, i8* (i32*)** %4
%7 = load i8* (i32*)*, i8* (i32*)** %4
%8 = call i8* %7(i32* %6)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* @LOG_ERR
%13 = call i32 @syslog(i32 %12, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %25
14: ; preds = %2
%15 = load %struct.upnphttp*, %struct.upnphttp** %3
%16 = load i8*, i8** %5
%17 = load i32, i32* %6
%18 = call i32 @BuildResp_upnphttp(%struct.upnphttp* %15, i8* %16, i32 %17)
%19 = load %struct.upnphttp*, %struct.upnphttp** %3
%20 = call i32 @SendResp_upnphttp(%struct.upnphttp* %19)
%21 = load %struct.upnphttp*, %struct.upnphttp** %3
%22 = call i32 @CloseSocket_upnphttp(%struct.upnphttp* %21)
%23 = load i8*, i8** %5
%24 = call i32 @free(i8* %23)
br label %25
25: ; preds = %14, %11
ret void
}

LLVM IR (-O2):
%struct.upnphttp = type { i32 }
@LOG_ERR = global i32 0
@.str = [35 x i8] c"Failed to generate XML description\00"
define void @sendXMLdesc(%struct.upnphttp* %0, i8* (i32*)* nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i8* %1(i32* %3)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* @LOG_ERR
%9 = call i32 @syslog(i32 %8, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %16
10: ; preds = %2
%11 = load i32, i32* %3
%12 = call i32 @BuildResp_upnphttp(%struct.upnphttp* %0, i8* %5, i32 %11)
%13 = call i32 @SendResp_upnphttp(%struct.upnphttp* %0)
%14 = call i32 @CloseSocket_upnphttp(%struct.upnphttp* %0)
%15 = call i32 @free(i8* %5)
br label %16
16: ; preds = %10, %7
ret void
}