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

/* Variables and functions */
struct iam_rec const *e_rec(int /*<<< orphan*/);
int /*<<< orphan*/ memcmp(struct iam_rec const *, struct iam_rec const *,
                          scalar_t__);
int /*<<< orphan*/ n_cur(struct iam_leaf const *);
scalar_t__ rec_size(struct iam_rec const *);
int lvar_rec_eq(const struct iam_leaf *l, const struct iam_rec *r) {
  struct iam_rec *rec = e_rec(n_cur(l));
  if (rec_size(rec) != rec_size(r))
    return 0;
  return !memcmp(rec, r, rec_size(r));
}


x86 assembly (clang, -O0):
<lvar_rec_eq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <n_cur@plt>
mov    %eax,%edi
call   1060 <e_rec@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <rec_size@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <rec_size@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     1196 <lvar_rec_eq+0x56>
movl   $0x0,-0x4(%rbp)
jmp    11cf <lvar_rec_eq+0x8f>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <rec_size@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
call   1050 <memcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lvar_rec_eq>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
call   1040 <n_cur@plt>
mov    %eax,%edi
call   1060 <e_rec@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1030 <rec_size@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <rec_size@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rbx
jne    1193 <lvar_rec_eq+0x53>
mov    %r14,%rdi
call   1030 <rec_size@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1050 <bcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.iam_leaf = type { i32 }
%struct.iam_rec = type opaque
define i32 @lvar_rec_eq(%struct.iam_leaf* %0, %struct.iam_rec* %1) {
%3 = alloca i32
%4 = alloca %struct.iam_leaf*
%5 = alloca %struct.iam_rec*
%6 = alloca %struct.iam_rec*
store %struct.iam_leaf* %0, %struct.iam_leaf** %4
store %struct.iam_rec* %1, %struct.iam_rec** %5
%7 = load %struct.iam_leaf*, %struct.iam_leaf** %4
%8 = call i32 @n_cur(%struct.iam_leaf* %7)
%9 = call %struct.iam_rec* @e_rec(i32 %8)
store %struct.iam_rec* %9, %struct.iam_rec** %6
%10 = load %struct.iam_rec*, %struct.iam_rec** %6
%11 = call i64 @rec_size(%struct.iam_rec* %10)
%12 = load %struct.iam_rec*, %struct.iam_rec** %5
%13 = call i64 @rec_size(%struct.iam_rec* %12)
%14 = icmp ne i64 %11, %13
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 0, i32* %3
br label %25
16: ; preds = %2
%17 = load %struct.iam_rec*, %struct.iam_rec** %6
%18 = load %struct.iam_rec*, %struct.iam_rec** %5
%19 = load %struct.iam_rec*, %struct.iam_rec** %5
%20 = call i64 @rec_size(%struct.iam_rec* %19)
%21 = call i32 @memcmp(%struct.iam_rec* %17, %struct.iam_rec* %18, i64 %20)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
store i32 %24, i32* %3
br label %25
25: ; preds = %16, %15
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
%struct.iam_leaf = type { i32 }
%struct.iam_rec = type opaque
define i32 @lvar_rec_eq(%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 i64 @rec_size(%struct.iam_rec* %4)
%6 = tail call i64 @rec_size(%struct.iam_rec* %1)
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = tail call i64 @rec_size(%struct.iam_rec* %1)
%10 = bitcast %struct.iam_rec* %4 to i8*
%11 = bitcast %struct.iam_rec* %1 to i8*
%12 = tail call i32 @bcmp(i8* %10, i8* %11, i64 %9)
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %2, %8
%16 = phi i32 [ %14, %8 ], [ 0, %2 ]
ret i32 %16
}