#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*/ printf(char *, ...);
int reverse(int);
void generate_reverse() {
  int i;
  printf("static const word_t reverse_table[256] = \n{\n ");
  for (i = 0; i < 256; i++) {
    if (i % 8 == 0 && i > 0)
      printf("\n ");
    printf(" 0x%02X%c", reverse(i), i == 255 ? '\n' : ',');
  }
  printf("};\n\n");
}


x86 assembly (clang, -O0):
<generate_reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x100,-0x4(%rbp)
jge    11b2 <generate_reverse+0x92>
mov    -0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1176 <generate_reverse+0x56>
cmpl   $0x0,-0x4(%rbp)
jle    1176 <generate_reverse+0x56>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
call   1030 <reverse@plt>
mov    %eax,%esi
mov    -0x4(%rbp),%ecx
mov    $0x2c,%edx
mov    $0xa,%eax
cmp    $0xff,%ecx
cmove  %eax,%edx
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113d <generate_reverse+0x1d>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_reverse>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xedf(%rip),%r14
mov    $0xa,%r15d
lea    0xed5(%rip),%rbx
xor    %ebp,%ebp
jmp    118d <generate_reverse+0x5d>
nopl   (%rax)
mov    %ebp,%edi
call   1030 <reverse@plt>
cmp    $0xff,%ebp
mov    $0x2c,%edx
cmove  %r15d,%edx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
je     11a4 <generate_reverse+0x74>
test   %ebp,%ebp
je     1160 <generate_reverse+0x30>
mov    %ebp,%eax
and    $0x7,%eax
jne    1160 <generate_reverse+0x30>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1160 <generate_reverse+0x30>
lea    0xe8d(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"static const word_t reverse_table[256] = \0A{\0A \00"
@.str.1 = [3 x i8] c"\0A \00"
@.str.2 = [10 x i8] c" 0x%02X%c\00"
@.str.3 = [5 x i8] c"};\0A\0A\00"
define void @generate_reverse() {
%1 = alloca i32
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %3
3: ; preds = %23, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 256
br i1 %5, label %6, label %26
6: ; preds = %3
%7 = load i32, i32* %1
%8 = srem i32 %7, 8
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %10, %6
%16 = load i32, i32* %1
%17 = call i32 @reverse(i32 %16)
%18 = load i32, i32* %1
%19 = icmp eq i32 %18, 255
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 10, i32 44
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %21)
br label %23
23: ; preds = %15
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %1
br label %3
26: ; preds = %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"static const word_t reverse_table[256] = \0A{\0A \00"
@.str.1 = [3 x i8] c"\0A \00"
@.str.2 = [10 x i8] c" 0x%02X%c\00"
@str = [4 x i8] c"};\0A\00"
define void @generate_reverse() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %10
%3 = phi i32 [ 0, %0 ], [ %15, %10 ]
%4 = and i32 %3, 7
%5 = icmp eq i32 %4, 0
%6 = icmp ne i32 %3, 0
%7 = and i1 %6, %5
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = tail call i32 @reverse(i32 %3)
%12 = icmp eq i32 %3, 255
%13 = select i1 %12, i32 10, i32 44
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %13)
%15 = add nuw nsw i32 %3, 1
%16 = icmp eq i32 %15, 256
br i1 %16, label %17, label %2
17: ; preds = %10
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret void
}