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


x86 assembly (clang, -O0):
<ndType_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%ecx
lea    0xedb(%rip),%rsi
lea    0xed6(%rip),%rax
cmp    $0x2,%ecx
cmove  %rax,%rsi
mov    -0x8(%rbp),%rdx
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     1182 <ndType_function+0x62>
mov    -0x18(%rbp),%rdi
call   1040 <ParseXML_Encode_Safe_XML@plt>
mov    %rax,%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
lea    0xe8c(%rip),%rsi
lea    0xe86(%rip),%rax
cmp    $0x3,%ecx
cmove  %rax,%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ndType_function>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbp
mov    %esi,%r14d
mov    %rdi,%rdx
cmp    $0x2,%esi
lea    0xee3(%rip),%rsi
lea    0xeda(%rip),%rbx
cmovne %rbx,%rsi
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %rbp,%rbp
je     116e <ndType_function+0x4e>
mov    %rbp,%rdi
call   1040 <ParseXML_Encode_Safe_XML@plt>
lea    0xea6(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x3,%r14d
lea    0xea0(%rip),%rax
cmove  %rax,%rbx
lea    0xe90(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
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 = [10 x i8] c" ref=\22%s\22\00"
@.str.4 = [5 x i8] c"%s>\0A\00"
@.str.5 = [3 x i8] c" /\00"
define i32 @ndType_function(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 2
%9 = zext i1 %8 to i64
%10 = select i1 %8, 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)
%11 = load i8*, i8** %4
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%13 = load i8*, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i8*, i8** %6
%17 = call i8* @ParseXML_Encode_Safe_XML(i8* %16)
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %15, %3
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 3
%22 = zext i1 %21 to i64
%23 = select i1 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %23)
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 = [10 x i8] c" ref=\22%s\22\00"
@.str.4 = [5 x i8] c"%s>\0A\00"
@.str.5 = [3 x i8] c" /\00"
define i32 @ndType_function(i8* %0, i32 %1, i8* %2) {
%4 = icmp eq i32 %1, 2
%5 = select i1 %4, 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)
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %0)
%7 = icmp eq i8* %2, null
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = tail call i8* @ParseXML_Encode_Safe_XML(i8* %2)
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %8, %3
%12 = icmp eq i32 %1, 3
%13 = select i1 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%14 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %13)
ret i32 0
}