#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 */
double fabs(double);
double fmod(double, int);
int /*<<< orphan*/ sprintf(char *, char *, double);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void comma_dprint(char *s, double size) {
  char tbuf[256];
  char t2[100];
  char fmt[10];
  int negative, c;
  c = 0;
  s[0] = '\0';
  if (size == 0.) {
    s[0] = '0';
    s[1] = '\0';
    return;
  }
  negative = (size < 0);
  size = fabs(size);
  while (size) {
    double m;
    int i;
    if (c > 0 && size < 0.5)
      break;
    m = fmod(size, 1000.);
    if (m != size)
      strcpy(fmt, "%03d");
    else
      strcpy(fmt, "%d");
    size = (size - m) / 1000.;
    i = (int)m;
    m -= i;
    sprintf(tbuf, fmt, i);
    if (c == 0 && m != 0.) {
      sprintf(t2, "%g", m);
      for (i = 0; t2[i] != '.' && t2[i] != '\0'; i++)
        ;
      strcat(tbuf, &t2[i]);
    }
    if (c)
      strcat(tbuf, ",");
    strcat(tbuf, s);
    strcpy(s, tbuf);
    c++;
  }
  if (negative) {
    strcpy(tbuf, "-");
    strcat(tbuf, s);
    strcpy(s, tbuf);
  }
}


