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

/* Variables and functions */
uint32_t compress_wkb_line(void *dest, const void *src, uint32_t len) {
  uint32_t d, s;
  double value;
  if (!len)
    return 0;
  for (s = 9, d = 0; s < len; d += 4, s += 8) {
    value = *(double *)(src + s);
    value *= 1000000;
    *(int32_t *)(dest + d) = (int32_t)value;
  }
  return d;
}


x86 assembly (clang, -O0):
<compress_wkb_line>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1125 <compress_wkb_line+0x25>
movl   $0x0,-0x4(%rbp)
jmp    1192 <compress_wkb_line+0x92>
movl   $0x9,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    118c <compress_wkb_line+0x8c>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,1),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xea7(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cvttsd2si -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x24(%rbp)
jmp    1133 <compress_wkb_line+0x33>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<compress_wkb_line>:
xor    %eax,%eax
cmp    $0xa,%edx
jl     1140 <compress_wkb_line+0x40>
mov    %edx,%r8d
mov    $0x9,%edx
xor    %eax,%eax
movsd  0xee7(%rip),%xmm0
nopl   0x0(%rax)
movsd  0x9(%rsi,%rax,2),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rcx
mov    %rcx,(%rdi,%rax,1)
add    $0x4,%rax
add    $0x8,%rdx
cmp    %r8,%rdx
jb     1120 <compress_wkb_line+0x20>
ret

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

LLVM IR (-O2):
define i32 @compress_wkb_line(i8* nocapture writeonly %0, i8* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 9
br i1 %4, label %5, label %22
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %17, %7 ]
%9 = phi i64 [ 9, %5 ], [ %18, %7 ]
%10 = getelementptr i8, i8* %1, i64 %9
%11 = bitcast i8* %10 to double*
%12 = load double, double* %11
%13 = fmul double %12, 1.000000e+06
%14 = fptosi double %13 to i64
%15 = getelementptr i8, i8* %0, i64 %8
%16 = bitcast i8* %15 to i64*
store i64 %14, i64* %16
%17 = add nuw nsw i64 %8, 4
%18 = add nuw nsw i64 %9, 8
%19 = icmp ult i64 %18, %6
br i1 %19, label %7, label %20
20: ; preds = %7
%21 = trunc i64 %17 to i32
br label %22
22: ; preds = %20, %3
%23 = phi i32 [ 0, %3 ], [ %21, %20 ]
ret i32 %23
}