#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 int /*<<< orphan*/ (*xdrproc_t)(int /*<<< orphan*/ *, char *,
                                        unsigned int);
struct xdr_discrim {
  scalar_t__ value;
  int /*<<< orphan*/ (*proc)(int /*<<< orphan*/ *, char *, unsigned int);
};
typedef scalar_t__ enum_t;
typedef int /*<<< orphan*/ bool_t;
typedef int /*<<< orphan*/ XDR;

/* Variables and functions */
int /*<<< orphan*/ FALSE;
int /*<<< orphan*/ NULL_xdrproc_t(int /*<<< orphan*/ *, char *, unsigned int);
int /*<<< orphan*/ stub1(int /*<<< orphan*/ *, char *, unsigned int);
int /*<<< orphan*/ stub2(int /*<<< orphan*/ *, char *, unsigned int);
int /*<<< orphan*/ xdr_enum(int /*<<< orphan*/ *, scalar_t__ *);
bool_t xdr_union(XDR *xdrs, enum_t *dscmp, char *unp,
                 const struct xdr_discrim *choices, xdrproc_t dfault) {
  register enum_t dscm;
  if (!xdr_enum(xdrs, dscmp)) {
    return (FALSE);
  }
  dscm = *dscmp;
  for (; choices->proc != NULL_xdrproc_t; choices++) {
    if (choices->value == dscm)
      return ((*(choices->proc))(xdrs, unp, ((unsigned int)0 - 1)));
  }
  return ((dfault == NULL_xdrproc_t)
              ? FALSE
              : (*dfault)(xdrs, unp, ((unsigned int)0 - 1)));
}


