#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*/ __writeUARTChar(char);
void __writeHex(unsigned long long n) {
  unsigned int i;
  for (i = 0; i < 16; ++i) {
    unsigned long long hexDigit = (n & 0xF000000000000000L) >> 60L;
    char hexDigitChar =
        (hexDigit < 10) ? ('0' + hexDigit) : ('A' + hexDigit - 10);
    __writeUARTChar(hexDigitChar);
    n = n << 4;
  }
}


x86 assembly (clang, -O0):
<__writeHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jae    1199 <__writeHex+0x89>
movabs $0xf000000000000000,%rax
and    -0x8(%rbp),%rax
shr    $0x3c,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0xa,-0x18(%rbp)
jae    115f <__writeHex+0x4f>
mov    -0x18(%rbp),%rax
add    $0x30,%rax
mov    %rax,-0x28(%rbp)
jmp    116f <__writeHex+0x5f>
mov    -0x18(%rbp),%rax
add    $0x41,%rax
sub    $0xa,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%edi
call   1030 <__writeUARTChar@plt>
mov    -0x8(%rbp),%rax
shl    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <__writeHex+0x13>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__writeHex>:
push   %rbx
mov    %rdi,%rbx
shr    $0x3c,%rdi
mov    %rbx,%rax
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x4,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x8,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0xc,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x10,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x14,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x18,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x1c,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x20,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x24,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x28,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x2c,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x30,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x34,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x38,%rax
mov    %rax,%rdi
shr    $0x3c,%rdi
shr    $0x3d,%rax
lea    0x30(%rdi),%ecx
add    $0x37,%edi
cmp    $0x5,%eax
cmovb  %ecx,%edi
call   1030 <__writeUARTChar@plt>
mov    %rbx,%rax
shl    $0x3c,%rax
and    $0xf,%ebx
shr    $0x3d,%rax
lea    0x30(%rbx),%ecx
add    $0x37,%ebx
cmp    $0x5,%eax
cmovb  %ecx,%ebx
mov    %ebx,%edi
pop    %rbx
jmp    1030 <__writeUARTChar@plt>

