#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 */
typedef enum XML_Status { ____Placeholder_XML_Status } XML_Status;
typedef int /*<<< orphan*/ XML_Parser;
typedef int /*<<< orphan*/ XML_Char;

/* Variables and functions */
int /*<<< orphan*/ XML_ExternalEntityParserCreate(int /*<<< orphan*/,
                                                  int /*<<< orphan*/ const *,
                                                  int /*<<< orphan*/ *);
int XML_Parse(int /*<<< orphan*/, char *, int /*<<< orphan*/,
              int /*<<< orphan*/);
int /*<<< orphan*/ XML_ParserFree(int /*<<< orphan*/);
int XML_STATUS_OK;
int /*<<< orphan*/ XML_StopParser(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XML_TRUE;
int externalEntityRef(XML_Parser parser, const XML_Char *context,
                      const XML_Char *base, const XML_Char *systemId,
                      const XML_Char *publicId) {
  if (systemId == NULL && publicId == NULL) {
    XML_Parser eep = XML_ExternalEntityParserCreate(parser, context, NULL);
    enum XML_Status ret = XML_Parse(eep, "", 0, XML_TRUE);
    if (ret == XML_STATUS_OK) {
      XML_ParserFree(eep);
    } else {
      XML_ParserFree(eep);
      XML_StopParser(parser, 0);
    }
  } else
    XML_StopParser(parser, 0);
}


x86 assembly (clang, -O0):
<externalEntityRef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d7 <externalEntityRef+0x97>
cmpq   $0x0,-0x28(%rbp)
jne    11d7 <externalEntityRef+0x97>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <XML_ExternalEntityParserCreate@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    0x2e42(%rip),%rax
mov    (%rax),%ecx
lea    0xe69(%rip),%rsi
xor    %edx,%edx
call   1060 <XML_Parse@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    0x2e3d(%rip),%rcx
cmp    (%rcx),%eax
jne    11c0 <externalEntityRef+0x80>
mov    -0x2c(%rbp),%edi
call   1040 <XML_ParserFree@plt>
jmp    11d2 <externalEntityRef+0x92>
mov    -0x2c(%rbp),%edi
call   1040 <XML_ParserFree@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1050 <XML_StopParser@plt>
jmp    11e1 <externalEntityRef+0xa1>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1050 <XML_StopParser@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<externalEntityRef>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
or     %r8,%rcx
jne    118b <externalEntityRef+0x4b>
mov    %ebx,%edi
xor    %edx,%edx
call   1030 <XML_ExternalEntityParserCreate@plt>
mov    %eax,%ebp
mov    0x2e70(%rip),%rax
mov    (%rax),%ecx
lea    0xe97(%rip),%rsi
mov    %ebp,%edi
xor    %edx,%edx
call   1060 <XML_Parse@plt>
mov    %eax,%r14d
mov    0x2e6c(%rip),%rax
mov    (%rax),%r15d
mov    %ebp,%edi
call   1040 <XML_ParserFree@plt>
cmp    %r15d,%r14d
je     1194 <externalEntityRef+0x54>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <XML_StopParser@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@XML_TRUE = global i32 0
@XML_STATUS_OK = global i32 0
define i32 @externalEntityRef(i32 %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
%14 = load i32*, i32** %10
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %38
16: ; preds = %5
%17 = load i32*, i32** %11
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %38
19: ; preds = %16
%20 = load i32, i32* %7
%21 = load i32*, i32** %8
%22 = call i32 @XML_ExternalEntityParserCreate(i32 %20, i32* %21, i32* null)
store i32 %22, i32* %12
%23 = load i32, i32* %12
%24 = load i32, i32* @XML_TRUE
%25 = call i32 @XML_Parse(i32 %23, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32 0, i32 %24)
store i32 %25, i32* %13
%26 = load i32, i32* %13
%27 = load i32, i32* @XML_STATUS_OK
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %32
29: ; preds = %19
%30 = load i32, i32* %12
%31 = call i32 @XML_ParserFree(i32 %30)
br label %37
32: ; preds = %19
%33 = load i32, i32* %12
%34 = call i32 @XML_ParserFree(i32 %33)
%35 = load i32, i32* %7
%36 = call i32 @XML_StopParser(i32 %35, i32 0)
br label %37
37: ; preds = %32, %29
br label %41
38: ; preds = %16, %5
%39 = load i32, i32* %7
%40 = call i32 @XML_StopParser(i32 %39, i32 0)
br label %41
41: ; preds = %38, %37
%42 = load i32, i32* %6
ret i32 %42
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@XML_TRUE = global i32 0
@XML_STATUS_OK = global i32 0
define i32 @externalEntityRef(i32 %0, i32* %1, i32* nocapture readnone %2, i32* readnone %3, i32* readnone %4) {
%6 = icmp eq i32* %3, null
%7 = icmp eq i32* %4, null
%8 = and i1 %6, %7
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = tail call i32 @XML_ExternalEntityParserCreate(i32 %0, i32* %1, i32* null)
%11 = load i32, i32* @XML_TRUE
%12 = tail call i32 @XML_Parse(i32 %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32 0, i32 %11)
%13 = load i32, i32* @XML_STATUS_OK
%14 = icmp eq i32 %12, %13
%15 = tail call i32 @XML_ParserFree(i32 %10)
br i1 %14, label %18, label %16
16: ; preds = %5, %9
%17 = tail call i32 @XML_StopParser(i32 %0, i32 0)
br label %18
18: ; preds = %16, %9
ret i32 undef
}