#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 */
void ParseSerial(char *dst, unsigned char *src) {
  size_t i;
  const char byte2hex[] = "0123456789ABCDEF";
  for (i = 0; i < 8; i++) {
    *dst++ = byte2hex[(*src) >> 4];
    *dst++ = byte2hex[(*src++) & 0x0f];
  }
  *dst = '\0';
}


x86 assembly (clang, -O0):
<ParseSerial>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeed(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeea(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xee8(%rip),%al
mov    %al,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x8,-0x18(%rbp)
jae    119c <ParseSerial+0x9c>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
sar    $0x4,%eax
cltq
mov    -0x30(%rbp,%rax,1),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%eax
and    $0xf,%eax
cltq
mov    -0x30(%rbp,%rax,1),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1133 <ParseSerial+0x33>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParseSerial>:
movzbl (%rsi),%ecx
shr    $0x4,%rcx
lea    0xef2(%rip),%rax
mov    (%rcx,%rax,1),%cl
mov    %cl,(%rdi)
movzbl (%rsi),%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x1(%rdi)
movzbl 0x1(%rsi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x2(%rdi)
movzbl 0x1(%rsi),%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x3(%rdi)
movzbl 0x2(%rsi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x4(%rdi)
movzbl 0x2(%rsi),%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x5(%rdi)
movzbl 0x3(%rsi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x6(%rdi)
movzbl 0x3(%rsi),%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x7(%rdi)
movzbl 0x4(%rsi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x8(%rdi)
movzbl 0x4(%rsi),%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x9(%rdi)
movzbl 0x5(%rsi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xa(%rdi)
movzbl 0x5(%rsi),%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xb(%rdi)
movzbl 0x6(%rsi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xc(%rdi)
movzbl 0x6(%rsi),%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xd(%rdi)
movzbl 0x7(%rsi),%ecx
shr    $0x4,%rcx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xe(%rdi)
movzbl 0x7(%rsi),%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%al
mov    %al,0xf(%rdi)
movb   $0x0,0x10(%rdi)
ret

LLVM IR (-O0):
@__const.ParseSerial.byte2hex = [17 x i8] c"0123456789ABCDEF\00"
define void @ParseSerial(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca [17 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = bitcast [17 x i8]* %6 to i8*
store i64 0, i64* %5
br label %8
8: ; preds = %31, %2
%9 = load i64, i64* %5
%10 = icmp ult i64 %9, 8
br i1 %10, label %11, label %34
11: ; preds = %8
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = ashr i32 %14, 4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
store i8 %18, i8* %19
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
%23 = load i8, i8* %21
%24 = zext i8 %23 to i32
%25 = and i32 %24, 15
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %3
store i8 %28, i8* %29
br label %31
31: ; preds = %11
%32 = load i64, i64* %5
%33 = add i64 %32, 1
store i64 %33, i64* %5
br label %8
34: ; preds = %8
%35 = load i8*, i8** %3
store i8 0, i8* %35
ret void
}

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