LLVM IR (-O0):
define void @__writeHex(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8
store i64 %0, i64* %2
store i32 0, i32* %3
br label %6
6: ; preds = %29, %1
%7 = load i32, i32* %3
%8 = icmp ult i32 %7, 16
br i1 %8, label %9, label %32
9: ; preds = %6
%10 = load i64, i64* %2
%11 = and i64 %10, -1152921504606846976
%12 = lshr i64 %11, 60
store i64 %12, i64* %4
%13 = load i64, i64* %4
%14 = icmp ult i64 %13, 10
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i64, i64* %4
%17 = add i64 48, %16
br label %22
18: ; preds = %9
%19 = load i64, i64* %4
%20 = add i64 65, %19
%21 = sub i64 %20, 10
br label %22
22: ; preds = %18, %15
%23 = phi i64 [ %17, %15 ], [ %21, %18 ]
%24 = trunc i64 %23 to i8
store i8 %24, i8* %5
%25 = load i8, i8* %5
%26 = call i32 @__writeUARTChar(i8 signext %25)
%27 = load i64, i64* %2
%28 = shl i64 %27, 4
store i64 %28, i64* %2
br label %29
29: ; preds = %22
%30 = load i32, i32* %3
%31 = add i32 %30, 1
store i32 %31, i32* %3
br label %6
32: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @__writeHex(i64 %0) {
%2 = lshr i64 %0, 60
%3 = icmp ult i64 %0, -6917529027641081856
%4 = or i64 %2, 48
%5 = add nuw nsw i64 %2, 55
%6 = select i1 %3, i64 %4, i64 %5
%7 = trunc i64 %6 to i8
%8 = tail call i32 @__writeUARTChar(i8 signext %7)
%9 = shl i64 %0, 4
%10 = lshr i64 %9, 60
%11 = icmp ult i64 %9, -6917529027641081856
%12 = or i64 %10, 48
%13 = add nuw nsw i64 %10, 55
%14 = select i1 %11, i64 %12, i64 %13
%15 = trunc i64 %14 to i8
%16 = tail call i32 @__writeUARTChar(i8 signext %15)
%17 = shl i64 %0, 8
%18 = lshr i64 %17, 60
%19 = icmp ult i64 %17, -6917529027641081856
%20 = or i64 %18, 48
%21 = add nuw nsw i64 %18, 55
%22 = select i1 %19, i64 %20, i64 %21
%23 = trunc i64 %22 to i8
%24 = tail call i32 @__writeUARTChar(i8 signext %23)
%25 = shl i64 %0, 12
%26 = lshr i64 %25, 60
%27 = icmp ult i64 %25, -6917529027641081856
%28 = or i64 %26, 48
%29 = add nuw nsw i64 %26, 55
%30 = select i1 %27, i64 %28, i64 %29
%31 = trunc i64 %30 to i8
%32 = tail call i32 @__writeUARTChar(i8 signext %31)
%33 = shl i64 %0, 16
%34 = lshr i64 %33, 60
%35 = icmp ult i64 %33, -6917529027641081856
%36 = or i64 %34, 48
%37 = add nuw nsw i64 %34, 55
%38 = select i1 %35, i64 %36, i64 %37
%39 = trunc i64 %38 to i8
%40 = tail call i32 @__writeUARTChar(i8 signext %39)
%41 = shl i64 %0, 20
%42 = lshr i64 %41, 60
%43 = icmp ult i64 %41, -6917529027641081856
%44 = or i64 %42, 48
%45 = add nuw nsw i64 %42, 55
%46 = select i1 %43, i64 %44, i64 %45
%47 = trunc i64 %46 to i8
%48 = tail call i32 @__writeUARTChar(i8 signext %47)
%49 = shl i64 %0, 24
%50 = lshr i64 %49, 60
%51 = icmp ult i64 %49, -6917529027641081856
%52 = or i64 %50, 48
%53 = add nuw nsw i64 %50, 55
%54 = select i1 %51, i64 %52, i64 %53
%55 = trunc i64 %54 to i8
%56 = tail call i32 @__writeUARTChar(i8 signext %55)
%57 = shl i64 %0, 28
%58 = lshr i64 %57, 60
%59 = icmp ult i64 %57, -6917529027641081856
%60 = or i64 %58, 48
%61 = add nuw nsw i64 %58, 55
%62 = select i1 %59, i64 %60, i64 %61
%63 = trunc i64 %62 to i8
%64 = tail call i32 @__writeUARTChar(i8 signext %63)
%65 = shl i64 %0, 32
%66 = lshr i64 %65, 60
%67 = icmp ult i64 %65, -6917529027641081856
%68 = or i64 %66, 48
%69 = add nuw nsw i64 %66, 55
%70 = select i1 %67, i64 %68, i64 %69
%71 = trunc i64 %70 to i8
%72 = tail call i32 @__writeUARTChar(i8 signext %71)
%73 = shl i64 %0, 36
%74 = lshr i64 %73, 60
%75 = icmp ult i64 %73, -6917529027641081856
%76 = or i64 %74, 48
%77 = add nuw nsw i64 %74, 55
%78 = select i1 %75, i64 %76, i64 %77
%79 = trunc i64 %78 to i8
%80 = tail call i32 @__writeUARTChar(i8 signext %79)
%81 = shl i64 %0, 40
%82 = lshr i64 %81, 60
%83 = icmp ult i64 %81, -6917529027641081856
%84 = or i64 %82, 48
%85 = add nuw nsw i64 %82, 55
%86 = select i1 %83, i64 %84, i64 %85
%87 = trunc i64 %86 to i8
%88 = tail call i32 @__writeUARTChar(i8 signext %87)
%89 = shl i64 %0, 44
%90 = lshr i64 %89, 60
%91 = icmp ult i64 %89, -6917529027641081856
%92 = or i64 %90, 48
%93 = add nuw nsw i64 %90, 55
%94 = select i1 %91, i64 %92, i64 %93
%95 = trunc i64 %94 to i8
%96 = tail call i32 @__writeUARTChar(i8 signext %95)
%97 = shl i64 %0, 48
%98 = lshr i64 %97, 60
%99 = icmp ult i64 %97, -6917529027641081856
%100 = or i64 %98, 48
%101 = add nuw nsw i64 %98, 55
%102 = select i1 %99, i64 %100, i64 %101
%103 = trunc i64 %102 to i8
%104 = tail call i32 @__writeUARTChar(i8 signext %103)
%105 = shl i64 %0, 52
%106 = lshr i64 %105, 60
%107 = icmp ult i64 %105, -6917529027641081856
%108 = or i64 %106, 48
%109 = add nuw nsw i64 %106, 55
%110 = select i1 %107, i64 %108, i64 %109
%111 = trunc i64 %110 to i8
%112 = tail call i32 @__writeUARTChar(i8 signext %111)
%113 = shl i64 %0, 56
%114 = lshr i64 %113, 60
%115 = icmp ult i64 %113, -6917529027641081856
%116 = or i64 %114, 48
%117 = add nuw nsw i64 %114, 55
%118 = select i1 %115, i64 %116, i64 %117
%119 = trunc i64 %118 to i8
%120 = tail call i32 @__writeUARTChar(i8 signext %119)
%121 = shl i64 %0, 60
%122 = and i64 %0, 15
%123 = icmp ult i64 %121, -6917529027641081856
%124 = or i64 %122, 48
%125 = add nuw nsw i64 %122, 55
%126 = select i1 %123, i64 %124, i64 %125
%127 = trunc i64 %126 to i8
%128 = tail call i32 @__writeUARTChar(i8 signext %127)
ret void
}