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

/* Variables and functions */
int maskContiguous(uint32_t mask) {
  uint32_t m = 0x80000000;
  int zero;
  int i;
  for (i = 0, zero = 0; i < 32; i++, m >>= 1) {
    if (zero == 1 && (m & mask) == 0)
      return 0;
    if ((m & mask) == 1)
      zero = 1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<maskContiguous>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
movl   $0x80000000,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    117d <maskContiguous+0x7d>
cmpl   $0x1,-0x10(%rbp)
jne    114b <maskContiguous+0x4b>
mov    -0xc(%rbp),%eax
and    -0x8(%rbp),%eax
cmp    $0x0,%eax
jne    114b <maskContiguous+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    1184 <maskContiguous+0x84>
mov    -0xc(%rbp),%eax
and    -0x8(%rbp),%eax
cmp    $0x1,%eax
jne    1161 <maskContiguous+0x61>
movl   $0x1,-0x10(%rbp)
jmp    1166 <maskContiguous+0x66>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    111c <maskContiguous+0x1c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<maskContiguous>:
mov    $0x80000000,%edx
xor    %eax,%eax
mov    $0x20,%r8d
xor    %esi,%esi
jmp    112f <maskContiguous+0x2f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x1,%ecx
cmove  %ecx,%esi
sar    $0x2,%edx
add    $0xfffffffe,%r8d
je     1152 <maskContiguous+0x52>
mov    %edx,%ecx
and    %edi,%ecx
cmp    $0x1,%esi
jne    113c <maskContiguous+0x3c>
test   %ecx,%ecx
je     1151 <maskContiguous+0x51>
cmp    $0x1,%ecx
cmove  %ecx,%esi
mov    %edx,%ecx
sar    %ecx
and    %edi,%ecx
cmp    $0x1,%esi
jne    1120 <maskContiguous+0x20>
test   %ecx,%ecx
jne    1120 <maskContiguous+0x20>
ret
mov    $0x1,%eax
ret

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

LLVM IR (-O2):
define i32 @maskContiguous(i32 %0) {
br label %2
2: ; preds = %18, %1
%3 = phi i32 [ 0, %1 ], [ %21, %18 ]
%4 = phi i32 [ 0, %1 ], [ %20, %18 ]
%5 = phi i32 [ -2147483648, %1 ], [ %22, %18 ]
%6 = icmp eq i32 %4, 1
%7 = and i32 %5, %0
%8 = icmp eq i32 %7, 0
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %24, label %10
10: ; preds = %2
%11 = icmp eq i32 %7, 1
%12 = select i1 %11, i32 1, i32 %4
%13 = ashr i32 %5, 1
%14 = icmp eq i32 %12, 1
%15 = and i32 %13, %0
%16 = icmp eq i32 %15, 0
%17 = select i1 %14, i1 %16, i1 false
br i1 %17, label %24, label %18
18: ; preds = %10
%19 = icmp eq i32 %15, 1
%20 = select i1 %19, i32 1, i32 %12
%21 = add nuw nsw i32 %3, 2
%22 = ashr i32 %5, 2
%23 = icmp eq i32 %21, 32
br i1 %23, label %24, label %2
24: ; preds = %18, %10, %2
%25 = phi i32 [ 0, %2 ], [ 0, %10 ], [ 1, %18 ]
ret i32 %25
}