#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__ Bitstream_NextStartCode();
int /*<<< orphan*/ Bitstream_PutBits(int, int);
scalar_t__ ceil(int);
int log(double);
int PutVoVolHeader(int vol_width, int vol_height, int time_increment_resolution,
                   float frame_rate) {
  int written = 0;
  int bits, fixed_vop_time_increment;
  Bitstream_PutBits(27, 0x8);
  Bitstream_PutBits(5, 0);
  written += 27 + 5;
  Bitstream_PutBits(28, 0x12);
  Bitstream_PutBits(4, 0);
  written += 28 + 4;
  Bitstream_PutBits(1, 0);
  Bitstream_PutBits(8, 1);
  Bitstream_PutBits(1, 1);
  Bitstream_PutBits(4, 2);
  Bitstream_PutBits(3, 1);
  written += 1 + 8 + 1 + 4 + 3;
  Bitstream_PutBits(4, 1);
  Bitstream_PutBits(1, 0);
  Bitstream_PutBits(2, 0);
  Bitstream_PutBits(1, 1);
  written += 4 + 1 + 2 + 1;
  Bitstream_PutBits(16, time_increment_resolution);
  Bitstream_PutBits(1, 1);
  Bitstream_PutBits(1, 1);
  bits = (int)ceil(log((double)time_increment_resolution) / log(2.0));
  if (bits < 1)
    bits = 1;
  fixed_vop_time_increment =
      (int)(time_increment_resolution / frame_rate + 0.1);
  Bitstream_PutBits(bits, fixed_vop_time_increment);
  Bitstream_PutBits(1, 1);
  written += 16 + 1 + 1 + bits + 1;
  Bitstream_PutBits(13, vol_width);
  Bitstream_PutBits(1, 1);
  Bitstream_PutBits(13, vol_height);
  Bitstream_PutBits(1, 1);
  written += 13 + 1 + 13 + 1;
  Bitstream_PutBits(1, 0);
  Bitstream_PutBits(1, 1);
  Bitstream_PutBits(2, 0);
  Bitstream_PutBits(1, 0);
  written += 1 + 1 + 2 + 1;
  Bitstream_PutBits(1, 0);
  Bitstream_PutBits(1, 0);
  Bitstream_PutBits(1, 1);
  Bitstream_PutBits(1, 1);
  Bitstream_PutBits(1, 0);
  Bitstream_PutBits(1, 0);
  written += 1 + 1 + 1 + 1 + 1 + 1;
  written += Bitstream_NextStartCode();
  return (written);
}