x86 assembly (clang, -O0):
<xdr_union>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <xdr_enum@plt>
cmp    $0x0,%eax
jne    1153 <xdr_union+0x43>
mov    0x2e8f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f7 <xdr_union+0xe7>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2e7f(%rip),%rcx
cmp    %rcx,0x8(%rax)
je     11b9 <xdr_union+0xa9>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
cmp    -0x38(%rbp),%rax
jne    11a3 <xdr_union+0x93>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0xffffffff,%edx
call   *%rax
mov    %eax,-0x4(%rbp)
jmp    11f7 <xdr_union+0xe7>
jmp    11a8 <xdr_union+0x98>
mov    -0x28(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x28(%rbp)
jmp    115e <xdr_union+0x4e>
mov    0x2e28(%rip),%rax
cmp    %rax,-0x30(%rbp)
jne    11db <xdr_union+0xcb>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
jmp    11f1 <xdr_union+0xe1>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0xffffffff,%edx
call   *%rax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdr_union>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r13
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
call   1030 <xdr_enum@plt>
test   %eax,%eax
je     1199 <xdr_union+0x89>
mov    0x8(%rbx),%rax
cmp    0x2eac(%rip),%rax
je     1177 <xdr_union+0x67>
mov    (%r12),%rcx
cmp    %rcx,(%rbx)
je     1183 <xdr_union+0x73>
add    $0x18,%rbx
mov    0x2e96(%rip),%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx),%rax
cmp    %rdx,%rax
je     1177 <xdr_union+0x67>
lea    0x10(%rbx),%rsi
cmp    %rcx,-0x8(%rbx)
mov    %rsi,%rbx
jne    1160 <xdr_union+0x50>
jmp    1183 <xdr_union+0x73>
cmp    0x2e6a(%rip),%r13
je     1199 <xdr_union+0x89>
mov    %r13,%rax
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0xffffffff,%edx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    *%rax
mov    0x2e38(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.xdr_discrim = type { i64, i32 (i32*, i8*, i32)* }
@FALSE = global i32 0
define i32 @xdr_union(i32* %0, i64* %1, i8* %2, %struct.xdr_discrim* %3, i32 (i32*, i8*, i32)* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i64*
%9 = alloca i8*
%10 = alloca %struct.xdr_discrim*
%11 = alloca i32 (i32*, i8*, i32)*
%12 = alloca i64
store i32* %0, i32** %7
store i64* %1, i64** %8
store i8* %2, i8** %9
store %struct.xdr_discrim* %3, %struct.xdr_discrim** %10
store i32 (i32*, i8*, i32)* %4, i32 (i32*, i8*, i32)** %11
%13 = load i32*, i32** %7
%14 = load i64*, i64** %8
%15 = call i32 @xdr_enum(i32* %13, i64* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %5
%18 = load i32, i32* @FALSE
store i32 %18, i32* %6
br label %56
19: ; preds = %5
%20 = load i64*, i64** %8
%21 = load i64, i64* %20
store i64 %21, i64* %12
br label %22
22: ; preds = %41, %19
%23 = load %struct.xdr_discrim*, %struct.xdr_discrim** %10
%24 = getelementptr inbounds %struct.xdr_discrim, %struct.xdr_discrim* %23, i32 0, i32 1
%25 = load i32 (i32*, i8*, i32)*, i32 (i32*, i8*, i32)** %24
%26 = icmp ne i32 (i32*, i8*, i32)* %25, @NULL_xdrproc_t
br i1 %26, label %27, label %44
27: ; preds = %22
%28 = load %struct.xdr_discrim*, %struct.xdr_discrim** %10
%29 = getelementptr inbounds %struct.xdr_discrim, %struct.xdr_discrim* %28, i32 0, i32 0
%30 = load i64, i64* %29
%31 = load i64, i64* %12
%32 = icmp eq i64 %30, %31
br i1 %32, label %33, label %40
33: ; preds = %27
%34 = load %struct.xdr_discrim*, %struct.xdr_discrim** %10
%35 = getelementptr inbounds %struct.xdr_discrim, %struct.xdr_discrim* %34, i32 0, i32 1
%36 = load i32 (i32*, i8*, i32)*, i32 (i32*, i8*, i32)** %35
%37 = load i32*, i32** %7
%38 = load i8*, i8** %9
%39 = call i32 %36(i32* %37, i8* %38, i32 -1)
store i32 %39, i32* %6
br label %56
40: ; preds = %27
br label %41
41: ; preds = %40
%42 = load %struct.xdr_discrim*, %struct.xdr_discrim** %10
%43 = getelementptr inbounds %struct.xdr_discrim, %struct.xdr_discrim* %42, i32 1
store %struct.xdr_discrim* %43, %struct.xdr_discrim** %10
br label %22
44: ; preds = %22
%45 = load i32 (i32*, i8*, i32)*, i32 (i32*, i8*, i32)** %11
%46 = icmp eq i32 (i32*, i8*, i32)* %45, @NULL_xdrproc_t
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = load i32, i32* @FALSE
br label %54
49: ; preds = %44
%50 = load i32 (i32*, i8*, i32)*, i32 (i32*, i8*, i32)** %11
%51 = load i32*, i32** %7
%52 = load i8*, i8** %9
%53 = call i32 %50(i32* %51, i8* %52, i32 -1)
br label %54
54: ; preds = %49, %47
%55 = phi i32 [ %48, %47 ], [ %53, %49 ]
store i32 %55, i32* %6
br label %56
56: ; preds = %54, %33, %17
%57 = load i32, i32* %6
ret i32 %57
}

LLVM IR (-O2):
%struct.xdr_discrim = type { i64, i32 (i32*, i8*, i32)* }
@FALSE = global i32 0
define i32 @xdr_union(i32* %0, i64* %1, i8* %2, %struct.xdr_discrim* nocapture %3, i32 (i32*, i8*, i32)* %4) {
%6 = tail call i32 @xdr_enum(i32* %0, i64* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = load i32, i32* @FALSE
br label %38
10: ; preds = %5
%11 = load i64, i64* %1
%12 = getelementptr inbounds %struct.xdr_discrim, %struct.xdr_discrim* %3, i64 0, i32 1
%13 = load i32 (i32*, i8*, i32)*, i32 (i32*, i8*, i32)** %12
%14 = icmp eq i32 (i32*, i8*, i32)* %13, @NULL_xdrproc_t
br i1 %14, label %32, label %15
15: ; preds = %10
%16 = getelementptr inbounds %struct.xdr_discrim, %struct.xdr_discrim* %3, i64 0, i32 0
%17 = load i64, i64* %16
%18 = icmp eq i64 %17, %11
br i1 %18, label %29, label %19
19: ; preds = %15, %25
%20 = phi %struct.xdr_discrim* [ %21, %25 ], [ %3, %15 ]
%21 = getelementptr inbounds %struct.xdr_discrim, %struct.xdr_discrim* %20, i64 1
%22 = getelementptr inbounds %struct.xdr_discrim, %struct.xdr_discrim* %20, i64 1, i32 1
%23 = load i32 (i32*, i8*, i32)*, i32 (i32*, i8*, i32)** %22
%24 = icmp eq i32 (i32*, i8*, i32)* %23, @NULL_xdrproc_t
br i1 %24, label %32, label %25
25: ; preds = %19
%26 = getelementptr inbounds %struct.xdr_discrim, %struct.xdr_discrim* %21, i64 0, i32 0
%27 = load i64, i64* %26
%28 = icmp eq i64 %27, %11
br i1 %28, label %29, label %19
29: ; preds = %25, %15
%30 = phi i32 (i32*, i8*, i32)* [ %13, %15 ], [ %23, %25 ]
%31 = tail call i32 %30(i32* %0, i8* %2, i32 -1)
br label %38
32: ; preds = %19, %10
%33 = icmp eq i32 (i32*, i8*, i32)* %4, @NULL_xdrproc_t
br i1 %33, label %34, label %36
34: ; preds = %32
%35 = load i32, i32* @FALSE
br label %38
36: ; preds = %32
%37 = tail call i32 %4(i32* %0, i8* %2, i32 -1)
br label %38
38: ; preds = %34, %36, %29, %8
%39 = phi i32 [ %31, %29 ], [ %9, %8 ], [ %35, %34 ], [ %37, %36 ]
ret i32 %39
}