#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 */
int first_leading_bit(int *, unsigned int);
int /*<<< orphan*/ printf(char *, int, unsigned int, ...);
void run_test(unsigned int mask) {
  int index;
  int rc;
  rc = first_leading_bit(&index, mask);
  if (rc)
    printf("rc: %d  mask: %08x  index: %d\n", rc, mask, index);
  else
    printf("rc: %d  mask: %08x  index: --\n", rc, mask);
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    -0x8(%rbp),%rdi
call   1030 <first_leading_bit@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1160 <run_test+0x40>
mov    -0xc(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1174 <run_test+0x54>
mov    -0xc(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xc(%rsp),%rdi
mov    %ebx,%esi
call   1030 <first_leading_bit@plt>
test   %eax,%eax
je     114f <run_test+0x2f>
mov    0xc(%rsp),%ecx
lea    0xebe(%rip),%rdi
mov    %eax,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1161 <run_test+0x41>
lea    0xec9(%rip),%rdi
xor    %esi,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"rc: %d mask: %08x index: %d\0A\00"
@.str.1 = [31 x i8] c"rc: %d mask: %08x index: --\0A\00"
define void @run_test(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @first_leading_bit(i32* %3, i32 %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i32, i32* %4
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i32 %12)
br label %18
14: ; preds = %1
%15 = load i32, i32* %4
%16 = load i32, i32* %2
%17 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16)
br label %18
18: ; preds = %14, %9
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"rc: %d mask: %08x index: %d\0A\00"
@.str.1 = [31 x i8] c"rc: %d mask: %08x index: --\0A\00"
define void @run_test(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @first_leading_bit(i32* %2, i32 %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* %2
%8 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %0, i32 %7)
br label %11
9: ; preds = %1
%10 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %0)
br label %11
11: ; preds = %9, %6
ret void
}