x86 assembly (clang, -O0):
<PutVoVolHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x1b,%edi
mov    $0x8,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x5,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x14(%rbp)
mov    $0x1c,%edi
mov    $0x12,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x14(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x8,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <Bitstream_PutBits@plt>
mov    $0x4,%edi
mov    $0x2,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x3,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    -0x14(%rbp),%eax
add    $0x11,%eax
mov    %eax,-0x14(%rbp)
mov    $0x4,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <Bitstream_PutBits@plt>
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x10,%edi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <Bitstream_PutBits@plt>
cvtsi2sdl -0xc(%rbp),%xmm0
call   1040 <log@plt>
mov    %eax,-0x20(%rbp)
movsd  0xd97(%rip),%xmm0
call   1040 <log@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <ceil@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jge    1291 <PutVoVolHeader+0x151>
movl   $0x1,-0x18(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd61(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <Bitstream_PutBits@plt>
mov    -0x18(%rbp),%eax
add    $0x12,%eax
add    $0x1,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%esi
mov    $0xd,%edi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <Bitstream_PutBits@plt>
mov    -0x8(%rbp),%esi
mov    $0xd,%edi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <Bitstream_PutBits@plt>
mov    -0x14(%rbp),%eax
add    $0x1c,%eax
mov    %eax,-0x14(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <Bitstream_PutBits@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    -0x14(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x14(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    -0x14(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <Bitstream_NextStartCode@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PutVoVolHeader>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movss  %xmm0,0xc(%rsp)
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%r15d
mov    $0x1b,%edi
mov    $0x8,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x5,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1c,%edi
mov    $0x12,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%r12d
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x8,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x4,%edi
mov    $0x2,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x3,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x10,%edi
mov    %ebx,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
cvtsi2sd %ebx,%xmm0
call   1040 <log@plt>
mov    %eax,%ebp
movsd  0xdaf(%rip),%xmm0
call   1040 <log@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <ceil@plt>
mov    %rax,%rbp
test   %ebp,%ebp
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
cmovle %r12d,%ebp
divss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xd82(%rip),%xmm0
cvttsd2si %xmm0,%esi
mov    %ebp,%edi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0xd,%edi
mov    %r15d,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0xd,%edi
mov    %r14d,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <Bitstream_PutBits@plt>
xor    %eax,%eax
call   1050 <Bitstream_NextStartCode@plt>
add    %ebp,%eax
add    $0x93,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @PutVoVolHeader(i32 %0, i32 %1, i32 %2, float %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store float %3, float* %8
store i32 0, i32* %9
%12 = call i32 @Bitstream_PutBits(i32 27, i32 8)
%13 = call i32 @Bitstream_PutBits(i32 5, i32 0)
%14 = load i32, i32* %9
%15 = add nsw i32 %14, 32
store i32 %15, i32* %9
%16 = call i32 @Bitstream_PutBits(i32 28, i32 18)
%17 = call i32 @Bitstream_PutBits(i32 4, i32 0)
%18 = load i32, i32* %9
%19 = add nsw i32 %18, 32
store i32 %19, i32* %9
%20 = call i32 @Bitstream_PutBits(i32 1, i32 0)
%21 = call i32 @Bitstream_PutBits(i32 8, i32 1)
%22 = call i32 @Bitstream_PutBits(i32 1, i32 1)
%23 = call i32 @Bitstream_PutBits(i32 4, i32 2)
%24 = call i32 @Bitstream_PutBits(i32 3, i32 1)
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 17
store i32 %26, i32* %9
%27 = call i32 @Bitstream_PutBits(i32 4, i32 1)
%28 = call i32 @Bitstream_PutBits(i32 1, i32 0)
%29 = call i32 @Bitstream_PutBits(i32 2, i32 0)
%30 = call i32 @Bitstream_PutBits(i32 1, i32 1)
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 8
store i32 %32, i32* %9
%33 = load i32, i32* %7
%34 = call i32 @Bitstream_PutBits(i32 16, i32 %33)
%35 = call i32 @Bitstream_PutBits(i32 1, i32 1)
%36 = call i32 @Bitstream_PutBits(i32 1, i32 1)
%37 = load i32, i32* %7
%38 = sitofp i32 %37 to double
%39 = call i32 @log(double %38)
%40 = call i32 @log(double 2.000000e+00)
%41 = sdiv i32 %39, %40
%42 = call i64 @ceil(i32 %41)
%43 = trunc i64 %42 to i32
store i32 %43, i32* %10
%44 = load i32, i32* %10
%45 = icmp slt i32 %44, 1
br i1 %45, label %46, label %47
46: ; preds = %4
store i32 1, i32* %10
br label %47
47: ; preds = %46, %4
%48 = load i32, i32* %7
%49 = sitofp i32 %48 to float
%50 = load float, float* %8
%51 = fdiv float %49, %50
%52 = fpext float %51 to double
%53 = fadd double %52, 1.000000e-01
%54 = fptosi double %53 to i32
store i32 %54, i32* %11
%55 = load i32, i32* %10
%56 = load i32, i32* %11
%57 = call i32 @Bitstream_PutBits(i32 %55, i32 %56)
%58 = call i32 @Bitstream_PutBits(i32 1, i32 1)
%59 = load i32, i32* %10
%60 = add nsw i32 18, %59
%61 = add nsw i32 %60, 1
%62 = load i32, i32* %9
%63 = add nsw i32 %62, %61
store i32 %63, i32* %9
%64 = load i32, i32* %5
%65 = call i32 @Bitstream_PutBits(i32 13, i32 %64)
%66 = call i32 @Bitstream_PutBits(i32 1, i32 1)
%67 = load i32, i32* %6
%68 = call i32 @Bitstream_PutBits(i32 13, i32 %67)
%69 = call i32 @Bitstream_PutBits(i32 1, i32 1)
%70 = load i32, i32* %9
%71 = add nsw i32 %70, 28
store i32 %71, i32* %9
%72 = call i32 @Bitstream_PutBits(i32 1, i32 0)
%73 = call i32 @Bitstream_PutBits(i32 1, i32 1)
%74 = call i32 @Bitstream_PutBits(i32 2, i32 0)
%75 = call i32 @Bitstream_PutBits(i32 1, i32 0)
%76 = load i32, i32* %9
%77 = add nsw i32 %76, 5
store i32 %77, i32* %9
%78 = call i32 @Bitstream_PutBits(i32 1, i32 0)
%79 = call i32 @Bitstream_PutBits(i32 1, i32 0)
%80 = call i32 @Bitstream_PutBits(i32 1, i32 1)
%81 = call i32 @Bitstream_PutBits(i32 1, i32 1)
%82 = call i32 @Bitstream_PutBits(i32 1, i32 0)
%83 = call i32 @Bitstream_PutBits(i32 1, i32 0)
%84 = load i32, i32* %9
%85 = add nsw i32 %84, 6
store i32 %85, i32* %9
%86 = call i64 (...) @Bitstream_NextStartCode()
%87 = load i32, i32* %9
%88 = sext i32 %87 to i64
%89 = add nsw i64 %88, %86
%90 = trunc i64 %89 to i32
store i32 %90, i32* %9
%91 = load i32, i32* %9
ret i32 %91
}

LLVM IR (-O2):
define i32 @PutVoVolHeader(i32 %0, i32 %1, i32 %2, float %3) {
%5 = tail call i32 @Bitstream_PutBits(i32 27, i32 8)
%6 = tail call i32 @Bitstream_PutBits(i32 5, i32 0)
%7 = tail call i32 @Bitstream_PutBits(i32 28, i32 18)
%8 = tail call i32 @Bitstream_PutBits(i32 4, i32 0)
%9 = tail call i32 @Bitstream_PutBits(i32 1, i32 0)
%10 = tail call i32 @Bitstream_PutBits(i32 8, i32 1)
%11 = tail call i32 @Bitstream_PutBits(i32 1, i32 1)
%12 = tail call i32 @Bitstream_PutBits(i32 4, i32 2)
%13 = tail call i32 @Bitstream_PutBits(i32 3, i32 1)
%14 = tail call i32 @Bitstream_PutBits(i32 4, i32 1)
%15 = tail call i32 @Bitstream_PutBits(i32 1, i32 0)
%16 = tail call i32 @Bitstream_PutBits(i32 2, i32 0)
%17 = tail call i32 @Bitstream_PutBits(i32 1, i32 1)
%18 = tail call i32 @Bitstream_PutBits(i32 16, i32 %2)
%19 = tail call i32 @Bitstream_PutBits(i32 1, i32 1)
%20 = tail call i32 @Bitstream_PutBits(i32 1, i32 1)
%21 = sitofp i32 %2 to double
%22 = tail call i32 @log(double %21)
%23 = tail call i32 @log(double 2.000000e+00)
%24 = sdiv i32 %22, %23
%25 = tail call i64 @ceil(i32 %24)
%26 = trunc i64 %25 to i32
%27 = icmp sgt i32 %26, 1
%28 = select i1 %27, i32 %26, i32 1
%29 = sitofp i32 %2 to float
%30 = fdiv float %29, %3
%31 = fpext float %30 to double
%32 = fadd double %31, 1.000000e-01
%33 = fptosi double %32 to i32
%34 = tail call i32 @Bitstream_PutBits(i32 %28, i32 %33)
%35 = tail call i32 @Bitstream_PutBits(i32 1, i32 1)
%36 = tail call i32 @Bitstream_PutBits(i32 13, i32 %0)
%37 = tail call i32 @Bitstream_PutBits(i32 1, i32 1)
%38 = tail call i32 @Bitstream_PutBits(i32 13, i32 %1)
%39 = tail call i32 @Bitstream_PutBits(i32 1, i32 1)
%40 = tail call i32 @Bitstream_PutBits(i32 1, i32 0)
%41 = tail call i32 @Bitstream_PutBits(i32 1, i32 1)
%42 = tail call i32 @Bitstream_PutBits(i32 2, i32 0)
%43 = tail call i32 @Bitstream_PutBits(i32 1, i32 0)
%44 = tail call i32 @Bitstream_PutBits(i32 1, i32 0)
%45 = tail call i32 @Bitstream_PutBits(i32 1, i32 0)
%46 = tail call i32 @Bitstream_PutBits(i32 1, i32 1)
%47 = tail call i32 @Bitstream_PutBits(i32 1, i32 1)
%48 = tail call i32 @Bitstream_PutBits(i32 1, i32 0)
%49 = tail call i32 @Bitstream_PutBits(i32 1, i32 0)
%50 = add nuw nsw i32 %28, 147
%51 = tail call i64 (...) @Bitstream_NextStartCode()
%52 = trunc i64 %51 to i32
%53 = add i32 %50, %52
ret i32 %53
}