#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 /*<<< orphan*/ v;
typedef int uint8_t;
typedef int uint32_t;

/* Variables and functions */
int get_bit(int *, int);
int get_exp_golomb(int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int mp4tree_selftest() {
  uint32_t t1 = 0xffffffff;
  uint32_t bit = 0;
  uint8_t v[] = {
      0x80, 0x40, 0x60, 0x20, 0x28, 0x30, 0x38, 0x10, 0x12,
  };
  int i;
  for (i = 0; i < 32; i++) {
    if (get_bit((uint8_t *)&t1, i) != 1) {
      printf("Failed 1\n");
      return -1;
    }
  }
  for (i = 0; i < sizeof(v) / sizeof(v[0]); i++) {
    printf("%x -> %u\n", i, get_exp_golomb(&v[i], &bit));
    printf("bit = %u\n", bit);
    bit = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<mp4tree_selftest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0xffffffff,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x20,-0x34(%rbp)
jge    11be <mp4tree_selftest+0x7e>
mov    -0x34(%rbp),%esi
lea    -0x8(%rbp),%rdi
call   1060 <get_bit@plt>
cmp    $0x1,%eax
je     11ab <mp4tree_selftest+0x6b>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1231 <mp4tree_selftest+0xf1>
jmp    11b0 <mp4tree_selftest+0x70>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1172 <mp4tree_selftest+0x32>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    $0x9,%rax
jae    122a <mp4tree_selftest+0xea>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
lea    -0xc(%rbp),%rsi
call   1030 <get_exp_golomb@plt>
mov    -0x38(%rbp),%esi
mov    %eax,%edx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11c5 <mp4tree_selftest+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp4tree_selftest>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
movl   $0xffffffff,0xc(%rsp)
ff
movl   $0x0,0x8(%rsp)
mov    0xec0(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xea5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe89(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xor    %ebx,%ebx
lea    0xc(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
mov    %ebx,%esi
call   1060 <get_bit@plt>
cmp    $0x1,%eax
jne    138c <mp4tree_selftest+0x24c>
add    $0x1,%ebx
cmp    $0x20,%ebx
jne    1190 <mp4tree_selftest+0x50>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%r15
mov    %r15,%rsi
call   1030 <get_exp_golomb@plt>
lea    0xe60(%rip),%rbp
xor    %r14d,%r14d
mov    %rbp,%rdi
xor    %esi,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xe4e(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x0,0x8(%rsp)
lea    0x14(%rsp),%rdi
mov    %r15,%rsi
call   1030 <get_exp_golomb@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x0,0x8(%rsp)
lea    0x18(%rsp),%rdi
mov    %r15,%rsi
call   1030 <get_exp_golomb@plt>
mov    %rbp,%rdi
mov    $0x2,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x0,0x8(%rsp)
lea    0x1c(%rsp),%rdi
mov    %r15,%rsi
call   1030 <get_exp_golomb@plt>
mov    %rbp,%rdi
mov    $0x3,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x0,0x8(%rsp)
lea    0x20(%rsp),%rdi
mov    %r15,%rsi
call   1030 <get_exp_golomb@plt>
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x0,0x8(%rsp)
lea    0x24(%rsp),%rdi
mov    %r15,%rsi
call   1030 <get_exp_golomb@plt>
mov    %rbp,%rdi
mov    $0x5,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x0,0x8(%rsp)
lea    0x28(%rsp),%rdi
mov    %r15,%rsi
call   1030 <get_exp_golomb@plt>
mov    %rbp,%rdi
mov    $0x6,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x0,0x8(%rsp)
lea    0x2c(%rsp),%rdi
mov    %r15,%rsi
call   1030 <get_exp_golomb@plt>
mov    %rbp,%rdi
mov    $0x7,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x0,0x8(%rsp)
lea    0x30(%rsp),%rdi
mov    %r15,%rsi
call   1030 <get_exp_golomb@plt>
mov    %rbp,%rdi
mov    $0x8,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    139e <mp4tree_selftest+0x25e>
lea    0xca5(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.mp4tree_selftest.v = [9 x i32] [i32 128, i32 64, i32 96, i32 32, i32 40, i32 48, i32 56, i32 16, i32 18]
@.str = [10 x i8] c"Failed 1\0A\00"
@.str.1 = [10 x i8] c"%x -> %u\0A\00"
@.str.2 = [10 x i8] c"bit = %u\0A\00"
define i32 @mp4tree_selftest() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [9 x i32]
%5 = alloca i32
store i32 -1, i32* %2
store i32 0, i32* %3
%6 = bitcast [9 x i32]* %4 to i8*
store i32 0, i32* %5
br label %7
7: ; preds = %17, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 32
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32, i32* %5
%12 = call i32 @get_bit(i32* %2, i32 %11)
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %38
16: ; preds = %10
br label %17
17: ; preds = %16
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %7
20: ; preds = %7
store i32 0, i32* %5
br label %21
21: ; preds = %34, %20
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = icmp ult i64 %23, 9
br i1 %24, label %25, label %37
25: ; preds = %21
%26 = load i32, i32* %5
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 %28
%30 = call i32 @get_exp_golomb(i32* %29, i32* %3)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %30)
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %32)
store i32 0, i32* %3
br label %34
34: ; preds = %25
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %21
37: ; preds = %21
store i32 0, i32* %1
br label %38
38: ; preds = %37, %14
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@__const.mp4tree_selftest.v = [9 x i32] [i32 128, i32 64, i32 96, i32 32, i32 40, i32 48, i32 56, i32 16, i32 18]
@.str.1 = [10 x i8] c"%x -> %u\0A\00"
@.str.2 = [10 x i8] c"bit = %u\0A\00"
@str = [9 x i8] c"Failed 1\00"
define i32 @mp4tree_selftest() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [9 x i32]
%4 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast [9 x i32]* %3 to i8*
br label %56
7: ; preds = %56
%8 = add nuw nsw i32 %57, 1
%9 = icmp eq i32 %8, 32
br i1 %9, label %10, label %56
10: ; preds = %7
%11 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 0
%12 = call i32 @get_exp_golomb(i32* %11, i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %12)
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %14)
store i32 0, i32* %2
%16 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 1
%17 = call i32 @get_exp_golomb(i32* %16, i32* %2)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %17)
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %19)
store i32 0, i32* %2
%21 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 2
%22 = call i32 @get_exp_golomb(i32* %21, i32* %2)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %22)
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %24)
store i32 0, i32* %2
%26 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 3
%27 = call i32 @get_exp_golomb(i32* %26, i32* %2)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %27)
%29 = load i32, i32* %2
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %29)
store i32 0, i32* %2
%31 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 4
%32 = call i32 @get_exp_golomb(i32* %31, i32* %2)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %32)
%34 = load i32, i32* %2
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %34)
store i32 0, i32* %2
%36 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 5
%37 = call i32 @get_exp_golomb(i32* %36, i32* %2)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %37)
%39 = load i32, i32* %2
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %39)
store i32 0, i32* %2
%41 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 6
%42 = call i32 @get_exp_golomb(i32* %41, i32* %2)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %42)
%44 = load i32, i32* %2
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %44)
store i32 0, i32* %2
%46 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 7
%47 = call i32 @get_exp_golomb(i32* %46, i32* %2)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 7, i32 %47)
%49 = load i32, i32* %2
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %49)
store i32 0, i32* %2
%51 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 8
%52 = call i32 @get_exp_golomb(i32* %51, i32* %2)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 8, i32 %52)
%54 = load i32, i32* %2
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %54)
br label %62
56: ; preds = %0, %7
%57 = phi i32 [ 0, %0 ], [ %8, %7 ]
%58 = call i32 @get_bit(i32* %1, i32 %57)
%59 = icmp eq i32 %58, 1
br i1 %59, label %7, label %60
60: ; preds = %56
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %62
62: ; preds = %10, %60
%63 = phi i32 [ -1, %60 ], [ 0, %10 ]
ret i32 %63
}