#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__ int64_t;

/* Variables and functions */
char *add_int(char *, char *, scalar_t__, int);
char *add_double(char *dest, char *end, double value) {
  int i;
  dest = add_int(dest, end, (int64_t)value, 10);
  value -= (int64_t)value;
  if (dest < end) {
    *(dest++) = '.';
  }
  for (i = 0; dest < end && i < 2; i++) {
    value *= 10;
    *(dest++) = '0' + (int)value;
  }
  return dest;
}


x86 assembly (clang, -O0):
<add_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
cvttsd2si -0x18(%rbp),%rdx
mov    $0xa,%ecx
call   1030 <add_int@plt>
mov    %rax,-0x8(%rbp)
cvttsd2si -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    117a <add_double+0x6a>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x2e,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x1d(%rbp)
jae    119e <add_double+0x8e>
cmpl   $0x2,-0x1c(%rbp)
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11ae <add_double+0x9e>
jmp    11e9 <add_double+0xd9>
movsd  0xe4a(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1181 <add_double+0x71>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_double>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
movsd  %xmm0,(%rsp)
cvttsd2si %xmm0,%r14
mov    %r14,%rdx
mov    $0xa,%ecx
call   1030 <add_int@plt>
cmp    %rbx,%rax
jae    113a <add_double+0x2a>
movb   $0x2e,(%rax)
add    $0x1,%rax
cmp    %rbx,%rax
jae    1184 <add_double+0x74>
xorps  %xmm0,%xmm0
cvtsi2sd %r14,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mulsd  0xea4(%rip),%xmm0
cvttsd2si %xmm0,%edx
add    $0x30,%dl
lea    0x1(%rax),%rcx
mov    %dl,(%rax)
cmp    %rbx,%rcx
jae    1187 <add_double+0x77>
mulsd  0xe8a(%rip),%xmm0
cvttsd2si %xmm0,%ecx
add    $0x30,%cl
mov    %cl,0x1(%rax)
add    $0x2,%rax
mov    %rax,%rcx
mov    %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @add_double(i8* %0, i8* %1, double %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store double %2, double* %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = load double, double* %6
%11 = fptosi double %10 to i64
%12 = call i8* @add_int(i8* %8, i8* %9, i64 %11, i32 10)
store i8* %12, i8** %4
%13 = load double, double* %6
%14 = fptosi double %13 to i64
%15 = sitofp i64 %14 to double
%16 = load double, double* %6
%17 = fsub double %16, %15
store double %17, double* %6
%18 = load i8*, i8** %4
%19 = load i8*, i8** %5
%20 = icmp ult i8* %18, %19
br i1 %20, label %21, label %24
21: ; preds = %3
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
store i8 46, i8* %22
br label %24
24: ; preds = %21, %3
store i32 0, i32* %7
br label %25
25: ; preds = %43, %24
%26 = load i8*, i8** %4
%27 = load i8*, i8** %5
%28 = icmp ult i8* %26, %27
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 2
br label %32
32: ; preds = %29, %25
%33 = phi i1 [ false, %25 ], [ %31, %29 ]
br i1 %33, label %34, label %46
34: ; preds = %32
%35 = load double, double* %6
%36 = fmul double %35, 1.000000e+01
store double %36, double* %6
%37 = load double, double* %6
%38 = fptosi double %37 to i32
%39 = add nsw i32 48, %38
%40 = trunc i32 %39 to i8
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %4
store i8 %40, i8* %41
br label %43
43: ; preds = %34
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %25
46: ; preds = %32
%47 = load i8*, i8** %4
ret i8* %47
}

LLVM IR (-O2):
define i8* @add_double(i8* %0, i8* %1, double %2) {
%4 = fptosi double %2 to i64
%5 = tail call i8* @add_int(i8* %0, i8* %1, i64 %4, i32 10)
%6 = sitofp i64 %4 to double
%7 = fsub double %2, %6
%8 = icmp ult i8* %5, %1
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = getelementptr inbounds i8, i8* %5, i64 1
store i8 46, i8* %5
br label %11
11: ; preds = %9, %3
%12 = phi i8* [ %10, %9 ], [ %5, %3 ]
%13 = icmp ult i8* %12, %1
br i1 %13, label %14, label %27
14: ; preds = %11
%15 = fmul double %7, 1.000000e+01
%16 = fptosi double %15 to i32
%17 = trunc i32 %16 to i8
%18 = add i8 %17, 48
%19 = getelementptr inbounds i8, i8* %12, i64 1
store i8 %18, i8* %12
%20 = icmp ult i8* %19, %1
br i1 %20, label %21, label %27
21: ; preds = %14
%22 = fmul double %15, 1.000000e+01
%23 = fptosi double %22 to i32
%24 = trunc i32 %23 to i8
%25 = add i8 %24, 48
%26 = getelementptr inbounds i8, i8* %12, i64 2
store i8 %25, i8* %19
br label %27
27: ; preds = %14, %21, %11
%28 = phi i8* [ %12, %11 ], [ %19, %14 ], [ %26, %21 ]
ret i8* %28
}