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

/* Variables and functions */
int /*<<< orphan*/ assert_corr(int /*<<< orphan*/);
scalar_t__ blocksize(struct iam_leaf const *);
scalar_t__ getsize(struct iam_leaf const *, int /*<<< orphan*/,
                   int /*<<< orphan*/);
scalar_t__ h_used(int /*<<< orphan*/);
int /*<<< orphan*/ iam_leaf_is_locked(struct iam_leaf const *);
int /*<<< orphan*/ kchar(struct iam_key const *);
int /*<<< orphan*/ n_head(struct iam_leaf const *);
int /*<<< orphan*/ rec_size(struct iam_rec const *);
int /*<<< orphan*/ strlen(int /*<<< orphan*/);
int lvar_can_add(const struct iam_leaf *l, const struct iam_key *k,
                 const struct iam_rec *r) {
  assert_corr(iam_leaf_is_locked(l));
  return h_used(n_head(l)) + getsize(l, strlen(kchar(k)), rec_size(r)) <=
         blocksize(l);
}


x86 assembly (clang, -O0):
<lvar_can_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <iam_leaf_is_locked@plt>
mov    %eax,%edi
call   1090 <assert_corr@plt>
mov    -0x8(%rbp),%rdi
call   1040 <n_head@plt>
mov    %eax,%edi
call   1050 <h_used@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <kchar@plt>
mov    %eax,%edi
call   1060 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <rec_size@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
call   10a0 <getsize@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   10b0 <blocksize@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
setle  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lvar_can_add>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1080 <iam_leaf_is_locked@plt>
mov    %eax,%edi
call   1090 <assert_corr@plt>
mov    %rbx,%rdi
call   1040 <n_head@plt>
mov    %eax,%edi
call   1050 <h_used@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1070 <kchar@plt>
mov    %eax,%edi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <rec_size@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   10a0 <getsize@plt>
mov    %rax,%rbp
add    %r12,%rbp
mov    %rbx,%rdi
call   10b0 <blocksize@plt>
xor    %ecx,%ecx
cmp    %rax,%rbp
setle  %cl
mov    %ecx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.iam_leaf = type { i32 }
%struct.iam_key = type { i32 }
%struct.iam_rec = type { i32 }
define i32 @lvar_can_add(%struct.iam_leaf* %0, %struct.iam_key* %1, %struct.iam_rec* %2) {
%4 = alloca %struct.iam_leaf*
%5 = alloca %struct.iam_key*
%6 = alloca %struct.iam_rec*
store %struct.iam_leaf* %0, %struct.iam_leaf** %4
store %struct.iam_key* %1, %struct.iam_key** %5
store %struct.iam_rec* %2, %struct.iam_rec** %6
%7 = load %struct.iam_leaf*, %struct.iam_leaf** %4
%8 = call i32 @iam_leaf_is_locked(%struct.iam_leaf* %7)
%9 = call i32 @assert_corr(i32 %8)
%10 = load %struct.iam_leaf*, %struct.iam_leaf** %4
%11 = call i32 @n_head(%struct.iam_leaf* %10)
%12 = call i64 @h_used(i32 %11)
%13 = load %struct.iam_leaf*, %struct.iam_leaf** %4
%14 = load %struct.iam_key*, %struct.iam_key** %5
%15 = call i32 @kchar(%struct.iam_key* %14)
%16 = call i32 @strlen(i32 %15)
%17 = load %struct.iam_rec*, %struct.iam_rec** %6
%18 = call i32 @rec_size(%struct.iam_rec* %17)
%19 = call i64 @getsize(%struct.iam_leaf* %13, i32 %16, i32 %18)
%20 = add nsw i64 %12, %19
%21 = load %struct.iam_leaf*, %struct.iam_leaf** %4
%22 = call i64 @blocksize(%struct.iam_leaf* %21)
%23 = icmp sle i64 %20, %22
%24 = zext i1 %23 to i32
ret i32 %24
}

LLVM IR (-O2):
%struct.iam_leaf = type { i32 }
%struct.iam_key = type { i32 }
%struct.iam_rec = type { i32 }
define i32 @lvar_can_add(%struct.iam_leaf* %0, %struct.iam_key* %1, %struct.iam_rec* %2) {
%4 = tail call i32 @iam_leaf_is_locked(%struct.iam_leaf* %0)
%5 = tail call i32 @assert_corr(i32 %4)
%6 = tail call i32 @n_head(%struct.iam_leaf* %0)
%7 = tail call i64 @h_used(i32 %6)
%8 = tail call i32 @kchar(%struct.iam_key* %1)
%9 = tail call i32 @strlen(i32 %8)
%10 = tail call i32 @rec_size(%struct.iam_rec* %2)
%11 = tail call i64 @getsize(%struct.iam_leaf* %0, i32 %9, i32 %10)
%12 = add nsw i64 %11, %7
%13 = tail call i64 @blocksize(%struct.iam_leaf* %0)
%14 = icmp sle i64 %12, %13
%15 = zext i1 %14 to i32
ret i32 %15
}