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

/* Variables and functions */
uint64_t _ioa_ntoh64(uint64_t v) {
  unsigned char *src = (unsigned char *)&v;
  unsigned char *dst = src + 7;
  while (src < dst) {
    unsigned char vdst = *dst;
    *(dst--) = *src;
    *(src++) = vdst;
  }
  return v;
}


x86 assembly (clang, -O0):
<_ioa_ntoh64>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1162 <_ioa_ntoh64+0x62>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x19(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    111b <_ioa_ntoh64+0x1b>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ioa_ntoh64>:
mov    %edi,-0x4(%rsp)
mov    %dil,0x3(%rsp)
lea    -0x3(%rsp),%rax
lea    0x1(%rsp),%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x1(%rcx),%esi
movzbl (%rax),%edx
mov    %dl,0x1(%rcx)
mov    %sil,(%rax)
add    $0x1,%rax
lea    -0x1(%rcx),%rdx
cmp    %rcx,%rax
mov    %rdx,%rcx
jb     1120 <_ioa_ntoh64+0x20>
mov    -0x4(%rsp),%eax
ret

LLVM IR (-O0):
define i32 @_ioa_ntoh64(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i32 %0, i32* %2
%6 = bitcast i32* %2 to i8*
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 7
store i8* %8, i8** %4
br label %9
9: ; preds = %13, %1
%10 = load i8*, i8** %3
%11 = load i8*, i8** %4
%12 = icmp ult i8* %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
store i8 %15, i8* %5
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 -1
store i8* %19, i8** %4
store i8 %17, i8* %18
%20 = load i8, i8* %5
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
store i8 %20, i8* %21
br label %9
23: ; preds = %9
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
define i32 @_ioa_ntoh64(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = bitcast i32* %2 to i8*
%4 = getelementptr inbounds i8, i8* %3, i64 7
%5 = trunc i32 %0 to i8
%6 = getelementptr inbounds i8, i8* %3, i64 6
store i8 %5, i8* %4
%7 = getelementptr inbounds i8, i8* %3, i64 1
br label %8
8: ; preds = %1, %8
%9 = phi i8* [ %7, %1 ], [ %14, %8 ]
%10 = phi i8* [ %6, %1 ], [ %13, %8 ]
%11 = load i8, i8* %10
%12 = load i8, i8* %9
%13 = getelementptr inbounds i8, i8* %10, i64 -1
store i8 %12, i8* %10
%14 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %11, i8* %9
%15 = icmp ult i8* %14, %13
br i1 %15, label %8, label %16
16: ; preds = %8
%17 = load i32, i32* %2
ret i32 %17
}