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

/* Variables and functions */
int Get_value_ptr(void *, char const *, void **);
int Get_var_nbytes(void *, char const *, int *);
int /*<<< orphan*/ memcpy(void *, void *, int);
int Get_value(void *self, const char *name, void *dest) {
  int status = (0);
  void *src = NULL;
  int nbytes = 0;
  status = Get_value_ptr(self, name, &src);
  if (status == (1))
    return status;
  status = Get_var_nbytes(self, name, &nbytes);
  if (status == (1))
    return status;
  memcpy(dest, src, nbytes);
  return status;
}


x86 assembly (clang, -O0):
<Get_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <Get_value_ptr@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    1183 <Get_value+0x53>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <Get_value+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   1050 <Get_var_nbytes@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    11ac <Get_value+0x7c>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <Get_value+0x92>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Get_value>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
movq   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdx
call   1040 <Get_value_ptr@plt>
mov    $0x1,%r15d
cmp    $0x1,%eax
je     1194 <Get_value+0x64>
lea    0xc(%rsp),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <Get_var_nbytes@plt>
cmp    $0x1,%eax
je     1194 <Get_value+0x64>
mov    %eax,%ebx
mov    0x10(%rsp),%rsi
mov    0xc(%rsp),%edx
mov    %r14,%rdi
call   1030 <memcpy@plt>
mov    %ebx,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @Get_value(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %8
store i8* null, i8** %9
store i32 0, i32* %10
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = call i32 @Get_value_ptr(i8* %11, i8* %12, i8** %9)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load i32, i32* %8
store i32 %17, i32* %4
br label %32
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = call i32 @Get_var_nbytes(i8* %19, i8* %20, i32* %10)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = load i32, i32* %8
store i32 %25, i32* %4
br label %32
26: ; preds = %18
%27 = load i8*, i8** %7
%28 = load i8*, i8** %9
%29 = load i32, i32* %10
%30 = call i32 @memcpy(i8* %27, i8* %28, i32 %29)
%31 = load i32, i32* %8
store i32 %31, i32* %4
br label %32
32: ; preds = %26, %24, %16
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
define i32 @Get_value(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%8 = call i32 @Get_value_ptr(i8* %0, i8* %1, i8** %4)
%9 = icmp eq i32 %8, 1
br i1 %9, label %17, label %10
10: ; preds = %3
%11 = call i32 @Get_var_nbytes(i8* %0, i8* %1, i32* %5)
%12 = icmp eq i32 %11, 1
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = load i32, i32* %5
%16 = call i32 @memcpy(i8* %2, i8* %14, i32 %15)
br label %17
17: ; preds = %10, %3, %13
%18 = phi i32 [ %11, %13 ], [ 1, %3 ], [ 1, %10 ]
ret i32 %18
}