#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*/ 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 fwrite(int /*<<< orphan*/, int, int, int /*<<< orphan*/ *);
long htonl(long const);
bool_t xdrstdio_putlong(XDR *xdrs, const long *lp) {
  long mycopy = htonl(*lp);
  lp = &mycopy;
  if (fwrite((caddr_t)lp, 4, 1, (FILE *)xdrs->x_private) != 1)
    return FALSE;
  return TRUE;
}


x86 assembly (clang, -O0):
<xdrstdio_putlong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <htonl@plt>
mov    %rax,-0x20(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
cmp    $0x1,%eax
je     117e <xdrstdio_putlong+0x5e>
mov    0x2e64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    118a <xdrstdio_putlong+0x6a>
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_putlong>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    (%rsi),%rdi
call   1030 <htonl@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    (%rbx),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
cmp    $0x1,%eax
jne    115a <xdrstdio_putlong+0x3a>
mov    0x2e90(%rip),%rax
jmp    1161 <xdrstdio_putlong+0x41>
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64 }
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @xdrstdio_putlong(%struct.TYPE_3__* %0, i64* %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_3__*
%5 = alloca i64*
%6 = alloca i64
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %4
store i64* %1, i64** %5
%7 = load i64*, i64** %5
%8 = load i64, i64* %7
%9 = call i64 @htonl(i64 %8)
store i64 %9, i64* %6
store i64* %6, i64** %5
%10 = load i64*, i64** %5
%11 = ptrtoint i64* %10 to i32
%12 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 0
%14 = load i64, i64* %13
%15 = inttoptr i64 %14 to i32*
%16 = call i32 @fwrite(i32 %11, i32 4, i32 1, i32* %15)
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = load i32, i32* @FALSE
store i32 %19, i32* %3
br label %22
20: ; preds = %2
%21 = load i32, i32* @TRUE
store i32 %21, i32* %3
br label %22
22: ; preds = %20, %18
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64 }
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @xdrstdio_putlong(%struct.TYPE_3__* nocapture %0, i64* nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = load i64, i64* %1
%6 = tail call i64 @htonl(i64 %5)
store i64 %6, i64* %3
%7 = ptrtoint i64* %3 to i64
%8 = trunc i64 %7 to i32
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%10 = load i64, i64* %9
%11 = inttoptr i64 %10 to i32*
%12 = call i32 @fwrite(i32 %8, i32 4, i32 1, i32* %11)
%13 = icmp eq i32 %12, 1
%14 = load i32, i32* @TRUE
%15 = load i32, i32* @FALSE
%16 = select i1 %13, i32 %14, i32 %15
ret i32 %16
}