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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void output_table(uint32_t table[8][256], int len, char trans) {
  int i, j;
  for (j = 0; j < 8; j++) {
    printf("static const u32 t%d_%ce[] = {", j, trans);
    for (i = 0; i < len - 1; i++) {
      if ((i % 4) == 0)
        printf("\n");
      printf("to%ce(0x%8.8xL),", trans, table[j][i]);
      if ((i % 4) != (4 - 1))
        printf(" ");
    }
    printf("to%ce(0x%8.8xL)};\n\n", trans, table[j][len - 1]);
    if (trans == 'l') {
      if ((j + 1) * 8 >= 64)
        break;
    } else {
      if ((j + 1) * 8 >= 64)
        break;
    }
  }
}


x86 assembly (clang, -O0):
<output_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    1266 <output_table+0x156>
mov    -0x18(%rbp),%esi
movsbl -0xd(%rbp),%edx
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11e1 <output_table+0xd1>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1184 <output_table+0x74>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0xd(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0xa,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x3,%edx
je     11ce <output_table+0xbe>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d3 <output_table+0xc3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1151 <output_table+0x41>
movsbl -0xd(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0xa,%rcx
add    %rcx,%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0xd(%rbp),%eax
cmp    $0x6c,%eax
jne    1237 <output_table+0x127>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
shl    $0x3,%eax
cmp    $0x40,%eax
jl     1232 <output_table+0x122>
jmp    1266 <output_table+0x156>
jmp    1253 <output_table+0x143>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
shl    $0x3,%eax
cmp    $0x40,%eax
jl     124e <output_table+0x13e>
jmp    1266 <output_table+0x156>
jmp    1253 <output_table+0x143>
jmp    1258 <output_table+0x148>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112b <output_table+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_table>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %rdi,%r15
mov    %rsi,%rax
mov    %rsi,0x10(%rsp)
lea    -0x1(%rsi),%ebp
movslq %ebp,%rax
mov    %rax,(%rsp)
mov    %rdi,0x8(%rsp)
xor    %r12d,%r12d
nopl   (%rax)
lea    0xea9(%rip),%rdi
mov    %r12d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x2,0x10(%rsp)
jl     11c0 <output_table+0xa0>
xor    %r14d,%r14d
jmp    1179 <output_table+0x59>
nop
add    $0x1,%r14
cmp    %r14,%rbp
je     11c0 <output_table+0xa0>
mov    %r14d,%r13d
and    $0x3,%r13d
jne    118c <output_table+0x6c>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%r15,%r14,4),%edx
lea    0xe88(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x3,%r13d
je     1170 <output_table+0x50>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1170 <output_table+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rax
shl    $0xa,%rax
add    0x8(%rsp),%rax
mov    (%rsp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe56(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x0(,%r12,8),%rax
cmp    $0x37,%rax
ja     1206 <output_table+0xe6>
add    $0x1,%r12
add    $0x400,%r15
cmp    $0x8,%r12
jne    1150 <output_table+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"static const u32 t%d_%ce[] = {\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [17 x i8] c"to%ce(0x%8.8xL),\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [20 x i8] c"to%ce(0x%8.8xL)};\0A\0A\00"
define void @output_table([256 x i32]* %0, i32 %1, i8 signext %2) {
%4 = alloca [256 x i32]*
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store [256 x i32]* %0, [256 x i32]** %4
store i32 %1, i32* %5
store i8 %2, i8* %6
store i32 0, i32* %8
br label %9
9: ; preds = %80, %3
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 8
br i1 %11, label %12, label %83
12: ; preds = %9
%13 = load i32, i32* %8
%14 = load i8, i8* %6
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %15)
store i32 0, i32* %7
br label %17
17: ; preds = %46, %12
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = sub nsw i32 %19, 1
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %49
22: ; preds = %17
%23 = load i32, i32* %7
%24 = srem i32 %23, 4
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = load i8, i8* %6
%30 = sext i8 %29 to i32
%31 = load [256 x i32]*, [256 x i32]** %4
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [256 x i32], [256 x i32]* %31, i64 %33
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [256 x i32], [256 x i32]* %34, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %38)
%40 = load i32, i32* %7
%41 = srem i32 %40, 4
%42 = icmp ne i32 %41, 3
br i1 %42, label %43, label %45
43: ; preds = %28
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %45
45: ; preds = %43, %28
br label %46
46: ; preds = %45
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %17
49: ; preds = %17
%50 = load i8, i8* %6
%51 = sext i8 %50 to i32
%52 = load [256 x i32]*, [256 x i32]** %4
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [256 x i32], [256 x i32]* %52, i64 %54
%56 = load i32, i32* %5
%57 = sub nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [256 x i32], [256 x i32]* %55, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %51, i32 %60)
%62 = load i8, i8* %6
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 108
br i1 %64, label %65, label %72
65: ; preds = %49
%66 = load i32, i32* %8
%67 = add nsw i32 %66, 1
%68 = mul nsw i32 %67, 8
%69 = icmp sge i32 %68, 64
br i1 %69, label %70, label %71
70: ; preds = %65
br label %83
71: ; preds = %65
br label %79
72: ; preds = %49
%73 = load i32, i32* %8
%74 = add nsw i32 %73, 1
%75 = mul nsw i32 %74, 8
%76 = icmp sge i32 %75, 64
br i1 %76, label %77, label %78
77: ; preds = %72
br label %83
78: ; preds = %72
br label %79
79: ; preds = %78, %71
br label %80
80: ; preds = %79
%81 = load i32, i32* %8
%82 = add nsw i32 %81, 1
store i32 %82, i32* %8
br label %9
83: ; preds = %77, %70, %9
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"static const u32 t%d_%ce[] = {\00"
@.str.2 = [17 x i8] c"to%ce(0x%8.8xL),\00"
@.str.4 = [20 x i8] c"to%ce(0x%8.8xL)};\0A\0A\00"
define void @output_table([256 x i32]* nocapture %0, i32 %1, i8 signext %2) {
%4 = sext i8 %2 to i32
%5 = add i32 %1, -1
%6 = icmp sgt i32 %1, 1
%7 = sext i32 %5 to i64
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %30, %3
%10 = phi i64 [ 0, %3 ], [ %36, %30 ]
%11 = trunc i64 %10 to i32
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %4)
br i1 %6, label %13, label %30
13: ; preds = %9, %27
%14 = phi i64 [ %28, %27 ], [ 0, %9 ]
%15 = trunc i64 %14 to i32
%16 = and i32 %15, 3
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 @putchar(i32 10)
br label %20
20: ; preds = %18, %13
%21 = getelementptr inbounds [256 x i32], [256 x i32]* %0, i64 %10, i64 %14
%22 = load i32, i32* %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %22)
%24 = icmp eq i32 %16, 3
br i1 %24, label %27, label %25
25: ; preds = %20
%26 = tail call i32 @putchar(i32 32)
br label %27
27: ; preds = %20, %25
%28 = add nuw nsw i64 %14, 1
%29 = icmp eq i64 %28, %8
br i1 %29, label %30, label %13
30: ; preds = %27, %9
%31 = getelementptr inbounds [256 x i32], [256 x i32]* %0, i64 %10, i64 %7
%32 = load i32, i32* %31
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %4, i32 %32)
%34 = shl i64 %10, 3
%35 = icmp ugt i64 %34, 55
%36 = add nuw nsw i64 %10, 1
%37 = icmp eq i64 %36, 8
%38 = select i1 %35, i1 true, i1 %37
br i1 %38, label %39, label %9
39: ; preds = %30
ret void
}