#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 */
unsigned int rcb_fast_circular_shift_right(unsigned int, unsigned int);
unsigned int rcb_fast_get_one_bits(int);
unsigned rcb_fast_generate(unsigned val) {
  unsigned tmp =
      ((val +
        ((val & rcb_fast_get_one_bits((sizeof(unsigned) * 8) / 2 - 1)) << 1)) %
       ((sizeof(unsigned) * 8) - 1)) |
      1;
  val ^= rcb_fast_circular_shift_right(val, (unsigned)1);
  val ^= val >> sizeof(unsigned) * 8 / 2;
  val ^= val << sizeof(unsigned) * 8 / 2;
  return val ^ rcb_fast_circular_shift_right(val, tmp);
}


x86 assembly (clang, -O0):
<rcb_fast_generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0xf,%edi
call   1040 <rcb_fast_get_one_bits@plt>
mov    -0x14(%rbp),%ecx
mov    %eax,%edx
mov    -0x10(%rbp),%eax
and    %edx,%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,%eax
mov    $0x1f,%ecx
xor    %edx,%edx
div    %rcx
or     $0x1,%rdx
mov    %edx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1030 <rcb_fast_circular_shift_right@plt>
xor    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x10,%eax
xor    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x10,%eax
xor    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <rcb_fast_circular_shift_right@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
xor    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rcb_fast_generate>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    $0xf,%edi
call   1040 <rcb_fast_get_one_bits@plt>
and    %r14d,%eax
lea    (%r14,%rax,2),%eax
imul   $0x8421085,%rax,%rcx
shr    $0x20,%rcx
mov    %eax,%ebp
sub    %ecx,%ebp
shr    %ebp
add    %ecx,%ebp
shr    $0x4,%ebp
mov    %ebp,%ecx
shl    $0x5,%ecx
sub    %ecx,%ebp
add    %eax,%ebp
or     $0x1,%ebp
mov    %r14d,%edi
mov    $0x1,%esi
call   1030 <rcb_fast_circular_shift_right@plt>
mov    %eax,%ebx
xor    %r14d,%ebx
mov    %ebx,%eax
shr    $0x10,%eax
xor    %eax,%ebx
mov    %ebx,%eax
shl    $0x10,%eax
xor    %eax,%ebx
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <rcb_fast_circular_shift_right@plt>
xor    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rcb_fast_generate(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @rcb_fast_get_one_bits(i32 15)
%7 = and i32 %5, %6
%8 = shl i32 %7, 1
%9 = add i32 %4, %8
%10 = zext i32 %9 to i64
%11 = urem i64 %10, 31
%12 = or i64 %11, 1
%13 = trunc i64 %12 to i32
store i32 %13, i32* %3
%14 = load i32, i32* %2
%15 = call i32 @rcb_fast_circular_shift_right(i32 %14, i32 1)
%16 = load i32, i32* %2
%17 = xor i32 %16, %15
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = lshr i32 %18, 16
%20 = load i32, i32* %2
%21 = xor i32 %20, %19
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = shl i32 %22, 16
%24 = load i32, i32* %2
%25 = xor i32 %24, %23
store i32 %25, i32* %2
%26 = load i32, i32* %2
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = call i32 @rcb_fast_circular_shift_right(i32 %27, i32 %28)
%30 = xor i32 %26, %29
ret i32 %30
}

LLVM IR (-O2):
define i32 @rcb_fast_generate(i32 %0) {
%2 = tail call i32 @rcb_fast_get_one_bits(i32 15)
%3 = and i32 %2, %0
%4 = shl i32 %3, 1
%5 = add i32 %4, %0
%6 = urem i32 %5, 31
%7 = or i32 %6, 1
%8 = tail call i32 @rcb_fast_circular_shift_right(i32 %0, i32 1)
%9 = xor i32 %8, %0
%10 = lshr i32 %9, 16
%11 = xor i32 %10, %9
%12 = shl i32 %11, 16
%13 = xor i32 %12, %11
%14 = tail call i32 @rcb_fast_circular_shift_right(i32 %13, i32 %7)
%15 = xor i32 %13, %14
ret i32 %15
}