#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 scalar_t__ uint32_t;
typedef scalar_t__ int32_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(void *, char *, int);
uint32_t uncompress_wkb_line(void *dest, const void *src, uint32_t len) {
  uint32_t d, s;
  double value;
  if (!len)
    return 0;
  memcpy(dest, "\01\02\00\00\00\06\00\00\00", 10);
  for (s = 0, d = 9; s < len; s += 4, d += 8) {
    value = (double)*(int32_t *)(src + s);
    value /= 1000000;
    *(double *)(dest + d) = value;
  }
  return d;
}


x86 assembly (clang, -O0):
<uncompress_wkb_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    113c <uncompress_wkb_line+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    11cf <uncompress_wkb_line+0xbf>
mov    -0x10(%rbp),%rdi
lea    0xec1(%rip),%rsi
mov    $0xa,%edx
call   1030 <memcpy@plt>
movq   $0x0,-0x30(%rbp)
movq   $0x9,-0x28(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11c7 <uncompress_wkb_line+0xb7>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
cvtsi2sdq (%rax,%rcx,1),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe71(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
jmp    1161 <uncompress_wkb_line+0x51>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uncompress_wkb_line>:
push   %r15
push   %r14
push   %rbx
test   %rdx,%rdx
je     115c <uncompress_wkb_line+0x4c>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xede(%rip),%rsi
mov    $0xa,%edx
call   1030 <memcpy@plt>
test   %r15,%r15
jle    1160 <uncompress_wkb_line+0x50>
add    $0xffffffffffffffff,%r15
mov    %r15,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
cmp    $0x4,%r15
jae    1167 <uncompress_wkb_line+0x57>
mov    $0x9,%eax
xor    %edx,%edx
test   $0x1,%cl
jne    11bd <uncompress_wkb_line+0xad>
jmp    11d7 <uncompress_wkb_line+0xc7>
xor    %eax,%eax
jmp    11d7 <uncompress_wkb_line+0xc7>
mov    $0x9,%eax
jmp    11d7 <uncompress_wkb_line+0xc7>
mov    %rcx,%rsi
and    $0xfffffffffffffffe,%rsi
mov    $0xfffffffffffffff7,%rax
xor    %edx,%edx
movsd  0xe81(%rip),%xmm0
nop
xorps  %xmm1,%xmm1
cvtsi2sdq (%r14,%rdx,1),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x9(%rbx,%rdx,2)
xorps  %xmm1,%xmm1
cvtsi2sdq 0x4(%r14,%rdx,1),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x11(%rbx,%rdx,2)
add    $0x8,%rdx
add    $0xfffffffffffffff0,%rax
add    $0xfffffffffffffffe,%rsi
jne    1180 <uncompress_wkb_line+0x70>
neg    %rax
test   $0x1,%cl
je     11d7 <uncompress_wkb_line+0xc7>
xorps  %xmm0,%xmm0
cvtsi2sdq (%r14,%rdx,1),%xmm0
divsd  0xe32(%rip),%xmm0
movsd  %xmm0,(%rbx,%rax,1)
add    $0x8,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"\01\02\00\00\00\06\00\00\00\00"
define i64 @uncompress_wkb_line(i8* %0, i8* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %54, label %5
5: ; preds = %3
%6 = tail call i32 @memcpy(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 10)
%7 = icmp sgt i64 %2, 0
br i1 %7, label %8, label %54
8: ; preds = %5
%9 = add i64 %2, -1
%10 = lshr i64 %9, 2
%11 = add nuw nsw i64 %10, 1
%12 = and i64 %11, 1
%13 = icmp ult i64 %9, 4
br i1 %13, label %40, label %14
14: ; preds = %8
%15 = and i64 %11, 9223372036854775806
br label %16
16: ; preds = %16, %14
%17 = phi i64 [ 0, %14 ], [ %36, %16 ]
%18 = phi i64 [ 9, %14 ], [ %37, %16 ]
%19 = phi i64 [ 0, %14 ], [ %38, %16 ]
%20 = getelementptr i8, i8* %1, i64 %17
%21 = bitcast i8* %20 to i64*
%22 = load i64, i64* %21
%23 = sitofp i64 %22 to double
%24 = fdiv double %23, 1.000000e+06
%25 = getelementptr i8, i8* %0, i64 %18
%26 = bitcast i8* %25 to double*
store double %24, double* %26
%27 = or i64 %17, 4
%28 = add nuw nsw i64 %18, 8
%29 = getelementptr i8, i8* %1, i64 %27
%30 = bitcast i8* %29 to i64*
%31 = load i64, i64* %30
%32 = sitofp i64 %31 to double
%33 = fdiv double %32, 1.000000e+06
%34 = getelementptr i8, i8* %0, i64 %28
%35 = bitcast i8* %34 to double*
store double %33, double* %35
%36 = add nuw nsw i64 %17, 8
%37 = add nuw nsw i64 %18, 16
%38 = add i64 %19, 2
%39 = icmp eq i64 %38, %15
br i1 %39, label %40, label %16
40: ; preds = %16, %8
%41 = phi i64 [ undef, %8 ], [ %37, %16 ]
%42 = phi i64 [ 0, %8 ], [ %36, %16 ]
%43 = phi i64 [ 9, %8 ], [ %37, %16 ]
%44 = icmp eq i64 %12, 0
br i1 %44, label %54, label %45
45: ; preds = %40
%46 = getelementptr i8, i8* %1, i64 %42
%47 = bitcast i8* %46 to i64*
%48 = load i64, i64* %47
%49 = sitofp i64 %48 to double
%50 = fdiv double %49, 1.000000e+06
%51 = getelementptr i8, i8* %0, i64 %43
%52 = bitcast i8* %51 to double*
store double %50, double* %52
%53 = add nuw nsw i64 %43, 8
br label %54
54: ; preds = %45, %40, %5, %3
%55 = phi i64 [ 0, %3 ], [ 9, %5 ], [ %41, %40 ], [ %53, %45 ]
ret i64 %55
}