#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*/ sprintf(char *, char *, double);
void WriteCoord(char *str, double x) {
  if (x < -9999999.9) {
    sprintf(str, "%10.2e", x);
  } else if (x < -999999.99) {
    sprintf(str, "%10.2f", x);
  } else if (x < -99999.999) {
    sprintf(str, "%10.3f", x);
  } else if (x < 99999.9999) {
    sprintf(str, "%10.4f", x);
  } else if (x < 999999.999) {
    sprintf(str, "%10.3f", x);
  } else if (x < 9999999.99) {
    sprintf(str, "%10.2f", x);
  } else if (x < 99999999.9) {
    sprintf(str, "%10.1f", x);
  } else {
    sprintf(str, "%10.3e", x);
  }
}


x86 assembly (clang, -O0):
<WriteCoord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  0xed7(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    114e <WriteCoord+0x3e>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xef4(%rip),%rsi
call   1030 <sprintf@plt>
jmp    128f <WriteCoord+0x17f>
movsd  0xeb2(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    117b <WriteCoord+0x6b>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xece(%rip),%rsi
call   1030 <sprintf@plt>
jmp    128a <WriteCoord+0x17a>
movsd  0xe8d(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11a8 <WriteCoord+0x98>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xea8(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1285 <WriteCoord+0x175>
movsd  0xe68(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11d5 <WriteCoord+0xc5>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xe82(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1280 <WriteCoord+0x170>
movsd  0xe43(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1202 <WriteCoord+0xf2>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xe4e(%rip),%rsi
call   1030 <sprintf@plt>
jmp    127b <WriteCoord+0x16b>
movsd  0xe1e(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    122f <WriteCoord+0x11f>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xe1a(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1276 <WriteCoord+0x166>
movsd  0xdf9(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    125c <WriteCoord+0x14c>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xe02(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1271 <WriteCoord+0x161>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xdef(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1276 <WriteCoord+0x166>
jmp    127b <WriteCoord+0x16b>
jmp    1280 <WriteCoord+0x170>
jmp    1285 <WriteCoord+0x175>
jmp    128a <WriteCoord+0x17a>
jmp    128f <WriteCoord+0x17f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteCoord>:
movsd  0xee8(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    112a <WriteCoord+0x1a>
lea    0xf13(%rip),%rsi
jmp    1030 <sprintf@plt>
lea    0xf0e(%rip),%rax
movsd  0xecf(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1147 <WriteCoord+0x37>
mov    %rax,%rsi
jmp    1030 <sprintf@plt>
lea    0xef8(%rip),%rsi
movsd  0xeba(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     11b3 <WriteCoord+0xa3>
movsd  0xeb4(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1176 <WriteCoord+0x66>
lea    0xedc(%rip),%rsi
jmp    1030 <sprintf@plt>
movsd  0xea2(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     11b3 <WriteCoord+0xa3>
movsd  0xe9c(%rip),%xmm1
ucomisd %xmm0,%xmm1
mov    %rax,%rsi
ja     11b3 <WriteCoord+0xa3>
movsd  0xe93(%rip),%xmm1
ucomisd %xmm0,%xmm1
lea    0xeac(%rip),%rax
lea    0xeac(%rip),%rsi
cmova  %rax,%rsi
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%10.2e\00"
@.str.1 = [7 x i8] c"%10.2f\00"
@.str.2 = [7 x i8] c"%10.3f\00"
@.str.3 = [7 x i8] c"%10.4f\00"
@.str.4 = [7 x i8] c"%10.1f\00"
@.str.5 = [7 x i8] c"%10.3e\00"
define void @WriteCoord(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
store i8* %0, i8** %3
store double %1, double* %4
%5 = load double, double* %4
%6 = fcmp olt double %5, 0xC16312CFFCCCCCCD
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = load double, double* %4
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %9)
br label %63
11: ; preds = %2
%12 = load double, double* %4
%13 = fcmp olt double %12, 0xC12E847FFAE147AE
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i8*, i8** %3
%16 = load double, double* %4
%17 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %16)
br label %62
18: ; preds = %11
%19 = load double, double* %4
%20 = fcmp olt double %19, 0xC0F869FFFBE76C8B
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i8*, i8** %3
%23 = load double, double* %4
%24 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %23)
br label %61
25: ; preds = %18
%26 = load double, double* %4
%27 = fcmp olt double %26, 0x40F869FFFF972474
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i8*, i8** %3
%30 = load double, double* %4
%31 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %30)
br label %60
32: ; preds = %25
%33 = load double, double* %4
%34 = fcmp olt double %33, 0x412E847FFF7CED91
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i8*, i8** %3
%37 = load double, double* %4
%38 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %37)
br label %59
39: ; preds = %32
%40 = load double, double* %4
%41 = fcmp olt double %40, 0x416312CFFFAE147B
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i8*, i8** %3
%44 = load double, double* %4
%45 = call i32 @sprintf(i8* %43, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %44)
br label %58
46: ; preds = %39
%47 = load double, double* %4
%48 = fcmp olt double %47, 0x4197D783FF99999A
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load i8*, i8** %3
%51 = load double, double* %4
%52 = call i32 @sprintf(i8* %50, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %51)
br label %57
53: ; preds = %46
%54 = load i8*, i8** %3
%55 = load double, double* %4
%56 = call i32 @sprintf(i8* %54, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double %55)
br label %57
57: ; preds = %53, %49
br label %58
58: ; preds = %57, %42
br label %59
59: ; preds = %58, %35
br label %60
60: ; preds = %59, %28
br label %61
61: ; preds = %60, %21
br label %62
62: ; preds = %61, %14
br label %63
63: ; preds = %62, %7
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%10.2e\00"
@.str.1 = [7 x i8] c"%10.2f\00"
@.str.2 = [7 x i8] c"%10.3f\00"
@.str.3 = [7 x i8] c"%10.4f\00"
@.str.4 = [7 x i8] c"%10.1f\00"
@.str.5 = [7 x i8] c"%10.3e\00"
define void @WriteCoord(i8* nocapture writeonly %0, double %1) {
%3 = fcmp olt double %1, 0xC16312CFFCCCCCCD
br i1 %3, label %17, label %4
4: ; preds = %2
%5 = fcmp olt double %1, 0xC12E847FFAE147AE
br i1 %5, label %17, label %6
6: ; preds = %4
%7 = fcmp olt double %1, 0xC0F869FFFBE76C8B
br i1 %7, label %17, label %8
8: ; preds = %6
%9 = fcmp olt double %1, 0x40F869FFFF972474
br i1 %9, label %17, label %10
10: ; preds = %8
%11 = fcmp olt double %1, 0x412E847FFF7CED91
br i1 %11, label %17, label %12
12: ; preds = %10
%13 = fcmp olt double %1, 0x416312CFFFAE147B
br i1 %13, label %17, label %14
14: ; preds = %12
%15 = fcmp olt double %1, 0x4197D783FF99999A
%16 = select i1 %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
br label %17
17: ; preds = %14, %12, %10, %8, %6, %4, %2
%18 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %8 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %12 ], [ %16, %14 ]
%19 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) %18, double %1)
ret void
}