#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 /*<<< orphan*/ assert(int);
scalar_t__ fill_word_branchless(int);
scalar_t__ fill_word_naive(int);
void verify() {
  assert(fill_word_branchless(0) == fill_word_naive(0));
  uint32_t bit = 1;
  for (int i = 0; i < 32; i++, bit <<= 1) {
    assert(fill_word_branchless(bit) == fill_word_naive(bit));
  }
}


x86 assembly (clang, -O0):
<verify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %edi,%edi
call   1030 <fill_word_branchless@plt>
mov    %rax,-0x10(%rbp)
xor    %edi,%edi
call   1050 <fill_word_naive@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jge    11bb <verify+0x8b>
mov    -0x4(%rbp),%edi
call   1030 <fill_word_branchless@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <fill_word_naive@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    116f <verify+0x3f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify>:
push   %rbp
push   %r14
push   %rbx
xor    %edi,%edi
call   1030 <fill_word_branchless@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1050 <fill_word_naive@plt>
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1040 <assert@plt>
mov    $0x1,%ebx
mov    $0x20,%ebp
nopl   (%rax)
mov    %ebx,%edi
call   1030 <fill_word_branchless@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1050 <fill_word_naive@plt>
xor    %edi,%edi
cmp    %rax,%r14
sete   %dil
call   1040 <assert@plt>
add    %ebx,%ebx
add    $0xffffffff,%ebp
jne    1160 <verify+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @verify() {
%1 = alloca i32
%2 = alloca i32
%3 = call i64 @fill_word_branchless(i32 0)
%4 = call i64 @fill_word_naive(i32 0)
%5 = icmp eq i64 %3, %4
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
store i32 1, i32* %1
store i32 0, i32* %2
br label %8
8: ; preds = %19, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 32
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = load i32, i32* %1
%13 = call i64 @fill_word_branchless(i32 %12)
%14 = load i32, i32* %1
%15 = call i64 @fill_word_naive(i32 %14)
%16 = icmp eq i64 %13, %15
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
br label %19
19: ; preds = %11
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
%22 = load i32, i32* %1
%23 = shl i32 %22, 1
store i32 %23, i32* %1
br label %8
24: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @verify() {
%1 = tail call i64 @fill_word_branchless(i32 0)
%2 = tail call i64 @fill_word_naive(i32 0)
%3 = icmp eq i64 %1, %2
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
br label %7
6: ; preds = %7
ret void
7: ; preds = %0, %7
%8 = phi i32 [ 0, %0 ], [ %15, %7 ]
%9 = phi i32 [ 1, %0 ], [ %16, %7 ]
%10 = tail call i64 @fill_word_branchless(i32 %9)
%11 = tail call i64 @fill_word_naive(i32 %9)
%12 = icmp eq i64 %10, %11
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = add nuw nsw i32 %8, 1
%16 = shl i32 %9, 1
%17 = icmp eq i32 %15, 32
br i1 %17, label %6, label %7
}