#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 */
char *ParseXML_Encode_Safe_XML(char const *);
int /*<<< orphan*/ printf(char *, char *, ...);
int memberType_function(const char *_tag_, int _type_, const char *type,
                        const char *ref, const char *role) {
  printf("    <%s%s", (_type_ == 2) ? "/" : "", _tag_);
  if (type)
    printf(" type=\"%s\"", ParseXML_Encode_Safe_XML(type));
  if (ref)
    printf(" ref=\"%s\"", ParseXML_Encode_Safe_XML(ref));
  if (role)
    printf(" role=\"%s\"", ParseXML_Encode_Safe_XML(role));
  printf("%s>\n", (_type_ == (1 | 2)) ? " /" : "");
  return (0);
}


x86 assembly (clang, -O0):
<memberType_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0xc(%rbp),%ecx
lea    0xee9(%rip),%rsi
lea    0xee4(%rip),%rax
cmp    $0x2,%ecx
cmove  %rax,%rsi
mov    -0x8(%rbp),%rdx
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     118a <memberType_function+0x6a>
mov    -0x18(%rbp),%rdi
call   1040 <ParseXML_Encode_Safe_XML@plt>
mov    %rax,%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     11af <memberType_function+0x8f>
mov    -0x20(%rbp),%rdi
call   1040 <ParseXML_Encode_Safe_XML@plt>
mov    %rax,%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     11d4 <memberType_function+0xb4>
mov    -0x28(%rbp),%rdi
call   1040 <ParseXML_Encode_Safe_XML@plt>
mov    %rax,%rsi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
lea    0xe50(%rip),%rsi
lea    0xe4a(%rip),%rax
cmp    $0x3,%ecx
cmove  %rax,%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memberType_function>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%rbp
mov    %esi,%r15d
mov    %rdi,%rdx
cmp    $0x2,%esi
lea    0xeef(%rip),%rsi
lea    0xee6(%rip),%rbx
cmovne %rbx,%rsi
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %rbp,%rbp
je     1178 <memberType_function+0x58>
mov    %rbp,%rdi
call   1040 <ParseXML_Encode_Safe_XML@plt>
lea    0xe9c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r12,%r12
je     1196 <memberType_function+0x76>
mov    %r12,%rdi
call   1040 <ParseXML_Encode_Safe_XML@plt>
lea    0xe89(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r14,%r14
je     11b4 <memberType_function+0x94>
mov    %r14,%rdi
call   1040 <ParseXML_Encode_Safe_XML@plt>
lea    0xe75(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x3,%r15d
lea    0xe70(%rip),%rax
cmove  %rax,%rbx
lea    0xe60(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c" <%s%s\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c" type=\22%s\22\00"
@.str.4 = [10 x i8] c" ref=\22%s\22\00"
@.str.5 = [11 x i8] c" role=\22%s\22\00"
@.str.6 = [5 x i8] c"%s>\0A\00"
@.str.7 = [3 x i8] c" /\00"
define i32 @memberType_function(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, 2
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%15 = load i8*, i8** %6
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15)
%17 = load i8*, i8** %8
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %23
19: ; preds = %5
%20 = load i8*, i8** %8
%21 = call i8* @ParseXML_Encode_Safe_XML(i8* %20)
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %5
%24 = load i8*, i8** %9
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i8*, i8** %9
%28 = call i8* @ParseXML_Encode_Safe_XML(i8* %27)
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %26, %23
%31 = load i8*, i8** %10
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i8*, i8** %10
%35 = call i8* @ParseXML_Encode_Safe_XML(i8* %34)
%36 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %33, %30
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, 3
%40 = zext i1 %39 to i64
%41 = select i1 %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%42 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c" <%s%s\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c" type=\22%s\22\00"
@.str.4 = [10 x i8] c" ref=\22%s\22\00"
@.str.5 = [11 x i8] c" role=\22%s\22\00"
@.str.6 = [5 x i8] c"%s>\0A\00"
@.str.7 = [3 x i8] c" /\00"
define i32 @memberType_function(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = icmp eq i32 %1, 2
%7 = select i1 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%8 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %0)
%9 = icmp eq i8* %2, null
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = tail call i8* @ParseXML_Encode_Safe_XML(i8* %2)
%12 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %5
%14 = icmp eq i8* %3, null
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = tail call i8* @ParseXML_Encode_Safe_XML(i8* %3)
%17 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %15, %13
%19 = icmp eq i8* %4, null
br i1 %19, label %23, label %20
20: ; preds = %18
%21 = tail call i8* @ParseXML_Encode_Safe_XML(i8* %4)
%22 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %18
%24 = icmp eq i32 %1, 3
%25 = select i1 %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%26 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %25)
ret i32 0
}