#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 /*<<< orphan*/ SwapBit(int *, int, int);
void ReverseBit(int *num) {
  int i;
  for (i = 31; i > 15; --i) {
    SwapBit(num, i, 31 - i);
  }
}


x86 assembly (clang, -O0):
<ReverseBit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1f,-0xc(%rbp)
cmpl   $0xf,-0xc(%rbp)
jle    114f <ReverseBit+0x3f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x1f,%edx
sub    -0xc(%rbp),%edx
call   1030 <SwapBit@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <ReverseBit+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReverseBit>:
push   %rbx
mov    %rdi,%rbx
mov    $0x1f,%esi
xor    %edx,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x1e,%esi
mov    $0x1,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x1d,%esi
mov    $0x2,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x1c,%esi
mov    $0x3,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x4,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x1a,%esi
mov    $0x5,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x19,%esi
mov    $0x6,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x18,%esi
mov    $0x7,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x17,%esi
mov    $0x8,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x16,%esi
mov    $0x9,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x15,%esi
mov    $0xa,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
mov    $0xb,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x13,%esi
mov    $0xc,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x12,%esi
mov    $0xd,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x11,%esi
mov    $0xe,%edx
call   1030 <SwapBit@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
mov    $0xf,%edx
pop    %rbx
jmp    1030 <SwapBit@plt>

LLVM IR (-O0):
define void @ReverseBit(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
store i32 31, i32* %3
br label %4
4: ; preds = %13, %1
%5 = load i32, i32* %3
%6 = icmp sgt i32 %5, 15
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = load i32*, i32** %2
%9 = load i32, i32* %3
%10 = load i32, i32* %3
%11 = sub nsw i32 31, %10
%12 = call i32 @SwapBit(i32* %8, i32 %9, i32 %11)
br label %13
13: ; preds = %7
%14 = load i32, i32* %3
%15 = add nsw i32 %14, -1
store i32 %15, i32* %3
br label %4
16: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @ReverseBit(i32* %0) {
%2 = tail call i32 @SwapBit(i32* %0, i32 31, i32 0)
%3 = tail call i32 @SwapBit(i32* %0, i32 30, i32 1)
%4 = tail call i32 @SwapBit(i32* %0, i32 29, i32 2)
%5 = tail call i32 @SwapBit(i32* %0, i32 28, i32 3)
%6 = tail call i32 @SwapBit(i32* %0, i32 27, i32 4)
%7 = tail call i32 @SwapBit(i32* %0, i32 26, i32 5)
%8 = tail call i32 @SwapBit(i32* %0, i32 25, i32 6)
%9 = tail call i32 @SwapBit(i32* %0, i32 24, i32 7)
%10 = tail call i32 @SwapBit(i32* %0, i32 23, i32 8)
%11 = tail call i32 @SwapBit(i32* %0, i32 22, i32 9)
%12 = tail call i32 @SwapBit(i32* %0, i32 21, i32 10)
%13 = tail call i32 @SwapBit(i32* %0, i32 20, i32 11)
%14 = tail call i32 @SwapBit(i32* %0, i32 19, i32 12)
%15 = tail call i32 @SwapBit(i32* %0, i32 18, i32 13)
%16 = tail call i32 @SwapBit(i32* %0, i32 17, i32 14)
%17 = tail call i32 @SwapBit(i32* %0, i32 16, i32 15)
ret void
}