#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 */
uint32_t setup_salt(uint32_t salt) {
  uint32_t obit, saltbit, saltbits;
  unsigned int i;
  saltbits = 0;
  saltbit = 1;
  obit = 0x800000;
  for (i = 0; i < 24; i++) {
    if (salt & saltbit)
      saltbits |= obit;
    saltbit <<= 1;
    obit >>= 1;
  }
  return saltbits;
}


x86 assembly (clang, -O0):
<setup_salt>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x800000,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x18,-0x14(%rbp)
jae    1165 <setup_salt+0x65>
mov    -0x4(%rbp),%eax
and    -0xc(%rbp),%eax
cmp    $0x0,%eax
je     1145 <setup_salt+0x45>
mov    -0x8(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <setup_salt+0x23>
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_salt>:
mov    $0x800000,%r9d
mov    $0x1,%edx
xor    %eax,%eax
mov    $0x18,%r8d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %edx,%esi
and    %edi,%esi
cmovne %r9d,%esi
or     %eax,%esi
lea    (%rdx,%rdx,1),%ecx
mov    %r9d,%eax
shr    %eax
and    %edi,%ecx
cmovne %eax,%ecx
or     %esi,%ecx
lea    0x0(,%rdx,4),%eax
mov    %r9d,%esi
shr    $0x2,%esi
and    %edi,%eax
cmovne %esi,%eax
or     %ecx,%eax
shl    $0x3,%edx
shr    $0x3,%r9d
add    $0xfffffffd,%r8d
jne    1120 <setup_salt+0x20>
ret

LLVM IR (-O0):
define i32 @setup_salt(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %5
store i32 1, i32* %4
store i32 8388608, i32* %3
store i32 0, i32* %6
br label %7
7: ; preds = %24, %1
%8 = load i32, i32* %6
%9 = icmp ult i32 %8, 24
br i1 %9, label %10, label %27
10: ; preds = %7
%11 = load i32, i32* %2
%12 = load i32, i32* %4
%13 = and i32 %11, %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = or i32 %17, %16
store i32 %18, i32* %5
br label %19
19: ; preds = %15, %10
%20 = load i32, i32* %4
%21 = shl i32 %20, 1
store i32 %21, i32* %4
%22 = load i32, i32* %3
%23 = ashr i32 %22, 1
store i32 %23, i32* %3
br label %24
24: ; preds = %19
%25 = load i32, i32* %6
%26 = add i32 %25, 1
store i32 %26, i32* %6
br label %7
27: ; preds = %7
%28 = load i32, i32* %5
ret i32 %28
}

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