#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 uint;

/* Variables and functions */
int /*<<< orphan*/ dub_die(char *);
uint estimate_rice_f_param(uint sum, uint max, uint len) {
  uint f;
  if (!len)
    dub_die("Estimate_rice_f with an empty list");
  sum /= len;
  for (f = 0; (1 << f) <= sum + 0; f++)
    ;
  if ((max >> f) >= 31)
    for (; (max >> f) >= 31; f++)
      ;
  return f;
}


x86 assembly (clang, -O0):
<estimate_rice_f_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1137 <estimate_rice_f_param+0x27>
lea    0xece(%rip),%rdi
call   1030 <dub_die@plt>
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x4(%rbp),%ecx
add    $0x0,%ecx
cmp    %ecx,%eax
jg     1175 <estimate_rice_f_param+0x65>
jmp    1167 <estimate_rice_f_param+0x57>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114a <estimate_rice_f_param+0x3a>
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    %cl,%eax
cmp    $0x1f,%eax
jl     11b4 <estimate_rice_f_param+0xa4>
jmp    118b <estimate_rice_f_param+0x7b>
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    %cl,%eax
cmp    $0x1f,%eax
jl     11af <estimate_rice_f_param+0x9f>
jmp    11a1 <estimate_rice_f_param+0x91>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118b <estimate_rice_f_param+0x7b>
jmp    11b4 <estimate_rice_f_param+0xa4>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<estimate_rice_f_param>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%ebx
mov    %edi,%r14d
test   %edx,%edx
jne    112b <estimate_rice_f_param+0x1b>
lea    0xeda(%rip),%rdi
call   1030 <dub_die@plt>
mov    %r14d,%eax
cltd
idiv   %ebp
mov    $0xfffffffe,%edx
cs nopw 0x0(%rax,%rax,1)
lea    0x2(%rdx),%ecx
mov    $0x1,%esi
shl    %cl,%esi
add    $0x1,%edx
cmp    %eax,%esi
jle    1140 <estimate_rice_f_param+0x30>
lea    0x1(%rdx),%ecx
mov    %ebx,%eax
sar    %cl,%eax
cmp    $0x1f,%eax
jl     116c <estimate_rice_f_param+0x5c>
mov    %edx,%ecx
nop
add    $0x1,%ecx
mov    %ebx,%eax
sar    %cl,%eax
cmp    $0x1e,%eax
jg     1160 <estimate_rice_f_param+0x50>
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Estimate_rice_f with an empty list\00"
define i32 @estimate_rice_f_param(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = call i32 @dub_die(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = sdiv i32 %14, %13
store i32 %15, i32* %4
store i32 0, i32* %7
br label %16
16: ; preds = %23, %12
%17 = load i32, i32* %7
%18 = shl i32 1, %17
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 0
%21 = icmp sle i32 %18, %20
br i1 %21, label %22, label %26
22: ; preds = %16
br label %23
23: ; preds = %22
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %16
26: ; preds = %16
%27 = load i32, i32* %5
%28 = load i32, i32* %7
%29 = ashr i32 %27, %28
%30 = icmp sge i32 %29, 31
br i1 %30, label %31, label %42
31: ; preds = %26
br label %32
32: ; preds = %38, %31
%33 = load i32, i32* %5
%34 = load i32, i32* %7
%35 = ashr i32 %33, %34
%36 = icmp sge i32 %35, 31
br i1 %36, label %37, label %41
37: ; preds = %32
br label %38
38: ; preds = %37
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %32
41: ; preds = %32
br label %42
42: ; preds = %41, %26
%43 = load i32, i32* %7
ret i32 %43
}

LLVM IR (-O2):
@.str = [35 x i8] c"Estimate_rice_f with an empty list\00"
define i32 @estimate_rice_f_param(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @dub_die(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %3
%8 = sdiv i32 %0, %2
br label %9
9: ; preds = %9, %7
%10 = phi i32 [ 0, %7 ], [ %13, %9 ]
%11 = shl nuw i32 1, %10
%12 = icmp sgt i32 %11, %8
%13 = add nuw nsw i32 %10, 1
br i1 %12, label %14, label %9
14: ; preds = %9
%15 = ashr i32 %1, %10
%16 = icmp sgt i32 %15, 30
br i1 %16, label %17, label %22
17: ; preds = %14, %17
%18 = phi i32 [ %21, %17 ], [ %10, %14 ]
%19 = ashr i32 %1, %18
%20 = icmp sgt i32 %19, 30
%21 = add nuw nsw i32 %18, 1
br i1 %20, label %17, label %22
22: ; preds = %17, %14
%23 = phi i32 [ %10, %14 ], [ %18, %17 ]
ret i32 %23
}