#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 scalar_t__ uint32_t;

/* Variables and functions */
int fls(scalar_t__);
__attribute__((always_)) int bigint_max_set_bit_raw(const uint32_t *value0,
                                                    unsigned int size) {
  const uint32_t *value = (value0 + size);
  int max_bit = (8 * sizeof(bigint_t(size)));
  uint32_t value_i;
  do {
    value_i = *(--value);
    max_bit -= (32 - fls(value_i));
    if (value_i)
      break;
  } while (--size);
  return max_bit;
}


x86 assembly (clang, -O0):
<bigint_max_set_bit_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
movl   $0x20,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <fls@plt>
mov    $0x20,%ecx
sub    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1177 <bigint_max_set_bit_raw+0x67>
jmp    118e <bigint_max_set_bit_raw+0x7e>
jmp    117c <bigint_max_set_bit_raw+0x6c>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jne    1138 <bigint_max_set_bit_raw+0x28>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bigint_max_set_bit_raw>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %esi,%r12d
mov    $0x20,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    -0x8(%r14,%r12,8),%r15
mov    %r15,%rdi
call   1030 <fls@plt>
add    %eax,%ebx
add    $0xffffffe0,%ebx
test   %r15,%r15
jne    1155 <bigint_max_set_bit_raw+0x45>
lea    -0x1(%r12),%rax
cmp    $0x1,%r12d
mov    %rax,%r12
jne    1130 <bigint_max_set_bit_raw+0x20>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @bigint_max_set_bit_raw(i64* %0, i32 %1) {
%3 = alloca i64*
%4 = alloca i32
%5 = alloca i64*
%6 = alloca i32
%7 = alloca i64
store i64* %0, i64** %3
store i32 %1, i32* %4
%8 = load i64*, i64** %3
%9 = load i32, i32* %4
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i64, i64* %8, i64 %10
store i64* %11, i64** %5
store i32 32, i32* %6
br label %12
12: ; preds = %25, %2
%13 = load i64*, i64** %5
%14 = getelementptr inbounds i64, i64* %13, i32 -1
store i64* %14, i64** %5
%15 = load i64, i64* %14
store i64 %15, i64* %7
%16 = load i64, i64* %7
%17 = call i32 @fls(i64 %16)
%18 = sub nsw i32 32, %17
%19 = load i32, i32* %6
%20 = sub nsw i32 %19, %18
store i32 %20, i32* %6
%21 = load i64, i64* %7
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %12
br label %29
24: ; preds = %12
br label %25
25: ; preds = %24
%26 = load i32, i32* %4
%27 = add i32 %26, -1
store i32 %27, i32* %4
%28 = icmp ne i32 %27, 0
br i1 %28, label %12, label %29
29: ; preds = %25, %23
%30 = load i32, i32* %6
ret i32 %30
}

LLVM IR (-O2):
define i32 @bigint_max_set_bit_raw(i64* nocapture %0, i32 %1) {
%3 = zext i32 %1 to i64
%4 = getelementptr inbounds i64, i64* %0, i64 %3
br label %5
5: ; preds = %5, %2
%6 = phi i64* [ %4, %2 ], [ %9, %5 ]
%7 = phi i32 [ 32, %2 ], [ %13, %5 ]
%8 = phi i32 [ %1, %2 ], [ %15, %5 ]
%9 = getelementptr inbounds i64, i64* %6, i64 -1
%10 = load i64, i64* %9
%11 = tail call i32 @fls(i64 %10)
%12 = add i32 %7, -32
%13 = add i32 %12, %11
%14 = icmp ne i64 %10, 0
%15 = add i32 %8, -1
%16 = icmp eq i32 %15, 0
%17 = select i1 %14, i1 true, i1 %16
br i1 %17, label %18, label %5
18: ; preds = %5
ret i32 %13
}