void dec2str(string, lstr, dec, ndec) char *string;
int lstr;
double dec;
int ndec;
{
  double a, b, dsgn, deg1;
  double seconds;
  char sign;
  int degrees;
  int minutes;
  int isec, ltstr;
  char tstring[64];
  deg1 = dec;
  if (deg1 < 0.0) {
    deg1 = -deg1;
    dsgn = -1.0;
  } else
    dsgn = 1.0;
  deg1 = fmod(deg1, 360.0);
  deg1 *= dsgn;
  if (deg1 <= -180.0)
    deg1 = deg1 + 360.0;
  a = deg1;
  if (a < 0) {
    sign = '-';
    a = -a;
  } else
    sign = '+';
  degrees = (int)a;
  b = (a - (double)degrees) * 60.0;
  minutes = (int)b;
  seconds = (b - (double)minutes) * 60.0;
  if (ndec > 5) {
    if (seconds > 59.999999) {
      seconds = 0.0;
      minutes = minutes + 1;
    }
    if (minutes > 59) {
      minutes = 0;
      degrees = degrees + 1;
    }
    (void)sprintf(tstring, "%c%02d:%02d:%09.6f", sign, degrees, minutes,
                  seconds);
  } else if (ndec > 4) {
    if (seconds > 59.99999) {
      seconds = 0.0;
      minutes = minutes + 1;
    }
    if (minutes > 59) {
      minutes = 0;
      degrees = degrees + 1;
    }
    (void)sprintf(tstring, "%c%02d:%02d:%08.5f", sign, degrees, minutes,
                  seconds);
  } else if (ndec > 3) {
    if (seconds > 59.9999) {
      seconds = 0.0;
      minutes = minutes + 1;
    }
    if (minutes > 59) {
      minutes = 0;
      degrees = degrees + 1;
    }
    (void)sprintf(tstring, "%c%02d:%02d:%07.4f", sign, degrees, minutes,
                  seconds);
  } else if (ndec > 2) {
    if (seconds > 59.999) {
      seconds = 0.0;
      minutes = minutes + 1;
    }
    if (minutes > 59) {
      minutes = 0;
      degrees = degrees + 1;
    }
    (void)sprintf(tstring, "%c%02d:%02d:%06.3f", sign, degrees, minutes,
                  seconds);
  } else if (ndec > 1) {
    if (seconds > 59.99) {
      seconds = 0.0;
      minutes = minutes + 1;
    }
    if (minutes > 59) {
      minutes = 0;
      degrees = degrees + 1;
    }
    (void)sprintf(tstring, "%c%02d:%02d:%05.2f", sign, degrees, minutes,
                  seconds);
  } else if (ndec > 0) {
    if (seconds > 59.9) {
      seconds = 0.0;
      minutes = minutes + 1;
    }
    if (minutes > 59) {
      minutes = 0;
      degrees = degrees + 1;
    }
    (void)sprintf(tstring, "%c%02d:%02d:%04.1f", sign, degrees, minutes,
                  seconds);
  } else {
    isec = (int)(seconds + 0.5);
    if (isec > 59) {
      isec = 0;
      minutes = minutes + 1;
    }
    if (minutes > 59) {
      minutes = 0;
      degrees = degrees + 1;
    }
    (void)sprintf(tstring, "%c%02d:%02d:%02d", sign, degrees, minutes, isec);
  }
  ltstr = (int)strlen(tstring);
  if (ltstr < lstr - 1)
    strcpy(string, tstring);
  else {
    strncpy(string, tstring, lstr - 1);
    string[lstr - 1] = 0;
  }
  return;
}


