#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*/ fputs(char *, 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    0x2e5f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <xdr_u_int@plt>
cmp    $0x0,%eax
jne    11b1 <xdr_array+0x61>
mov    0x2e23(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    137f <xdr_array+0x22f>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     11e6 <xdr_array+0x96>
mov    -0x44(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
cltd
idivl  -0x28(%rbp)
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
cmp    %ecx,%eax
jle    1209 <xdr_array+0xb9>
mov    -0x10(%rbp),%rax
cmpl   $0x80,(%rax)
je     1209 <xdr_array+0xb9>
mov    0x2dcb(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    137f <xdr_array+0x22f>
mov    -0x44(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x54(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12e0 <xdr_array+0x190>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
sub    $0x80,%eax
je     12c3 <xdr_array+0x173>
jmp    1237 <xdr_array+0xe7>
mov    -0x5c(%rbp),%eax
sub    $0x81,%eax
jne    12d6 <xdr_array+0x186>
jmp    124a <xdr_array+0xfa>
cmpl   $0x0,-0x44(%rbp)
jne    1267 <xdr_array+0x117>
mov    0x2d85(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    137f <xdr_array+0x22f>
mov    -0x54(%rbp),%edi
call   1060 <mem_alloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x40(%rbp)
jne    12b0 <xdr_array+0x160>
mov    0x2d41(%rip),%rax
mov    (%rax),%esi
lea    0xd68(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2d24(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    137f <xdr_array+0x22f>
mov    -0x40(%rbp),%rdi
mov    -0x54(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
jmp    12db <xdr_array+0x18b>
mov    0x2d16(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    137f <xdr_array+0x22f>
jmp    12db <xdr_array+0x18b>
jmp    12e0 <xdr_array+0x190>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%ecx
xor    %eax,%eax
cmp    -0x44(%rbp),%ecx
mov    %al,-0x5d(%rbp)
jge    1303 <xdr_array+0x1b3>
cmpq   $0x0,-0x50(%rbp)
setne  %al
mov    %al,-0x5d(%rbp)
mov    -0x5d(%rbp),%al
test   $0x1,%al
jne    1313 <xdr_array+0x1c3>
jmp    134d <xdr_array+0x1fd>
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    12e7 <xdr_array+0x197>
mov    -0x10(%rbp),%rax
cmpl   $0x80,(%rax)
jne    1377 <xdr_array+0x227>
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    0x2e63(%rip),%rax
mov    (%rax),%rbx
mov    %rdx,%rsi
call   1070 <xdr_u_int@plt>
test   %eax,%eax
je     12a0 <xdr_array+0x150>
mov    0x0(%r13),%r13d
cmp    %r14d,%r13d
mov    (%rsp),%ecx
jg     11ad <xdr_array+0x5d>
mov    0x2e45(%rip),%rax
mov    (%rax),%eax
cltd
idiv   %ecx
cmp    %eax,%r13d
jle    11ba <xdr_array+0x6a>
cmpl   $0x80,(%r15)
jne    12a0 <xdr_array+0x150>
mov    %r13d,%r14d
imul   %ecx,%r14d
test   %rbp,%rbp
je     123c <xdr_array+0xec>
test   %r13d,%r13d
mov    %r12,0x8(%rsp)
mov    %r14d,0x4(%rsp)
jle    1213 <xdr_array+0xc3>
test   %rbx,%rbx
je     1213 <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    1213 <xdr_array+0xc3>
add    $0x1,%r12d
add    %r14,%rbp
test   %rbx,%rbx
jne    11f0 <xdr_array+0xa0>
cmpl   $0x80,(%r15)
jne    12aa <xdr_array+0x15a>
mov    0x8(%rsp),%rbp
mov    0x0(%rbp),%rdi
mov    0x4(%rsp),%esi
call   1030 <mem_free@plt>
movq   $0x0,0x0(%rbp)
jmp    12aa <xdr_array+0x15a>
mov    (%r15),%eax
cmp    $0x80,%eax
je     127b <xdr_array+0x12b>
cmp    $0x81,%eax
jne    1284 <xdr_array+0x134>
test   %r13d,%r13d
je     127b <xdr_array+0x12b>
mov    %r14d,%edi
call   1060 <mem_alloc@plt>
mov    %rax,(%r12)
test   %rax,%rax
je     128b <xdr_array+0x13b>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1050 <memset@plt>
mov    (%rsp),%ecx
jmp    11c6 <xdr_array+0x76>
mov    0x2d5e(%rip),%rax
jmp    12a7 <xdr_array+0x157>
xor    %ebp,%ebp
jmp    11c6 <xdr_array+0x76>
mov    0x2d3e(%rip),%rax
mov    (%rax),%esi
lea    0xd65(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2d21(%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 %115
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 %115
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 %80
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 %78 [
i32 129, label %57
i32 128, label %76
]
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 %115
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 %72
68: ; preds = %62
%69 = load i32, i32* @stderr
%70 = call i32 @fputs(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %69)
%71 = load i64, i64* @FALSE
store i64 %71, i64* %7
br label %115
72: ; preds = %62
%73 = load i32*, i32** %15
%74 = load i32, i32* %18
%75 = call i32 @memset(i32* %73, i32 0, i32 %74)
br label %79
76: ; preds = %53
%77 = load i64, i64* @TRUE
store i64 %77, i64* %7
br label %115
78: ; preds = %53
br label %79
79: ; preds = %78, %72
br label %80
80: ; preds = %79, %47
store i32 0, i32* %14
br label %81
81: ; preds = %99, %80
%82 = load i32, i32* %14
%83 = load i32, i32* %16
%84 = icmp slt i32 %82, %83
br i1 %84, label %85, label %88
85: ; preds = %81
%86 = load i64, i64* %17
%87 = icmp ne i64 %86, 0
br label %88
88: ; preds = %85, %81
%89 = phi i1 [ false, %81 ], [ %87, %85 ]
br i1 %89, label %90, label %102
90: ; preds = %88
%91 = load i64 (%struct.TYPE_7__*, i32*, i32)*, i64 (%struct.TYPE_7__*, i32*, i32)** %13
%92 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%93 = load i32*, i32** %15
%94 = call i64 %91(%struct.TYPE_7__* %92, i32* %93, i32 -1)
store i64 %94, i64* %17
%95 = load i32, i32* %12
%96 = load i32*, i32** %15
%97 = sext i32 %95 to i64
%98 = getelementptr inbounds i32, i32* %96, i64 %97
store i32* %98, i32** %15
br label %99
99: ; preds = %90
%100 = load i32, i32* %14
%101 = add nsw i32 %100, 1
store i32 %101, i32* %14
br label %81
102: ; preds = %88
%103 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%104 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %103, i32 0, i32 0
%105 = load i32, i32* %104
%106 = icmp eq i32 %105, 128
br i1 %106, label %107, label %113
107: ; preds = %102
%108 = load i32**, i32*** %9
%109 = load i32*, i32** %108
%110 = load i32, i32* %18
%111 = call i32 @mem_free(i32* %109, i32 %110)
%112 = load i32**, i32*** %9
store i32* null, i32** %112
br label %113
113: ; preds = %107, %102
%114 = load i64, i64* %17
store i64 %114, i64* %7
br label %115
115: ; preds = %113, %76, %68, %60, %45, %26
%116 = load i64, i64* %7
ret i64 %116
}

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 %71
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 %71
26: ; preds = %20, %16
%27 = mul nsw i32 %14, %4
%28 = icmp eq i32* %7, null
br i1 %28, label %29, label %47
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 %47 [
i32 129, label %32
i32 128, label %45
]
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 %71
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 %43
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = tail call i32 @fputs(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = load i64, i64* @FALSE
br label %71
43: ; preds = %36
%44 = tail call i32 @memset(i32* %37, i32 0, i32 %27)
br label %47
45: ; preds = %29
%46 = load i64, i64* @TRUE
br label %71
47: ; preds = %43, %29, %26
%48 = phi i32* [ null, %29 ], [ %37, %43 ], [ %7, %26 ]
%49 = icmp sgt i32 %14, 0
%50 = icmp ne i64 %8, 0
%51 = select i1 %49, i1 %50, i1 false
br i1 %51, label %52, label %63
52: ; preds = %47
%53 = sext i32 %4 to i64
br label %54
54: ; preds = %52, %54
%55 = phi i32 [ 0, %52 ], [ %59, %54 ]
%56 = phi i32* [ %48, %52 ], [ %58, %54 ]
%57 = tail call i64 %5(%struct.TYPE_7__* %0, i32* %56, i32 -1)
%58 = getelementptr inbounds i32, i32* %56, i64 %53
%59 = add nuw nsw i32 %55, 1
%60 = icmp slt i32 %59, %14
%61 = icmp ne i64 %57, 0
%62 = select i1 %60, i1 %61, i1 false
br i1 %62, label %54, label %63
63: ; preds = %54, %47
%64 = phi i64 [ %8, %47 ], [ %57, %54 ]
%65 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %0, i64 0, i32 0
%66 = load i32, i32* %65
%67 = icmp eq i32 %66, 128
br i1 %67, label %68, label %71
68: ; preds = %63
%69 = load i32*, i32** %1
%70 = tail call i32 @mem_free(i32* %69, i32 %27)
store i32* null, i32** %1
br label %71
71: ; preds = %63, %68, %45, %39, %34, %24, %11
%72 = phi i64 [ %25, %24 ], [ %46, %45 ], [ %35, %34 ], [ %42, %39 ], [ %12, %11 ], [ %64, %68 ], [ %64, %63 ]
ret i64 %72
}