#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 convert_to_higher_bitlen(int, int, int);
int /*<<< orphan*/ printf(char *, ...);
void gentable_any2eight(void) {
  int bitwidth;
  int value;
  int this_entry;
  int total_subtables = 9;
  printf("const unsigned char table_bitres_any2eight [9][256] = { \\\n");
  for (bitwidth = 0; bitwidth < total_subtables; bitwidth++) {
    printf("\t{ ");
    for (value = 0; value < 256; value++) {
      if (bitwidth == 0) {
        this_entry = 0;
      } else if (bitwidth == 8) {
        this_entry = value;
      } else {
        this_entry = convert_to_higher_bitlen(bitwidth, 8,
                                              value & ((1 << bitwidth) - 1));
      }
      printf("0x%02x", this_entry);
      if (value != 255) {
        if ((value & 0x07) == 0x07)
          printf(", \\\n\t");
        else
          printf(", ");
      }
    }
    if (bitwidth < (total_subtables - 1))
      printf(" }, \\\n");
    else
      printf(" } \\\n");
  }
  printf("\t};\n\n");
}


x86 assembly (clang, -O0):
<gentable_any2eight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x9,-0x10(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    126f <gentable_any2eight+0x14f>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    122a <gentable_any2eight+0x10a>
cmpl   $0x0,-0x4(%rbp)
jne    1188 <gentable_any2eight+0x68>
movl   $0x0,-0xc(%rbp)
jmp    11c4 <gentable_any2eight+0xa4>
cmpl   $0x8,-0x4(%rbp)
jne    119d <gentable_any2eight+0x7d>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11bf <gentable_any2eight+0x9f>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
and    %eax,%edx
mov    $0x8,%esi
call   1030 <convert_to_higher_bitlen@plt>
mov    %eax,-0xc(%rbp)
jmp    11c4 <gentable_any2eight+0xa4>
mov    -0xc(%rbp),%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xff,-0x8(%rbp)
je     1217 <gentable_any2eight+0xf7>
mov    -0x8(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    1204 <gentable_any2eight+0xe4>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1212 <gentable_any2eight+0xf2>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1217 <gentable_any2eight+0xf7>
jmp    121c <gentable_any2eight+0xfc>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1165 <gentable_any2eight+0x45>
mov    -0x4(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    124e <gentable_any2eight+0x12e>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125c <gentable_any2eight+0x13c>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1261 <gentable_any2eight+0x141>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1144 <gentable_any2eight+0x24>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gentable_any2eight>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%rbx
lea    0xeb6(%rip),%r13
lea    0xeb5(%rip),%r14
xor    %ebp,%ebp
jmp    1186 <gentable_any2eight+0x56>
cmp    $0x8,%ebp
lea    0xee9(%rip),%rdi
lea    0xee7(%rip),%rax
cmovb  %rax,%rdi
call   1030 <puts@plt>
add    $0x1,%ebp
cmp    $0x9,%ebp
je     1210 <gentable_any2eight+0xe0>
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%r15d
mov    %ebp,%ecx
shl    %cl,%r15d
not    %r15d
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%esi
test   %ebp,%ebp
je     11d2 <gentable_any2eight+0xa2>
mov    %r12d,%esi
cmp    $0x8,%ebp
je     11d2 <gentable_any2eight+0xa2>
mov    %r12d,%edx
and    %r15d,%edx
mov    %ebp,%edi
mov    $0x8,%esi
call   1040 <convert_to_higher_bitlen@plt>
mov    %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xff,%r12d
je     1160 <gentable_any2eight+0x30>
mov    %r12d,%eax
not    %eax
test   $0x7,%al
mov    %r14,%rdi
cmove  %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12d
cmp    $0x100,%r12d
jne    11b0 <gentable_any2eight+0x80>
jmp    1160 <gentable_any2eight+0x30>
lea    0xe37(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [59 x i8] c"const unsigned char table_bitres_any2eight [9][256] = { \\\0A\00"
@.str.1 = [4 x i8] c"\09{ \00"
@.str.2 = [7 x i8] c"0x%02x\00"
@.str.3 = [6 x i8] c", \\\0A\09\00"
@.str.4 = [3 x i8] c", \00"
@.str.5 = [7 x i8] c" }, \\\0A\00"
@.str.6 = [6 x i8] c" } \\\0A\00"
@.str.7 = [6 x i8] c"\09};\0A\0A\00"
define void @gentable_any2eight() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 9, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %6
6: ; preds = %61, %0
%7 = load i32, i32* %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %64
10: ; preds = %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %12
12: ; preds = %48, %10
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 256
br i1 %14, label %15, label %51
15: ; preds = %12
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 0, i32* %3
br label %33
19: ; preds = %15
%20 = load i32, i32* %1
%21 = icmp eq i32 %20, 8
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = load i32, i32* %2
store i32 %23, i32* %3
br label %32
24: ; preds = %19
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = load i32, i32* %1
%28 = shl i32 1, %27
%29 = sub nsw i32 %28, 1
%30 = and i32 %26, %29
%31 = call i32 @convert_to_higher_bitlen(i32 %25, i32 8, i32 %30)
store i32 %31, i32* %3
br label %32
32: ; preds = %24, %22
br label %33
33: ; preds = %32, %18
%34 = load i32, i32* %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %2
%37 = icmp ne i32 %36, 255
br i1 %37, label %38, label %47
38: ; preds = %33
%39 = load i32, i32* %2
%40 = and i32 %39, 7
%41 = icmp eq i32 %40, 7
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %46
44: ; preds = %38
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
br label %47
47: ; preds = %46, %33
br label %48
48: ; preds = %47
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %12
51: ; preds = %12
%52 = load i32, i32* %1
%53 = load i32, i32* %4
%54 = sub nsw i32 %53, 1
%55 = icmp slt i32 %52, %54
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %60
58: ; preds = %51
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %60
60: ; preds = %58, %56
br label %61
61: ; preds = %60
%62 = load i32, i32* %1
%63 = add nsw i32 %62, 1
store i32 %63, i32* %1
br label %6
64: ; preds = %6
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"\09{ \00"
@.str.2 = [7 x i8] c"0x%02x\00"
@.str.3 = [6 x i8] c", \\\0A\09\00"
@.str.4 = [3 x i8] c", \00"
@str = [58 x i8] c"const unsigned char table_bitres_any2eight [9][256] = { \\\00"
@str.8 = [5 x i8] c"\09};\0A\00"
@str.9 = [5 x i8] c" } \\\00"
@str.10 = [6 x i8] c" }, \\\00"
define void @gentable_any2eight() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %24
%3 = phi i32 [ 0, %0 ], [ %28, %24 ]
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = shl nsw i32 -1, %3
%6 = xor i32 %5, -1
br label %7
7: ; preds = %2, %17
%8 = phi i32 [ 0, %2 ], [ %22, %17 ]
switch i32 %3, label %10 [
i32 0, label %13
i32 8, label %9
]
9: ; preds = %7
br label %13
10: ; preds = %7
%11 = and i32 %8, %6
%12 = tail call i32 @convert_to_higher_bitlen(i32 %3, i32 8, i32 %11)
br label %13
13: ; preds = %7, %9, %10
%14 = phi i32 [ %8, %9 ], [ %12, %10 ], [ %3, %7 ]
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = icmp eq i32 %8, 255
br i1 %16, label %24, label %17
17: ; preds = %13
%18 = and i32 %8, 7
%19 = icmp eq i32 %18, 7
%20 = select i1 %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %20)
%22 = add nuw nsw i32 %8, 1
%23 = icmp eq i32 %22, 256
br i1 %23, label %24, label %7
24: ; preds = %13, %17
%25 = icmp ult i32 %3, 8
%26 = select i1 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0)
%27 = tail call i32 @puts(i8* dereferenceable(1) %26)
%28 = add nuw nsw i32 %3, 1
%29 = icmp eq i32 %28, 9
br i1 %29, label %30, label %2
30: ; preds = %24
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.8, i64 0, i64 0))
ret void
}