#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 */

/* Variables and functions */
scalar_t__ edi2xml_conv(char const *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ output_init(char **);
int /*<<< orphan*/ output_set_enc(char const *);
int /*<<< orphan*/ output_shutdown();
char *edi2xml_conv2(const char *edi_text, const char *enc) {
  int ok;
  char *r = NULL;
  output_init(&r);
  if (enc)
    output_set_enc(enc);
  ok = 0 == edi2xml_conv(edi_text);
  output_shutdown();
  if (!ok) {
    if (r)
      free(r);
    r = NULL;
  }
  return r;
}


x86 assembly (clang, -O0):
<edi2xml_conv2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <output_init@plt>
cmpq   $0x0,-0x10(%rbp)
je     1185 <edi2xml_conv2+0x35>
mov    -0x10(%rbp),%rdi
call   1040 <output_set_enc@plt>
mov    -0x8(%rbp),%rdi
call   1070 <edi2xml_conv@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1060 <output_shutdown@plt>
cmpl   $0x0,-0x14(%rbp)
jne    11ce <edi2xml_conv2+0x7e>
cmpq   $0x0,-0x20(%rbp)
je     11c6 <edi2xml_conv2+0x76>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<edi2xml_conv2>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
movq   $0x0,(%rsp)
mov    %rsp,%rdi
call   1050 <output_init@plt>
test   %rbx,%rbx
je     1177 <edi2xml_conv2+0x27>
mov    %rbx,%rdi
call   1040 <output_set_enc@plt>
mov    %r14,%rdi
call   1070 <edi2xml_conv@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <output_shutdown@plt>
mov    (%rsp),%rax
test   %rbx,%rbx
je     11a1 <edi2xml_conv2+0x51>
test   %rax,%rax
je     119f <edi2xml_conv2+0x4f>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @edi2xml_conv2(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* null, i8** %6
%7 = call i32 @output_init(i8** %6)
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i32 @output_set_enc(i8* %11)
br label %13
13: ; preds = %10, %2
%14 = load i8*, i8** %3
%15 = call i64 @edi2xml_conv(i8* %14)
%16 = icmp eq i64 0, %15
%17 = zext i1 %16 to i32
store i32 %17, i32* %5
%18 = call i32 (...) @output_shutdown()
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %13
%22 = load i8*, i8** %6
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i8*, i8** %6
%26 = call i32 @free(i8* %25)
br label %27
27: ; preds = %24, %21
store i8* null, i8** %6
br label %28
28: ; preds = %27, %13
%29 = load i8*, i8** %6
ret i8* %29
}

LLVM IR (-O2):
define i8* @edi2xml_conv2(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = call i32 @output_init(i8** %3)
%6 = icmp eq i8* %1, null
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = call i32 @output_set_enc(i8* %1)
br label %9
9: ; preds = %7, %2
%10 = call i64 @edi2xml_conv(i8* %0)
%11 = icmp eq i64 %10, 0
%12 = call i32 (...) @output_shutdown()
%13 = load i8*, i8** %3
br i1 %11, label %18, label %14
14: ; preds = %9
%15 = icmp eq i8* %13, null
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = call i32 @free(i8* %13)
br label %18
18: ; preds = %14, %16, %9
%19 = phi i8* [ %13, %9 ], [ null, %16 ], [ null, %14 ]
ret i8* %19
}