#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 *, ...);
void draw_oct_table() {
  unsigned idx;
  printf("extern const char oct_digits[64] = {\n");
  for (idx = 0; idx < 64; idx += 1) {
    unsigned cnt_z = 0, cnt_x = 0;
    unsigned bv = 0, bdx;
    for (bdx = 0; bdx < 3; bdx += 1) {
      switch ((idx >> (bdx * 2)) & 3) {
      case 0:
        break;
      case 1:
        bv |= 1 << bdx;
        break;
      case 2:
        cnt_x += 1;
        break;
      case 3:
        cnt_z += 1;
        break;
      }
    }
    if (cnt_z == 3)
      printf(" 'z',");
    else if (cnt_x == 3)
      printf(" 'x',");
    else if ((cnt_z > 0) && (cnt_x == 0))
      printf(" 'Z',");
    else if (cnt_x > 0)
      printf(" 'X',");
    else
      printf(" '%c',", "01234567"[bv]);
    if (((idx + 1) % 8) == 0)
      printf("\n");
  }
  printf("};\n");
}


x86 assembly (clang, -O0):
<draw_oct_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x40,-0x4(%rbp)
jae    12af <draw_oct_table+0x19f>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jae    11d1 <draw_oct_table+0xc1>
mov    -0x4(%rbp),%eax
mov    -0x14(%rbp),%cl
add    %cl,%cl
shr    %cl,%eax
and    $0x3,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     11be <draw_oct_table+0xae>
mov    -0x20(%rbp),%rax
lea    0xe7c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    11be <draw_oct_table+0xae>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11be <draw_oct_table+0xae>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11be <draw_oct_table+0xae>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c3 <draw_oct_table+0xb3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1153 <draw_oct_table+0x43>
cmpl   $0x3,-0x8(%rbp)
jne    11ee <draw_oct_table+0xde>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127c <draw_oct_table+0x16c>
cmpl   $0x3,-0xc(%rbp)
jne    120b <draw_oct_table+0xfb>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1277 <draw_oct_table+0x167>
cmpl   $0x0,-0x8(%rbp)
jbe    1232 <draw_oct_table+0x122>
cmpl   $0x0,-0xc(%rbp)
jne    1232 <draw_oct_table+0x122>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1272 <draw_oct_table+0x162>
cmpl   $0x0,-0xc(%rbp)
jbe    124f <draw_oct_table+0x13f>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126d <draw_oct_table+0x15d>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
lea    0xdfa(%rip),%rax
movsbl (%rax,%rcx,1),%esi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1272 <draw_oct_table+0x162>
jmp    1277 <draw_oct_table+0x167>
jmp    127c <draw_oct_table+0x16c>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    129c <draw_oct_table+0x18c>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a1 <draw_oct_table+0x191>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112d <draw_oct_table+0x1d>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_oct_table>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xee6(%rip),%rdi
call   1040 <puts@plt>
lea    0xf02(%rip),%rbp
lea    0xf07(%rip),%r15
lea    0xf0c(%rip),%r14
lea    0xea9(%rip),%r12
lea    0xea8(%rip),%rbx
xor    %r13d,%r13d
jmp    117a <draw_oct_table+0x4a>
nop
cmp    $0x40,%r13d
je     1288 <draw_oct_table+0x158>
mov    %r13d,%esi
and    $0x3,%esi
add    $0xffffffff,%esi
mov    $0x0,%edx
mov    $0x0,%ecx
mov    $0x0,%eax
cmp    $0x2,%esi
ja     11a6 <draw_oct_table+0x76>
movslq %esi,%rax
mov    0x0(%rbp,%rax,4),%edx
mov    (%r15,%rax,4),%ecx
mov    (%r14,%rax,4),%eax
mov    %r13d,%esi
shr    $0x2,%esi
and    $0x3,%esi
cmp    $0x1,%esi
je     11e0 <draw_oct_table+0xb0>
cmp    $0x3,%esi
je     11d0 <draw_oct_table+0xa0>
cmp    $0x2,%esi
jne    11e3 <draw_oct_table+0xb3>
add    $0x1,%ecx
jmp    11e3 <draw_oct_table+0xb3>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%edx
jmp    11e3 <draw_oct_table+0xb3>
cs nopw 0x0(%rax,%rax,1)
nop
or     $0x2,%eax
mov    %r13d,%esi
shr    $0x4,%esi
and    $0x3,%esi
cmp    $0x3,%esi
je     1210 <draw_oct_table+0xe0>
cmp    $0x2,%esi
je     1200 <draw_oct_table+0xd0>
cmp    $0x1,%esi
jne    1230 <draw_oct_table+0x100>
or     $0x4,%eax
jmp    1230 <draw_oct_table+0x100>
cmp    $0x2,%ecx
jne    1244 <draw_oct_table+0x114>
lea    0xdfa(%rip),%rdi
jmp    1247 <draw_oct_table+0x117>
xchg   %ax,%ax
add    $0x1,%edx
cmp    $0x3,%edx
jne    1230 <draw_oct_table+0x100>
lea    0xde1(%rip),%rdi
jmp    1247 <draw_oct_table+0x117>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %edx,%edx
je     1240 <draw_oct_table+0x110>
test   %ecx,%ecx
jne    1240 <draw_oct_table+0x110>
mov    %r12,%rdi
jmp    1247 <draw_oct_table+0x117>
nopl   (%rax)
test   %ecx,%ecx
je     126b <draw_oct_table+0x13b>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r13d
test   $0x7,%r13b
jne    1170 <draw_oct_table+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1170 <draw_oct_table+0x40>
mov    %eax,%eax
lea    0xdab(%rip),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd99(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    124e <draw_oct_table+0x11e>
lea    0xdbe(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"extern const char oct_digits[64] = {\0A\00"
@.str.1 = [6 x i8] c" 'z',\00"
@.str.2 = [6 x i8] c" 'x',\00"
@.str.3 = [6 x i8] c" 'Z',\00"
@.str.4 = [6 x i8] c" 'X',\00"
@.str.5 = [7 x i8] c" '%c',\00"
@.str.6 = [9 x i8] c"01234567\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [4 x i8] c"};\0A\00"
define void @draw_oct_table() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %7
7: ; preds = %77, %0
%8 = load i32, i32* %1
%9 = icmp ult i32 %8, 64
br i1 %9, label %10, label %80
10: ; preds = %7
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %11
11: ; preds = %33, %10
%12 = load i32, i32* %5
%13 = icmp ult i32 %12, 3
br i1 %13, label %14, label %36
14: ; preds = %11
%15 = load i32, i32* %1
%16 = load i32, i32* %5
%17 = mul i32 %16, 2
%18 = lshr i32 %15, %17
%19 = and i32 %18, 3
switch i32 %19, label %32 [
i32 0, label %20
i32 1, label %21
i32 2, label %26
i32 3, label %29
]
20: ; preds = %14
br label %32
21: ; preds = %14
%22 = load i32, i32* %5
%23 = shl i32 1, %22
%24 = load i32, i32* %4
%25 = or i32 %24, %23
store i32 %25, i32* %4
br label %32
26: ; preds = %14
%27 = load i32, i32* %3
%28 = add i32 %27, 1
store i32 %28, i32* %3
br label %32
29: ; preds = %14
%30 = load i32, i32* %2
%31 = add i32 %30, 1
store i32 %31, i32* %2
br label %32
32: ; preds = %14, %29, %26, %21, %20
br label %33
33: ; preds = %32
%34 = load i32, i32* %5
%35 = add i32 %34, 1
store i32 %35, i32* %5
br label %11
36: ; preds = %11
%37 = load i32, i32* %2
%38 = icmp eq i32 %37, 3
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %69
41: ; preds = %36
%42 = load i32, i32* %3
%43 = icmp eq i32 %42, 3
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %68
46: ; preds = %41
%47 = load i32, i32* %2
%48 = icmp ugt i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i32, i32* %3
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %67
54: ; preds = %49, %46
%55 = load i32, i32* %3
%56 = icmp ugt i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %66
59: ; preds = %54
%60 = load i32, i32* %4
%61 = zext i32 %60 to i64
%62 = getelementptr inbounds [9 x i8], [9 x i8]* @.str.6, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %59, %57
br label %67
67: ; preds = %66, %52
br label %68
68: ; preds = %67, %44
br label %69
69: ; preds = %68, %39
%70 = load i32, i32* %1
%71 = add i32 %70, 1
%72 = urem i32 %71, 8
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %69
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %76
76: ; preds = %74, %69
br label %77
77: ; preds = %76
%78 = load i32, i32* %1
%79 = add i32 %78, 1
store i32 %79, i32* %1
br label %7
80: ; preds = %7
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c" 'z',\00"
@.str.2 = [6 x i8] c" 'x',\00"
@.str.3 = [6 x i8] c" 'Z',\00"
@.str.4 = [6 x i8] c" 'X',\00"
@.str.5 = [7 x i8] c" '%c',\00"
@.str.6 = [9 x i8] c"01234567\00"
@str = [37 x i8] c"extern const char oct_digits[64] = {\00"
@str.9 = [3 x i8] c"};\00"
@switch.table.draw_oct_table = [3 x i32] [i32 0, i32 0, i32 1]
@switch.table.draw_oct_table.10 = [3 x i32] [i32 0, i32 1, i32 0]
@switch.table.draw_oct_table.11 = [3 x i32] [i32 1, i32 0, i32 0]
define void @draw_oct_table() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %69
%3 = phi i32 [ 0, %0 ], [ %64, %69 ]
%4 = and i32 %3, 3
%5 = add nsw i32 %4, -1
%6 = icmp ult i32 %5, 3
br i1 %6, label %7, label %17
7: ; preds = %2
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.draw_oct_table, i64 0, i64 %8
%10 = load i32, i32* %9
%11 = sext i32 %5 to i64
%12 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.draw_oct_table.10, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = sext i32 %5 to i64
%15 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.draw_oct_table.11, i64 0, i64 %14
%16 = load i32, i32* %15
br label %17
17: ; preds = %7, %2
%18 = phi i32 [ 0, %2 ], [ %10, %7 ]
%19 = phi i32 [ 0, %2 ], [ %13, %7 ]
%20 = phi i32 [ 0, %2 ], [ %16, %7 ]
%21 = lshr i32 %3, 2
%22 = and i32 %21, 3
switch i32 %22, label %29 [
i32 3, label %27
i32 1, label %25
i32 2, label %23
]
23: ; preds = %17
%24 = add nuw nsw i32 %19, 1
br label %29
25: ; preds = %17
%26 = or i32 %20, 2
br label %29
27: ; preds = %17
%28 = add nuw nsw i32 %18, 1
br label %29
29: ; preds = %27, %25, %23, %17
%30 = phi i32 [ %18, %17 ], [ %18, %23 ], [ %18, %25 ], [ %28, %27 ]
%31 = phi i32 [ %19, %17 ], [ %24, %23 ], [ %19, %25 ], [ %19, %27 ]
%32 = phi i32 [ %20, %17 ], [ %20, %23 ], [ %26, %25 ], [ %20, %27 ]
%33 = lshr i32 %3, 4
%34 = and i32 %33, 3
switch i32 %34, label %46 [
i32 3, label %37
i32 1, label %35
i32 2, label %42
]
35: ; preds = %29
%36 = or i32 %32, 4
br label %46
37: ; preds = %29
%38 = add nuw nsw i32 %30, 1
%39 = icmp eq i32 %38, 3
br i1 %39, label %40, label %46
40: ; preds = %37
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %63
42: ; preds = %29
%43 = icmp eq i32 %31, 2
br i1 %43, label %44, label %55
44: ; preds = %42
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %63
46: ; preds = %29, %35, %37
%47 = phi i32 [ %38, %37 ], [ %30, %35 ], [ %30, %29 ]
%48 = phi i32 [ %32, %37 ], [ %36, %35 ], [ %32, %29 ]
%49 = icmp ne i32 %47, 0
%50 = icmp eq i32 %31, 0
%51 = select i1 %49, i1 %50, i1 false
br i1 %51, label %52, label %54
52: ; preds = %46
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %63
54: ; preds = %46
br i1 %50, label %57, label %55
55: ; preds = %42, %54
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %63
57: ; preds = %54
%58 = zext i32 %48 to i64
%59 = getelementptr inbounds [9 x i8], [9 x i8]* @.str.6, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %44, %55, %57, %52, %40
%64 = add nuw nsw i32 %3, 1
%65 = and i32 %64, 7
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %63
%68 = tail call i32 @putchar(i32 10)
br label %69
69: ; preds = %67, %63
%70 = icmp eq i32 %64, 64
br i1 %70, label %71, label %2
71: ; preds = %69
%72 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.9, i64 0, i64 0))
ret void
}