#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 u_int;
typedef int /*<<< orphan*/ bool_t;
struct TYPE_3__ {
  char *x_base;
  char *x_private;
  int x_handy;
};
typedef TYPE_1__ XDR;

/* Variables and functions */
int /*<<< orphan*/ FALSE;
int /*<<< orphan*/ TRUE;
bool_t xdrmem_setpos(XDR *xdrs, u_int pos) {
  char *newaddr = xdrs->x_base + pos;
  char *lastaddr = (char *)xdrs->x_private + xdrs->x_handy;
  if (newaddr > lastaddr)
    return (FALSE);
  xdrs->x_private = newaddr;
  xdrs->x_handy = (u_int)(lastaddr - 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
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rcx
movslq 0x10(%rcx),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jbe    1153 <xdrmem_setpos+0x53>
mov    0x2e8f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    117f <xdrmem_setpos+0x7f>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    0x2e6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdrmem_setpos>:
movslq %esi,%rax
add    (%rdi),%rax
movslq 0x10(%rdi),%rcx
add    0x8(%rdi),%rcx
cmp    %rcx,%rax
jbe    111d <xdrmem_setpos+0x1d>
mov    0x2ebe(%rip),%rax
mov    (%rax),%eax
ret
mov    %rax,0x8(%rdi)
sub    %eax,%ecx
mov    %ecx,0x10(%rdi)
mov    0x2ebb(%rip),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8*, i8*, i32 }
@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 = sext 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 i32, i32* %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %16, i64 %20
store i8* %21, i8** %7
%22 = load i8*, i8** %6
%23 = load i8*, i8** %7
%24 = icmp ugt i8* %22, %23
br i1 %24, label %25, label %27
25: ; preds = %2
%26 = load i32, i32* @FALSE
store i32 %26, i32* %3
br label %40
27: ; preds = %2
%28 = load i8*, i8** %6
%29 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%30 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %29, i32 0, i32 1
store i8* %28, i8** %30
%31 = load i8*, i8** %7
%32 = load i8*, i8** %6
%33 = ptrtoint i8* %31 to i64
%34 = ptrtoint i8* %32 to i64
%35 = sub i64 %33, %34
%36 = trunc i64 %35 to i32
%37 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%38 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i32 0, i32 2
store i32 %36, i32* %38
%39 = load i32, i32* @TRUE
store i32 %39, i32* %3
br label %40
40: ; preds = %27, %25
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8*, i8*, i32 }
@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 = sext 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 i32, i32* %9
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
%13 = icmp ugt i8* %6, %12
br i1 %13, label %19, label %14
14: ; preds = %2
store i8* %6, i8** %7
%15 = ptrtoint i8* %12 to i64
%16 = ptrtoint i8* %6 to i64
%17 = sub i64 %15, %16
%18 = trunc i64 %17 to i32
store i32 %18, i32* %9
br label %19
19: ; preds = %2, %14
%20 = phi i32* [ @TRUE, %14 ], [ @FALSE, %2 ]
%21 = load i32, i32* %20
ret i32 %21
}