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

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/, char const *, scalar_t__);
bool_t xdrmem_putbytes(XDR *xdrs, const char *addr, u_int len) {
  if (xdrs->x_handy < len)
    return (0);
  xdrs->x_handy -= len;
  memcpy(xdrs->x_private, addr, len);
  xdrs->x_private += len;
  return (1);
}


x86 assembly (clang, -O0):
<xdrmem_putbytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmp    -0x20(%rbp),%rax
jge    1141 <xdrmem_putbytes+0x31>
movl   $0x0,-0x4(%rbp)
jmp    117f <xdrmem_putbytes+0x6f>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
sub    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq 0x8(%rax),%rcx
add    %rdx,%rcx
mov    %ecx,0x8(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdrmem_putbytes>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rcx
xor    %eax,%eax
sub    %rdx,%rcx
jl     1138 <xdrmem_putbytes+0x28>
mov    %rdx,%r14
mov    %rdi,%rbx
mov    %rcx,(%rdi)
mov    0x8(%rdi),%edi
call   1030 <memcpy@plt>
add    %r14d,0x8(%rbx)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i32 }
define i32 @xdrmem_putbytes(%struct.TYPE_3__* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_3__*
%6 = alloca i8*
%7 = alloca i64
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%8 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
%10 = load i64, i64* %9
%11 = load i64, i64* %7
%12 = icmp slt i64 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 0, i32* %4
br label %33
14: ; preds = %3
%15 = load i64, i64* %7
%16 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i32 0, i32 0
%18 = load i64, i64* %17
%19 = sub nsw i64 %18, %15
store i64 %19, i64* %17
%20 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%21 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = load i8*, i8** %6
%24 = load i64, i64* %7
%25 = call i32 @memcpy(i32 %22, i8* %23, i64 %24)
%26 = load i64, i64* %7
%27 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%28 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %27, i32 0, i32 1
%29 = load i32, i32* %28
%30 = sext i32 %29 to i64
%31 = add nsw i64 %30, %26
%32 = trunc i64 %31 to i32
store i32 %32, i32* %28
store i32 1, i32* %4
br label %33
33: ; preds = %14, %13
%34 = load i32, i32* %4
ret i32 %34
}

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