#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 *, ...);
int main() {
  int i0, i1;
  int i, j, k;
  printf("Swap:\n");
  for (i = 0; i < 16; i++) {
    printf("%01X: ", i);
    for (j = 0; j < 16; j++) {
      i0 = i * 16 + j;
      i1 = (i0 * 7) >> 3;
      printf("%02X ", i1);
    }
    printf("\n");
  }
  printf("Swap dist to 0:\n");
  for (i = 0; i < 16; i++) {
    printf("%01X: ", i);
    for (j = 0; j < 16; j++) {
      i0 = i * 16 + j;
      i1 = (i0 * 7) >> 3;
      k = 0;
      while (i1 > 0) {
        k++;
        i1 = (i1 * 7) >> 3;
      }
      printf("%02X ", k);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    11b1 <main+0xa1>
mov    -0x10(%rbp),%esi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    1195 <main+0x85>
mov    -0x10(%rbp),%eax
shl    $0x4,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
imul   $0x7,-0x8(%rbp),%eax
sar    $0x3,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <main+0x46>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <main+0x24>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    126c <main+0x15c>
mov    -0x10(%rbp),%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    1250 <main+0x140>
mov    -0x10(%rbp),%eax
shl    $0x4,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
imul   $0x7,-0x8(%rbp),%eax
sar    $0x3,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1231 <main+0x121>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
imul   $0x7,-0xc(%rbp),%eax
sar    $0x3,%eax
mov    %eax,-0xc(%rbp)
jmp    120f <main+0xff>
mov    -0x18(%rbp),%esi
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e8 <main+0xd8>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c6 <main+0xb6>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb5(%rip),%r14
lea    0xeb5(%rip),%r15
xor    %ebx,%ebx
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x2(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x3(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x5(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x6(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x7(%rbx),%ebp
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x9(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xa(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xb(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
add    $0xe,%ebx
cmp    $0xe0,%ebx
jne    1160 <main+0x30>
lea    0xdb3(%rip),%rdi
call   1040 <puts@plt>
lea    0xd94(%rip),%r14
lea    0xd94(%rip),%r12
xor    %r15d,%r15d
jmp    1294 <main+0x164>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15d
cmp    $0x10,%r15d
je     12f8 <main+0x1c8>
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15d,%ebx
shl    $0x4,%ebx
xor    %ebp,%ebp
jmp    12c2 <main+0x192>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0x10,%ebp
je     1280 <main+0x150>
lea    (%rbx,%rbp,1),%ecx
lea    0x0(,%rcx,8),%eax
sub    %ecx,%eax
xor    %esi,%esi
cmp    $0x8,%eax
jb     12b0 <main+0x180>
shr    $0x3,%eax
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
add    $0x1,%esi
lea    0x0(,%rax,8),%ecx
sub    %eax,%ecx
mov    %ecx,%eax
sar    $0x3,%eax
cmp    $0x7,%ecx
jg     12e0 <main+0x1b0>
jmp    12b0 <main+0x180>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Swap:\0A\00"
@.str.1 = [7 x i8] c"%01X: \00"
@.str.2 = [6 x i8] c"%02X \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [17 x i8] c"Swap dist to 0:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %8
8: ; preds = %32, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 16
br i1 %10, label %11, label %35
11: ; preds = %8
%12 = load i32, i32* %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %12)
store i32 0, i32* %5
br label %14
14: ; preds = %27, %11
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 16
br i1 %16, label %17, label %30
17: ; preds = %14
%18 = load i32, i32* %4
%19 = mul nsw i32 %18, 16
%20 = load i32, i32* %5
%21 = add nsw i32 %19, %20
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = mul nsw i32 %22, 7
%24 = ashr i32 %23, 3
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %17
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %14
30: ; preds = %14
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %8
35: ; preds = %8
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %37
37: ; preds = %71, %35
%38 = load i32, i32* %4
%39 = icmp slt i32 %38, 16
br i1 %39, label %40, label %74
40: ; preds = %37
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %41)
store i32 0, i32* %5
br label %43
43: ; preds = %66, %40
%44 = load i32, i32* %5
%45 = icmp slt i32 %44, 16
br i1 %45, label %46, label %69
46: ; preds = %43
%47 = load i32, i32* %4
%48 = mul nsw i32 %47, 16
%49 = load i32, i32* %5
%50 = add nsw i32 %48, %49
store i32 %50, i32* %2
%51 = load i32, i32* %2
%52 = mul nsw i32 %51, 7
%53 = ashr i32 %52, 3
store i32 %53, i32* %3
store i32 0, i32* %6
br label %54
54: ; preds = %57, %46
%55 = load i32, i32* %3
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %63
57: ; preds = %54
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
%60 = load i32, i32* %3
%61 = mul nsw i32 %60, 7
%62 = ashr i32 %61, 3
store i32 %62, i32* %3
br label %54
63: ; preds = %54
%64 = load i32, i32* %6
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %63
%67 = load i32, i32* %5
%68 = add nsw i32 %67, 1
store i32 %68, i32* %5
br label %43
69: ; preds = %43
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %71
71: ; preds = %69
%72 = load i32, i32* %4
%73 = add nsw i32 %72, 1
store i32 %73, i32* %4
br label %37
74: ; preds = %37
%75 = load i32, i32* %1
ret i32 %75
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%01X: \00"
@.str.2 = [6 x i8] c"%02X \00"
@str = [6 x i8] c"Swap:\00"
@str.5 = [16 x i8] c"Swap dist to 0:\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %70, %2 ]
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = shl nsw i32 %3, 4
%6 = mul nsw i32 %3, 112
%7 = lshr exact i32 %6, 3
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = or i32 %5, 1
%10 = mul nuw nsw i32 %9, 7
%11 = lshr i32 %10, 3
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = or i32 %5, 2
%14 = mul nuw nsw i32 %13, 7
%15 = lshr i32 %14, 3
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = or i32 %5, 3
%18 = mul nuw nsw i32 %17, 7
%19 = lshr i32 %18, 3
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = or i32 %5, 4
%22 = mul nuw nsw i32 %21, 7
%23 = lshr i32 %22, 3
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = or i32 %5, 5
%26 = mul nuw nsw i32 %25, 7
%27 = lshr i32 %26, 3
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = or i32 %5, 6
%30 = mul nuw nsw i32 %29, 7
%31 = lshr i32 %30, 3
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = or i32 %5, 7
%34 = mul nuw nsw i32 %33, 7
%35 = lshr i32 %34, 3
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = or i32 %5, 8
%38 = mul nuw nsw i32 %37, 7
%39 = lshr exact i32 %38, 3
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = or i32 %5, 9
%42 = mul nuw nsw i32 %41, 7
%43 = lshr i32 %42, 3
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = or i32 %5, 10
%46 = mul nuw nsw i32 %45, 7
%47 = lshr i32 %46, 3
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = or i32 %5, 11
%50 = mul nuw nsw i32 %49, 7
%51 = lshr i32 %50, 3
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = or i32 %5, 12
%54 = mul nuw nsw i32 %53, 7
%55 = lshr i32 %54, 3
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = or i32 %5, 13
%58 = mul nuw nsw i32 %57, 7
%59 = lshr i32 %58, 3
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %59)
%61 = or i32 %5, 14
%62 = mul nuw nsw i32 %61, 7
%63 = lshr i32 %62, 3
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %63)
%65 = or i32 %5, 15
%66 = mul nuw nsw i32 %65, 7
%67 = lshr i32 %66, 3
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %67)
%69 = tail call i32 @putchar(i32 10)
%70 = add nuw nsw i32 %3, 1
%71 = icmp eq i32 %70, 16
br i1 %71, label %72, label %2
72: ; preds = %2
%73 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.5, i64 0, i64 0))
br label %74
74: ; preds = %72, %97
%75 = phi i32 [ 0, %72 ], [ %99, %97 ]
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %75)
%77 = shl nsw i32 %75, 4
br label %78
78: ; preds = %74, %92
%79 = phi i32 [ 0, %74 ], [ %95, %92 ]
%80 = add nuw nsw i32 %79, %77
%81 = mul nuw nsw i32 %80, 7
%82 = icmp ult i32 %81, 8
br i1 %82, label %92, label %83
83: ; preds = %78
%84 = lshr i32 %81, 3
br label %85
85: ; preds = %83, %85
%86 = phi i32 [ %88, %85 ], [ 0, %83 ]
%87 = phi i32 [ %90, %85 ], [ %84, %83 ]
%88 = add nuw nsw i32 %86, 1
%89 = mul nsw i32 %87, 7
%90 = ashr i32 %89, 3
%91 = icmp sgt i32 %89, 7
br i1 %91, label %85, label %92
92: ; preds = %85, %78
%93 = phi i32 [ 0, %78 ], [ %88, %85 ]
%94 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %93)
%95 = add nuw nsw i32 %79, 1
%96 = icmp eq i32 %95, 16
br i1 %96, label %97, label %78
97: ; preds = %92
%98 = tail call i32 @putchar(i32 10)
%99 = add nuw nsw i32 %75, 1
%100 = icmp eq i32 %99, 16
br i1 %100, label %101, label %74
101: ; preds = %97
ret i32 0
}