#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_5__ TYPE_1__;

/* Type definitions */
typedef scalar_t__ u_int;
typedef int /*<<< orphan*/ bool_t;
struct TYPE_5__ {
  int x_op;
};
typedef TYPE_1__ XDR;

/* Variables and functions */
int /*<<< orphan*/ FALSE;
int /*<<< orphan*/ TRUE;
#define XDR_DECODE 130
#define XDR_ENCODE 129
#define XDR_FREE 128
char *mem_alloc(scalar_t__);
int /*<<< orphan*/ mem_free(char *, scalar_t__);
int /*<<< orphan*/ warnx(char *);
int /*<<< orphan*/ xdr_opaque(TYPE_1__ *, char *, scalar_t__);
int /*<<< orphan*/ xdr_u_int(TYPE_1__ *, scalar_t__ *);
bool_t xdr_bytes(XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize) {
  char *sp = *cpp;
  u_int nodesize;
  if (!xdr_u_int(xdrs, sizep)) {
    return (FALSE);
  }
  nodesize = *sizep;
  if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) {
    return (FALSE);
  }
  switch (xdrs->x_op) {
  case XDR_DECODE:
    if (nodesize == 0) {
      return (TRUE);
    }
    if (sp == NULL) {
      *cpp = sp = mem_alloc(nodesize);
    }
    if (sp == NULL) {
      warnx("xdr_bytes: out of memory");
      return (FALSE);
    }
  case XDR_ENCODE:
    return (xdr_opaque(xdrs, sp, nodesize));
  case XDR_FREE:
    if (sp != NULL) {
      mem_free(sp, nodesize);
      *cpp = NULL;
    }
    return (TRUE);
  }
  return (FALSE);
}


x86 assembly (clang, -O0):
<xdr_bytes>:
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    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <xdr_u_int@plt>
cmp    $0x0,%eax
jne    119a <xdr_bytes+0x4a>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d7 <xdr_bytes+0x187>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x28(%rbp),%rax
jle    11d4 <xdr_bytes+0x84>
mov    -0x10(%rbp),%rax
cmpl   $0x80,(%rax)
je     11d4 <xdr_bytes+0x84>
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d7 <xdr_bytes+0x187>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x80,%eax
je     1297 <xdr_bytes+0x147>
jmp    11ed <xdr_bytes+0x9d>
mov    -0x3c(%rbp),%eax
sub    $0x81,%eax
je     127e <xdr_bytes+0x12e>
jmp    1200 <xdr_bytes+0xb0>
mov    -0x3c(%rbp),%eax
sub    $0x82,%eax
jne    12cb <xdr_bytes+0x17b>
jmp    1213 <xdr_bytes+0xc3>
cmpq   $0x0,-0x38(%rbp)
jne    122f <xdr_bytes+0xdf>
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d7 <xdr_bytes+0x187>
cmpq   $0x0,-0x30(%rbp)
jne    1251 <xdr_bytes+0x101>
mov    -0x38(%rbp),%rdi
call   1050 <mem_alloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x30(%rbp)
jne    1279 <xdr_bytes+0x129>
lea    0xd9d(%rip),%rdi
call   1040 <warnx@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d7 <xdr_bytes+0x187>
jmp    127e <xdr_bytes+0x12e>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1060 <xdr_opaque@plt>
mov    %eax,-0x4(%rbp)
jmp    12d7 <xdr_bytes+0x187>
cmpq   $0x0,-0x30(%rbp)
je     12ba <xdr_bytes+0x16a>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <mem_free@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    0x2d27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d7 <xdr_bytes+0x187>
mov    0x2d06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdr_bytes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbp
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r13
mov    (%rsi),%r14
mov    %rdx,%rsi
call   1070 <xdr_u_int@plt>
test   %eax,%eax
je     120b <xdr_bytes+0xbb>
mov    (%rbx),%r15
mov    0x0(%r13),%eax
cmp    %rbp,%r15
jle    118f <xdr_bytes+0x3f>
cmp    $0x80,%eax
jne    120b <xdr_bytes+0xbb>
jmp    11de <xdr_bytes+0x8e>
cmp    $0x80,%eax
je     11de <xdr_bytes+0x8e>
cmp    $0x81,%eax
je     11c2 <xdr_bytes+0x72>
cmp    $0x82,%eax
jne    120b <xdr_bytes+0xbb>
test   %r15,%r15
je     11f6 <xdr_bytes+0xa6>
test   %r14,%r14
jne    11c2 <xdr_bytes+0x72>
mov    %r15,%rdi
call   1050 <mem_alloc@plt>
mov    %rax,%r14
mov    %rax,(%r12)
test   %rax,%rax
je     11ff <xdr_bytes+0xaf>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <xdr_opaque@plt>
test   %r14,%r14
je     11f6 <xdr_bytes+0xa6>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <mem_free@plt>
movq   $0x0,(%r12)
mov    0x2deb(%rip),%rax
jmp    1212 <xdr_bytes+0xc2>
lea    0xdfa(%rip),%rdi
call   1040 <warnx@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32 }
@FALSE = global i32 0
@TRUE = global i32 0
@.str = [25 x i8] c"xdr_bytes: out of memory\00"
define i32 @xdr_bytes(%struct.TYPE_5__* %0, i8** nocapture %1, i64* %2, i64 %3) {
%5 = load i8*, i8** %1
%6 = tail call i32 @xdr_u_int(%struct.TYPE_5__* %0, i64* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = load i32, i32* @FALSE
br label %43
10: ; preds = %4
%11 = load i64, i64* %2
%12 = icmp sgt i64 %11, %3
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 0
%14 = load i32, i32* %13
br i1 %12, label %15, label %19
15: ; preds = %10
%16 = icmp eq i32 %14, 128
br i1 %16, label %35, label %17
17: ; preds = %15
%18 = load i32, i32* @FALSE
br label %43
19: ; preds = %10
switch i32 %14, label %41 [
i32 130, label %20
i32 129, label %32
i32 128, label %35
]
20: ; preds = %19
%21 = icmp eq i64 %11, 0
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = load i32, i32* @TRUE
br label %43
24: ; preds = %20
%25 = icmp eq i8* %5, null
br i1 %25, label %26, label %32
26: ; preds = %24
%27 = tail call i8* @mem_alloc(i64 %11)
store i8* %27, i8** %1
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = tail call i32 @warnx(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%31 = load i32, i32* @FALSE
br label %43
32: ; preds = %24, %26, %19
%33 = phi i8* [ %5, %19 ], [ %27, %26 ], [ %5, %24 ]
%34 = tail call i32 @xdr_opaque(%struct.TYPE_5__* %0, i8* %33, i64 %11)
br label %43
35: ; preds = %15, %19
%36 = icmp eq i8* %5, null
br i1 %36, label %39, label %37
37: ; preds = %35
%38 = tail call i32 @mem_free(i8* %5, i64 %11)
store i8* null, i8** %1
br label %39
39: ; preds = %37, %35
%40 = load i32, i32* @TRUE
br label %43
41: ; preds = %19
%42 = load i32, i32* @FALSE
br label %43
43: ; preds = %41, %39, %32, %29, %22, %17, %8
%44 = phi i32 [ %18, %17 ], [ %42, %41 ], [ %40, %39 ], [ %34, %32 ], [ %23, %22 ], [ %31, %29 ], [ %9, %8 ]
ret i32 %44
}