#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 iam_rec {
  int dummy;
};
struct iam_leaf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert_corr(int /*<<< orphan*/);
int /*<<< orphan*/ assert_inv(int /*<<< orphan*/);
struct iam_rec *e_rec(int /*<<< orphan*/);
int /*<<< orphan*/ iam_leaf_is_locked(struct iam_leaf const *);
int /*<<< orphan*/ memcpy(struct iam_rec *, struct iam_rec *,
                          int /*<<< orphan*/);
int /*<<< orphan*/ n_at_rec(struct iam_leaf const *);
int /*<<< orphan*/ n_cur(struct iam_leaf const *);
int /*<<< orphan*/ n_invariant(struct iam_leaf const *);
int /*<<< orphan*/ rec_size(struct iam_rec *);
void lvar_rec_get(const struct iam_leaf *l, struct iam_rec *r) {
  struct iam_rec *rec;
  rec = e_rec(n_cur(l));
  assert_corr(n_at_rec(l));
  assert_corr(iam_leaf_is_locked(l));
  memcpy(r, rec, rec_size(rec));
  assert_inv(n_invariant(l));
}


x86 assembly (clang, -O0):
<lvar_rec_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <n_cur@plt>
mov    %eax,%edi
call   10a0 <e_rec@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <n_at_rec@plt>
mov    %eax,%edi
call   1090 <assert_corr@plt>
mov    -0x8(%rbp),%rdi
call   1070 <iam_leaf_is_locked@plt>
mov    %eax,%edi
call   1090 <assert_corr@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <rec_size@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x8(%rbp),%rdi
call   10b0 <n_invariant@plt>
mov    %eax,%edi
call   1080 <assert_inv@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lvar_rec_get>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <n_cur@plt>
mov    %eax,%edi
call   10a0 <e_rec@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1050 <n_at_rec@plt>
mov    %eax,%edi
call   1090 <assert_corr@plt>
mov    %rbx,%rdi
call   1070 <iam_leaf_is_locked@plt>
mov    %eax,%edi
call   1090 <assert_corr@plt>
mov    %r15,%rdi
call   1030 <rec_size@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    %rbx,%rdi
call   10b0 <n_invariant@plt>
mov    %eax,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1080 <assert_inv@plt>

LLVM IR (-O0):
%struct.iam_leaf = type { i32 }
%struct.iam_rec = type { i32 }
define void @lvar_rec_get(%struct.iam_leaf* %0, %struct.iam_rec* %1) {
%3 = alloca %struct.iam_leaf*
%4 = alloca %struct.iam_rec*
%5 = alloca %struct.iam_rec*
store %struct.iam_leaf* %0, %struct.iam_leaf** %3
store %struct.iam_rec* %1, %struct.iam_rec** %4
%6 = load %struct.iam_leaf*, %struct.iam_leaf** %3
%7 = call i32 @n_cur(%struct.iam_leaf* %6)
%8 = call %struct.iam_rec* @e_rec(i32 %7)
store %struct.iam_rec* %8, %struct.iam_rec** %5
%9 = load %struct.iam_leaf*, %struct.iam_leaf** %3
%10 = call i32 @n_at_rec(%struct.iam_leaf* %9)
%11 = call i32 @assert_corr(i32 %10)
%12 = load %struct.iam_leaf*, %struct.iam_leaf** %3
%13 = call i32 @iam_leaf_is_locked(%struct.iam_leaf* %12)
%14 = call i32 @assert_corr(i32 %13)
%15 = load %struct.iam_rec*, %struct.iam_rec** %4
%16 = load %struct.iam_rec*, %struct.iam_rec** %5
%17 = load %struct.iam_rec*, %struct.iam_rec** %5
%18 = call i32 @rec_size(%struct.iam_rec* %17)
%19 = call i32 @memcpy(%struct.iam_rec* %15, %struct.iam_rec* %16, i32 %18)
%20 = load %struct.iam_leaf*, %struct.iam_leaf** %3
%21 = call i32 @n_invariant(%struct.iam_leaf* %20)
%22 = call i32 @assert_inv(i32 %21)
ret void
}

LLVM IR (-O2):
%struct.iam_leaf = type { i32 }
%struct.iam_rec = type { i32 }
define void @lvar_rec_get(%struct.iam_leaf* %0, %struct.iam_rec* %1) {
%3 = tail call i32 @n_cur(%struct.iam_leaf* %0)
%4 = tail call %struct.iam_rec* @e_rec(i32 %3)
%5 = tail call i32 @n_at_rec(%struct.iam_leaf* %0)
%6 = tail call i32 @assert_corr(i32 %5)
%7 = tail call i32 @iam_leaf_is_locked(%struct.iam_leaf* %0)
%8 = tail call i32 @assert_corr(i32 %7)
%9 = tail call i32 @rec_size(%struct.iam_rec* %4)
%10 = tail call i32 @memcpy(%struct.iam_rec* %1, %struct.iam_rec* %4, i32 %9)
%11 = tail call i32 @n_invariant(%struct.iam_leaf* %0)
%12 = tail call i32 @assert_inv(i32 %11)
ret void
}