#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 scalar_t__ u_int;
typedef scalar_t__ caddr_t;
typedef int /*<<< orphan*/ bool_t;
struct TYPE_3__ {
  long x_handy;
  scalar_t__ x_private;
  scalar_t__ x_base;
};
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, u_int pos) {
  caddr_t newaddr = xdrs->x_base + pos;
  caddr_t 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    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rcx
add    (%rcx),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jg     1172 <xdrmem_setpos+0x72>
mov    0x2ea4(%rip),%rax
mov    (%rax),%rax
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%rax
jge    1183 <xdrmem_setpos+0x83>
mov    0x2e8a(%rip),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
sub    -0x20(%rbp),%rcx
cmp    %rcx,%rax
jge    1183 <xdrmem_setpos+0x83>
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11aa <xdrmem_setpos+0xaa>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x28(%rbp),%rcx
sub    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdrmem_setpos>:
add    0x10(%rdi),%rsi
mov    (%rdi),%rcx
add    0x8(%rdi),%rcx
mov    0x2eb6(%rip),%rax
sub    %rsi,%rcx
jl     1132 <xdrmem_setpos+0x32>
mov    0x2eca(%rip),%rdx
mov    (%rdx),%r8
mov    0x2ea8(%rip),%rdx
cmp    (%rdx),%r8
jge    1135 <xdrmem_setpos+0x35>
cmp    %rcx,%r8
jge    1135 <xdrmem_setpos+0x35>
mov    (%rax),%eax
ret
mov    %rsi,0x8(%rdi)
mov    %rcx,(%rdi)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
ret

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

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i64, 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, i64 %1) {
%3 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 2
%4 = load i64, i64* %3
%5 = add nsw i64 %4, %1
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%7 = load i64, i64* %6
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%9 = load i64, i64* %8
%10 = add nsw i64 %9, %7
%11 = icmp slt i64 %10, %5
br i1 %11, label %20, label %12
12: ; preds = %2
%13 = load i64, i64* @UINT_MAX
%14 = load i64, i64* @LONG_MAX
%15 = icmp slt i64 %13, %14
%16 = sub nsw i64 %10, %5
%17 = icmp slt i64 %13, %16
%18 = select i1 %15, i1 %17, i1 false
br i1 %18, label %20, label %19
19: ; preds = %12
store i64 %5, i64* %6
store i64 %16, i64* %8
br label %20
20: ; preds = %2, %12, %19
%21 = phi i32* [ @TRUE, %19 ], [ @FALSE, %12 ], [ @FALSE, %2 ]
%22 = load i32, i32* %21
ret i32 %22
}