#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 bitreverse(unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int, int);
int main(void) {
  printf("test(0x%08x, 0x%08x);\n", 0, bitreverse(0));
  for (int i = 0; i < 31; i++) {
    unsigned int x = 0x103785af << i;
    unsigned int y = bitreverse(x);
    printf("test(0x%08x, 0x%08x);\n", x, y);
    printf("test(0x%08x, 0x%08x);\n", y, bitreverse(y));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1040 <bitreverse@plt>
mov    %eax,%edx
lea    0xec1(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x1f,-0x8(%rbp)
jge    11ae <main+0x8e>
mov    -0x8(%rbp),%ecx
mov    $0x103785af,%eax
shl    %cl,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <bitreverse@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <bitreverse@plt>
mov    -0x14(%rbp),%esi
mov    %eax,%edx
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x2d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <bitreverse@plt>
lea    0xec9(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1030 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x103785af,%ebp
mov    %ebx,%ecx
shl    %cl,%ebp
mov    %ebp,%edi
call   1040 <bitreverse@plt>
mov    %eax,%r15d
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %r15d,%edi
call   1040 <bitreverse@plt>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %eax,%edx
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0x1f,%ebx
jne    1150 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"test(0x%08x, 0x%08x);\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @bitreverse(i32 0)
%6 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 0, i32 %5)
store i32 0, i32* %2
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 31
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = load i32, i32* %2
%12 = shl i32 272074159, %11
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = call i32 @bitreverse(i32 %13)
store i32 %14, i32* %4
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
%18 = load i32, i32* %4
%19 = load i32, i32* %4
%20 = call i32 @bitreverse(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %20)
br label %22
22: ; preds = %10
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %7
25: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"test(0x%08x, 0x%08x);\0A\00"
define i32 @main() {
%1 = tail call i32 @bitreverse(i32 0)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 0, i32 %1)
br label %4
3: ; preds = %4
ret i32 0
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %11, %4 ]
%6 = shl i32 272074159, %5
%7 = tail call i32 @bitreverse(i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = tail call i32 @bitreverse(i32 %7)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
%11 = add nuw nsw i32 %5, 1
%12 = icmp eq i32 %11, 31
br i1 %12, label %3, label %4
}