#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 j;
int /*<<< orphan*/ printf(char *, ...);
int to_edge(int *, int);
int total;
main() {
  int edge[8], i;
  printf("unsigned short Edge_To_Quat[6561] = \n{\n    ");
  for (i = 0; i < 6561; i++) {
    printf(" %5u,", to_edge(edge, i));
    if (i % 10 == 9)
      printf("\n    ");
  }
  printf("\n};\n\n");
  printf("unsigned short String_To_Quat[256] = \n{\n    ");
  for (i = 0; i < 256; i++) {
    register j, total;
    total = 0;
    for (j = 0; j < 8; j++)
      if (((i >> j) & 1) == 1)
        total += 1 << (2 * j);
    printf(" %5u,", total);
    if (i % 10 == 9)
      printf("\n    ");
  }
  printf("\n};\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x19a1,-0x34(%rbp)
jge    11a2 <main+0x82>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1040 <to_edge@plt>
mov    %eax,%esi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x9,%edx
jne    118f <main+0x6f>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1194 <main+0x74>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1144 <main+0x24>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x100,-0x34(%rbp)
jge    126a <main+0x14a>
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x8,-0x38(%rbp)
jge    1224 <main+0x104>
mov    -0x34(%rbp),%eax
mov    -0x38(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    1211 <main+0xf1>
mov    -0x38(%rbp),%ecx
shl    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    1216 <main+0xf6>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11e0 <main+0xc0>
mov    -0x3c(%rbp),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x9,%edx
jne    1257 <main+0x137>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125c <main+0x13c>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11c5 <main+0xa5>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%r14
lea    0xed4(%rip),%r12
lea    0xec7(%rip),%r15
xor    %ebp,%ebp
jmp    117b <main+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
cmp    $0x19a1,%ebp
je     11b7 <main+0x87>
movzwl %bp,%ebx
imul   $0xcccd,%ebx,%eax
shr    $0x13,%eax
lea    (%rax,%rax,4),%r13d
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <to_edge@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x9(%r13,%r13,1),%eax
cmp    %bx,%ax
jne    1170 <main+0x40>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <main+0x40>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe68(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %r14d,%r14d
xor    %esi,%esi
xor    %edi,%edi
xor    %r12d,%r12d
xor    %r15d,%r15d
xor    %edx,%edx
xor    %r13d,%r13d
xor    %ebx,%ebx
jmp    1229 <main+0xf9>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
sub    $0xffffff80,%r13d
mov    0x4(%rsp),%edx
add    $0x40,%edx
add    $0x20,%r15d
add    $0x10,%r12d
mov    0x8(%rsp),%ecx
add    $0x8,%ecx
mov    0xc(%rsp),%eax
add    $0x4,%eax
add    $0x2,%r14d
cmp    $0x8000,%r13d
mov    %eax,%esi
mov    %ecx,%edi
je     12be <main+0x18e>
mov    %edx,0x4(%rsp)
mov    %edi,0x8(%rsp)
mov    %esi,0xc(%rsp)
mov    %ebx,%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%ebp
shl    $0x8,%ebp
add    $0x480,%ebp
mov    %ebx,%eax
and    $0x1,%eax
mov    %r14d,%ecx
and    $0x4,%ecx
or     %eax,%ecx
mov    %esi,%eax
and    $0x10,%eax
or     %ecx,%eax
mov    %edi,%ecx
and    $0x40,%ecx
or     %eax,%ecx
mov    %r12d,%eax
and    $0x100,%eax
or     %ecx,%eax
mov    %r15d,%ecx
and    $0x400,%ecx
or     %eax,%ecx
mov    %edx,%eax
and    $0x1000,%eax
or     %ecx,%eax
mov    %r13d,%esi
and    $0x4000,%esi
add    %eax,%esi
lea    0xd91(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r13d,%ebp
jne    11f0 <main+0xc0>
lea    0xd74(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f0 <main+0xc0>
lea    0xd9f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [44 x i8] c"unsigned short Edge_To_Quat[6561] = \0A{\0A \00"
@.str.1 = [6 x i8] c" %5u,\00"
@.str.2 = [6 x i8] c"\0A \00"
@.str.4 = [45 x i8] c"unsigned short String_To_Quat[256] = \0A{\0A \00"
@j = global i32 0
@total = global i32 0
@str = [5 x i8] c"\0A};\0A\00"
@str.6 = [4 x i8] c"\0A};\00"
define i32 @main() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
br label %5
5: ; preds = %0, %14
%6 = phi i32 [ 0, %0 ], [ %15, %14 ]
%7 = call i32 @to_edge(i32* %4, i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = trunc i32 %6 to i16
%10 = urem i16 %9, 10
%11 = icmp eq i16 %10, 9
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %5, %12
%15 = add nuw nsw i32 %6, 1
%16 = icmp eq i32 %15, 6561
br i1 %16, label %17, label %5
17: ; preds = %14
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %17, %49
%21 = phi i32 [ 0, %17 ], [ %50, %49 ]
%22 = and i32 %21, 1
%23 = shl nuw i32 %21, 1
%24 = and i32 %23, 4
%25 = or i32 %24, %22
%26 = shl i32 %21, 2
%27 = and i32 %26, 16
%28 = or i32 %27, %25
%29 = shl i32 %21, 3
%30 = and i32 %29, 64
%31 = or i32 %30, %28
%32 = shl i32 %21, 4
%33 = and i32 %32, 256
%34 = or i32 %33, %31
%35 = shl i32 %21, 5
%36 = and i32 %35, 1024
%37 = or i32 %36, %34
%38 = shl i32 %21, 6
%39 = and i32 %38, 4096
%40 = or i32 %39, %37
%41 = shl i32 %21, 7
%42 = and i32 %41, 16384
%43 = add nsw i32 %42, %40
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = urem i32 %21, 10
%46 = icmp eq i32 %45, 9
br i1 %46, label %47, label %49
47: ; preds = %20
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %49
49: ; preds = %47, %20
%50 = add nuw nsw i32 %21, 1
%51 = icmp eq i32 %50, 256
br i1 %51, label %52, label %20
52: ; preds = %49
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}