#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_1__;

/* Type definitions */
typedef scalar_t__ (*xdrproc_t)(TYPE_1__ *, int /*<<< orphan*/ *, int);
typedef int u_int;
typedef int /*<<< orphan*/ *caddr_t;
typedef scalar_t__ bool_t;
struct TYPE_7__ {
  int x_op;
};
typedef TYPE_1__ XDR;

/* Variables and functions */
scalar_t__ FALSE;
scalar_t__ TRUE;
int UINT_MAX;
#define XDR_DECODE 129
#define XDR_FREE 128
int /*<<< orphan*/ _(char *);
int /*<<< orphan*/ fputs(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ *mem_alloc(int);
int /*<<< orphan*/ mem_free(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
scalar_t__ stub1(TYPE_1__ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ xdr_u_int(TYPE_1__ *, int *);
bool_t xdr_array(XDR *xdrs, caddr_t *addrp, u_int *sizep, u_int maxsize,
                 u_int elsize, xdrproc_t elproc) {
  u_int i;
  caddr_t target = *addrp;
  u_int c;
  bool_t stat = TRUE;
  u_int nodesize;
  if (!xdr_u_int(xdrs, sizep)) {
    return FALSE;
  }
  c = *sizep;
  if ((c > maxsize || c > UINT_MAX / elsize) && (xdrs->x_op != XDR_FREE)) {
    return FALSE;
  }
  nodesize = c * elsize;
  if (target == NULL)
    switch (xdrs->x_op) {
    case XDR_DECODE:
      if (c == 0)
        return TRUE;
      *addrp = target = mem_alloc(nodesize);
      if (target == NULL) {
        (void)fputs(_("xdr_array: out of memory\n"), stderr);
        return FALSE;
      }
      memset(target, 0, nodesize);
      break;
    case XDR_FREE:
      return TRUE;
    default:
      break;
    }
  for (i = 0; (i < c) && stat; i++) {
    stat = (*elproc)(xdrs, target, ((u_int)0 - 1));
    target += elsize;
  }
  if (xdrs->x_op == XDR_FREE) {
    mem_free(*addrp, nodesize);
    *addrp = NULL;
  }
  return stat;
}


x86 assembly (clang, -O0):
<xdr_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    0x2e4f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <xdr_u_int@plt>
cmp    $0x0,%eax
jne    11c1 <xdr_array+0x61>
mov    0x2e13(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1396 <xdr_array+0x236>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     11f6 <xdr_array+0x96>
mov    -0x44(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
cltd
idivl  -0x28(%rbp)
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
cmp    %ecx,%eax
jle    1219 <xdr_array+0xb9>
mov    -0x10(%rbp),%rax
cmpl   $0x80,(%rax)
je     1219 <xdr_array+0xb9>
mov    0x2dbb(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1396 <xdr_array+0x236>
mov    -0x44(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x54(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12f7 <xdr_array+0x197>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
sub    $0x80,%eax
je     12da <xdr_array+0x17a>
jmp    1247 <xdr_array+0xe7>
mov    -0x5c(%rbp),%eax
sub    $0x81,%eax
jne    12ed <xdr_array+0x18d>
jmp    125a <xdr_array+0xfa>
cmpl   $0x0,-0x44(%rbp)
jne    1277 <xdr_array+0x117>
mov    0x2d75(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1396 <xdr_array+0x236>
mov    -0x54(%rbp),%edi
call   1070 <mem_alloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x40(%rbp)
jne    12c7 <xdr_array+0x167>
lea    0xd61(%rip),%rdi
call   1060 <_@plt>
mov    %eax,%edi
mov    0x2d23(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    0x2d0d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1396 <xdr_array+0x236>
mov    -0x40(%rbp),%rdi
mov    -0x54(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
jmp    12f2 <xdr_array+0x192>
mov    0x2cff(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1396 <xdr_array+0x236>
jmp    12f2 <xdr_array+0x192>
jmp    12f7 <xdr_array+0x197>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%ecx
xor    %eax,%eax
cmp    -0x44(%rbp),%ecx
mov    %al,-0x5d(%rbp)
jge    131a <xdr_array+0x1ba>
cmpq   $0x0,-0x50(%rbp)
setne  %al
mov    %al,-0x5d(%rbp)
mov    -0x5d(%rbp),%al
test   $0x1,%al
jne    132a <xdr_array+0x1ca>
jmp    1364 <xdr_array+0x204>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    $0xffffffff,%edx
call   *%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12fe <xdr_array+0x19e>
mov    -0x10(%rbp),%rax
cmpl   $0x80,(%rax)
jne    138e <xdr_array+0x22e>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x54(%rbp),%esi
call   1030 <mem_free@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdr_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8d,(%rsp)
mov    %ecx,%r14d
mov    %rdx,%r13
mov    %rsi,%r12
mov    %rdi,%r15
mov    (%rsi),%rbp
mov    0x2e53(%rip),%rax
mov    (%rax),%rbx
mov    %rdx,%rsi
call   1080 <xdr_u_int@plt>
test   %eax,%eax
je     12b7 <xdr_array+0x157>
mov    0x0(%r13),%r13d
cmp    %r14d,%r13d
mov    (%rsp),%ecx
jg     11bd <xdr_array+0x5d>
mov    0x2e35(%rip),%rax
mov    (%rax),%eax
cltd
idiv   %ecx
cmp    %eax,%r13d
jle    11ca <xdr_array+0x6a>
cmpl   $0x80,(%r15)
jne    12b7 <xdr_array+0x157>
mov    %r13d,%r14d
imul   %ecx,%r14d
test   %rbp,%rbp
je     124c <xdr_array+0xec>
test   %r13d,%r13d
mov    %r12,0x8(%rsp)
mov    %r14d,0x4(%rsp)
jle    1223 <xdr_array+0xc3>
test   %rbx,%rbx
je     1223 <xdr_array+0xc3>
movslq %ecx,%r14
shl    $0x2,%r14
mov    $0x1,%r12d
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0xffffffff,%edx
call   *0x10(%rsp)
mov    %rax,%rbx
cmp    %r13d,%r12d
jge    1223 <xdr_array+0xc3>
add    $0x1,%r12d
add    %r14,%rbp
test   %rbx,%rbx
jne    1200 <xdr_array+0xa0>
cmpl   $0x80,(%r15)
jne    12c1 <xdr_array+0x161>
mov    0x8(%rsp),%rbp
mov    0x0(%rbp),%rdi
mov    0x4(%rsp),%esi
call   1030 <mem_free@plt>
movq   $0x0,0x0(%rbp)
jmp    12c1 <xdr_array+0x161>
mov    (%r15),%eax
cmp    $0x80,%eax
je     128b <xdr_array+0x12b>
cmp    $0x81,%eax
jne    1294 <xdr_array+0x134>
test   %r13d,%r13d
je     128b <xdr_array+0x12b>
mov    %r14d,%edi
call   1070 <mem_alloc@plt>
mov    %rax,(%r12)
test   %rax,%rax
je     129b <xdr_array+0x13b>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1050 <memset@plt>
mov    (%rsp),%ecx
jmp    11d6 <xdr_array+0x76>
mov    0x2d4e(%rip),%rax
jmp    12be <xdr_array+0x15e>
xor    %ebp,%ebp
jmp    11d6 <xdr_array+0x76>
lea    0xd5e(%rip),%rdi
call   1060 <_@plt>
mov    0x2d22(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1040 <fputs@plt>
mov    0x2d0a(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_7__ = type { i32 }
@TRUE = global i64 0
@FALSE = global i64 0
@UINT_MAX = global i32 0
@.str = [26 x i8] c"xdr_array: out of memory\0A\00"
@stderr = global i32 0
define i64 @xdr_array(%struct.TYPE_7__* %0, i32** %1, i32* %2, i32 %3, i32 %4, i64 (%struct.TYPE_7__*, i32*, i32)* %5) {
%7 = alloca i64
%8 = alloca %struct.TYPE_7__*
%9 = alloca i32**
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64 (%struct.TYPE_7__*, i32*, i32)*
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i64
%18 = alloca i32
store %struct.TYPE_7__* %0, %struct.TYPE_7__** %8
store i32** %1, i32*** %9
store i32* %2, i32** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i64 (%struct.TYPE_7__*, i32*, i32)* %5, i64 (%struct.TYPE_7__*, i32*, i32)** %13
%19 = load i32**, i32*** %9
%20 = load i32*, i32** %19
store i32* %20, i32** %15
%21 = load i64, i64* @TRUE
store i64 %21, i64* %17
%22 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%23 = load i32*, i32** %10
%24 = call i32 @xdr_u_int(%struct.TYPE_7__* %22, i32* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %6
%27 = load i64, i64* @FALSE
store i64 %27, i64* %7
br label %116
28: ; preds = %6
%29 = load i32*, i32** %10
%30 = load i32, i32* %29
store i32 %30, i32* %16
%31 = load i32, i32* %16
%32 = load i32, i32* %11
%33 = icmp sgt i32 %31, %32
br i1 %33, label %40, label %34
34: ; preds = %28
%35 = load i32, i32* %16
%36 = load i32, i32* @UINT_MAX
%37 = load i32, i32* %12
%38 = sdiv i32 %36, %37
%39 = icmp sgt i32 %35, %38
br i1 %39, label %40, label %47
40: ; preds = %34, %28
%41 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%42 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %41, i32 0, i32 0
%43 = load i32, i32* %42
%44 = icmp ne i32 %43, 128
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = load i64, i64* @FALSE
store i64 %46, i64* %7
br label %116
47: ; preds = %40, %34
%48 = load i32, i32* %16
%49 = load i32, i32* %12
%50 = mul nsw i32 %48, %49
store i32 %50, i32* %18
%51 = load i32*, i32** %15
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %81
53: ; preds = %47
%54 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%55 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %54, i32 0, i32 0
%56 = load i32, i32* %55
switch i32 %56, label %79 [
i32 129, label %57
i32 128, label %77
]
57: ; preds = %53
%58 = load i32, i32* %16
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = load i64, i64* @TRUE
store i64 %61, i64* %7
br label %116
62: ; preds = %57
%63 = load i32, i32* %18
%64 = call i32* @mem_alloc(i32 %63)
store i32* %64, i32** %15
%65 = load i32**, i32*** %9
store i32* %64, i32** %65
%66 = load i32*, i32** %15
%67 = icmp eq i32* %66, null
br i1 %67, label %68, label %73
68: ; preds = %62
%69 = call i32 @_(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%70 = load i32, i32* @stderr
%71 = call i32 @fputs(i32 %69, i32 %70)
%72 = load i64, i64* @FALSE
store i64 %72, i64* %7
br label %116
73: ; preds = %62
%74 = load i32*, i32** %15
%75 = load i32, i32* %18
%76 = call i32 @memset(i32* %74, i32 0, i32 %75)
br label %80
77: ; preds = %53
%78 = load i64, i64* @TRUE
store i64 %78, i64* %7
br label %116
79: ; preds = %53
br label %80
80: ; preds = %79, %73
br label %81
81: ; preds = %80, %47
store i32 0, i32* %14
br label %82
82: ; preds = %100, %81
%83 = load i32, i32* %14
%84 = load i32, i32* %16
%85 = icmp slt i32 %83, %84
br i1 %85, label %86, label %89
86: ; preds = %82
%87 = load i64, i64* %17
%88 = icmp ne i64 %87, 0
br label %89
89: ; preds = %86, %82
%90 = phi i1 [ false, %82 ], [ %88, %86 ]
br i1 %90, label %91, label %103
91: ; preds = %89
%92 = load i64 (%struct.TYPE_7__*, i32*, i32)*, i64 (%struct.TYPE_7__*, i32*, i32)** %13
%93 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%94 = load i32*, i32** %15
%95 = call i64 %92(%struct.TYPE_7__* %93, i32* %94, i32 -1)
store i64 %95, i64* %17
%96 = load i32, i32* %12
%97 = load i32*, i32** %15
%98 = sext i32 %96 to i64
%99 = getelementptr inbounds i32, i32* %97, i64 %98
store i32* %99, i32** %15
br label %100
100: ; preds = %91
%101 = load i32, i32* %14
%102 = add nsw i32 %101, 1
store i32 %102, i32* %14
br label %82
103: ; preds = %89
%104 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%105 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %104, i32 0, i32 0
%106 = load i32, i32* %105
%107 = icmp eq i32 %106, 128
br i1 %107, label %108, label %114
108: ; preds = %103
%109 = load i32**, i32*** %9
%110 = load i32*, i32** %109
%111 = load i32, i32* %18
%112 = call i32 @mem_free(i32* %110, i32 %111)
%113 = load i32**, i32*** %9
store i32* null, i32** %113
br label %114
114: ; preds = %108, %103
%115 = load i64, i64* %17
store i64 %115, i64* %7
br label %116
116: ; preds = %114, %77, %68, %60, %45, %26
%117 = load i64, i64* %7
ret i64 %117
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { i32 }
@TRUE = global i64 0
@FALSE = global i64 0
@UINT_MAX = global i32 0
@.str = [26 x i8] c"xdr_array: out of memory\0A\00"
@stderr = global i32 0
define i64 @xdr_array(%struct.TYPE_7__* %0, i32** nocapture %1, i32* %2, i32 %3, i32 %4, i64 (%struct.TYPE_7__*, i32*, i32)* nocapture %5) {
%7 = load i32*, i32** %1
%8 = load i64, i64* @TRUE
%9 = tail call i32 @xdr_u_int(%struct.TYPE_7__* %0, i32* %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = load i64, i64* @FALSE
br label %72
13: ; preds = %6
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, %3
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i32, i32* @UINT_MAX
%18 = sdiv i32 %17, %4
%19 = icmp sgt i32 %14, %18
br i1 %19, label %20, label %26
20: ; preds = %16, %13
%21 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %0, i64 0, i32 0
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 128
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = load i64, i64* @FALSE
br label %72
26: ; preds = %20, %16
%27 = mul nsw i32 %14, %4
%28 = icmp eq i32* %7, null
br i1 %28, label %29, label %48
29: ; preds = %26
%30 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %0, i64 0, i32 0
%31 = load i32, i32* %30
switch i32 %31, label %48 [
i32 129, label %32
i32 128, label %46
]
32: ; preds = %29
%33 = icmp eq i32 %14, 0
br i1 %33, label %34, label %36
34: ; preds = %32
%35 = load i64, i64* @TRUE
br label %72
36: ; preds = %32
%37 = tail call i32* @mem_alloc(i32 %27)
store i32* %37, i32** %1
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = tail call i32 @_(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%41 = load i32, i32* @stderr
%42 = tail call i32 @fputs(i32 %40, i32 %41)
%43 = load i64, i64* @FALSE
br label %72
44: ; preds = %36
%45 = tail call i32 @memset(i32* %37, i32 0, i32 %27)
br label %48
46: ; preds = %29
%47 = load i64, i64* @TRUE
br label %72
48: ; preds = %44, %29, %26
%49 = phi i32* [ null, %29 ], [ %37, %44 ], [ %7, %26 ]
%50 = icmp sgt i32 %14, 0
%51 = icmp ne i64 %8, 0
%52 = select i1 %50, i1 %51, i1 false
br i1 %52, label %53, label %64
53: ; preds = %48
%54 = sext i32 %4 to i64
br label %55
55: ; preds = %53, %55
%56 = phi i32 [ 0, %53 ], [ %60, %55 ]
%57 = phi i32* [ %49, %53 ], [ %59, %55 ]
%58 = tail call i64 %5(%struct.TYPE_7__* %0, i32* %57, i32 -1)
%59 = getelementptr inbounds i32, i32* %57, i64 %54
%60 = add nuw nsw i32 %56, 1
%61 = icmp slt i32 %60, %14
%62 = icmp ne i64 %58, 0
%63 = select i1 %61, i1 %62, i1 false
br i1 %63, label %55, label %64
64: ; preds = %55, %48
%65 = phi i64 [ %8, %48 ], [ %58, %55 ]
%66 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %0, i64 0, i32 0
%67 = load i32, i32* %66
%68 = icmp eq i32 %67, 128
br i1 %68, label %69, label %72
69: ; preds = %64
%70 = load i32*, i32** %1
%71 = tail call i32 @mem_free(i32* %70, i32 %27)
store i32* null, i32** %1
br label %72
72: ; preds = %64, %69, %46, %39, %34, %24, %11
%73 = phi i64 [ %25, %24 ], [ %47, %46 ], [ %35, %34 ], [ %43, %39 ], [ %12, %11 ], [ %65, %69 ], [ %65, %64 ]
ret i64 %73
}