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;
  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;
  isec = (int)(seconds + 0.5);
  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 if (ndec > -1) {
    if (isec > 59) {
      isec = 0;
      minutes = minutes + 1;
    }
    if (minutes > 59) {
      minutes = 0;
      degrees = degrees + 1;
    }
    (void)sprintf(tstring, "%c%02d:%02d:%04.1f", sign, degrees, minutes,
                  seconds);
  }
  if (strlen(tstring) < (unsigned int)(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  0xdb7(%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  0xd90(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd77(%rip),%xmm0
addsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jle    132b <dec2str+0x1db>
movsd  -0x48(%rbp),%xmm0
movsd  0xd8c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12e7 <dec2str+0x197>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    1301 <dec2str+0x1b1>
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    0xd41(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15fa <dec2str+0x4aa>
cmpl   $0x4,-0x1c(%rbp)
jle    13a1 <dec2str+0x251>
movsd  -0x48(%rbp),%xmm0
movsd  0xd0e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    135d <dec2str+0x20d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    1377 <dec2str+0x227>
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    0xcde(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15f5 <dec2str+0x4a5>
cmpl   $0x3,-0x1c(%rbp)
jle    1417 <dec2str+0x2c7>
movsd  -0x48(%rbp),%xmm0
movsd  0xc90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    13d3 <dec2str+0x283>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    13ed <dec2str+0x29d>
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    0xc7b(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15f0 <dec2str+0x4a0>
cmpl   $0x2,-0x1c(%rbp)
jle    148d <dec2str+0x33d>
movsd  -0x48(%rbp),%xmm0
movsd  0xc12(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1449 <dec2str+0x2f9>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    1463 <dec2str+0x313>
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    0xc18(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15eb <dec2str+0x49b>
cmpl   $0x1,-0x1c(%rbp)
jle    1503 <dec2str+0x3b3>
movsd  -0x48(%rbp),%xmm0
movsd  0xb94(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    14bf <dec2str+0x36f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    14d9 <dec2str+0x389>
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    0xbb5(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15e6 <dec2str+0x496>
cmpl   $0x0,-0x1c(%rbp)
jle    1579 <dec2str+0x429>
movsd  -0x48(%rbp),%xmm0
movsd  0xb16(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1535 <dec2str+0x3e5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    154f <dec2str+0x3ff>
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    0xb52(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15e1 <dec2str+0x491>
cmpl   $0xffffffff,-0x1c(%rbp)
jle    15dc <dec2str+0x48c>
cmpl   $0x3b,-0x58(%rbp)
jle    159d <dec2str+0x44d>
movl   $0x0,-0x58(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    15b7 <dec2str+0x467>
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    0xaea(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    15e1 <dec2str+0x491>
jmp    15e6 <dec2str+0x496>
jmp    15eb <dec2str+0x49b>
jmp    15f0 <dec2str+0x4a0>
jmp    15f5 <dec2str+0x4a5>
jmp    15fa <dec2str+0x4aa>
lea    -0xa0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
cmp    %rcx,%rax
jae    162c <dec2str+0x4dc>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1656 <dec2str+0x506>
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
movapd %xmm0,%xmm1
ucomisd 0x40(%rsp),%xmm3
ja     11b4 <dec2str+0x64>
movapd 0xe4e(%rip),%xmm2
jmp    11c0 <dec2str+0x70>
movapd 0xe44(%rip),%xmm2
xorpd  %xmm2,%xmm1
movsd  0xe48(%rip),%xmm4
addsd  %xmm1,%xmm4
movapd %xmm1,%xmm0
cmpnlesd 0xe3f(%rip),%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm4,%xmm0
orpd   %xmm1,%xmm0
xor    %edx,%edx
ucomisd %xmm0,%xmm3
seta   %cl
jbe    11f4 <dec2str+0xa4>
xorpd  %xmm2,%xmm0
cvttsd2si %xmm0,%eax
cvttpd2dq %xmm0,%xmm1
mov    %cl,%dl
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe12(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
cvttpd2dq %xmm0,%xmm2
cvtdq2pd %xmm2,%xmm2
add    %edx,%edx
add    $0x2b,%edx
subsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
cmp    $0x6,%ebp
jl     1269 <dec2str+0x119>
xor    %esi,%esi
ucomisd 0xe1e(%rip),%xmm0
seta   %bl
xorpd  %xmm1,%xmm1
ja     1247 <dec2str+0xf7>
movapd %xmm0,%xmm1
mov    %bl,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xdfc(%rip),%rsi
jmp    139b <dec2str+0x24b>
cmp    $0x5,%ebp
jne    12a7 <dec2str+0x157>
xor    %esi,%esi
ucomisd 0xdd8(%rip),%xmm0
seta   %bl
xorpd  %xmm1,%xmm1
ja     1285 <dec2str+0x135>
movapd %xmm0,%xmm1
mov    %bl,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xdd1(%rip),%rsi
jmp    139b <dec2str+0x24b>
cmp    $0x4,%ebp
jl     12e5 <dec2str+0x195>
xor    %esi,%esi
ucomisd 0xd92(%rip),%xmm0
seta   %bl
xorpd  %xmm1,%xmm1
ja     12c3 <dec2str+0x173>
movapd %xmm0,%xmm1
mov    %bl,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xda6(%rip),%rsi
jmp    139b <dec2str+0x24b>
cmp    $0x3,%ebp
jne    1321 <dec2str+0x1d1>
xor    %esi,%esi
ucomisd 0xd4c(%rip),%xmm0
seta   %dil
xorpd  %xmm1,%xmm1
ja     1302 <dec2str+0x1b2>
movapd %xmm0,%xmm1
mov    %dil,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xd7a(%rip),%rsi
jmp    139b <dec2str+0x24b>
cmp    $0x2,%ebp
jl     135d <dec2str+0x20d>
xor    %esi,%esi
ucomisd 0xd08(%rip),%xmm0
seta   %dil
xorpd  %xmm1,%xmm1
ja     133e <dec2str+0x1ee>
movapd %xmm0,%xmm1
mov    %dil,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xd51(%rip),%rsi
jmp    139b <dec2str+0x24b>
cmp    $0x1,%ebp
jne    13e7 <dec2str+0x297>
xor    %esi,%esi
ucomisd 0xcc0(%rip),%xmm0
seta   %dil
xorpd  %xmm1,%xmm1
ja     137e <dec2str+0x22e>
movapd %xmm0,%xmm1
mov    %dil,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
setge  %cl
cmovl  %esi,%r8d
add    %eax,%ecx
lea    0xd24(%rip),%rsi
mov    %rsp,%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1070 <sprintf@plt>
mov    %rsp,%rdi
call   1050 <strlen@plt>
movslq %r14d,%rbp
add    $0xffffffffffffffff,%rbp
mov    %ebp,%ecx
mov    %rsp,%rsi
cmp    %rcx,%rax
jae    13cc <dec2str+0x27c>
mov    %r15,%rdi
call   1040 <strcpy@plt>
jmp    13dc <dec2str+0x28c>
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
test   %ebp,%ebp
js     13a9 <dec2str+0x259>
movsd  0xc35(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%esi
xor    %edi,%edi
cmp    $0x3c,%esi
setge  %dil
add    %ecx,%edi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%edi
setge  %cl
cmovl  %edi,%r8d
add    %eax,%ecx
lea    0xca1(%rip),%rsi
mov    %rsp,%rdi
jmp    13a2 <dec2str+0x252>

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