#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_hex_table(void) {
  unsigned idx;
  printf("extern const char hex_digits[256] = {\n");
  for (idx = 0; idx < 256; idx += 1) {
    unsigned cnt_z = 0, cnt_x = 0;
    unsigned bv = 0, bdx;
    for (bdx = 0; bdx < 4; 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 == 4)
      printf(" 'z',");
    else if (cnt_x == 4)
      printf(" 'x',");
    else if ((cnt_z > 0) && (cnt_x == 0))
      printf(" 'Z',");
    else if (cnt_x > 0)
      printf(" 'X',");
    else
      printf(" '%c',", "0123456789abcdef"[bv]);
    if (((idx + 1) % 8) == 0)
      printf("\n");
  }
  printf("};\n");
}


x86 assembly (clang, -O0):
<draw_hex_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   $0x100,-0x4(%rbp)
jae    12b2 <draw_hex_table+0x1a2>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jae    11d4 <draw_hex_table+0xc4>
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     11c1 <draw_hex_table+0xb1>
mov    -0x20(%rbp),%rax
lea    0xe79(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    11c1 <draw_hex_table+0xb1>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11c1 <draw_hex_table+0xb1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c1 <draw_hex_table+0xb1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c6 <draw_hex_table+0xb6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <draw_hex_table+0x46>
cmpl   $0x4,-0x8(%rbp)
jne    11f1 <draw_hex_table+0xe1>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127f <draw_hex_table+0x16f>
cmpl   $0x4,-0xc(%rbp)
jne    120e <draw_hex_table+0xfe>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127a <draw_hex_table+0x16a>
cmpl   $0x0,-0x8(%rbp)
jbe    1235 <draw_hex_table+0x125>
cmpl   $0x0,-0xc(%rbp)
jne    1235 <draw_hex_table+0x125>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1275 <draw_hex_table+0x165>
cmpl   $0x0,-0xc(%rbp)
jbe    1252 <draw_hex_table+0x142>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1270 <draw_hex_table+0x160>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
lea    0xdf8(%rip),%rax
movsbl (%rax,%rcx,1),%esi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1275 <draw_hex_table+0x165>
jmp    127a <draw_hex_table+0x16a>
jmp    127f <draw_hex_table+0x16f>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    129f <draw_hex_table+0x18f>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a4 <draw_hex_table+0x194>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112d <draw_hex_table+0x1d>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_hex_table>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeee(%rip),%rdi
call   1040 <puts@plt>
lea    0xf0e(%rip),%rbp
lea    0xf13(%rip),%r15
lea    0xf18(%rip),%r14
lea    0xea9(%rip),%r12
lea    0xea8(%rip),%rbx
xor    %r13d,%r13d
jmp    117d <draw_hex_table+0x4d>
nop
cmp    $0x100,%r13d
je     12b8 <draw_hex_table+0x188>
mov    %r13d,%esi
and    $0x3,%esi
add    $0xffffffff,%esi
mov    $0x0,%edx
mov    $0x0,%ecx
mov    $0x0,%eax
cmp    $0x2,%esi
ja     11a9 <draw_hex_table+0x79>
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_hex_table+0xb0>
cmp    $0x3,%esi
je     11d0 <draw_hex_table+0xa0>
cmp    $0x2,%esi
jne    11e3 <draw_hex_table+0xb3>
add    $0x1,%ecx
jmp    11e3 <draw_hex_table+0xb3>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%edx
jmp    11e3 <draw_hex_table+0xb3>
cs nopw 0x0(%rax,%rax,1)
nop
or     $0x2,%eax
mov    %r13d,%esi
shr    $0x4,%esi
and    $0x3,%esi
cmp    $0x1,%esi
je     1210 <draw_hex_table+0xe0>
cmp    $0x3,%esi
je     1200 <draw_hex_table+0xd0>
cmp    $0x2,%esi
jne    1213 <draw_hex_table+0xe3>
add    $0x1,%ecx
jmp    1213 <draw_hex_table+0xe3>
add    $0x1,%edx
jmp    1213 <draw_hex_table+0xe3>
cs nopw 0x0(%rax,%rax,1)
nop
or     $0x4,%eax
mov    %r13d,%esi
shr    $0x6,%esi
and    $0x3,%esi
cmp    $0x3,%esi
je     1240 <draw_hex_table+0x110>
cmp    $0x2,%esi
je     1230 <draw_hex_table+0x100>
cmp    $0x1,%esi
jne    1260 <draw_hex_table+0x130>
or     $0x8,%eax
jmp    1260 <draw_hex_table+0x130>
cmp    $0x3,%ecx
jne    1274 <draw_hex_table+0x144>
lea    0xdca(%rip),%rdi
jmp    1277 <draw_hex_table+0x147>
xchg   %ax,%ax
add    $0x1,%edx
cmp    $0x4,%edx
jne    1260 <draw_hex_table+0x130>
lea    0xdb1(%rip),%rdi
jmp    1277 <draw_hex_table+0x147>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %edx,%edx
je     1270 <draw_hex_table+0x140>
test   %ecx,%ecx
jne    1270 <draw_hex_table+0x140>
mov    %r12,%rdi
jmp    1277 <draw_hex_table+0x147>
nopl   (%rax)
test   %ecx,%ecx
je     129b <draw_hex_table+0x16b>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r13d
test   $0x7,%r13b
jne    1170 <draw_hex_table+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1170 <draw_hex_table+0x40>
mov    %eax,%eax
lea    0xd7b(%rip),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd69(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    127e <draw_hex_table+0x14e>
lea    0xd97(%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 = [39 x i8] c"extern const char hex_digits[256] = {\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 = [17 x i8] c"0123456789abcdef\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [4 x i8] c"};\0A\00"
define void @draw_hex_table() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 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, 256
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, 4
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, 4
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, 4
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 [17 x i8], [17 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 = [17 x i8] c"0123456789abcdef\00"
@str = [38 x i8] c"extern const char hex_digits[256] = {\00"
@str.9 = [3 x i8] c"};\00"
@switch.table.draw_hex_table = [3 x i32] [i32 0, i32 0, i32 1]
@switch.table.draw_hex_table.10 = [3 x i32] [i32 0, i32 1, i32 0]
@switch.table.draw_hex_table.11 = [3 x i32] [i32 1, i32 0, i32 0]
define void @draw_hex_table() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %81
%3 = phi i32 [ 0, %0 ], [ %76, %81 ]
%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_hex_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_hex_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_hex_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 %41 [
i32 3, label %39
i32 1, label %37
i32 2, label %35
]
35: ; preds = %29
%36 = add nuw nsw i32 %31, 1
br label %41
37: ; preds = %29
%38 = or i32 %32, 4
br label %41
39: ; preds = %29
%40 = add nuw nsw i32 %30, 1
br label %41
41: ; preds = %39, %37, %35, %29
%42 = phi i32 [ %30, %29 ], [ %30, %35 ], [ %30, %37 ], [ %40, %39 ]
%43 = phi i32 [ %31, %29 ], [ %36, %35 ], [ %31, %37 ], [ %31, %39 ]
%44 = phi i32 [ %32, %29 ], [ %32, %35 ], [ %38, %37 ], [ %32, %39 ]
%45 = lshr i32 %3, 6
%46 = and i32 %45, 3
switch i32 %46, label %58 [
i32 3, label %49
i32 1, label %47
i32 2, label %54
]
47: ; preds = %41
%48 = or i32 %44, 8
br label %58
49: ; preds = %41
%50 = add nuw nsw i32 %42, 1
%51 = icmp eq i32 %50, 4
br i1 %51, label %52, label %58
52: ; preds = %49
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %75
54: ; preds = %41
%55 = icmp eq i32 %43, 3
br i1 %55, label %56, label %67
56: ; preds = %54
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %75
58: ; preds = %41, %47, %49
%59 = phi i32 [ %50, %49 ], [ %42, %47 ], [ %42, %41 ]
%60 = phi i32 [ %44, %49 ], [ %48, %47 ], [ %44, %41 ]
%61 = icmp ne i32 %59, 0
%62 = icmp eq i32 %43, 0
%63 = select i1 %61, i1 %62, i1 false
br i1 %63, label %64, label %66
64: ; preds = %58
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %75
66: ; preds = %58
br i1 %62, label %69, label %67
67: ; preds = %54, %66
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %75
69: ; preds = %66
%70 = zext i32 %60 to i64
%71 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.6, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %73)
br label %75
75: ; preds = %56, %67, %69, %64, %52
%76 = add nuw nsw i32 %3, 1
%77 = and i32 %76, 7
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %75
%80 = tail call i32 @putchar(i32 10)
br label %81
81: ; preds = %79, %75
%82 = icmp eq i32 %76, 256
br i1 %82, label %83, label %2
83: ; preds = %81
%84 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.9, i64 0, i64 0))
ret void
}