x86 assembly (clang, -O0):
<dec2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    11b5 <dec2str+0x65>
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe5d(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11c2 <dec2str+0x72>
movsd  0xe43(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xe49(%rip),%xmm1
call   1060 <fmod@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe20(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jb     120d <dec2str+0xbd>
movsd  0xe15(%rip),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    124f <dec2str+0xff>
movb   $0x2d,-0x49(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1253 <dec2str+0x103>
movb   $0x2b,-0x49(%rbp)
cvttsd2si -0x28(%rbp),%eax
mov    %eax,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x50(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xdaf(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvttsd2si -0x30(%rbp),%eax
mov    %eax,-0x54(%rbp)
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x54(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xd88(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jle    1317 <dec2str+0x1c7>
movsd  -0x48(%rbp),%xmm0
movsd  0xda0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12d3 <dec2str+0x183>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    12ed <dec2str+0x19d>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
movsbl -0x49(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
movsd  -0x48(%rbp),%xmm0
lea    0xd55(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15ea <dec2str+0x49a>
cmpl   $0x4,-0x1c(%rbp)
jle    138d <dec2str+0x23d>
movsd  -0x48(%rbp),%xmm0
movsd  0xd22(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1349 <dec2str+0x1f9>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    1363 <dec2str+0x213>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
movsbl -0x49(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
movsd  -0x48(%rbp),%xmm0
lea    0xcf2(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15e5 <dec2str+0x495>
cmpl   $0x3,-0x1c(%rbp)
jle    1403 <dec2str+0x2b3>
movsd  -0x48(%rbp),%xmm0
movsd  0xca4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    13bf <dec2str+0x26f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    13d9 <dec2str+0x289>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
movsbl -0x49(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
movsd  -0x48(%rbp),%xmm0
lea    0xc8f(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15e0 <dec2str+0x490>
cmpl   $0x2,-0x1c(%rbp)
jle    1479 <dec2str+0x329>
movsd  -0x48(%rbp),%xmm0
movsd  0xc26(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1435 <dec2str+0x2e5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    144f <dec2str+0x2ff>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
movsbl -0x49(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
movsd  -0x48(%rbp),%xmm0
lea    0xc2c(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15db <dec2str+0x48b>
cmpl   $0x1,-0x1c(%rbp)
jle    14ef <dec2str+0x39f>
movsd  -0x48(%rbp),%xmm0
movsd  0xba8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    14ab <dec2str+0x35b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    14c5 <dec2str+0x375>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
movsbl -0x49(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
movsd  -0x48(%rbp),%xmm0
lea    0xbc9(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15d6 <dec2str+0x486>
cmpl   $0x0,-0x1c(%rbp)
jle    1565 <dec2str+0x415>
movsd  -0x48(%rbp),%xmm0
movsd  0xb2a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1521 <dec2str+0x3d1>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    153b <dec2str+0x3eb>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
movsbl -0x49(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
movsd  -0x48(%rbp),%xmm0
lea    0xb66(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15d1 <dec2str+0x481>
movsd  0xabb(%rip),%xmm0
addsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x3b,-0x58(%rbp)
jle    1593 <dec2str+0x443>
movl   $0x0,-0x58(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    15ad <dec2str+0x45d>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
movsbl -0x49(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
mov    -0x58(%rbp),%r9d
lea    0xb08(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    15d6 <dec2str+0x486>
jmp    15db <dec2str+0x48b>
jmp    15e0 <dec2str+0x490>
jmp    15e5 <dec2str+0x495>
jmp    15ea <dec2str+0x49a>
lea    -0xa0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    161f <dec2str+0x4cf>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1649 <dec2str+0x4f9>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rdx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dec2str>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %edx,%ebp
movapd %xmm0,%xmm3
movapd %xmm0,0x40(%rsp)
mov    %esi,%r14d
mov    %rdi,%r15
movapd %xmm0,%xmm1
xorpd  0xe88(%rip),%xmm1
xorpd  %xmm2,%xmm2
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
movsd  0xe7b(%rip),%xmm1
call   1060 <fmod@plt>
xorpd  %xmm3,%xmm3
ucomisd 0x40(%rsp),%xmm3
ja     11b0 <dec2str+0x60>
movapd 0xe52(%rip),%xmm2
jmp    11bc <dec2str+0x6c>
movapd 0xe48(%rip),%xmm2
xorpd  %xmm2,%xmm0
movsd  0xe4c(%rip),%xmm4
addsd  %xmm0,%xmm4
movapd %xmm0,%xmm1
cmpnlesd 0xe43(%rip),%xmm1
andpd  %xmm1,%xmm0
andnpd %xmm4,%xmm1
orpd   %xmm0,%xmm1
xor    %edx,%edx
ucomisd %xmm1,%xmm3
seta   %dl
jbe    11f0 <dec2str+0xa0>
xorpd  %xmm2,%xmm1
cvttsd2si %xmm1,%eax
cvttpd2dq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
subsd  %xmm0,%xmm1
movsd  0xe18(%rip),%xmm0
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ecx
cvttpd2dq %xmm1,%xmm2
cvtdq2pd %xmm2,%xmm2
add    %edx,%edx
add    $0x2b,%edx
subsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
cmp    $0x6,%ebp
jl     1263 <dec2str+0x113>
xor    %esi,%esi
ucomisd 0xe24(%rip),%xmm1
seta   %bl
xorpd  %xmm0,%xmm0
ja     1241 <dec2str+0xf1>
movapd %xmm1,%xmm0
mov    %bl,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xe02(%rip),%rsi
jmp    1391 <dec2str+0x241>
cmp    $0x5,%ebp
jne    12a1 <dec2str+0x151>
xor    %esi,%esi
ucomisd 0xdde(%rip),%xmm1
seta   %bl
xorpd  %xmm0,%xmm0
ja     127f <dec2str+0x12f>
movapd %xmm1,%xmm0
mov    %bl,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xdd7(%rip),%rsi
jmp    1391 <dec2str+0x241>
cmp    $0x4,%ebp
jl     12df <dec2str+0x18f>
xor    %esi,%esi
ucomisd 0xd98(%rip),%xmm1
seta   %bl
xorpd  %xmm0,%xmm0
ja     12bd <dec2str+0x16d>
movapd %xmm1,%xmm0
mov    %bl,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xdac(%rip),%rsi
jmp    1391 <dec2str+0x241>
cmp    $0x3,%ebp
jne    131b <dec2str+0x1cb>
xor    %esi,%esi
ucomisd 0xd52(%rip),%xmm1
seta   %dil
xorpd  %xmm0,%xmm0
ja     12fc <dec2str+0x1ac>
movapd %xmm1,%xmm0
mov    %dil,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xd80(%rip),%rsi
jmp    1391 <dec2str+0x241>
cmp    $0x2,%ebp
jl     1357 <dec2str+0x207>
xor    %esi,%esi
ucomisd 0xd0e(%rip),%xmm1
seta   %dil
xorpd  %xmm0,%xmm0
ja     1338 <dec2str+0x1e8>
movapd %xmm1,%xmm0
mov    %dil,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xd57(%rip),%rsi
jmp    1391 <dec2str+0x241>
cmp    $0x1,%ebp
jne    13d6 <dec2str+0x286>
xor    %esi,%esi
ucomisd 0xcca(%rip),%xmm1
seta   %dil
xorpd  %xmm0,%xmm0
ja     1374 <dec2str+0x224>
movapd %xmm1,%xmm0
mov    %dil,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xd2e(%rip),%rsi
mov    %rsp,%rdi
mov    $0x1,%al
call   1070 <sprintf@plt>
mov    %rsp,%rdi
call   1050 <strlen@plt>
movslq %r14d,%rbp
add    $0xffffffffffffffff,%rbp
mov    %rsp,%rsi
cmp    %eax,%ebp
jle    13bb <dec2str+0x26b>
mov    %r15,%rdi
call   1040 <strcpy@plt>
jmp    13cb <dec2str+0x27b>
mov    %r15,%rdi
mov    %rbp,%rdx
call   1030 <strncpy@plt>
movb   $0x0,(%r15,%rbp,1)
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
addsd  0xc4a(%rip),%xmm1
cvttsd2si %xmm1,%r9d
xor    %esi,%esi
xor    %r8d,%r8d
cmp    $0x3c,%r9d
cmovge %esi,%r9d
setge  %r8b
add    %ecx,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%r8d
setge  %cl
cmovge %esi,%r8d
add    %eax,%ecx
lea    0xcc5(%rip),%rsi
mov    %rsp,%rdi
xor    %eax,%eax
call   1070 <sprintf@plt>
jmp    139b <dec2str+0x24b>

LLVM IR (-O0):
@.str = [19 x i8] c"%c%02d:%02d:%09.6f\00"
@.str.1 = [19 x i8] c"%c%02d:%02d:%08.5f\00"
@.str.2 = [19 x i8] c"%c%02d:%02d:%07.4f\00"
@.str.3 = [19 x i8] c"%c%02d:%02d:%06.3f\00"
@.str.4 = [19 x i8] c"%c%02d:%02d:%05.2f\00"
@.str.5 = [19 x i8] c"%c%02d:%02d:%04.1f\00"
@.str.6 = [17 x i8] c"%c%02d:%02d:%02d\00"
define void @dec2str(i8* %0, i32 %1, double %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i8
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca [64 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store double %2, double* %7
store i32 %3, i32* %8
%20 = load double, double* %7
store double %20, double* %12
%21 = load double, double* %12
%22 = fcmp olt double %21, 0.000000e+00
br i1 %22, label %23, label %26
23: ; preds = %4
%24 = load double, double* %12
%25 = fneg double %24
store double %25, double* %12
store double -1.000000e+00, double* %11
br label %27
26: ; preds = %4
store double 1.000000e+00, double* %11
br label %27
27: ; preds = %26, %23
%28 = load double, double* %12
%29 = call double @fmod(double %28, double 3.600000e+02)
store double %29, double* %12
%30 = load double, double* %11
%31 = load double, double* %12
%32 = fmul double %31, %30
store double %32, double* %12
%33 = load double, double* %12
%34 = fcmp ole double %33, -1.800000e+02
br i1 %34, label %35, label %38
35: ; preds = %27
%36 = load double, double* %12
%37 = fadd double %36, 3.600000e+02
store double %37, double* %12
br label %38
38: ; preds = %35, %27
%39 = load double, double* %12
store double %39, double* %9
%40 = load double, double* %9
%41 = fcmp olt double %40, 0.000000e+00
br i1 %41, label %42, label %45
42: ; preds = %38
store i8 45, i8* %14
%43 = load double, double* %9
%44 = fneg double %43
store double %44, double* %9
br label %46
45: ; preds = %38
store i8 43, i8* %14
br label %46
46: ; preds = %45, %42
%47 = load double, double* %9
%48 = fptosi double %47 to i32
store i32 %48, i32* %15
%49 = load double, double* %9
%50 = load i32, i32* %15
%51 = sitofp i32 %50 to double
%52 = fsub double %49, %51
%53 = fmul double %52, 6.000000e+01
store double %53, double* %10
%54 = load double, double* %10
%55 = fptosi double %54 to i32
store i32 %55, i32* %16
%56 = load double, double* %10
%57 = load i32, i32* %16
%58 = sitofp i32 %57 to double
%59 = fsub double %56, %58
%60 = fmul double %59, 6.000000e+01
store double %60, double* %13
%61 = load i32, i32* %8
%62 = icmp sgt i32 %61, 5
br i1 %62, label %63, label %83
63: ; preds = %46
%64 = load double, double* %13
%65 = fcmp ogt double %64, 0x404DFFFFF79C8430
br i1 %65, label %66, label %69
66: ; preds = %63
store double 0.000000e+00, double* %13
%67 = load i32, i32* %16
%68 = add nsw i32 %67, 1
store i32 %68, i32* %16
br label %69
69: ; preds = %66, %63
%70 = load i32, i32* %16
%71 = icmp sgt i32 %70, 59
br i1 %71, label %72, label %75
72: ; preds = %69
store i32 0, i32* %16
%73 = load i32, i32* %15
%74 = add nsw i32 %73, 1
store i32 %74, i32* %15
br label %75
75: ; preds = %72, %69
%76 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%77 = load i8, i8* %14
%78 = sext i8 %77 to i32
%79 = load i32, i32* %15
%80 = load i32, i32* %16
%81 = load double, double* %13
%82 = call i32 (i8*, i8*, ...) @sprintf(i8* %76, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %78, i32 %79, i32 %80, double %81)
br label %226
83: ; preds = %46
%84 = load i32, i32* %8
%85 = icmp sgt i32 %84, 4
br i1 %85, label %86, label %106
86: ; preds = %83
%87 = load double, double* %13
%88 = fcmp ogt double %87, 0x404DFFFFAC1D29DC
br i1 %88, label %89, label %92
89: ; preds = %86
store double 0.000000e+00, double* %13
%90 = load i32, i32* %16
%91 = add nsw i32 %90, 1
store i32 %91, i32* %16
br label %92
92: ; preds = %89, %86
%93 = load i32, i32* %16
%94 = icmp sgt i32 %93, 59
br i1 %94, label %95, label %98
95: ; preds = %92
store i32 0, i32* %16
%96 = load i32, i32* %15
%97 = add nsw i32 %96, 1
store i32 %97, i32* %15
br label %98
98: ; preds = %95, %92
%99 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%100 = load i8, i8* %14
%101 = sext i8 %100 to i32
%102 = load i32, i32* %15
%103 = load i32, i32* %16
%104 = load double, double* %13
%105 = call i32 (i8*, i8*, ...) @sprintf(i8* %99, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %101, i32 %102, i32 %103, double %104)
br label %225
106: ; preds = %83
%107 = load i32, i32* %8
%108 = icmp sgt i32 %107, 3
br i1 %108, label %109, label %129
109: ; preds = %106
%110 = load double, double* %13
%111 = fcmp ogt double %110, 5.999990e+01
br i1 %111, label %112, label %115
112: ; preds = %109
store double 0.000000e+00, double* %13
%113 = load i32, i32* %16
%114 = add nsw i32 %113, 1
store i32 %114, i32* %16
br label %115
115: ; preds = %112, %109
%116 = load i32, i32* %16
%117 = icmp sgt i32 %116, 59
br i1 %117, label %118, label %121
118: ; preds = %115
store i32 0, i32* %16
%119 = load i32, i32* %15
%120 = add nsw i32 %119, 1
store i32 %120, i32* %15
br label %121
121: ; preds = %118, %115
%122 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%123 = load i8, i8* %14
%124 = sext i8 %123 to i32
%125 = load i32, i32* %15
%126 = load i32, i32* %16
%127 = load double, double* %13
%128 = call i32 (i8*, i8*, ...) @sprintf(i8* %122, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %124, i32 %125, i32 %126, double %127)
br label %224
129: ; preds = %106
%130 = load i32, i32* %8
%131 = icmp sgt i32 %130, 2
br i1 %131, label %132, label %152
132: ; preds = %129
%133 = load double, double* %13
%134 = fcmp ogt double %133, 5.999900e+01
br i1 %134, label %135, label %138
135: ; preds = %132
store double 0.000000e+00, double* %13
%136 = load i32, i32* %16
%137 = add nsw i32 %136, 1
store i32 %137, i32* %16
br label %138
138: ; preds = %135, %132
%139 = load i32, i32* %16
%140 = icmp sgt i32 %139, 59
br i1 %140, label %141, label %144
141: ; preds = %138
store i32 0, i32* %16
%142 = load i32, i32* %15
%143 = add nsw i32 %142, 1
store i32 %143, i32* %15
br label %144
144: ; preds = %141, %138
%145 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%146 = load i8, i8* %14
%147 = sext i8 %146 to i32
%148 = load i32, i32* %15
%149 = load i32, i32* %16
%150 = load double, double* %13
%151 = call i32 (i8*, i8*, ...) @sprintf(i8* %145, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %147, i32 %148, i32 %149, double %150)
br label %223
152: ; preds = %129
%153 = load i32, i32* %8
%154 = icmp sgt i32 %153, 1
br i1 %154, label %155, label %175
155: ; preds = %152
%156 = load double, double* %13
%157 = fcmp ogt double %156, 5.999000e+01
br i1 %157, label %158, label %161
158: ; preds = %155
store double 0.000000e+00, double* %13
%159 = load i32, i32* %16
%160 = add nsw i32 %159, 1
store i32 %160, i32* %16
br label %161
161: ; preds = %158, %155
%162 = load i32, i32* %16
%163 = icmp sgt i32 %162, 59
br i1 %163, label %164, label %167
164: ; preds = %161
store i32 0, i32* %16
%165 = load i32, i32* %15
%166 = add nsw i32 %165, 1
store i32 %166, i32* %15
br label %167
167: ; preds = %164, %161
%168 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%169 = load i8, i8* %14
%170 = sext i8 %169 to i32
%171 = load i32, i32* %15
%172 = load i32, i32* %16
%173 = load double, double* %13
%174 = call i32 (i8*, i8*, ...) @sprintf(i8* %168, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %170, i32 %171, i32 %172, double %173)
br label %222
175: ; preds = %152
%176 = load i32, i32* %8
%177 = icmp sgt i32 %176, 0
br i1 %177, label %178, label %198
178: ; preds = %175
%179 = load double, double* %13
%180 = fcmp ogt double %179, 0x404DF33333333333
br i1 %180, label %181, label %184
181: ; preds = %178
store double 0.000000e+00, double* %13
%182 = load i32, i32* %16
%183 = add nsw i32 %182, 1
store i32 %183, i32* %16
br label %184
184: ; preds = %181, %178
%185 = load i32, i32* %16
%186 = icmp sgt i32 %185, 59
br i1 %186, label %187, label %190
187: ; preds = %184
store i32 0, i32* %16
%188 = load i32, i32* %15
%189 = add nsw i32 %188, 1
store i32 %189, i32* %15
br label %190
190: ; preds = %187, %184
%191 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%192 = load i8, i8* %14
%193 = sext i8 %192 to i32
%194 = load i32, i32* %15
%195 = load i32, i32* %16
%196 = load double, double* %13
%197 = call i32 (i8*, i8*, ...) @sprintf(i8* %191, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %193, i32 %194, i32 %195, double %196)
br label %221
198: ; preds = %175
%199 = load double, double* %13
%200 = fadd double %199, 5.000000e-01
%201 = fptosi double %200 to i32
store i32 %201, i32* %17
%202 = load i32, i32* %17
%203 = icmp sgt i32 %202, 59
br i1 %203, label %204, label %207
204: ; preds = %198
store i32 0, i32* %17
%205 = load i32, i32* %16
%206 = add nsw i32 %205, 1
store i32 %206, i32* %16
br label %207
207: ; preds = %204, %198
%208 = load i32, i32* %16
%209 = icmp sgt i32 %208, 59
br i1 %209, label %210, label %213
210: ; preds = %207
store i32 0, i32* %16
%211 = load i32, i32* %15
%212 = add nsw i32 %211, 1
store i32 %212, i32* %15
br label %213
213: ; preds = %210, %207
%214 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%215 = load i8, i8* %14
%216 = sext i8 %215 to i32
%217 = load i32, i32* %15
%218 = load i32, i32* %16
%219 = load i32, i32* %17
%220 = call i32 (i8*, i8*, ...) @sprintf(i8* %214, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %216, i32 %217, i32 %218, i32 %219)
br label %221
221: ; preds = %213, %190
br label %222
222: ; preds = %221, %167
br label %223
223: ; preds = %222, %144
br label %224
224: ; preds = %223, %121
br label %225
225: ; preds = %224, %98
br label %226
226: ; preds = %225, %75
%227 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%228 = call i64 @strlen(i8* %227)
%229 = trunc i64 %228 to i32
store i32 %229, i32* %18
%230 = load i32, i32* %18
%231 = load i32, i32* %6
%232 = sub nsw i32 %231, 1
%233 = icmp slt i32 %230, %232
br i1 %233, label %234, label %238
234: ; preds = %226
%235 = load i8*, i8** %5
%236 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%237 = call i8* @strcpy(i8* %235, i8* %236)
br label %250
238: ; preds = %226
%239 = load i8*, i8** %5
%240 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%241 = load i32, i32* %6
%242 = sub nsw i32 %241, 1
%243 = sext i32 %242 to i64
%244 = call i8* @strncpy(i8* %239, i8* %240, i64 %243)
%245 = load i8*, i8** %5
%246 = load i32, i32* %6
%247 = sub nsw i32 %246, 1
%248 = sext i32 %247 to i64
%249 = getelementptr inbounds i8, i8* %245, i64 %248
store i8 0, i8* %249
br label %250
250: ; preds = %238, %234
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"%c%02d:%02d:%09.6f\00"
@.str.1 = [19 x i8] c"%c%02d:%02d:%08.5f\00"
@.str.2 = [19 x i8] c"%c%02d:%02d:%07.4f\00"
@.str.3 = [19 x i8] c"%c%02d:%02d:%06.3f\00"
@.str.4 = [19 x i8] c"%c%02d:%02d:%05.2f\00"
@.str.5 = [19 x i8] c"%c%02d:%02d:%04.1f\00"
@.str.6 = [17 x i8] c"%c%02d:%02d:%02d\00"
define void @dec2str(i8* %0, i32 %1, double %2, i32 %3) {
%5 = alloca [64 x i8]
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%7 = fcmp olt double %2, 0.000000e+00
%8 = fneg double %2
%9 = select i1 %7, double %8, double %2
%10 = tail call double @fmod(double %9, double 3.600000e+02)
%11 = fneg double %10
%12 = select i1 %7, double %11, double %10
%13 = fcmp ugt double %12, -1.800000e+02
%14 = fadd double %12, 3.600000e+02
%15 = select i1 %13, double %12, double %14
%16 = fcmp olt double %15, 0.000000e+00
%17 = fneg double %15
%18 = select i1 %16, i32 45, i32 43
%19 = select i1 %16, double %17, double %15
%20 = fptosi double %19 to i32
%21 = sitofp i32 %20 to double
%22 = fsub double %19, %21
%23 = fmul double %22, 6.000000e+01
%24 = fptosi double %23 to i32
%25 = sitofp i32 %24 to double
%26 = fsub double %23, %25
%27 = fmul double %26, 6.000000e+01
%28 = icmp sgt i32 %3, 5
br i1 %28, label %29, label %39
29: ; preds = %4
%30 = fcmp ogt double %27, 0x404DFFFFF79C8430
%31 = select i1 %30, double 0.000000e+00, double %27
%32 = zext i1 %30 to i32
%33 = add nsw i32 %32, %24
%34 = icmp sgt i32 %33, 59
%35 = zext i1 %34 to i32
%36 = add nsw i32 %35, %20
%37 = select i1 %34, i32 0, i32 %33
%38 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %36, i32 %37, double %31)
br label %111
39: ; preds = %4
%40 = icmp eq i32 %3, 5
br i1 %40, label %41, label %51
41: ; preds = %39
%42 = fcmp ogt double %27, 0x404DFFFFAC1D29DC
%43 = select i1 %42, double 0.000000e+00, double %27
%44 = zext i1 %42 to i32
%45 = add nsw i32 %44, %24
%46 = icmp sgt i32 %45, 59
%47 = zext i1 %46 to i32
%48 = add nsw i32 %47, %20
%49 = select i1 %46, i32 0, i32 %45
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %48, i32 %49, double %43)
br label %111
51: ; preds = %39
%52 = icmp sgt i32 %3, 3
br i1 %52, label %53, label %63
53: ; preds = %51
%54 = fcmp ogt double %27, 5.999990e+01
%55 = select i1 %54, double 0.000000e+00, double %27
%56 = zext i1 %54 to i32
%57 = add nsw i32 %56, %24
%58 = icmp sgt i32 %57, 59
%59 = zext i1 %58 to i32
%60 = add nsw i32 %59, %20
%61 = select i1 %58, i32 0, i32 %57
%62 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %60, i32 %61, double %55)
br label %111
63: ; preds = %51
%64 = icmp eq i32 %3, 3
br i1 %64, label %65, label %75
65: ; preds = %63
%66 = fcmp ogt double %27, 5.999900e+01
%67 = select i1 %66, double 0.000000e+00, double %27
%68 = zext i1 %66 to i32
%69 = add nsw i32 %68, %24
%70 = icmp sgt i32 %69, 59
%71 = zext i1 %70 to i32
%72 = add nsw i32 %71, %20
%73 = select i1 %70, i32 0, i32 %69
%74 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 %72, i32 %73, double %67)
br label %111
75: ; preds = %63
%76 = icmp sgt i32 %3, 1
br i1 %76, label %77, label %87
77: ; preds = %75
%78 = fcmp ogt double %27, 5.999000e+01
%79 = select i1 %78, double 0.000000e+00, double %27
%80 = zext i1 %78 to i32
%81 = add nsw i32 %80, %24
%82 = icmp sgt i32 %81, 59
%83 = zext i1 %82 to i32
%84 = add nsw i32 %83, %20
%85 = select i1 %82, i32 0, i32 %81
%86 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %18, i32 %84, i32 %85, double %79)
br label %111
87: ; preds = %75
%88 = icmp eq i32 %3, 1
br i1 %88, label %89, label %99
89: ; preds = %87
%90 = fcmp ogt double %27, 0x404DF33333333333
%91 = select i1 %90, double 0.000000e+00, double %27
%92 = zext i1 %90 to i32
%93 = add nsw i32 %92, %24
%94 = icmp sgt i32 %93, 59
%95 = zext i1 %94 to i32
%96 = add nsw i32 %95, %20
%97 = select i1 %94, i32 0, i32 %93
%98 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %18, i32 %96, i32 %97, double %91)
br label %111
99: ; preds = %87
%100 = fadd double %27, 5.000000e-01
%101 = fptosi double %100 to i32
%102 = icmp sgt i32 %101, 59
%103 = zext i1 %102 to i32
%104 = add nsw i32 %103, %24
%105 = select i1 %102, i32 0, i32 %101
%106 = icmp sgt i32 %104, 59
%107 = zext i1 %106 to i32
%108 = add nsw i32 %107, %20
%109 = select i1 %106, i32 0, i32 %104
%110 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %18, i32 %108, i32 %109, i32 %105)
br label %111
111: ; preds = %41, %65, %89, %99, %77, %53, %29
%112 = call i64 @strlen(i8* %6)
%113 = trunc i64 %112 to i32
%114 = add nsw i32 %1, -1
%115 = icmp sgt i32 %114, %113
br i1 %115, label %116, label %118
116: ; preds = %111
%117 = call i8* @strcpy(i8* dereferenceable(1) %0, i8* %6)
br label %122
118: ; preds = %111
%119 = sext i32 %114 to i64
%120 = call i8* @strncpy(i8* dereferenceable(1) %0, i8* %6, i64 %119)
%121 = getelementptr inbounds i8, i8* %0, i64 %119
store i8 0, i8* %121
br label %122
122: ; preds = %118, %116
ret void
}