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

/* Variables and functions */
int /*<<< orphan*/ FALSE;
int /*<<< orphan*/ TRUE;
scalar_t__ ntohl(long);
bool_t xdrmem_getlong(XDR *xdrs, long *lp) {
  if ((xdrs->x_handy -= 4) < 0)
    return FALSE;
  *lp = (int32_t)ntohl((*((int32_t *)(xdrs->x_private))));
  xdrs->x_private += 4;
  return TRUE;
}


x86 assembly (clang, -O0):
<xdrmem_getlong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
mov    (%rcx),%eax
sub    $0x4,%eax
mov    %eax,(%rcx)
cmp    $0x0,%eax
jge    1145 <xdrmem_getlong+0x35>
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    117b <xdrmem_getlong+0x6b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rdi
call   1030 <ntohl@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
add    $0x4,%rcx
mov    %rcx,0x8(%rax)
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdrmem_getlong>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%eax
lea    -0x4(%rax),%ecx
mov    %ecx,(%rdi)
cmp    $0x4,%eax
jge    1129 <xdrmem_getlong+0x19>
mov    0x2eb1(%rip),%rax
jmp    114a <xdrmem_getlong+0x3a>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x8(%rdi),%rax
mov    (%rax),%rdi
call   1030 <ntohl@plt>
mov    %rax,(%r14)
addq   $0x4,0x8(%rbx)
mov    0x2e9e(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i64 }
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @xdrmem_getlong(%struct.TYPE_3__* %0, i64* %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_3__*
%5 = alloca i64*
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %4
store i64* %1, i64** %5
%6 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = sub nsw i32 %8, 4
store i32 %9, i32* %7
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i32, i32* @FALSE
store i32 %12, i32* %3
br label %26
13: ; preds = %2
%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 i64, i64* %15
%17 = inttoptr i64 %16 to i64*
%18 = load i64, i64* %17
%19 = call i64 @ntohl(i64 %18)
%20 = load i64*, i64** %5
store i64 %19, i64* %20
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i32 0, i32 1
%23 = load i64, i64* %22
%24 = add nsw i64 %23, 4
store i64 %24, i64* %22
%25 = load i32, i32* @TRUE
store i32 %25, i32* %3
br label %26
26: ; preds = %13, %11
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i64 }
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @xdrmem_getlong(%struct.TYPE_3__* nocapture %0, i64* nocapture writeonly %1) {
%3 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = add nsw i32 %4, -4
store i32 %5, i32* %3
%6 = icmp slt i32 %4, 4
br i1 %6, label %15, label %7
7: ; preds = %2
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%9 = load i64, i64* %8
%10 = inttoptr i64 %9 to i64*
%11 = load i64, i64* %10
%12 = tail call i64 @ntohl(i64 %11)
store i64 %12, i64* %1
%13 = load i64, i64* %8
%14 = add nsw i64 %13, 4
store i64 %14, i64* %8
br label %15
15: ; preds = %2, %7
%16 = phi i32* [ @TRUE, %7 ], [ @FALSE, %2 ]
%17 = load i32, i32* %16
ret i32 %17
}