char *pt(unsigned char *p) {
  static char bufs[10][20];
  static int bnum = 0;
  char *ret;
  int i;
  static const char *f = "0123456789ABCDEF";
  ret = &(bufs[bnum++][0]);
  bnum %= 10;
  for (i = 0; i < 8; i++) {
    ret[i * 2] = f[(p[i] >> 4) & 0xf];
    ret[i * 2 + 1] = f[p[i] & 0xf];
  }
  ret[16] = '\0';
  return (ret);
}


x86 assembly (clang, -O0):
<pt>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    0x2ffa(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2fef(%rip)
movslq %eax,%rcx
lea    0x2f1d(%rip),%rax
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    0x2fd4(%rip),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,0x2fc6(%rip)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11bf <pt+0xbf>
mov    0x2ec6(%rip),%rax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
sar    $0x4,%ecx
and    $0xf,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    0x2e97(%rip),%rax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
and    $0xf,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <pt+0x49>
mov    -0x10(%rbp),%rax
movb   $0x0,0x10(%rax)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pt>:
mov    0x2ff2(%rip),%eax
lea    0x1(%rax),%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ecx
mov    %ecx,0x2fcb(%rip)
movzbl (%rdi),%edx
shr    $0x4,%rdx
lea    0xec5(%rip),%r8
mov    (%rdx,%r8,1),%cl
lea    (%rax,%rax,4),%rdx
lea    0x2ee6(%rip),%rsi
lea    (%rsi,%rdx,4),%rax
mov    %cl,(%rsi,%rdx,4)
movzbl (%rdi),%ecx
and    $0xf,%ecx
mov    (%rcx,%r8,1),%cl
mov    %cl,0x1(%rsi,%rdx,4)
movzbl 0x1(%rdi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%r8,1),%cl
mov    %cl,0x2(%rsi,%rdx,4)
movzbl 0x1(%rdi),%ecx
and    $0xf,%ecx
mov    (%rcx,%r8,1),%cl
mov    %cl,0x3(%rsi,%rdx,4)
movzbl 0x2(%rdi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%r8,1),%cl
mov    %cl,0x4(%rsi,%rdx,4)
movzbl 0x2(%rdi),%ecx
and    $0xf,%ecx
mov    (%rcx,%r8,1),%cl
mov    %cl,0x5(%rsi,%rdx,4)
movzbl 0x3(%rdi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%r8,1),%cl
mov    %cl,0x6(%rsi,%rdx,4)
movzbl 0x3(%rdi),%ecx
and    $0xf,%ecx
mov    (%rcx,%r8,1),%cl
mov    %cl,0x7(%rsi,%rdx,4)
movzbl 0x4(%rdi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%r8,1),%cl
mov    %cl,0x8(%rsi,%rdx,4)
movzbl 0x4(%rdi),%ecx
and    $0xf,%ecx
mov    (%rcx,%r8,1),%cl
mov    %cl,0x9(%rsi,%rdx,4)
movzbl 0x5(%rdi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%r8,1),%cl
mov    %cl,0xa(%rsi,%rdx,4)
movzbl 0x5(%rdi),%ecx
and    $0xf,%ecx
mov    (%rcx,%r8,1),%cl
mov    %cl,0xb(%rsi,%rdx,4)
movzbl 0x6(%rdi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%r8,1),%cl
mov    %cl,0xc(%rsi,%rdx,4)
movzbl 0x6(%rdi),%ecx
and    $0xf,%ecx
mov    (%rcx,%r8,1),%cl
mov    %cl,0xd(%rsi,%rdx,4)
movzbl 0x7(%rdi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%r8,1),%cl
mov    %cl,0xe(%rsi,%rdx,4)
movzbl 0x7(%rdi),%ecx
and    $0xf,%ecx
mov    (%rcx,%r8,1),%cl
mov    %cl,0xf(%rsi,%rdx,4)
movb   $0x0,0x10(%rsi,%rdx,4)
ret

LLVM IR (-O0):
@pt.bufs = internal global [10 x [20 x i8]] zeroinitializer
@pt.bnum = internal global i32 0
@pt.f = internal global i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0)
@.str = [17 x i8] c"0123456789ABCDEF\00"
define i8* @pt(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i32, i32* @pt.bnum
%6 = add nsw i32 %5, 1
store i32 %6, i32* @pt.bnum
%7 = sext i32 %5 to i64
%8 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %7
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
store i8* %9, i8** %3
%10 = load i32, i32* @pt.bnum
%11 = srem i32 %10, 10
store i32 %11, i32* @pt.bnum
store i32 0, i32* %4
br label %12
12: ; preds = %50, %1
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 8
br i1 %14, label %15, label %53
15: ; preds = %12
%16 = load i8*, i8** @pt.f
%17 = load i8*, i8** %2
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = ashr i32 %22, 4
%24 = and i32 %23, 15
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %16, i64 %25
%27 = load i8, i8* %26
%28 = load i8*, i8** %3
%29 = load i32, i32* %4
%30 = mul nsw i32 %29, 2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
store i8 %27, i8* %32
%33 = load i8*, i8** @pt.f
%34 = load i8*, i8** %2
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = and i32 %39, 15
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %33, i64 %41
%43 = load i8, i8* %42
%44 = load i8*, i8** %3
%45 = load i32, i32* %4
%46 = mul nsw i32 %45, 2
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %44, i64 %48
store i8 %43, i8* %49
br label %50
50: ; preds = %15
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %12
53: ; preds = %12
%54 = load i8*, i8** %3
%55 = getelementptr inbounds i8, i8* %54, i64 16
store i8 0, i8* %55
%56 = load i8*, i8** %3
ret i8* %56
}

