#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 */
unsigned long long hexreversetoulong(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
unsigned long long hexreversetoulonglong(char *hex) {
  char tmp[9];
  tmp[8] = '\0';
  memset(tmp + 4, '0', 4);
  memcpy(tmp, hex + 8, 4);
  unsigned long long ret = hexreversetoulong(tmp);
  ret <<= 32;
  memcpy(tmp, hex, 8);
  ret += hexreversetoulong(tmp);
  return ret;
}


x86 assembly (clang, -O0):
<hexreversetoulonglong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
lea    -0x11(%rbp),%rdi
add    $0x4,%rdi
mov    $0x30,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
lea    -0x11(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x8,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
lea    -0x11(%rbp),%rdi
call   1040 <hexreversetoulong@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x20,%rax
mov    %rax,-0x20(%rbp)
lea    -0x11(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1050 <memcpy@plt>
lea    -0x11(%rbp),%rdi
call   1040 <hexreversetoulong@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexreversetoulonglong>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r15
movb   $0x0,0xf(%rsp)
lea    0xb(%rsp),%rdi
mov    $0x30,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
lea    0x8(%r15),%rsi
lea    0x7(%rsp),%r14
mov    %r14,%rdi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    %r14,%rdi
call   1040 <hexreversetoulong@plt>
mov    %rax,%rbx
shl    $0x20,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x8,%edx
call   1050 <memcpy@plt>
mov    %r14,%rdi
call   1040 <hexreversetoulong@plt>
add    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @hexreversetoulonglong(i8* %0) {
%2 = alloca i8*
%3 = alloca [9 x i8]
%4 = alloca i64
store i8* %0, i8** %2
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 8
store i8 0, i8* %5
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds i8, i8* %6, i64 4
%8 = call i32 @memset(i8* %7, i32 48, i32 4)
%9 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 8
%12 = call i32 @memcpy(i8* %9, i8* %11, i32 4)
%13 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%14 = call i64 @hexreversetoulong(i8* %13)
store i64 %14, i64* %4
%15 = load i64, i64* %4
%16 = shl i64 %15, 32
store i64 %16, i64* %4
%17 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%18 = load i8*, i8** %2
%19 = call i32 @memcpy(i8* %17, i8* %18, i32 8)
%20 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%21 = call i64 @hexreversetoulong(i8* %20)
%22 = load i64, i64* %4
%23 = add i64 %22, %21
store i64 %23, i64* %4
%24 = load i64, i64* %4
ret i64 %24
}

LLVM IR (-O2):
define i64 @hexreversetoulonglong(i8* %0) {
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 8
store i8 0, i8* %4
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 4
%6 = call i32 @memset(i8* %5, i32 48, i32 4)
%7 = getelementptr inbounds i8, i8* %0, i64 8
%8 = call i32 @memcpy(i8* %3, i8* %7, i32 4)
%9 = call i64 @hexreversetoulong(i8* %3)
%10 = shl i64 %9, 32
%11 = call i32 @memcpy(i8* %3, i8* %0, i32 8)
%12 = call i64 @hexreversetoulong(i8* %3)
%13 = add i64 %12, %10
ret i64 %13
}