#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 */

/* Type definitions */
struct cli_val_ieee754 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ cli_val_ieee754_data(struct cli_val_ieee754 *);
size_t cli_val_ieee754_sizeof(struct cli_val_ieee754 *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/, void const *, size_t);
int cli_val_ieee754_parse_binary(struct cli_val_ieee754 *v, const void *b,
                                 size_t length) {
  size_t size = cli_val_ieee754_sizeof(v);
  if (size > length) {
    return 0;
  }
  memcpy(cli_val_ieee754_data(v), b, size);
  return size;
}


x86 assembly (clang, -O0):
<cli_val_ieee754_parse_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <cli_val_ieee754_sizeof@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    116b <cli_val_ieee754_parse_binary+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    118a <cli_val_ieee754_parse_binary+0x5a>
mov    -0x10(%rbp),%rdi
call   1050 <cli_val_ieee754_data@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cli_val_ieee754_parse_binary>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <cli_val_ieee754_sizeof@plt>
mov    %rax,%rbx
xor    %eax,%eax
cmp    %r12,%rbx
ja     1167 <cli_val_ieee754_parse_binary+0x37>
mov    %r15,%rdi
call   1050 <cli_val_ieee754_data@plt>
mov    %eax,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <memcpy@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.cli_val_ieee754 = type { i32 }
define i32 @cli_val_ieee754_parse_binary(%struct.cli_val_ieee754* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca %struct.cli_val_ieee754*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
store %struct.cli_val_ieee754* %0, %struct.cli_val_ieee754** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%9 = load %struct.cli_val_ieee754*, %struct.cli_val_ieee754** %5
%10 = call i64 @cli_val_ieee754_sizeof(%struct.cli_val_ieee754* %9)
store i64 %10, i64* %8
%11 = load i64, i64* %8
%12 = load i64, i64* %7
%13 = icmp ugt i64 %11, %12
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 0, i32* %4
br label %23
15: ; preds = %3
%16 = load %struct.cli_val_ieee754*, %struct.cli_val_ieee754** %5
%17 = call i32 @cli_val_ieee754_data(%struct.cli_val_ieee754* %16)
%18 = load i8*, i8** %6
%19 = load i64, i64* %8
%20 = call i32 @memcpy(i32 %17, i8* %18, i64 %19)
%21 = load i64, i64* %8
%22 = trunc i64 %21 to i32
store i32 %22, i32* %4
br label %23
23: ; preds = %15, %14
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
%struct.cli_val_ieee754 = type { i32 }
define i32 @cli_val_ieee754_parse_binary(%struct.cli_val_ieee754* %0, i8* %1, i64 %2) {
%4 = tail call i64 @cli_val_ieee754_sizeof(%struct.cli_val_ieee754* %0)
%5 = icmp ugt i64 %4, %2
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 @cli_val_ieee754_data(%struct.cli_val_ieee754* %0)
%8 = tail call i32 @memcpy(i32 %7, i8* %1, i64 %4)
%9 = trunc i64 %4 to i32
br label %10
10: ; preds = %3, %6
%11 = phi i32 [ %9, %6 ], [ 0, %3 ]
ret i32 %11
}