#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 int comp_t;

/* Variables and functions */
unsigned long compt2ulong(comp_t comptime) {
  unsigned long val;
  int exp;
  val = comptime & 0x1fff;
  exp = (comptime >> 13) & 7;
  while (exp-- > 0) {
    val *= 8;
  }
  return val;
}


x86 assembly (clang, -O0):
<compt2ulong>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1fff,%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sar    $0xd,%eax
and    $0x7,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    1146 <compt2ulong+0x46>
mov    -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %rax,-0x10(%rbp)
jmp    1121 <compt2ulong+0x21>
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<compt2ulong>:
mov    %edi,%eax
and    $0x1fff,%eax
mov    %edi,%ecx
shr    $0xd,%ecx
and    $0x7,%ecx
je     116a <compt2ulong+0x6a>
cmp    $0x2,%ecx
jb     1131 <compt2ulong+0x31>
lea    -0x3(%rcx),%edx
cmp    $0xfffffffd,%edx
ja     1136 <compt2ulong+0x36>
and    $0xc000,%edi
cmp    $0x4000,%edi
jne    113b <compt2ulong+0x3b>
shl    $0x9,%rax
ret
shl    $0x3,%rax
ret
shl    $0x6,%rax
ret
lea    -0x5(%rcx),%edx
cmp    $0xfffffffd,%edx
ja     1150 <compt2ulong+0x50>
cmp    $0x8000,%edi
jne    1155 <compt2ulong+0x55>
shl    $0xf,%rax
ret
shl    $0xc,%rax
ret
mov    %rax,%rdx
shl    $0x12,%rdx
add    $0xfffffff9,%ecx
shl    $0x15,%rax
cmp    $0xfffffffe,%ecx
cmovae %rdx,%rax
ret

LLVM IR (-O0):
define i64 @compt2ulong(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = and i32 %5, 8191
%7 = sext i32 %6 to i64
store i64 %7, i64* %3
%8 = load i32, i32* %2
%9 = ashr i32 %8, 13
%10 = and i32 %9, 7
store i32 %10, i32* %4
br label %11
11: ; preds = %15, %1
%12 = load i32, i32* %4
%13 = add nsw i32 %12, -1
store i32 %13, i32* %4
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i64, i64* %3
%17 = mul i64 %16, 8
store i64 %17, i64* %3
br label %11
18: ; preds = %11
%19 = load i64, i64* %3
ret i64 %19
}

LLVM IR (-O2):
define i64 @compt2ulong(i32 %0) {
%2 = and i32 %0, 8191
%3 = zext i32 %2 to i64
%4 = lshr i32 %0, 13
%5 = and i32 %4, 7
%6 = icmp eq i32 %5, 0
br i1 %6, label %32, label %7
7: ; preds = %1
%8 = shl nuw nsw i64 %3, 3
%9 = icmp ugt i32 %5, 1
br i1 %9, label %10, label %32
10: ; preds = %7
%11 = shl nuw nsw i64 %3, 6
%12 = add nsw i32 %5, -3
%13 = icmp ult i32 %12, -2
br i1 %13, label %14, label %32
14: ; preds = %10
%15 = shl nuw nsw i64 %3, 9
%16 = and i32 %0, 49152
%17 = icmp eq i32 %16, 16384
br i1 %17, label %32, label %18
18: ; preds = %14
%19 = shl nuw nsw i64 %3, 12
%20 = add nsw i32 %5, -5
%21 = icmp ult i32 %20, -2
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = shl nuw nsw i64 %3, 15
%24 = and i32 %0, 49152
%25 = icmp eq i32 %24, 32768
br i1 %25, label %32, label %26
26: ; preds = %22
%27 = shl nuw nsw i64 %3, 18
%28 = add nsw i32 %5, -7
%29 = icmp ult i32 %28, -2
%30 = shl nuw nsw i64 %3, 21
%31 = select i1 %29, i64 %30, i64 %27
br label %32
32: ; preds = %26, %7, %10, %14, %18, %22, %1
%33 = phi i64 [ %3, %1 ], [ %8, %7 ], [ %11, %10 ], [ %15, %14 ], [ %19, %18 ], [ %23, %22 ], [ %31, %26 ]
ret i64 %33
}