#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 /*<<< 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(char *, size_t, int, int /*<<< orphan*/ *);
bool_t xdrstdio_getbytes(XDR *xdrs, char *addr, u_int len) {
  if ((len != 0) && (fread(addr, (size_t)len, 1, (FILE *)xdrs->x_private) != 1))
    return (FALSE);
  return (TRUE);
}


x86 assembly (clang, -O0):
<xdrstdio_getbytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1162 <xdrstdio_getbytes+0x52>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1162 <xdrstdio_getbytes+0x52>
mov    0x2e80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    116e <xdrstdio_getbytes+0x5e>
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdrstdio_getbytes>:
push   %rax
test   %rdx,%rdx
je     112e <xdrstdio_getbytes+0x1e>
mov    (%rdi),%rcx
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1137 <xdrstdio_getbytes+0x27>
mov    0x2eb3(%rip),%rax
jmp    113e <xdrstdio_getbytes+0x2e>
mov    0x2e9a(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

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

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