LLVM IR (-O2):
@pt.bufs = internal global [10 x [20 x i8]] zeroinitializer
@pt.bnum = internal unnamed_addr global i32 0
@.str = [17 x i8] c"0123456789ABCDEF\00"
define i8* @pt(i8* nocapture %0) {
%2 = load i32, i32* @pt.bnum
%3 = add nsw i32 %2, 1
%4 = zext i32 %2 to i64
%5 = srem i32 %3, 10
store i32 %5, i32* @pt.bnum
%6 = load i8, i8* %0
%7 = lshr i8 %6, 4
%8 = zext i8 %7 to i64
%9 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 0
store i8 %10, i8* %11
%12 = load i8, i8* %0
%13 = and i8 %12, 15
%14 = zext i8 %13 to i64
%15 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 1
store i8 %16, i8* %17
%18 = getelementptr inbounds i8, i8* %0, i64 1
%19 = load i8, i8* %18
%20 = lshr i8 %19, 4
%21 = zext i8 %20 to i64
%22 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 2
store i8 %23, i8* %24
%25 = load i8, i8* %18
%26 = and i8 %25, 15
%27 = zext i8 %26 to i64
%28 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 3
store i8 %29, i8* %30
%31 = getelementptr inbounds i8, i8* %0, i64 2
%32 = load i8, i8* %31
%33 = lshr i8 %32, 4
%34 = zext i8 %33 to i64
%35 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 4
store i8 %36, i8* %37
%38 = load i8, i8* %31
%39 = and i8 %38, 15
%40 = zext i8 %39 to i64
%41 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 5
store i8 %42, i8* %43
%44 = getelementptr inbounds i8, i8* %0, i64 3
%45 = load i8, i8* %44
%46 = lshr i8 %45, 4
%47 = zext i8 %46 to i64
%48 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 6
store i8 %49, i8* %50
%51 = load i8, i8* %44
%52 = and i8 %51, 15
%53 = zext i8 %52 to i64
%54 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 7
store i8 %55, i8* %56
%57 = getelementptr inbounds i8, i8* %0, i64 4
%58 = load i8, i8* %57
%59 = lshr i8 %58, 4
%60 = zext i8 %59 to i64
%61 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 8
store i8 %62, i8* %63
%64 = load i8, i8* %57
%65 = and i8 %64, 15
%66 = zext i8 %65 to i64
%67 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 9
store i8 %68, i8* %69
%70 = getelementptr inbounds i8, i8* %0, i64 5
%71 = load i8, i8* %70
%72 = lshr i8 %71, 4
%73 = zext i8 %72 to i64
%74 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %73
%75 = load i8, i8* %74
%76 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 10
store i8 %75, i8* %76
%77 = load i8, i8* %70
%78 = and i8 %77, 15
%79 = zext i8 %78 to i64
%80 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %79
%81 = load i8, i8* %80
%82 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 11
store i8 %81, i8* %82
%83 = getelementptr inbounds i8, i8* %0, i64 6
%84 = load i8, i8* %83
%85 = lshr i8 %84, 4
%86 = zext i8 %85 to i64
%87 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %86
%88 = load i8, i8* %87
%89 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 12
store i8 %88, i8* %89
%90 = load i8, i8* %83
%91 = and i8 %90, 15
%92 = zext i8 %91 to i64
%93 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %92
%94 = load i8, i8* %93
%95 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 13
store i8 %94, i8* %95
%96 = getelementptr inbounds i8, i8* %0, i64 7
%97 = load i8, i8* %96
%98 = lshr i8 %97, 4
%99 = zext i8 %98 to i64
%100 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %99
%101 = load i8, i8* %100
%102 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 14
store i8 %101, i8* %102
%103 = load i8, i8* %96
%104 = and i8 %103, 15
%105 = zext i8 %104 to i64
%106 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %105
%107 = load i8, i8* %106
%108 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 15
store i8 %107, i8* %108
%109 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* @pt.bufs, i64 0, i64 %4, i64 16
store i8 0, i8* %109
ret i8* %11
}