#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*/ test_bitpack_fitss(int, int);
int /*<<< orphan*/ test_bitpack_fitsu(int, int);
int /*<<< orphan*/ test_bitpack_gets(int, int, int, int);
int /*<<< orphan*/ test_bitpack_getu(int, int, int, int);
int /*<<< orphan*/ test_bitpack_sets(unsigned long long, int, int, int, int);
int /*<<< orphan*/ test_bitpack_setu(unsigned long long, int, int, int, int);
int main(void) {
  test_bitpack_fitsu(0, 1);
  test_bitpack_fitsu(-1, 64);
  test_bitpack_fitsu(20, 5);
  test_bitpack_fitsu(20, 4);
  test_bitpack_fitss(-1, 1);
  test_bitpack_fitss(-2, 2);
  test_bitpack_fitss(-2, 1);
  test_bitpack_fitss(-4, 3);
  test_bitpack_fitss(-4, 2);
  test_bitpack_fitss(10, 64);
  test_bitpack_getu(0xE00ull, 9, 3, 7);
  test_bitpack_gets(0xE00ull, 9, 3, -1);
  test_bitpack_setu(0ull, 9, 3, 7, 0xE00ull);
  test_bitpack_sets(0ull, 9, 3, -1, 0xE00ull);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <test_bitpack_fitsu@plt>
mov    $0xffffffff,%edi
mov    $0x40,%esi
call   1050 <test_bitpack_fitsu@plt>
mov    $0x14,%edi
mov    $0x5,%esi
call   1050 <test_bitpack_fitsu@plt>
mov    $0x14,%edi
mov    $0x4,%esi
call   1050 <test_bitpack_fitsu@plt>
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xfffffffe,%edi
mov    $0x2,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xfffffffe,%edi
mov    $0x1,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xfffffffc,%edi
mov    $0x3,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xfffffffc,%edi
mov    $0x2,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xa,%edi
mov    $0x40,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xe00,%edi
mov    $0x9,%esi
mov    $0x3,%edx
mov    $0x7,%ecx
call   1070 <test_bitpack_getu@plt>
mov    $0xe00,%edi
mov    $0x9,%esi
mov    $0x3,%edx
mov    $0xffffffff,%ecx
call   1080 <test_bitpack_gets@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x9,%esi
mov    $0x3,%edx
mov    $0x7,%ecx
mov    $0xe00,%r8d
call   1030 <test_bitpack_setu@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x9,%esi
mov    $0x3,%edx
mov    $0xffffffff,%ecx
mov    $0xe00,%r8d
call   1040 <test_bitpack_sets@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <test_bitpack_fitsu@plt>
mov    $0xffffffff,%edi
mov    $0x40,%esi
call   1050 <test_bitpack_fitsu@plt>
mov    $0x14,%edi
mov    $0x5,%esi
call   1050 <test_bitpack_fitsu@plt>
mov    $0x14,%edi
mov    $0x4,%esi
call   1050 <test_bitpack_fitsu@plt>
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xfffffffe,%edi
mov    $0x2,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xfffffffe,%edi
mov    $0x1,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xfffffffc,%edi
mov    $0x3,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xfffffffc,%edi
mov    $0x2,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xa,%edi
mov    $0x40,%esi
call   1060 <test_bitpack_fitss@plt>
mov    $0xe00,%edi
mov    $0x9,%esi
mov    $0x3,%edx
mov    $0x7,%ecx
call   1070 <test_bitpack_getu@plt>
mov    $0xe00,%edi
mov    $0x9,%esi
mov    $0x3,%edx
mov    $0xffffffff,%ecx
call   1080 <test_bitpack_gets@plt>
xor    %edi,%edi
mov    $0x9,%esi
mov    $0x3,%edx
mov    $0x7,%ecx
mov    $0xe00,%r8d
call   1030 <test_bitpack_setu@plt>
xor    %edi,%edi
mov    $0x9,%esi
mov    $0x3,%edx
mov    $0xffffffff,%ecx
mov    $0xe00,%r8d
call   1040 <test_bitpack_sets@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @test_bitpack_fitsu(i32 0, i32 1)
%3 = call i32 @test_bitpack_fitsu(i32 -1, i32 64)
%4 = call i32 @test_bitpack_fitsu(i32 20, i32 5)
%5 = call i32 @test_bitpack_fitsu(i32 20, i32 4)
%6 = call i32 @test_bitpack_fitss(i32 -1, i32 1)
%7 = call i32 @test_bitpack_fitss(i32 -2, i32 2)
%8 = call i32 @test_bitpack_fitss(i32 -2, i32 1)
%9 = call i32 @test_bitpack_fitss(i32 -4, i32 3)
%10 = call i32 @test_bitpack_fitss(i32 -4, i32 2)
%11 = call i32 @test_bitpack_fitss(i32 10, i32 64)
%12 = call i32 @test_bitpack_getu(i32 3584, i32 9, i32 3, i32 7)
%13 = call i32 @test_bitpack_gets(i32 3584, i32 9, i32 3, i32 -1)
%14 = call i32 @test_bitpack_setu(i64 0, i32 9, i32 3, i32 7, i32 3584)
%15 = call i32 @test_bitpack_sets(i64 0, i32 9, i32 3, i32 -1, i32 3584)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @test_bitpack_fitsu(i32 0, i32 1)
%2 = tail call i32 @test_bitpack_fitsu(i32 -1, i32 64)
%3 = tail call i32 @test_bitpack_fitsu(i32 20, i32 5)
%4 = tail call i32 @test_bitpack_fitsu(i32 20, i32 4)
%5 = tail call i32 @test_bitpack_fitss(i32 -1, i32 1)
%6 = tail call i32 @test_bitpack_fitss(i32 -2, i32 2)
%7 = tail call i32 @test_bitpack_fitss(i32 -2, i32 1)
%8 = tail call i32 @test_bitpack_fitss(i32 -4, i32 3)
%9 = tail call i32 @test_bitpack_fitss(i32 -4, i32 2)
%10 = tail call i32 @test_bitpack_fitss(i32 10, i32 64)
%11 = tail call i32 @test_bitpack_getu(i32 3584, i32 9, i32 3, i32 7)
%12 = tail call i32 @test_bitpack_gets(i32 3584, i32 9, i32 3, i32 -1)
%13 = tail call i32 @test_bitpack_setu(i64 0, i32 9, i32 3, i32 7, i32 3584)
%14 = tail call i32 @test_bitpack_sets(i64 0, i32 9, i32 3, i32 -1, i32 3584)
ret i32 0
}