#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 */
scalar_t__ div64_64(unsigned long long, unsigned long long);
unsigned long fls64(unsigned long long);
unsigned long cubic_root(unsigned long long a) {
  unsigned long x, b, shift;
  static const unsigned char v[] = {
      0,   54,  54,  54,  118, 118, 118, 118, 123, 129, 134, 138, 143,
      147, 151, 156, 157, 161, 164, 168, 170, 173, 176, 179, 181, 185,
      187, 190, 192, 194, 197, 199, 200, 202, 204, 206, 209, 211, 213,
      215, 217, 219, 221, 222, 224, 225, 227, 229, 231, 232, 234, 236,
      237, 239, 240, 242, 244, 245, 246, 248, 250, 251, 252, 254,
  };
  b = fls64(a);
  if (b < 7) {
    return ((unsigned long)v[(unsigned long)a] + 35) >> 6;
  }
  b = ((b * 84) >> 8) - 1;
  shift = (a >> (b * 3));
  x = ((unsigned long)(((unsigned long)v[shift] + 10) << b)) >> 6;
  x = (2 * x + (unsigned long)div64_64(a, (unsigned long long)x *
                                              (unsigned long long)(x - 1)));
  x = ((x * 341) >> 10);
  return x;
}


x86 assembly (clang, -O0):
<cubic_root>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fls64@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x7,-0x20(%rbp)
jae    1164 <cubic_root+0x44>
mov    -0x10(%rbp),%rcx
lea    0xeb1(%rip),%rax
movzbl (%rax,%rcx,1),%eax
add    $0x23,%rax
shr    $0x6,%rax
mov    %rax,-0x8(%rbp)
jmp    11f2 <cubic_root+0xd2>
imul   $0x54,-0x20(%rbp),%rax
shr    $0x8,%rax
sub    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3,-0x20(%rbp),%rcx
shr    %cl,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
lea    0xe70(%rip),%rax
movzbl (%rax,%rcx,1),%eax
add    $0xa,%rax
mov    -0x20(%rbp),%rcx
shl    %cl,%rax
shr    $0x6,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
imul   %rax,%rsi
call   1030 <div64_64@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
imul   $0x155,-0x18(%rbp),%rax
shr    $0xa,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cubic_root>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <fls64@plt>
cmp    $0x6,%rax
ja     1148 <cubic_root+0x28>
lea    0xec7(%rip),%rax
movzbl (%r14,%rax,1),%eax
add    $0x23,%rax
shr    $0x6,%rax
jmp    1194 <cubic_root+0x74>
imul   $0x54,%rax,%rax
shr    $0x8,%rax
add    $0xffffffffffffffff,%rax
lea    (%rax,%rax,2),%ecx
mov    %r14,%rdx
shr    %cl,%rdx
lea    0xe9c(%rip),%rcx
movzbl (%rdx,%rcx,1),%ebx
add    $0xa,%rbx
mov    %eax,%ecx
shl    %cl,%rbx
shr    $0x6,%rbx
lea    -0x1(%rbx),%rsi
imul   %rbx,%rsi
mov    %r14,%rdi
call   1030 <div64_64@plt>
lea    (%rax,%rbx,2),%rax
imul   $0x155,%rax,%rax
shr    $0xa,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@cubic_root.v = internal constant [64 x i8] c"\00666vvvv{\81\86\8A\8F\93\97\9C\9D\A1\A4\A8\AA\AD\B0\B3\B5\B9\BB\BE\C0\C2\C5\C7\C8\CA\CC\CE\D1\D3\D5\D7\D9\DB\DD\DE\E0\E1\E3\E5\E7\E8\EA\EC\ED\EF\F0\F2\F4\F5\F6\F8\FA\FB\FC\FE"
define i64 @cubic_root(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %3
%7 = load i64, i64* %3
%8 = call i64 @fls64(i64 %7)
store i64 %8, i64* %5
%9 = load i64, i64* %5
%10 = icmp ult i64 %9, 7
br i1 %10, label %11, label %18
11: ; preds = %1
%12 = load i64, i64* %3
%13 = getelementptr inbounds [64 x i8], [64 x i8]* @cubic_root.v, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i64
%16 = add i64 %15, 35
%17 = lshr i64 %16, 6
store i64 %17, i64* %2
br label %48
18: ; preds = %1
%19 = load i64, i64* %5
%20 = mul i64 %19, 84
%21 = lshr i64 %20, 8
%22 = sub i64 %21, 1
store i64 %22, i64* %5
%23 = load i64, i64* %3
%24 = load i64, i64* %5
%25 = mul i64 %24, 3
%26 = lshr i64 %23, %25
store i64 %26, i64* %6
%27 = load i64, i64* %6
%28 = getelementptr inbounds [64 x i8], [64 x i8]* @cubic_root.v, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = zext i8 %29 to i64
%31 = add i64 %30, 10
%32 = load i64, i64* %5
%33 = shl i64 %31, %32
%34 = lshr i64 %33, 6
store i64 %34, i64* %4
%35 = load i64, i64* %4
%36 = mul i64 2, %35
%37 = load i64, i64* %3
%38 = load i64, i64* %4
%39 = load i64, i64* %4
%40 = sub i64 %39, 1
%41 = mul i64 %38, %40
%42 = call i64 @div64_64(i64 %37, i64 %41)
%43 = add i64 %36, %42
store i64 %43, i64* %4
%44 = load i64, i64* %4
%45 = mul i64 %44, 341
%46 = lshr i64 %45, 10
store i64 %46, i64* %4
%47 = load i64, i64* %4
store i64 %47, i64* %2
br label %48
48: ; preds = %18, %11
%49 = load i64, i64* %2
ret i64 %49
}

LLVM IR (-O2):
@cubic_root.v = internal unnamed_addr constant [64 x i8] c"\00666vvvv{\81\86\8A\8F\93\97\9C\9D\A1\A4\A8\AA\AD\B0\B3\B5\B9\BB\BE\C0\C2\C5\C7\C8\CA\CC\CE\D1\D3\D5\D7\D9\DB\DD\DE\E0\E1\E3\E5\E7\E8\EA\EC\ED\EF\F0\F2\F4\F5\F6\F8\FA\FB\FC\FE"
define i64 @cubic_root(i64 %0) {
%2 = tail call i64 @fls64(i64 %0)
%3 = icmp ult i64 %2, 7
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = getelementptr inbounds [64 x i8], [64 x i8]* @cubic_root.v, i64 0, i64 %0
%6 = load i8, i8* %5
%7 = zext i8 %6 to i64
%8 = add nuw nsw i64 %7, 35
%9 = lshr i64 %8, 6
br label %29
10: ; preds = %1
%11 = mul i64 %2, 84
%12 = lshr i64 %11, 8
%13 = add nsw i64 %12, -1
%14 = mul nsw i64 %13, 3
%15 = lshr i64 %0, %14
%16 = getelementptr inbounds [64 x i8], [64 x i8]* @cubic_root.v, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i64
%19 = add nuw nsw i64 %18, 10
%20 = shl i64 %19, %13
%21 = lshr i64 %20, 6
%22 = shl nuw nsw i64 %21, 1
%23 = add nsw i64 %21, -1
%24 = mul i64 %23, %21
%25 = tail call i64 @div64_64(i64 %0, i64 %24)
%26 = add i64 %22, %25
%27 = mul i64 %26, 341
%28 = lshr i64 %27, 10
br label %29
29: ; preds = %10, %4
%30 = phi i64 [ %9, %4 ], [ %28, %10 ]
ret i64 %30
}