#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 */
struct aom_write_bit_buffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ aom_wb_overwrite_bit(struct aom_write_bit_buffer *, int);
void aom_wb_overwrite_literal(struct aom_write_bit_buffer *wb, int data,
                              int bits) {
  int bit;
  for (bit = bits - 1; bit >= 0; bit--)
    aom_wb_overwrite_bit(wb, (data >> bit) & 1);
}


x86 assembly (clang, -O0):
<aom_wb_overwrite_literal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1157 <aom_wb_overwrite_literal+0x47>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%ecx
sar    %cl,%esi
and    $0x1,%esi
call   1030 <aom_wb_overwrite_bit@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    112b <aom_wb_overwrite_literal+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aom_wb_overwrite_literal>:
push   %rbp
push   %r14
push   %rbx
test   %edx,%edx
jle    114b <aom_wb_overwrite_literal+0x3b>
mov    %edx,%ebx
mov    %esi,%r14d
mov    %rdi,%rbp
add    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x2(%rbx),%ecx
mov    %r14d,%esi
shr    %cl,%esi
and    $0x1,%esi
mov    %rbp,%rdi
call   1030 <aom_wb_overwrite_bit@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1130 <aom_wb_overwrite_literal+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.aom_write_bit_buffer = type { i32 }
define void @aom_wb_overwrite_literal(%struct.aom_write_bit_buffer* %0, i32 %1, i32 %2) {
%4 = alloca %struct.aom_write_bit_buffer*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store %struct.aom_write_bit_buffer* %0, %struct.aom_write_bit_buffer** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = sub nsw i32 %8, 1
store i32 %9, i32* %7
br label %10
10: ; preds = %20, %3
%11 = load i32, i32* %7
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load %struct.aom_write_bit_buffer*, %struct.aom_write_bit_buffer** %4
%15 = load i32, i32* %5
%16 = load i32, i32* %7
%17 = ashr i32 %15, %16
%18 = and i32 %17, 1
%19 = call i32 @aom_wb_overwrite_bit(%struct.aom_write_bit_buffer* %14, i32 %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %7
%22 = add nsw i32 %21, -1
store i32 %22, i32* %7
br label %10
23: ; preds = %10
ret void
}

LLVM IR (-O2):
%struct.aom_write_bit_buffer = type { i32 }
define void @aom_wb_overwrite_literal(%struct.aom_write_bit_buffer* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %12
5: ; preds = %3, %5
%6 = phi i32 [ %7, %5 ], [ %2, %3 ]
%7 = add nsw i32 %6, -1
%8 = lshr i32 %1, %7
%9 = and i32 %8, 1
%10 = tail call i32 @aom_wb_overwrite_bit(%struct.aom_write_bit_buffer* %0, i32 %9)
%11 = icmp ugt i32 %6, 1
br i1 %11, label %5, label %12
12: ; preds = %5, %3
ret void
}