#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 */
scalar_t__ ConvertBitOrder();
void ConvertToDouble(unsigned char *cnv, double *val) {
  unsigned char *out;
  int i;
  out = (unsigned char *)val;
  if (ConvertBitOrder() == 0)
    for (i = 0; i < 8; i++)
      out[i] = cnv[7 - i];
  else
    for (i = 0; i < 8; i++)
      out[i] = cnv[i];
}


x86 assembly (clang, -O0):
<ConvertToDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <ConvertBitOrder@plt>
cmp    $0x0,%rax
jne    117a <ConvertToDouble+0x6a>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    1175 <ConvertToDouble+0x65>
mov    -0x8(%rbp),%rax
mov    $0x7,%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1140 <ConvertToDouble+0x30>
jmp    11b4 <ConvertToDouble+0xa4>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    11af <ConvertToDouble+0x9f>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1181 <ConvertToDouble+0x71>
jmp    11b4 <ConvertToDouble+0xa4>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConvertToDouble>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <ConvertBitOrder@plt>
test   %rax,%rax
je     115b <ConvertToDouble+0x4b>
mov    (%rbx),%al
mov    %al,(%r14)
mov    0x1(%rbx),%al
mov    %al,0x1(%r14)
mov    0x2(%rbx),%al
mov    %al,0x2(%r14)
mov    0x3(%rbx),%al
mov    %al,0x3(%r14)
mov    0x4(%rbx),%al
mov    %al,0x4(%r14)
mov    0x5(%rbx),%al
mov    %al,0x5(%r14)
mov    0x6(%rbx),%al
mov    %al,0x6(%r14)
add    $0x7,%rbx
jmp    118b <ConvertToDouble+0x7b>
mov    0x7(%rbx),%al
mov    %al,(%r14)
mov    0x6(%rbx),%al
mov    %al,0x1(%r14)
mov    0x5(%rbx),%al
mov    %al,0x2(%r14)
mov    0x4(%rbx),%al
mov    %al,0x3(%r14)
mov    0x3(%rbx),%al
mov    %al,0x4(%r14)
mov    0x2(%rbx),%al
mov    %al,0x5(%r14)
mov    0x1(%rbx),%al
mov    %al,0x6(%r14)
mov    (%rbx),%al
mov    %al,0x7(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @ConvertToDouble(i8* %0, double* %1) {
%3 = alloca i8*
%4 = alloca double*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store double* %1, double** %4
%7 = load double*, double** %4
%8 = bitcast double* %7 to i8*
store i8* %8, i8** %5
%9 = call i64 (...) @ConvertBitOrder()
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %30
11: ; preds = %2
store i32 0, i32* %6
br label %12
12: ; preds = %26, %11
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 8
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = load i32, i32* %6
%18 = sub nsw i32 7, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = load i8, i8* %20
%22 = load i8*, i8** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 %21, i8* %25
br label %26
26: ; preds = %15
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %12
29: ; preds = %12
br label %48
30: ; preds = %2
store i32 0, i32* %6
br label %31
31: ; preds = %44, %30
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 8
br i1 %33, label %34, label %47
34: ; preds = %31
%35 = load i8*, i8** %3
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = load i8*, i8** %5
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
store i8 %39, i8* %43
br label %44
44: ; preds = %34
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %31
47: ; preds = %31
br label %48
48: ; preds = %47, %29
ret void
}

LLVM IR (-O2):
define void @ConvertToDouble(i8* nocapture %0, double* nocapture writeonly %1) {
%3 = bitcast double* %1 to i8*
%4 = tail call i64 (...) @ConvertBitOrder()
%5 = icmp eq i64 %4, 0
br i1 %5, label %27, label %6
6: ; preds = %2
%7 = load i8, i8* %0
store i8 %7, i8* %3
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %9, i8* %10
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %3, i64 2
store i8 %12, i8* %13
%14 = getelementptr inbounds i8, i8* %0, i64 3
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %3, i64 3
store i8 %15, i8* %16
%17 = getelementptr inbounds i8, i8* %0, i64 4
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %3, i64 4
store i8 %18, i8* %19
%20 = getelementptr inbounds i8, i8* %0, i64 5
%21 = load i8, i8* %20
%22 = getelementptr inbounds i8, i8* %3, i64 5
store i8 %21, i8* %22
%23 = getelementptr inbounds i8, i8* %0, i64 6
%24 = load i8, i8* %23
%25 = getelementptr inbounds i8, i8* %3, i64 6
store i8 %24, i8* %25
%26 = getelementptr inbounds i8, i8* %0, i64 7
br label %48
27: ; preds = %2
%28 = getelementptr inbounds i8, i8* %0, i64 7
%29 = load i8, i8* %28
store i8 %29, i8* %3
%30 = getelementptr inbounds i8, i8* %0, i64 6
%31 = load i8, i8* %30
%32 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %31, i8* %32
%33 = getelementptr inbounds i8, i8* %0, i64 5
%34 = load i8, i8* %33
%35 = getelementptr inbounds i8, i8* %3, i64 2
store i8 %34, i8* %35
%36 = getelementptr inbounds i8, i8* %0, i64 4
%37 = load i8, i8* %36
%38 = getelementptr inbounds i8, i8* %3, i64 3
store i8 %37, i8* %38
%39 = getelementptr inbounds i8, i8* %0, i64 3
%40 = load i8, i8* %39
%41 = getelementptr inbounds i8, i8* %3, i64 4
store i8 %40, i8* %41
%42 = getelementptr inbounds i8, i8* %0, i64 2
%43 = load i8, i8* %42
%44 = getelementptr inbounds i8, i8* %3, i64 5
store i8 %43, i8* %44
%45 = getelementptr inbounds i8, i8* %0, i64 1
%46 = load i8, i8* %45
%47 = getelementptr inbounds i8, i8* %3, i64 6
store i8 %46, i8* %47
br label %48
48: ; preds = %6, %27
%49 = phi i8* [ %26, %6 ], [ %0, %27 ]
%50 = load i8, i8* %49
%51 = getelementptr inbounds i8, i8* %3, i64 7
store i8 %50, i8* %51
ret void
}