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

/* Variables and functions */
int /*<<< orphan*/ htonl(int /*<<< orphan*/ const);
bool_t xdrmem_putint32(XDR *xdrs, const int32_t *ip) {
  if (xdrs->x_handy < 4)
    return (0);
  xdrs->x_handy -= 4;
  *(int32_t *)xdrs->x_private = htonl(*ip);
  xdrs->x_private += 4;
  return (1);
}


x86 assembly (clang, -O0):
<xdrmem_putint32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x4,(%rax)
jge    1139 <xdrmem_putint32+0x29>
movl   $0x0,-0x4(%rbp)
jmp    1172 <xdrmem_putint32+0x62>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x4,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
add    $0x4,%rcx
mov    %rcx,0x8(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdrmem_putint32>:
push   %rbx
mov    (%rdi),%ecx
xor    %eax,%eax
cmp    $0x4,%ecx
jl     113c <xdrmem_putint32+0x2c>
mov    %rdi,%rbx
add    $0xfffffffc,%ecx
mov    %ecx,(%rdi)
mov    (%rsi),%edi
call   1030 <htonl@plt>
mov    0x8(%rbx),%rcx
mov    %eax,(%rcx)
add    $0x4,%rcx
mov    %rcx,0x8(%rbx)
mov    $0x1,%eax
pop    %rbx
ret

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

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