#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_address {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ cli_val_address_data(struct cli_val_address *);
size_t cli_val_address_sizeof();
int /*<<< orphan*/ memcpy(int /*<<< orphan*/, void const *, size_t);
int cli_val_address_parse_binary(struct cli_val_address *v, const void *b,
                                 size_t length) {
  size_t size = cli_val_address_sizeof();
  if (size > length) {
    return 0;
  }
  memcpy(cli_val_address_data(v), b, size);
  return size;
}


x86 assembly (clang, -O0):
<cli_val_address_parse_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x0,%al
call   1050 <cli_val_address_sizeof@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    1169 <cli_val_address_parse_binary+0x39>
movl   $0x0,-0x4(%rbp)
jmp    1188 <cli_val_address_parse_binary+0x58>
mov    -0x10(%rbp),%rdi
call   1030 <cli_val_address_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_address_parse_binary>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <cli_val_address_sizeof@plt>
cmp    %r12,%rax
ja     1169 <cli_val_address_parse_binary+0x39>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <cli_val_address_data@plt>
mov    %eax,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <memcpy@plt>
mov    %ebx,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.cli_val_address = type { i32 }
define i32 @cli_val_address_parse_binary(%struct.cli_val_address* %0, i8* %1, i64 %2) {
%4 = tail call i64 (...) @cli_val_address_sizeof()
%5 = icmp ugt i64 %4, %2
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 @cli_val_address_data(%struct.cli_val_address* %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
}