#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 */
typedef int uint64_t;

/* Variables and functions */
void sprint_uint64(char *buf, uint64_t val) {
  static const char hexdigits[] = "0123456789abcdef";
  int indian = 1;
  int i;
  for (i = 0; i < 8; ++i) {
    if ((*(char *)(void *)&indian)) {
      buf[2 * (7 - i)] = hexdigits[(val >> (56 - 8 * i + 4)) & 15];
      buf[(2 * (7 - i)) + 1] = hexdigits[(val >> (56 - 8 * i)) & 15];
    } else {
      buf[2 * i] = hexdigits[(val >> (56 - 8 * i + 4)) & 15];
      buf[(2 * i) + 1] = hexdigits[(val >> (56 - 8 * i)) & 15];
    }
  }
}


x86 assembly (clang, -O0):
<sprint_uint64>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1223 <sprint_uint64+0x123>
cmpb   $0x0,-0x10(%rbp)
je     11a6 <sprint_uint64+0xa6>
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%edx
shl    $0x3,%edx
mov    $0x38,%ecx
sub    %edx,%ecx
add    $0x4,%ecx
sar    %cl,%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xeb1(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    $0x7,%ecx
sub    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%edx
shl    $0x3,%edx
mov    $0x38,%ecx
sub    %edx,%ecx
sar    %cl,%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xe7a(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    $0x7,%ecx
sub    -0x14(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1210 <sprint_uint64+0x110>
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%edx
shl    $0x3,%edx
mov    $0x38,%ecx
sub    %edx,%ecx
add    $0x4,%ecx
sar    %cl,%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xe38(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%edx
shl    $0x3,%edx
mov    $0x38,%ecx
sub    %edx,%ecx
sar    %cl,%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xe06(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1215 <sprint_uint64+0x115>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1119 <sprint_uint64+0x19>
pop    %rbp
ret

x86 assembly (clang, -O2):
<sprint_uint64>:
mov    %esi,%eax
mov    %rax,%rdx
shr    $0x1c,%rdx
lea    0xef0(%rip),%rcx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x6(%rdi)
mov    %esi,%edx
shr    $0x18,%edx
and    $0xf,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x7(%rdi)
mov    %esi,%edx
shr    $0x14,%edx
and    $0xf,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x4(%rdi)
mov    %esi,%edx
shr    $0x10,%edx
and    $0xf,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x5(%rdi)
mov    %esi,%edx
shr    $0xc,%edx
and    $0xf,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x2(%rdi)
mov    %esi,%edx
shr    $0x8,%edx
and    $0xf,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x3(%rdi)
shr    $0x4,%esi
and    $0xf,%esi
mov    (%rsi,%rcx,1),%dl
mov    %dl,(%rdi)
and    $0xf,%eax
mov    (%rax,%rcx,1),%al
mov    %al,0x1(%rdi)
ret

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

LLVM IR (-O2):
@sprint_uint64.hexdigits = internal unnamed_addr constant [17 x i8] c"0123456789abcdef\00"
define void @sprint_uint64(i8* nocapture writeonly %0, i32 %1) {
%3 = lshr i32 %1, 28
%4 = zext i32 %3 to i64
%5 = getelementptr inbounds [17 x i8], [17 x i8]* @sprint_uint64.hexdigits, i64 0, i64 %4
%6 = load i8, i8* %5
%7 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %6, i8* %7
%8 = lshr i32 %1, 24
%9 = and i32 %8, 15
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds [17 x i8], [17 x i8]* @sprint_uint64.hexdigits, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %12, i8* %13
%14 = lshr i32 %1, 20
%15 = and i32 %14, 15
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds [17 x i8], [17 x i8]* @sprint_uint64.hexdigits, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %18, i8* %19
%20 = lshr i32 %1, 16
%21 = and i32 %20, 15
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [17 x i8], [17 x i8]* @sprint_uint64.hexdigits, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %24, i8* %25
%26 = lshr i32 %1, 12
%27 = and i32 %26, 15
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [17 x i8], [17 x i8]* @sprint_uint64.hexdigits, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %30, i8* %31
%32 = lshr i32 %1, 8
%33 = and i32 %32, 15
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds [17 x i8], [17 x i8]* @sprint_uint64.hexdigits, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %36, i8* %37
%38 = lshr i32 %1, 4
%39 = and i32 %38, 15
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds [17 x i8], [17 x i8]* @sprint_uint64.hexdigits, i64 0, i64 %40
%42 = load i8, i8* %41
store i8 %42, i8* %0
%43 = and i32 %1, 15
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds [17 x i8], [17 x i8]* @sprint_uint64.hexdigits, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %46, i8* %47
ret void
}