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

/* Variables and functions */
int /*<<< orphan*/ FALSE;
int /*<<< orphan*/ TRUE;
int fread(int /*<<< orphan*/, int, int, int /*<<< orphan*/ *);
scalar_t__ ntohl(int /*<<< orphan*/);
bool_t xdrstdio_getlong(XDR *xdrs, long *lp) {
  if (fread((caddr_t)lp, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
    return (FALSE);
  *lp = (long)ntohl((int32_t)*lp);
  return (TRUE);
}


x86 assembly (clang, -O0):
<xdrstdio_getlong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1166 <xdrstdio_getlong+0x46>
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    118a <xdrstdio_getlong+0x6a>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%edi
call   1040 <ntohl@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdrstdio_getlong>:
push   %rbx
mov    %rsi,%rbx
mov    (%rdi),%rcx
mov    %ebx,%edi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1150 <xdrstdio_getlong+0x30>
mov    (%rbx),%edi
call   1040 <ntohl@plt>
mov    %rax,(%rbx)
mov    0x2e9a(%rip),%rax
jmp    1157 <xdrstdio_getlong+0x37>
mov    0x2e81(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64 }
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @xdrstdio_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 i64*, i64** %5
%7 = ptrtoint i64* %6 to i32
%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 i64, i64* %9
%11 = inttoptr i64 %10 to i32*
%12 = call i32 @fread(i32 %7, i32 4, i32 1, i32* %11)
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = load i32, i32* @FALSE
store i32 %15, i32* %3
br label %23
16: ; preds = %2
%17 = load i64*, i64** %5
%18 = load i64, i64* %17
%19 = trunc i64 %18 to i32
%20 = call i64 @ntohl(i32 %19)
%21 = load i64*, i64** %5
store i64 %20, i64* %21
%22 = load i32, i32* @TRUE
store i32 %22, i32* %3
br label %23
23: ; preds = %16, %14
%24 = load i32, i32* %3
ret i32 %24
}

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