#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 RC {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ rc_encode1(struct RC *, unsigned int *, unsigned int);
void rc_treeout1(struct RC *rc, unsigned int *prb, int len, unsigned int data) {
  int i;
  prb--;
  data |= 1 << len;
  for (i = len; i > 0; i--)
    rc_encode1(rc, &prb[data >> i], (data >> (i - 1)) & 1);
  return;
}


x86 assembly (clang, -O0):
<rc_treeout1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    118c <rc_treeout1+0x7c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shr    %cl,%eax
mov    %eax,%eax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
shr    %cl,%edx
and    $0x1,%edx
call   1030 <rc_encode1@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1148 <rc_treeout1+0x38>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rc_treeout1>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    1157 <rc_treeout1+0x47>
mov    %ecx,%r12d
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
add    $0xfffffffffffffffc,%r14
bts    %edx,%r12d
nop
mov    %r12d,%eax
mov    %ebx,%ecx
shr    %cl,%eax
lea    (%r14,%rax,4),%rsi
lea    -0x1(%rbx),%ebp
mov    %r12d,%edx
mov    %ebp,%ecx
shr    %cl,%edx
and    $0x1,%edx
mov    %r15,%rdi
call   1030 <rc_encode1@plt>
cmp    $0x1,%ebx
mov    %ebp,%ebx
ja     1130 <rc_treeout1+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.RC = type { i32 }
define void @rc_treeout1(%struct.RC* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca %struct.RC*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store %struct.RC* %0, %struct.RC** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32*, i32** %6
%11 = getelementptr inbounds i32, i32* %10, i32 -1
store i32* %11, i32** %6
%12 = load i32, i32* %7
%13 = shl i32 1, %12
%14 = load i32, i32* %8
%15 = or i32 %14, %13
store i32 %15, i32* %8
%16 = load i32, i32* %7
store i32 %16, i32* %9
br label %17
17: ; preds = %34, %4
%18 = load i32, i32* %9
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %37
20: ; preds = %17
%21 = load %struct.RC*, %struct.RC** %5
%22 = load i32*, i32** %6
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = lshr i32 %23, %24
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %22, i64 %26
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = sub nsw i32 %29, 1
%31 = lshr i32 %28, %30
%32 = and i32 %31, 1
%33 = call i32 @rc_encode1(%struct.RC* %21, i32* %27, i32 %32)
br label %34
34: ; preds = %20
%35 = load i32, i32* %9
%36 = add nsw i32 %35, -1
store i32 %36, i32* %9
br label %17
37: ; preds = %17
ret void
}

LLVM IR (-O2):
%struct.RC = type { i32 }
define void @rc_treeout1(%struct.RC* %0, i32* %1, i32 %2, i32 %3) {
%5 = getelementptr inbounds i32, i32* %1, i64 -1
%6 = shl nuw i32 1, %2
%7 = or i32 %6, %3
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %19
9: ; preds = %4, %9
%10 = phi i32 [ %14, %9 ], [ %2, %4 ]
%11 = lshr i32 %7, %10
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %5, i64 %12
%14 = add nsw i32 %10, -1
%15 = lshr i32 %7, %14
%16 = and i32 %15, 1
%17 = tail call i32 @rc_encode1(%struct.RC* %0, i32* %13, i32 %16)
%18 = icmp ugt i32 %10, 1
br i1 %18, label %9, label %19
19: ; preds = %9, %4
ret void
}