#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__ get_bit(int, int);
int longest_seq(int /*<<< orphan*/);
int /*<<< orphan*/ set_bit(int, int);
int find_seq(int number) {
  if (number == ~0)
    return 32;
  int max_len = 0;
  for (int i = 0; i < 32; i++) {
    if (get_bit(number, i))
      continue;
    int len = longest_seq(set_bit(number, i));
    if (len > max_len) {
      max_len = len;
    }
  }
  return max_len;
}


x86 assembly (clang, -O0):
<find_seq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1151 <find_seq+0x21>
movl   $0x20,-0x4(%rbp)
jmp    11c3 <find_seq+0x93>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x20,-0x10(%rbp)
jge    11bd <find_seq+0x8d>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <get_bit@plt>
cmp    $0x0,%rax
je     1183 <find_seq+0x53>
jmp    11af <find_seq+0x7f>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <set_bit@plt>
mov    %eax,%edi
call   1040 <longest_seq@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11aa <find_seq+0x7a>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11af <find_seq+0x7f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115f <find_seq+0x2f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_seq>:
push   %rbp
push   %r14
push   %rbx
cmp    $0xffffffff,%edi
je     117f <find_seq+0x4f>
mov    %edi,%ebx
xor    %ebp,%ebp
xor    %r14d,%r14d
jmp    1158 <find_seq+0x28>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    $0x20,%ebp
je     1185 <find_seq+0x55>
mov    %ebx,%edi
mov    %ebp,%esi
call   1050 <get_bit@plt>
test   %rax,%rax
jne    1150 <find_seq+0x20>
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <set_bit@plt>
mov    %eax,%edi
call   1040 <longest_seq@plt>
cmp    %r14d,%eax
cmovg  %eax,%r14d
jmp    1150 <find_seq+0x20>
mov    $0x20,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @find_seq(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 32, i32* %2
br label %36
10: ; preds = %1
store i32 0, i32* %4
store i32 0, i32* %5
br label %11
11: ; preds = %31, %10
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 32
br i1 %13, label %14, label %34
14: ; preds = %11
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = call i64 @get_bit(i32 %15, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
br label %31
20: ; preds = %14
%21 = load i32, i32* %3
%22 = load i32, i32* %5
%23 = call i32 @set_bit(i32 %21, i32 %22)
%24 = call i32 @longest_seq(i32 %23)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = load i32, i32* %4
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = load i32, i32* %6
store i32 %29, i32* %4
br label %30
30: ; preds = %28, %20
br label %31
31: ; preds = %30, %19
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %11
34: ; preds = %11
%35 = load i32, i32* %4
store i32 %35, i32* %2
br label %36
36: ; preds = %34, %9
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
define i32 @find_seq(i32 %0) {
%2 = icmp eq i32 %0, -1
br i1 %2, label %17, label %3
3: ; preds = %1, %13
%4 = phi i32 [ %15, %13 ], [ 0, %1 ]
%5 = phi i32 [ %14, %13 ], [ 0, %1 ]
%6 = tail call i64 @get_bit(i32 %0, i32 %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = tail call i32 @set_bit(i32 %0, i32 %4)
%10 = tail call i32 @longest_seq(i32 %9)
%11 = icmp sgt i32 %10, %5
%12 = select i1 %11, i32 %10, i32 %5
br label %13
13: ; preds = %3, %8
%14 = phi i32 [ %5, %3 ], [ %12, %8 ]
%15 = add nuw nsw i32 %4, 1
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %3
17: ; preds = %13, %1
%18 = phi i32 [ 32, %1 ], [ %14, %13 ]
ret i32 %18
}