#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*/ commas_in_double(char *, double);
int /*<<< orphan*/ printf(char *, double, int /*<<< orphan*/);
void test_commas_in_double(void) {
  double d;
  char buffer[512];
  for (d = 1000000000000.0; d > 1.0; d /= 1000.0) {
    printf("for d = %.2lf: %s\n", d, commas_in_double(buffer, d));
  }
}


x86 assembly (clang, -O0):
<test_commas_in_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movsd  0xecd(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xec3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119e <test_commas_in_double+0x7e>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x218(%rbp)
ff
lea    -0x210(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
call   1040 <commas_in_double@plt>
movsd  -0x218(%rbp),%xmm0
ff
mov    %eax,%esi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
movsd  0xe80(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1138 <test_commas_in_double+0x18>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_commas_in_double>:
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rsp,%r14
movsd  0xecb(%rip),%xmm0
mov    %r14,%rdi
call   1040 <commas_in_double@plt>
lea    0xedc(%rip),%rbx
mov    %rbx,%rdi
movsd  0xeb1(%rip),%xmm0
mov    %eax,%esi
call   1030 <printf@plt>
movsd  0xeaa(%rip),%xmm0
mov    %r14,%rdi
call   1040 <commas_in_double@plt>
mov    %rbx,%rdi
movsd  0xe97(%rip),%xmm0
mov    %eax,%esi
call   1030 <printf@plt>
movsd  0xe90(%rip),%xmm0
mov    %r14,%rdi
call   1040 <commas_in_double@plt>
mov    %rbx,%rdi
movsd  0xe7d(%rip),%xmm0
mov    %eax,%esi
call   1030 <printf@plt>
movsd  0xe76(%rip),%xmm0
mov    %r14,%rdi
call   1040 <commas_in_double@plt>
mov    %rbx,%rdi
movsd  0xe63(%rip),%xmm0
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"for d = %.2lf: %s\0A\00"
define void @test_commas_in_double() {
%1 = alloca double
%2 = alloca [512 x i8]
store double 1.000000e+12, double* %1
br label %3
3: ; preds = %12, %0
%4 = load double, double* %1
%5 = fcmp ogt double %4, 1.000000e+00
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = load double, double* %1
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%9 = load double, double* %1
%10 = call i32 @commas_in_double(i8* %8, double %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %7, i32 %10)
br label %12
12: ; preds = %6
%13 = load double, double* %1
%14 = fdiv double %13, 1.000000e+03
store double %14, double* %1
br label %3
15: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"for d = %.2lf: %s\0A\00"
define void @test_commas_in_double() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = call i32 @commas_in_double(i8* %2, double 1.000000e+12)
%4 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double 1.000000e+12, i32 %3)
%5 = call i32 @commas_in_double(i8* %2, double 1.000000e+09)
%6 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double 1.000000e+09, i32 %5)
%7 = call i32 @commas_in_double(i8* %2, double 1.000000e+06)
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double 1.000000e+06, i32 %7)
%9 = call i32 @commas_in_double(i8* %2, double 1.000000e+03)
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double 1.000000e+03, i32 %9)
ret void
}