#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 */
char hexc1(int);
void h5f(char *to, int x) {
  to[0] = hexc1(x >> 16);
  x = (x & 0xff00) | ((x & 255) << 24);
  x = (x & 0xf000f00) | ((x >> 12) & 0xf000f);
  unsigned int ten = (x + 0x6060606) & 0x10101010;
  *(int *)(to + 1) = (int)(x + 0x30303030 + (ten >> 1) - (ten >> 4));
}


x86 assembly (clang, -O0):
<h5f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
sar    $0x10,%edi
call   1030 <hexc1@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
and    $0xff00,%eax
mov    -0xc(%rbp),%ecx
and    $0xff,%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xf000f00,%eax
mov    -0xc(%rbp),%ecx
sar    $0xc,%ecx
and    $0xf000f,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x6060606,%eax
and    $0x10101010,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%ecx
add    $0x30303030,%ecx
mov    -0x10(%rbp),%eax
shr    $0x1,%eax
add    %eax,%ecx
mov    -0x10(%rbp),%eax
shr    $0x4,%eax
sub    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x1(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<h5f>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
sar    $0x10,%edi
call   1030 <hexc1@plt>
mov    %al,(%rbx)
mov    %ebp,%eax
and    $0xff00,%eax
shl    $0x18,%ebp
or     %eax,%ebp
mov    %ebp,%eax
shr    $0xc,%eax
or     %ebp,%eax
and    $0xf0f0f0f,%eax
lea    0x6060606(%rax),%ecx
and    $0x10101010,%ecx
mov    %ecx,%edx
shr    %edx
add    %eax,%edx
shr    $0x4,%ecx
sub    %ecx,%edx
add    $0x30303030,%edx
mov    %edx,0x1(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @h5f(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = ashr i32 %6, 16
%8 = call signext i8 @hexc1(i32 %7)
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
store i8 %8, i8* %10
%11 = load i32, i32* %4
%12 = and i32 %11, 65280
%13 = load i32, i32* %4
%14 = and i32 %13, 255
%15 = shl i32 %14, 24
%16 = or i32 %12, %15
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = and i32 %17, 251662080
%19 = load i32, i32* %4
%20 = ashr i32 %19, 12
%21 = and i32 %20, 983055
%22 = or i32 %18, %21
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 101058054
%25 = and i32 %24, 269488144
store i32 %25, i32* %5
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 808464432
%28 = load i32, i32* %5
%29 = lshr i32 %28, 1
%30 = add i32 %27, %29
%31 = load i32, i32* %5
%32 = lshr i32 %31, 4
%33 = sub i32 %30, %32
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = bitcast i8* %35 to i32*
store i32 %33, i32* %36
ret void
}

LLVM IR (-O2):
define void @h5f(i8* nocapture writeonly %0, i32 %1) {
%3 = ashr i32 %1, 16
%4 = tail call signext i8 @hexc1(i32 %3)
store i8 %4, i8* %0
%5 = and i32 %1, 65280
%6 = shl i32 %1, 24
%7 = or i32 %5, %6
%8 = and i32 %7, 251662080
%9 = lshr i32 %7, 12
%10 = and i32 %9, 983055
%11 = or i32 %10, %8
%12 = add nuw nsw i32 %11, 101058054
%13 = and i32 %12, 269488144
%14 = or i32 %11, 808464432
%15 = lshr exact i32 %13, 1
%16 = add nuw nsw i32 %14, %15
%17 = lshr exact i32 %13, 4
%18 = sub nuw nsw i32 %16, %17
%19 = getelementptr inbounds i8, i8* %0, i64 1
%20 = bitcast i8* %19 to i32*
store i32 %18, i32* %20
ret void
}