x86 assembly (clang, -O0):
<comma_dprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x194(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1191 <comma_dprint+0x51>
jp     1191 <comma_dprint+0x51>
mov    -0x8(%rbp),%rax
movb   $0x30,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x1(%rax)
jmp    142b <comma_dprint+0x2eb>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x190(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xe4d(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d9 <comma_dprint+0x99>
jp     11d9 <comma_dprint+0x99>
jmp    13eb <comma_dprint+0x2ab>
cmpl   $0x0,-0x194(%rbp)
jle    11fe <comma_dprint+0xbe>
movsd  0xe22(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11fe <comma_dprint+0xbe>
jmp    13eb <comma_dprint+0x2ab>
movsd  -0x10(%rbp),%xmm0
mov    $0x3e8,%edi
call   1040 <fmod@plt>
movsd  %xmm0,-0x1a0(%rbp)
ff
movsd  -0x1a0(%rbp),%xmm0
ff
ucomisd -0x10(%rbp),%xmm0
jne    1233 <comma_dprint+0xf3>
jp     1233 <comma_dprint+0xf3>
jmp    124b <comma_dprint+0x10b>
lea    -0x18a(%rbp),%rdi
lea    0xddf(%rip),%rsi
call   1030 <strcpy@plt>
jmp    125e <comma_dprint+0x11e>
lea    -0x18a(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   1030 <strcpy@plt>
movsd  -0x10(%rbp),%xmm0
subsd  -0x1a0(%rbp),%xmm0
ff
movsd  0xda5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x1a0(%rbp),%eax
ff
mov    %eax,-0x1a4(%rbp)
cvtsi2sdl -0x1a4(%rbp),%xmm1
ff
movsd  -0x1a0(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x1a0(%rbp)
ff
lea    -0x110(%rbp),%rdi
lea    -0x18a(%rbp),%rsi
cvtsi2sdl -0x1a4(%rbp),%xmm0
ff
call   1060 <sprintf@plt>
cmpl   $0x0,-0x194(%rbp)
jne    1397 <comma_dprint+0x257>
movsd  -0x1a0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12ee <comma_dprint+0x1ae>
jp     12ee <comma_dprint+0x1ae>
jmp    1397 <comma_dprint+0x257>
lea    -0x180(%rbp),%rdi
movsd  -0x1a0(%rbp),%xmm0
ff
lea    0xd24(%rip),%rsi
call   1060 <sprintf@plt>
movl   $0x0,-0x1a4(%rbp)
movslq -0x1a4(%rbp),%rax
movsbl -0x180(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0x2e,%ecx
mov    %al,-0x1a5(%rbp)
je     134e <comma_dprint+0x20e>
movslq -0x1a4(%rbp),%rax
movsbl -0x180(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1a5(%rbp)
mov    -0x1a5(%rbp),%al
test   $0x1,%al
jne    1361 <comma_dprint+0x221>
jmp    137a <comma_dprint+0x23a>
jmp    1366 <comma_dprint+0x226>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1313 <comma_dprint+0x1d3>
lea    -0x110(%rbp),%rdi
movslq -0x1a4(%rbp),%rax
lea    -0x180(%rbp),%rsi
add    %rax,%rsi
call   1050 <strcat@plt>
cmpl   $0x0,-0x194(%rbp)
je     13b7 <comma_dprint+0x277>
lea    -0x110(%rbp),%rdi
lea    0xc79(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x194(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x194(%rbp)
jmp    11bc <comma_dprint+0x7c>
cmpl   $0x0,-0x190(%rbp)
je     142b <comma_dprint+0x2eb>
lea    -0x110(%rbp),%rdi
lea    0xc27(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comma_dprint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1c8,%rsp
mov    %rdi,%r15
movb   $0x0,(%rdi)
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116e <comma_dprint+0x2e>
jp     116e <comma_dprint+0x2e>
movw   $0x30,(%r15)
jmp    1308 <comma_dprint+0x1c8>
movapd 0xe8a(%rip),%xmm1
movapd %xmm0,0x20(%rsp)
andpd  %xmm0,%xmm1
xor    %r12d,%r12d
lea    0xe9e(%rip),%r13
lea    0xe9c(%rip),%rbp
lea    0x46(%rsp),%r14
lea    0xc0(%rsp),%rbx
jmp    11cf <comma_dprint+0x8f>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
add    $0x1,%r12d
xorpd  %xmm0,%xmm0
movapd (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    11cf <comma_dprint+0x8f>
jnp    12cf <comma_dprint+0x18f>
test   %r12d,%r12d
je     11e6 <comma_dprint+0xa6>
movsd  0xe34(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     12cf <comma_dprint+0x18f>
movapd %xmm1,%xmm0
mov    $0x3e8,%edi
movapd %xmm1,(%rsp)
call   1040 <fmod@plt>
movapd %xmm0,0x10(%rsp)
ucomisd (%rsp),%xmm0
mov    %rbp,%rsi
cmovne %r13,%rsi
cmovp  %r13,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
movapd 0x10(%rsp),%xmm1
movapd (%rsp),%xmm0
subsd  %xmm1,%xmm0
divsd  0xdea(%rip),%xmm0
movapd %xmm0,(%rsp)
cvttpd2dq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
movaps %xmm0,0x30(%rsp)
call   1060 <sprintf@plt>
movapd 0x10(%rsp),%xmm0
test   %r12d,%r12d
jne    12b2 <comma_dprint+0x172>
subsd  0x30(%rsp),%xmm0
ucomisd 0xdbc(%rip),%xmm0
jne    1268 <comma_dprint+0x128>
jnp    12b2 <comma_dprint+0x172>
lea    0x50(%rsp),%rdi
lea    0xdbc(%rip),%rsi
call   1060 <sprintf@plt>
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movzbl 0x50(%rsp,%rax,1),%ecx
test   %cl,%cl
je     12a0 <comma_dprint+0x160>
cmp    $0x2e,%cl
je     12a0 <comma_dprint+0x160>
add    $0x1,%rax
jmp    1280 <comma_dprint+0x140>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%eax
lea    (%rsp,%rax,1),%rsi
add    $0x50,%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
test   %r12d,%r12d
je     11a0 <comma_dprint+0x60>
mov    %rbx,%rdi
lea    0xd6e(%rip),%rsi
call   1050 <strcat@plt>
jmp    11a0 <comma_dprint+0x60>
xorpd  %xmm0,%xmm0
ucomisd 0x20(%rsp),%xmm0
jbe    1308 <comma_dprint+0x1c8>
lea    0xd53(%rip),%rsi
lea    0xc0(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
add    $0x1c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%03d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%g\00"
@.str.3 = [2 x i8] c",\00"
@.str.4 = [2 x i8] c"-\00"
define void @comma_dprint(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca [256 x i8]
%6 = alloca [100 x i8]
%7 = alloca [10 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
store i8* %0, i8** %3
store double %1, double* %4
store i32 0, i32* %9
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 0, i8* %13
%14 = load double, double* %4
%15 = fcmp oeq double %14, 0.000000e+00
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 0
store i8 48, i8* %18
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 0, i8* %20
br label %127
21: ; preds = %2
%22 = load double, double* %4
%23 = fcmp olt double %22, 0.000000e+00
%24 = zext i1 %23 to i32
store i32 %24, i32* %8
%25 = load double, double* %4
%26 = call double @llvm.fabs.f64(double %25)
store double %26, double* %4
br label %27
27: ; preds = %106, %21
%28 = load double, double* %4
%29 = fcmp une double %28, 0.000000e+00
br i1 %29, label %30, label %115
30: ; preds = %27
%31 = load i32, i32* %9
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load double, double* %4
%35 = fcmp olt double %34, 5.000000e-01
br i1 %35, label %36, label %37
36: ; preds = %33
br label %115
37: ; preds = %33, %30
%38 = load double, double* %4
%39 = call double @fmod(double %38, i32 1000)
store double %39, double* %10
%40 = load double, double* %10
%41 = load double, double* %4
%42 = fcmp une double %40, %41
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%45 = call i32 @strcpy(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %49
46: ; preds = %37
%47 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%48 = call i32 @strcpy(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %49
49: ; preds = %46, %43
%50 = load double, double* %4
%51 = load double, double* %10
%52 = fsub double %50, %51
%53 = fdiv double %52, 1.000000e+03
store double %53, double* %4
%54 = load double, double* %10
%55 = fptosi double %54 to i32
store i32 %55, i32* %11
%56 = load i32, i32* %11
%57 = sitofp i32 %56 to double
%58 = load double, double* %10
%59 = fsub double %58, %57
store double %59, double* %10
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%61 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%62 = load i32, i32* %11
%63 = sitofp i32 %62 to double
%64 = call i32 @sprintf(i8* %60, i8* %61, double %63)
%65 = load i32, i32* %9
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %100
67: ; preds = %49
%68 = load double, double* %10
%69 = fcmp une double %68, 0.000000e+00
br i1 %69, label %70, label %100
70: ; preds = %67
%71 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%72 = load double, double* %10
%73 = call i32 @sprintf(i8* %71, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double %72)
store i32 0, i32* %11
br label %74
74: ; preds = %91, %70
%75 = load i32, i32* %11
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp ne i32 %79, 46
br i1 %80, label %81, label %88
81: ; preds = %74
%82 = load i32, i32* %11
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %83
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp ne i32 %86, 0
br label %88
88: ; preds = %81, %74
%89 = phi i1 [ false, %74 ], [ %87, %81 ]
br i1 %89, label %90, label %94
90: ; preds = %88
br label %91
91: ; preds = %90
%92 = load i32, i32* %11
%93 = add nsw i32 %92, 1
store i32 %93, i32* %11
br label %74
94: ; preds = %88
%95 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%96 = load i32, i32* %11
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %97
%99 = call i32 @strcat(i8* %95, i8* %98)
br label %100
100: ; preds = %94, %67, %49
%101 = load i32, i32* %9
%102 = icmp ne i32 %101, 0
br i1 %102, label %103, label %106
103: ; preds = %100
%104 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%105 = call i32 @strcat(i8* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %106
106: ; preds = %103, %100
%107 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%108 = load i8*, i8** %3
%109 = call i32 @strcat(i8* %107, i8* %108)
%110 = load i8*, i8** %3
%111 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%112 = call i32 @strcpy(i8* %110, i8* %111)
%113 = load i32, i32* %9
%114 = add nsw i32 %113, 1
store i32 %114, i32* %9
br label %27
115: ; preds = %36, %27
%116 = load i32, i32* %8
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %127
118: ; preds = %115
%119 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%120 = call i32 @strcpy(i8* %119, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%121 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%122 = load i8*, i8** %3
%123 = call i32 @strcat(i8* %121, i8* %122)
%124 = load i8*, i8** %3
%125 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%126 = call i32 @strcpy(i8* %124, i8* %125)
br label %127
127: ; preds = %16, %118, %115
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%03d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%g\00"
@.str.3 = [2 x i8] c",\00"
@.str.4 = [2 x i8] c"-\00"
define void @comma_dprint(i8* %0, double %1) {
%3 = alloca [256 x i8]
%4 = alloca [100 x i8]
%5 = alloca [10 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
store i8 0, i8* %0
%9 = fcmp oeq double %1, 0.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %2
store i8 48, i8* %0
%11 = getelementptr inbounds i8, i8* %0, i64 1
store i8 0, i8* %11
br label %60
12: ; preds = %2
%13 = fcmp olt double %1, 0.000000e+00
%14 = tail call double @llvm.fabs.f64(double %1)
br label %15
15: ; preds = %12, %50
%16 = phi i32 [ %53, %50 ], [ 0, %12 ]
%17 = phi double [ %27, %50 ], [ %14, %12 ]
%18 = icmp ne i32 %16, 0
%19 = fcmp olt double %17, 5.000000e-01
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %55, label %21
21: ; preds = %15
%22 = call double @fmod(double %17, i32 1000)
%23 = fcmp une double %22, %17
%24 = select i1 %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%25 = call i32 @strcpy(i8* %8, i8* %24)
%26 = fsub double %17, %22
%27 = fdiv double %26, 1.000000e+03
%28 = fptosi double %22 to i32
%29 = sitofp i32 %28 to double
%30 = fsub double %22, %29
%31 = call i32 @sprintf(i8* %6, i8* %8, double %29)
%32 = icmp eq i32 %16, 0
%33 = fcmp une double %30, 0.000000e+00
%34 = select i1 %32, i1 %33, i1 false
br i1 %34, label %35, label %47
35: ; preds = %21
%36 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double %30)
br label %37
37: ; preds = %41, %35
%38 = phi i64 [ %42, %41 ], [ 0, %35 ]
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %38
%40 = load i8, i8* %39
switch i8 %40, label %41 [
i8 46, label %43
i8 0, label %43
]
41: ; preds = %37
%42 = add nuw i64 %38, 1
br label %37
43: ; preds = %37, %37
%44 = and i64 %38, 4294967295
%45 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %44
%46 = call i32 @strcat(i8* %6, i8* %45)
br label %47
47: ; preds = %43, %21
br i1 %32, label %50, label %48
48: ; preds = %47
%49 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %47, %48
%51 = call i32 @strcat(i8* %6, i8* %0)
%52 = call i32 @strcpy(i8* %0, i8* %6)
%53 = add nuw nsw i32 %16, 1
%54 = fcmp une double %27, 0.000000e+00
br i1 %54, label %15, label %55
55: ; preds = %50, %15
br i1 %13, label %56, label %60
56: ; preds = %55
%57 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%58 = call i32 @strcat(i8* %6, i8* %0)
%59 = call i32 @strcpy(i8* %0, i8* %6)
br label %60
60: ; preds = %55, %56, %10
ret void
}