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

/* Type definitions */
typedef int /*<<< orphan*/ bool_t;
struct TYPE_3__ {
  char *x_base;
  char *x_private;
  long x_handy;
};
typedef TYPE_1__ XDR;

/* Variables and functions */
int /*<<< orphan*/ FALSE;
scalar_t__ LONG_MAX;
int /*<<< orphan*/ TRUE;
scalar_t__ UINT_MAX;
bool_t xdrmem_setpos(XDR *xdrs, unsigned int pos) {
  register char *newaddr = xdrs->x_base + pos;
  register char *lastaddr = xdrs->x_private + xdrs->x_handy;
  if ((long)newaddr > (long)lastaddr ||
      (UINT_MAX < LONG_MAX && (long)UINT_MAX < (long)lastaddr - (long)newaddr))
    return (FALSE);
  xdrs->x_private = newaddr;
  xdrs->x_handy = (long)lastaddr - (long)newaddr;
  return (TRUE);
}


x86 assembly (clang, -O0):
<xdrmem_setpos>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x14(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rcx
add    0x10(%rcx),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmp    %rcx,%rax
jg     1179 <xdrmem_setpos+0x79>
mov    0x2ea0(%rip),%rax
mov    (%rax),%rax
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%rax
jge    118a <xdrmem_setpos+0x8a>
mov    0x2e86(%rip),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rdx
sub    %rdx,%rcx
cmp    %rcx,%rax
jge    118a <xdrmem_setpos+0x8a>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <xdrmem_setpos+0xb5>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
sub    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdrmem_setpos>:
mov    %esi,%eax
add    (%rdi),%rax
mov    0x8(%rdi),%rdx
add    0x10(%rdi),%rdx
mov    0x2eb4(%rip),%rcx
sub    %rax,%rdx
jl     1134 <xdrmem_setpos+0x34>
mov    0x2ec8(%rip),%rsi
mov    (%rsi),%r8
mov    0x2ea6(%rip),%rsi
cmp    (%rsi),%r8
jge    1137 <xdrmem_setpos+0x37>
cmp    %rdx,%r8
jge    1137 <xdrmem_setpos+0x37>
mov    (%rcx),%eax
ret
mov    %rax,0x8(%rdi)
mov    %rdx,0x10(%rdi)
mov    0x2e9a(%rip),%rcx
mov    (%rcx),%eax
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8*, i8*, i64 }
@UINT_MAX = global i64 0
@LONG_MAX = global i64 0
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @xdrmem_setpos(%struct.TYPE_3__* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_3__*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %4
store i32 %1, i32* %5
%8 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = load i32, i32* %5
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
store i8* %13, i8** %6
%14 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%15 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %14, i32 0, i32 1
%16 = load i8*, i8** %15
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 2
%19 = load i64, i64* %18
%20 = getelementptr inbounds i8, i8* %16, i64 %19
store i8* %20, i8** %7
%21 = load i8*, i8** %6
%22 = ptrtoint i8* %21 to i64
%23 = load i8*, i8** %7
%24 = ptrtoint i8* %23 to i64
%25 = icmp sgt i64 %22, %24
br i1 %25, label %38, label %26
26: ; preds = %2
%27 = load i64, i64* @UINT_MAX
%28 = load i64, i64* @LONG_MAX
%29 = icmp slt i64 %27, %28
br i1 %29, label %30, label %40
30: ; preds = %26
%31 = load i64, i64* @UINT_MAX
%32 = load i8*, i8** %7
%33 = ptrtoint i8* %32 to i64
%34 = load i8*, i8** %6
%35 = ptrtoint i8* %34 to i64
%36 = sub nsw i64 %33, %35
%37 = icmp slt i64 %31, %36
br i1 %37, label %38, label %40
38: ; preds = %30, %2
%39 = load i32, i32* @FALSE
store i32 %39, i32* %3
br label %52
40: ; preds = %30, %26
%41 = load i8*, i8** %6
%42 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%43 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %42, i32 0, i32 1
store i8* %41, i8** %43
%44 = load i8*, i8** %7
%45 = ptrtoint i8* %44 to i64
%46 = load i8*, i8** %6
%47 = ptrtoint i8* %46 to i64
%48 = sub nsw i64 %45, %47
%49 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%50 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %49, i32 0, i32 2
store i64 %48, i64* %50
%51 = load i32, i32* @TRUE
store i32 %51, i32* %3
br label %52
52: ; preds = %40, %38
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8*, i8*, i64 }
@UINT_MAX = global i64 0
@LONG_MAX = global i64 0
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @xdrmem_setpos(%struct.TYPE_3__* nocapture %0, i32 %1) {
%3 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%4 = load i8*, i8** %3
%5 = zext i32 %1 to i64
%6 = getelementptr inbounds i8, i8* %4, i64 %5
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%8 = load i8*, i8** %7
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 2
%10 = load i64, i64* %9
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = icmp slt i8* %11, %6
br i1 %12, label %23, label %13
13: ; preds = %2
%14 = ptrtoint i8* %11 to i64
%15 = ptrtoint i8* %6 to i64
%16 = load i64, i64* @UINT_MAX
%17 = load i64, i64* @LONG_MAX
%18 = icmp slt i64 %16, %17
%19 = sub nsw i64 %14, %15
%20 = icmp slt i64 %16, %19
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %23, label %22
22: ; preds = %13
store i8* %6, i8** %7
store i64 %19, i64* %9
br label %23
23: ; preds = %2, %13, %22
%24 = phi i32* [ @TRUE, %22 ], [ @FALSE, %13 ], [ @FALSE, %2 ]
%25 = load i32, i32* %24
ret i32 %25
}