#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*/ u_int32_t;
typedef int /*<<< orphan*/ int32_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*/ *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
bool_t xdrstdio_putlong(XDR *xdrs, const long *lp) {
  int32_t mycopy = htonl((u_int32_t)*lp);
  if (fwrite(&mycopy, sizeof(int32_t), 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),%rax
mov    %eax,%edi
call   1030 <htonl@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    -0x1c(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
cmp    $0x1,%eax
je     1175 <xdrstdio_putlong+0x55>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1181 <xdrstdio_putlong+0x61>
mov    0x2e6c(%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),%edi
call   1030 <htonl@plt>
mov    %eax,0xc(%rsp)
mov    (%rbx),%rcx
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
cmp    $0x1,%eax
jne    1158 <xdrstdio_putlong+0x38>
mov    0x2e92(%rip),%rax
jmp    115f <xdrstdio_putlong+0x3f>
mov    0x2e79(%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 i32
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 = trunc i64 %8 to i32
%10 = call i32 @htonl(i32 %9)
store i32 %10, i32* %6
%11 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 0
%13 = load i64, i64* %12
%14 = inttoptr i64 %13 to i32*
%15 = call i32 @fwrite(i32* %6, i32 4, i32 1, i32* %14)
%16 = icmp ne i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = load i32, i32* @FALSE
store i32 %18, i32* %3
br label %21
19: ; preds = %2
%20 = load i32, i32* @TRUE
store i32 %20, i32* %3
br label %21
21: ; preds = %19, %17
%22 = load i32, i32* %3
ret i32 %22
}

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 i32
%4 = bitcast i32* %3 to i8*
%5 = load i64, i64* %1
%6 = trunc i64 %5 to i32
%7 = tail call i32 @htonl(i32 %6)
store i32 %7, i32* %3
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%9 = load i64, i64* %8
%10 = inttoptr i64 %9 to i32*
%11 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32* %10)
%12 = icmp eq i32 %11, 1
%13 = load i32, i32* @TRUE
%14 = load i32, i32* @FALSE
%15 = select i1 %12, i32 %13, i32 %14
ret i32 %15
}