#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 */
typedef struct TYPE_7__ TYPE_2__;
typedef struct TYPE_6__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ u_short;
typedef int /*<<< orphan*/ u_long;
typedef int bool_t;
struct TYPE_7__ {
  int x_op;
  TYPE_1__ *x_ops;
};
typedef TYPE_2__ XDR;
struct TYPE_6__ {
  int (*x_putlong)(TYPE_2__ *, long *);
  int /*<<< orphan*/ (*x_getlong)(TYPE_2__ *, long *);
};

/* Variables and functions */
#define XDR_DECODE 130
#define XDR_ENCODE 129
#define XDR_FREE 128
int stub1(TYPE_2__ *, long *);
int /*<<< orphan*/ stub2(TYPE_2__ *, long *);
bool_t xdr_u_short(XDR *xdrs, u_short *usp) {
  u_long l;
  switch (xdrs->x_op) {
  case XDR_ENCODE:
    l = (u_long)*usp;
    return ((*(xdrs)->x_ops->x_putlong)(xdrs, (long *)&l));
  case XDR_DECODE:
    if (!(*(xdrs)->x_ops->x_getlong)(xdrs, (long *)&l)) {
      return (0);
    }
    *usp = (u_short)l;
    return (1);
  case XDR_FREE:
    return (1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<xdr_u_short>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
sub    $0x80,%eax
je     11b5 <xdr_u_short+0xb5>
jmp    1129 <xdr_u_short+0x29>
mov    -0x20(%rbp),%eax
sub    $0x81,%eax
je     114f <xdr_u_short+0x4f>
jmp    113c <xdr_u_short+0x3c>
mov    -0x20(%rbp),%eax
sub    $0x82,%eax
je     1175 <xdr_u_short+0x75>
jmp    11c1 <xdr_u_short+0xc1>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   *%rax
mov    %eax,-0x4(%rbp)
jmp    11c8 <xdr_u_short+0xc8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   *%rax
cmp    $0x0,%eax
jne    11a0 <xdr_u_short+0xa0>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <xdr_u_short+0xc8>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11c8 <xdr_u_short+0xc8>
movl   $0x1,-0x4(%rbp)
jmp    11c8 <xdr_u_short+0xc8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdr_u_short>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%eax
mov    $0x1,%ebx
cmp    $0x80,%eax
je     1154 <xdr_u_short+0x54>
mov    %rsi,%r14
cmp    $0x82,%eax
je     1139 <xdr_u_short+0x39>
cmp    $0x81,%eax
jne    1152 <xdr_u_short+0x52>
mov    (%r14),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rdi),%rax
lea    0x4(%rsp),%rsi
call   *(%rax)
mov    %eax,%ebx
jmp    1154 <xdr_u_short+0x54>
mov    0x8(%rdi),%rax
lea    0x4(%rsp),%rsi
call   *0x8(%rax)
test   %eax,%eax
je     1152 <xdr_u_short+0x52>
mov    0x4(%rsp),%eax
mov    %eax,(%r14)
jmp    1154 <xdr_u_short+0x54>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_7__ = type { i32, %struct.TYPE_6__* }
%struct.TYPE_6__ = type { i32 (%struct.TYPE_7__*, i64*)*, i32 (%struct.TYPE_7__*, i64*)* }
define i32 @xdr_u_short(%struct.TYPE_7__* %0, i32* %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_7__*
%5 = alloca i32*
%6 = alloca i32
store %struct.TYPE_7__* %0, %struct.TYPE_7__** %4
store i32* %1, i32** %5
%7 = load %struct.TYPE_7__*, %struct.TYPE_7__** %4
%8 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %7, i32 0, i32 0
%9 = load i32, i32* %8
switch i32 %9, label %36 [
i32 129, label %10
i32 130, label %21
i32 128, label %35
]
10: ; preds = %2
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
store i32 %12, i32* %6
%13 = load %struct.TYPE_7__*, %struct.TYPE_7__** %4
%14 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %13, i32 0, i32 1
%15 = load %struct.TYPE_6__*, %struct.TYPE_6__** %14
%16 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %15, i32 0, i32 0
%17 = load i32 (%struct.TYPE_7__*, i64*)*, i32 (%struct.TYPE_7__*, i64*)** %16
%18 = load %struct.TYPE_7__*, %struct.TYPE_7__** %4
%19 = bitcast i32* %6 to i64*
%20 = call i32 %17(%struct.TYPE_7__* %18, i64* %19)
store i32 %20, i32* %3
br label %37
21: ; preds = %2
%22 = load %struct.TYPE_7__*, %struct.TYPE_7__** %4
%23 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %22, i32 0, i32 1
%24 = load %struct.TYPE_6__*, %struct.TYPE_6__** %23
%25 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %24, i32 0, i32 1
%26 = load i32 (%struct.TYPE_7__*, i64*)*, i32 (%struct.TYPE_7__*, i64*)** %25
%27 = load %struct.TYPE_7__*, %struct.TYPE_7__** %4
%28 = bitcast i32* %6 to i64*
%29 = call i32 %26(%struct.TYPE_7__* %27, i64* %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %21
store i32 0, i32* %3
br label %37
32: ; preds = %21
%33 = load i32, i32* %6
%34 = load i32*, i32** %5
store i32 %33, i32* %34
store i32 1, i32* %3
br label %37
35: ; preds = %2
store i32 1, i32* %3
br label %37
36: ; preds = %2
store i32 0, i32* %3
br label %37
37: ; preds = %36, %35, %32, %31, %10
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { i32, %struct.TYPE_6__* }
%struct.TYPE_6__ = type { i32 (%struct.TYPE_7__*, i64*)*, i32 (%struct.TYPE_7__*, i64*)* }
define i32 @xdr_u_short(%struct.TYPE_7__* %0, i32* nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %0, i64 0, i32 0
%6 = load i32, i32* %5
switch i32 %6, label %25 [
i32 129, label %7
i32 130, label %15
i32 128, label %26
]
7: ; preds = %2
%8 = load i32, i32* %1
store i32 %8, i32* %3
%9 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %0, i64 0, i32 1
%10 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%11 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %10, i64 0, i32 0
%12 = load i32 (%struct.TYPE_7__*, i64*)*, i32 (%struct.TYPE_7__*, i64*)** %11
%13 = bitcast i32* %3 to i64*
%14 = call i32 %12(%struct.TYPE_7__* %0, i64* %13)
br label %26
15: ; preds = %2
%16 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %0, i64 0, i32 1
%17 = load %struct.TYPE_6__*, %struct.TYPE_6__** %16
%18 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %17, i64 0, i32 1
%19 = load i32 (%struct.TYPE_7__*, i64*)*, i32 (%struct.TYPE_7__*, i64*)** %18
%20 = bitcast i32* %3 to i64*
%21 = call i32 %19(%struct.TYPE_7__* %0, i64* %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %15
%24 = load i32, i32* %3
store i32 %24, i32* %1
br label %26
25: ; preds = %2
br label %26
26: ; preds = %2, %15, %25, %23, %7
%27 = phi i32 [ 0, %25 ], [ 1, %23 ], [ %14, %7 ], [ 0, %15 ], [ 1, %2 ]
ret i32 %27
}