#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*/ int2unico(int, char *);
int /*<<< orphan*/ strcat(char *, char *);
void doub2unico(double db, char ch[]) {
  int i1, i2;
  double db1;
  i1 = db;
  db1 = db - i1;
  int2unico(i1, ch);
  if (db1 < 0.1) {
    strcat(ch, "002E");
    strcat(ch, "0030");
  } else if (db1 >= 0.1) {
    strcat(ch, "002E");
  }
  i2 = db1 * 1000;
  int2unico(i2, ch);
}


x86 assembly (clang, -O0):
<doub2unico>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <int2unico@plt>
movsd  0xea0(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1190 <doub2unico+0x70>
mov    -0x10(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1040 <strcat@plt>
jmp    11bc <doub2unico+0x9c>
movsd  -0x20(%rbp),%xmm0
movsd  0xe63(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11b7 <doub2unico+0x97>
mov    -0x10(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1040 <strcat@plt>
jmp    11bc <doub2unico+0x9c>
movsd  0xe44(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <int2unico@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doub2unico>:
push   %rbx
sub    $0x10,%rsp
cvttsd2si %xmm0,%eax
cvttpd2dq %xmm0,%xmm1
mov    %rdi,%rbx
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <int2unico@plt>
movsd  0xeb1(%rip),%xmm0
movapd (%rsp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1172 <doub2unico+0x52>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
lea    0xea5(%rip),%rsi
jmp    1187 <doub2unico+0x67>
movapd %xmm1,%xmm0
ucomisd 0xe82(%rip),%xmm1
jb     1194 <doub2unico+0x74>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
movapd (%rsp),%xmm0
mulsd  0xe6c(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    %rbx,%rsi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <int2unico@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"002E\00"
@.str.1 = [5 x i8] c"0030\00"
define void @doub2unico(double %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store double %0, double* %3
store i8* %1, i8** %4
%8 = load double, double* %3
%9 = fptosi double %8 to i32
store i32 %9, i32* %5
%10 = load double, double* %3
%11 = load i32, i32* %5
%12 = sitofp i32 %11 to double
%13 = fsub double %10, %12
store double %13, double* %7
%14 = load i32, i32* %5
%15 = load i8*, i8** %4
%16 = call i32 @int2unico(i32 %14, i8* %15)
%17 = load double, double* %7
%18 = fcmp olt double %17, 1.000000e-01
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%22 = load i8*, i8** %4
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %31
24: ; preds = %2
%25 = load double, double* %7
%26 = fcmp oge double %25, 1.000000e-01
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i8*, i8** %4
%29 = call i32 @strcat(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %27, %24
br label %31
31: ; preds = %30, %19
%32 = load double, double* %7
%33 = fmul double %32, 1.000000e+03
%34 = fptosi double %33 to i32
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = load i8*, i8** %4
%37 = call i32 @int2unico(i32 %35, i8* %36)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"002E\00"
@.str.1 = [5 x i8] c"0030\00"
define void @doub2unico(double %0, i8* %1) {
%3 = fptosi double %0 to i32
%4 = sitofp i32 %3 to double
%5 = fsub double %0, %4
%6 = tail call i32 @int2unico(i32 %3, i8* %1)
%7 = fcmp olt double %5, 1.000000e-01
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %2
%11 = fcmp ult double %5, 1.000000e-01
br i1 %11, label %15, label %12
12: ; preds = %10, %8
%13 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %8 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %10 ]
%14 = tail call i32 @strcat(i8* %1, i8* %13)
br label %15
15: ; preds = %12, %10
%16 = fmul double %5, 1.000000e+03
%17 = fptosi double %16 to i32
%18 = tail call i32 @int2unico(i32 %17, i8* %1)
ret void
}