#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 /*<<< orphan*/ assert(int);
int /*<<< orphan*/ calpriv_fbt_build_subtree(void *, void const *, size_t,
                                             size_t, size_t, int /*<<< orphan*/,
                                             size_t, size_t);
void cal_fbt_build(void *dest, const void *src, size_t count, size_t size,
                   size_t children_per_node) {
  size_t dim = 1;
  assert(children_per_node > 1);
  while (dim <= count) {
    dim *= children_per_node;
  }
  calpriv_fbt_build_subtree(dest, src, count, size, children_per_node, 0,
                            children_per_node - 1, dim);
}


x86 assembly (clang, -O0):
<cal_fbt_build>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x1,-0x30(%rbp)
cmpq   $0x1,-0x28(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     1176 <cal_fbt_build+0x56>
mov    -0x28(%rbp),%rax
imul   -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1156 <cal_fbt_build+0x36>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x28(%rbp),%r10
sub    $0x1,%r10
mov    -0x30(%rbp),%rax
xor    %r9d,%r9d
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <calpriv_fbt_build_subtree@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cal_fbt_build>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r15
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r13
xor    %edi,%edi
cmp    $0x2,%r8
setae  %dil
call   1030 <assert@plt>
mov    $0x1,%eax
test   %rbx,%rbx
je     1169 <cal_fbt_build+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
imul   %r15,%rax
cmp    %rbx,%rax
jbe    1160 <cal_fbt_build+0x40>
lea    -0x1(%r15),%r10
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %r15,%r8
xor    %r9d,%r9d
push   %rax
push   %r10
call   1040 <calpriv_fbt_build_subtree@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @cal_fbt_build(i8* %0, i8* %1, i64 %2, i64 %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i8* %0, i8** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i64 %4, i64* %10
store i64 1, i64* %11
%12 = load i64, i64* %10
%13 = icmp ugt i64 %12, 1
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
br label %16
16: ; preds = %20, %5
%17 = load i64, i64* %11
%18 = load i64, i64* %8
%19 = icmp ule i64 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i64, i64* %10
%22 = load i64, i64* %11
%23 = mul i64 %22, %21
store i64 %23, i64* %11
br label %16
24: ; preds = %16
%25 = load i8*, i8** %6
%26 = load i8*, i8** %7
%27 = load i64, i64* %8
%28 = load i64, i64* %9
%29 = load i64, i64* %10
%30 = load i64, i64* %10
%31 = sub i64 %30, 1
%32 = load i64, i64* %11
%33 = call i32 @calpriv_fbt_build_subtree(i8* %25, i8* %26, i64 %27, i64 %28, i64 %29, i32 0, i64 %31, i64 %32)
ret void
}

LLVM IR (-O2):
define void @cal_fbt_build(i8* %0, i8* %1, i64 %2, i64 %3, i64 %4) {
%6 = icmp ugt i64 %4, 1
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = icmp eq i64 %2, 0
br i1 %9, label %14, label %10
10: ; preds = %5, %10
%11 = phi i64 [ %12, %10 ], [ 1, %5 ]
%12 = mul i64 %11, %4
%13 = icmp ugt i64 %12, %2
br i1 %13, label %14, label %10
14: ; preds = %10, %5
%15 = phi i64 [ 1, %5 ], [ %12, %10 ]
%16 = add i64 %4, -1
%17 = tail call i32 @calpriv_fbt_build_subtree(i8* %0, i8* %1, i64 %2, i64 %3, i64 %4, i32 0, i64 %16, i64 %15)
ret void
}