#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 _ilog(int);
int _determine_node_bytes(long used, int leafwidth) {
  if (used < 2)
    return 4;
  if (leafwidth == 3)
    leafwidth = 4;
  if (_ilog(3 * used - 6) + 1 <= leafwidth * 4)
    return leafwidth / 2 ? leafwidth / 2 : 1;
  return leafwidth;
}


x86 assembly (clang, -O0):
<_determine_node_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x2,-0x10(%rbp)
jge    1136 <_determine_node_bytes+0x26>
movl   $0x4,-0x4(%rbp)
jmp    11ad <_determine_node_bytes+0x9d>
cmpl   $0x3,-0x14(%rbp)
jne    1147 <_determine_node_bytes+0x37>
movl   $0x4,-0x14(%rbp)
imul   $0x3,-0x10(%rbp),%rax
sub    $0x6,%rax
mov    %eax,%edi
call   1030 <_ilog@plt>
add    $0x1,%eax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jg     11a7 <_determine_node_bytes+0x97>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     118f <_determine_node_bytes+0x7f>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    119c <_determine_node_bytes+0x8c>
mov    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119c <_determine_node_bytes+0x8c>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ad <_determine_node_bytes+0x9d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_determine_node_bytes>:
push   %rbx
mov    $0x4,%ebx
cmp    $0x2,%rdi
jl     1155 <_determine_node_bytes+0x45>
cmp    $0x3,%esi
mov    $0x4,%ebx
cmovne %esi,%ebx
lea    (%rdi,%rdi,2),%edi
add    $0xfffffffa,%edi
call   1030 <_ilog@plt>
lea    0x0(,%rbx,4),%ecx
cmp    %ecx,%eax
jge    1155 <_determine_node_bytes+0x45>
lea    0x1(%rbx),%ecx
mov    $0x1,%eax
cmp    $0x3,%ecx
jb     1153 <_determine_node_bytes+0x43>
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
mov    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @_determine_node_bytes(i64 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
store i64 %0, i64* %4
store i32 %1, i32* %5
%6 = load i64, i64* %4
%7 = icmp slt i64 %6, 2
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 4, i32* %3
br label %35
9: ; preds = %2
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 3
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 4, i32* %5
br label %13
13: ; preds = %12, %9
%14 = load i64, i64* %4
%15 = mul nsw i64 3, %14
%16 = sub nsw i64 %15, 6
%17 = trunc i64 %16 to i32
%18 = call i32 @_ilog(i32 %17)
%19 = add nsw i32 %18, 1
%20 = load i32, i32* %5
%21 = mul nsw i32 %20, 4
%22 = icmp sle i32 %19, %21
br i1 %22, label %23, label %33
23: ; preds = %13
%24 = load i32, i32* %5
%25 = sdiv i32 %24, 2
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %5
%29 = sdiv i32 %28, 2
br label %31
30: ; preds = %23
br label %31
31: ; preds = %30, %27
%32 = phi i32 [ %29, %27 ], [ 1, %30 ]
store i32 %32, i32* %3
br label %35
33: ; preds = %13
%34 = load i32, i32* %5
store i32 %34, i32* %3
br label %35
35: ; preds = %33, %31, %8
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
define i32 @_determine_node_bytes(i64 %0, i32 %1) {
%3 = icmp slt i64 %0, 2
br i1 %3, label %18, label %4
4: ; preds = %2
%5 = icmp eq i32 %1, 3
%6 = select i1 %5, i32 4, i32 %1
%7 = trunc i64 %0 to i32
%8 = mul i32 %7, 3
%9 = add i32 %8, -6
%10 = tail call i32 @_ilog(i32 %9)
%11 = shl nsw i32 %6, 2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %18
13: ; preds = %4
%14 = add i32 %6, 1
%15 = icmp ult i32 %14, 3
%16 = sdiv i32 %6, 2
%17 = select i1 %15, i32 1, i32 %16
br label %18
18: ; preds = %4, %2, %13
%19 = phi i32 [ %17, %13 ], [ 4, %2 ], [ %6, %4 ]
ret i32 %19
}