#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*/ memcpy(double *, unsigned char *, int);
int sqliterkParseNumber(const unsigned char *data, int offset, double *value) {
  if (!data || !value) {
    return 2;
  }
  unsigned char out[8];
  const unsigned char *begin = data + offset;
  int i;
  for (i = 0; i < 8; i++) {
    out[i] = begin[8 - 1 - i];
  }
  memcpy(value, out, 8);
  return 0;
}


x86 assembly (clang, -O0):
<sqliterkParseNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1139 <sqliterkParseNumber+0x29>
cmpq   $0x0,-0x20(%rbp)
jne    1145 <sqliterkParseNumber+0x35>
movl   $0x2,-0x4(%rbp)
jmp    11a6 <sqliterkParseNumber+0x96>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    118d <sqliterkParseNumber+0x7d>
mov    -0x30(%rbp),%rax
mov    $0x7,%ecx
sub    -0x34(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x34(%rbp),%rax
mov    %cl,-0x28(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115b <sqliterkParseNumber+0x4b>
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqliterkParseNumber>:
mov    $0x2,%eax
test   %rdi,%rdi
je     1177 <sqliterkParseNumber+0x67>
test   %rdx,%rdx
je     1177 <sqliterkParseNumber+0x67>
push   %rax
movslq %esi,%rax
mov    0x7(%rdi,%rax,1),%cl
mov    %cl,(%rsp)
mov    0x6(%rdi,%rax,1),%cl
mov    %cl,0x1(%rsp)
mov    0x5(%rdi,%rax,1),%cl
mov    %cl,0x2(%rsp)
mov    0x4(%rdi,%rax,1),%cl
mov    %cl,0x3(%rsp)
mov    0x3(%rdi,%rax,1),%cl
mov    %cl,0x4(%rsp)
mov    0x2(%rdi,%rax,1),%cl
mov    %cl,0x5(%rsp)
mov    0x1(%rdi,%rax,1),%cl
mov    %cl,0x6(%rsp)
mov    (%rdi,%rax,1),%al
mov    %al,0x7(%rsp)
mov    %rsp,%rsi
mov    %rdx,%rdi
mov    $0x8,%edx
call   1030 <memcpy@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

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

LLVM IR (-O2):
define i32 @sqliterkParseNumber(i8* %0, i32 %1, double* %2) {
%4 = alloca [8 x i8]
%5 = icmp ne i8* %0, null
%6 = icmp ne double* %2, null
%7 = and i1 %5, %6
br i1 %7, label %8, label %35
8: ; preds = %3
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%10 = sext i32 %1 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = getelementptr inbounds i8, i8* %11, i64 7
%13 = load i8, i8* %12
store i8 %13, i8* %9
%14 = getelementptr inbounds i8, i8* %11, i64 6
%15 = load i8, i8* %14
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 1
store i8 %15, i8* %16
%17 = getelementptr inbounds i8, i8* %11, i64 5
%18 = load i8, i8* %17
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 2
store i8 %18, i8* %19
%20 = getelementptr inbounds i8, i8* %11, i64 4
%21 = load i8, i8* %20
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 3
store i8 %21, i8* %22
%23 = getelementptr inbounds i8, i8* %11, i64 3
%24 = load i8, i8* %23
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 4
store i8 %24, i8* %25
%26 = getelementptr inbounds i8, i8* %11, i64 2
%27 = load i8, i8* %26
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 5
store i8 %27, i8* %28
%29 = getelementptr inbounds i8, i8* %11, i64 1
%30 = load i8, i8* %29
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 6
store i8 %30, i8* %31
%32 = load i8, i8* %11
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 7
store i8 %32, i8* %33
%34 = call i32 @memcpy(double* %2, i8* %9, i32 8)
br label %35
35: ; preds = %3, %8
%36 = phi i32 [ 0, %8 ], [ 2, %3 ]
ret i32 %36
}