#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 i;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void rev_nibble_table() {
  size_t i;
  printf("const uint8_t rev_nibble_table[16]\n");
  printf("  = {");
  for (i = 0; i < 16; i++)
    printf("%s%zu", i ? ", " : "",
           ((((i)&1) << 3) | (((i)&2) << 1) | (((i)&4) >> 1) | (((i)&8) >> 3)));
  printf("};\n\n");
}


x86 assembly (clang, -O0):
<rev_nibble_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
cmpq   $0x10,-0x8(%rbp)
jae    11b9 <rev_nibble_table+0xa9>
mov    -0x8(%rbp),%rcx
lea    0xee5(%rip),%rsi
lea    0xed7(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
mov    -0x8(%rbp),%rdx
and    $0x1,%rdx
shl    $0x3,%rdx
mov    -0x8(%rbp),%rax
and    $0x2,%rax
shl    $0x1,%rax
or     %rax,%rdx
mov    -0x8(%rbp),%rax
and    $0x4,%rax
shr    $0x1,%rax
or     %rax,%rdx
mov    -0x8(%rbp),%rax
and    $0x8,%rax
shr    $0x3,%rax
or     %rax,%rdx
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113c <rev_nibble_table+0x2c>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rev_nibble_table>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeec(%rip),%r14
lea    0xebc(%rip),%r15
lea    0xeaf(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
test   %rbx,%rbx
mov    %r15,%rsi
cmove  %r14,%rsi
mov    %ebx,%eax
rol    $0x4,%al
mov    %eax,%ecx
and    $0x33,%cl
shl    $0x2,%cl
shr    $0x2,%al
and    $0x33,%al
or     %cl,%al
mov    %eax,%ecx
and    $0x50,%cl
add    %cl,%cl
shr    %al
and    $0x50,%al
or     %cl,%al
shr    $0x4,%al
movzbl %al,%edx
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x10,%rbx
jne    1160 <rev_nibble_table+0x40>
lea    0xe86(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"const uint8_t rev_nibble_table[16]\0A\00"
@.str.1 = [6 x i8] c" = {\00"
@.str.2 = [6 x i8] c"%s%zu\00"
@.str.3 = [3 x i8] c", \00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [5 x i8] c"};\0A\0A\00"
define void @rev_nibble_table() {
%1 = alloca i64
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i64 0, i64* %1
br label %4
4: ; preds = %28, %0
%5 = load i64, i64* %1
%6 = icmp ult i64 %5, 16
br i1 %6, label %7, label %31
7: ; preds = %4
%8 = load i64, i64* %1
%9 = icmp ne i64 %8, 0
%10 = zext i1 %9 to i64
%11 = select i1 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%12 = load i64, i64* %1
%13 = and i64 %12, 1
%14 = shl i64 %13, 3
%15 = load i64, i64* %1
%16 = and i64 %15, 2
%17 = shl i64 %16, 1
%18 = or i64 %14, %17
%19 = load i64, i64* %1
%20 = and i64 %19, 4
%21 = lshr i64 %20, 1
%22 = or i64 %18, %21
%23 = load i64, i64* %1
%24 = and i64 %23, 8
%25 = lshr i64 %24, 3
%26 = or i64 %22, %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %11, i64 %26)
br label %28
28: ; preds = %7
%29 = load i64, i64* %1
%30 = add i64 %29, 1
store i64 %30, i64* %1
br label %4
31: ; preds = %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c" = {\00"
@.str.2 = [6 x i8] c"%s%zu\00"
@.str.3 = [3 x i8] c", \00"
@.str.4 = [1 x i8] zeroinitializer
@str = [35 x i8] c"const uint8_t rev_nibble_table[16]\00"
@str.6 = [4 x i8] c"};\0A\00"
define void @rev_nibble_table() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %11, %3 ]
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%7 = trunc i64 %4 to i4
%8 = tail call i4 @llvm.bitreverse.i4(i4 %7)
%9 = zext i4 %8 to i64
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %6, i64 %9)
%11 = add nuw nsw i64 %4, 1
%12 = icmp eq i64 %11, 16
br i1 %12, label %13, label %3
13: ; preds = %3
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.6, i64 0, i64 0))
ret void
}