#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 fmod(double, double);
int /*<<< orphan*/ sprintf(char *, char *, char, int, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void dec2str(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    1318 <dec2str+0x1c8>
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
mov    -0x49(%rbp),%al
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
cvttsd2si -0x48(%rbp),%r9d
lea    0xd55(%rip),%rsi
movsbl %al,%edx
call   1070 <sprintf@plt>
jmp    15f0 <dec2str+0x4a0>
cmpl   $0x4,-0x1c(%rbp)
jle    138f <dec2str+0x23f>
movsd  -0x48(%rbp),%xmm0
movsd  0xd21(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    134a <dec2str+0x1fa>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    1364 <dec2str+0x214>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x49(%rbp),%al
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
cvttsd2si -0x48(%rbp),%r9d
lea    0xcf1(%rip),%rsi
movsbl %al,%edx
call   1070 <sprintf@plt>
jmp    15eb <dec2str+0x49b>
cmpl   $0x3,-0x1c(%rbp)
jle    1406 <dec2str+0x2b6>
movsd  -0x48(%rbp),%xmm0
movsd  0xca2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    13c1 <dec2str+0x271>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    13db <dec2str+0x28b>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x49(%rbp),%al
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
cvttsd2si -0x48(%rbp),%r9d
lea    0xc8d(%rip),%rsi
movsbl %al,%edx
call   1070 <sprintf@plt>
jmp    15e6 <dec2str+0x496>
cmpl   $0x2,-0x1c(%rbp)
jle    147d <dec2str+0x32d>
movsd  -0x48(%rbp),%xmm0
movsd  0xc23(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1438 <dec2str+0x2e8>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    1452 <dec2str+0x302>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x49(%rbp),%al
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
cvttsd2si -0x48(%rbp),%r9d
lea    0xc29(%rip),%rsi
movsbl %al,%edx
call   1070 <sprintf@plt>
jmp    15e1 <dec2str+0x491>
cmpl   $0x1,-0x1c(%rbp)
jle    14f4 <dec2str+0x3a4>
movsd  -0x48(%rbp),%xmm0
movsd  0xba4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    14af <dec2str+0x35f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    14c9 <dec2str+0x379>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x49(%rbp),%al
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
cvttsd2si -0x48(%rbp),%r9d
lea    0xbc5(%rip),%rsi
movsbl %al,%edx
call   1070 <sprintf@plt>
jmp    15dc <dec2str+0x48c>
cmpl   $0x0,-0x1c(%rbp)
jle    156b <dec2str+0x41b>
movsd  -0x48(%rbp),%xmm0
movsd  0xb25(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1526 <dec2str+0x3d6>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    1540 <dec2str+0x3f0>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x49(%rbp),%al
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
cvttsd2si -0x48(%rbp),%r9d
lea    0xb61(%rip),%rsi
movsbl %al,%edx
call   1070 <sprintf@plt>
jmp    15d7 <dec2str+0x487>
movsd  0xab5(%rip),%xmm0
addsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x3b,-0x58(%rbp)
jle    1599 <dec2str+0x449>
movl   $0x0,-0x58(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x3b,-0x54(%rbp)
jle    15b3 <dec2str+0x463>
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x49(%rbp),%al
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
mov    -0x58(%rbp),%r9d
lea    0xb03(%rip),%rsi
movsbl %al,%edx
call   1070 <sprintf@plt>
jmp    15dc <dec2str+0x48c>
jmp    15e1 <dec2str+0x491>
jmp    15e6 <dec2str+0x496>
jmp    15eb <dec2str+0x49b>
jmp    15f0 <dec2str+0x4a0>
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    1625 <dec2str+0x4d5>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    164c <dec2str+0x4fc>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
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
movapd %xmm0,%xmm1
cmpnlesd 0xe47(%rip),%xmm1
addsd  %xmm0,%xmm4
andpd  %xmm1,%xmm0
andnpd %xmm4,%xmm1
orpd   %xmm0,%xmm1
ucomisd %xmm1,%xmm3
seta   %al
jbe    11ee <dec2str+0x9e>
xorpd  %xmm2,%xmm1
cvttsd2si %xmm1,%edx
cvttpd2dq %xmm1,%xmm0
add    %al,%al
cvtdq2pd %xmm0,%xmm0
subsd  %xmm0,%xmm1
movsd  0xe18(%rip),%xmm0
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ecx
cvttpd2dq %xmm1,%xmm2
cvtdq2pd %xmm2,%xmm2
add    $0x2b,%al
subsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
cmp    $0x6,%ebp
jl     1268 <dec2str+0x118>
xor    %esi,%esi
ucomisd 0xe27(%rip),%xmm1
seta   %bl
xorpd  %xmm0,%xmm0
ja     123e <dec2str+0xee>
movapd %xmm1,%xmm0
mov    %bl,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
cmovl  %esi,%r8d
setge  %cl
add    %edx,%ecx
cvttsd2si %xmm0,%r9d
movzbl %al,%edx
lea    0xdfd(%rip),%rsi
jmp    13fd <dec2str+0x2ad>
cmp    $0x5,%ebp
jne    12ae <dec2str+0x15e>
xor    %esi,%esi
ucomisd 0xdd9(%rip),%xmm1
seta   %bl
xorpd  %xmm0,%xmm0
ja     1284 <dec2str+0x134>
movapd %xmm1,%xmm0
mov    %bl,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
cmovl  %esi,%r8d
setge  %cl
add    %edx,%ecx
cvttsd2si %xmm0,%r9d
movzbl %al,%edx
lea    0xdca(%rip),%rsi
jmp    13fd <dec2str+0x2ad>
cmp    $0x4,%ebp
jl     12f4 <dec2str+0x1a4>
xor    %esi,%esi
ucomisd 0xd8b(%rip),%xmm1
seta   %bl
xorpd  %xmm0,%xmm0
ja     12ca <dec2str+0x17a>
movapd %xmm1,%xmm0
mov    %bl,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
cmovl  %esi,%r8d
setge  %cl
add    %edx,%ecx
cvttsd2si %xmm0,%r9d
movzbl %al,%edx
lea    0xd97(%rip),%rsi
jmp    13fd <dec2str+0x2ad>
cmp    $0x3,%ebp
jne    133b <dec2str+0x1eb>
xor    %esi,%esi
ucomisd 0xd3d(%rip),%xmm1
seta   %dil
xorpd  %xmm0,%xmm0
ja     1311 <dec2str+0x1c1>
movapd %xmm1,%xmm0
mov    %dil,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
cmovl  %esi,%r8d
setge  %cl
add    %edx,%ecx
cvttsd2si %xmm0,%r9d
movzbl %al,%edx
lea    0xd63(%rip),%rsi
jmp    13fd <dec2str+0x2ad>
cmp    $0x2,%ebp
jl     137f <dec2str+0x22f>
xor    %esi,%esi
ucomisd 0xcee(%rip),%xmm1
seta   %dil
xorpd  %xmm0,%xmm0
ja     1358 <dec2str+0x208>
movapd %xmm1,%xmm0
mov    %dil,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
cmovl  %esi,%r8d
setge  %cl
add    %edx,%ecx
cvttsd2si %xmm0,%r9d
movzbl %al,%edx
lea    0xd2f(%rip),%rsi
jmp    13fd <dec2str+0x2ad>
cmp    $0x1,%ebp
jne    13c3 <dec2str+0x273>
xor    %esi,%esi
ucomisd 0xca2(%rip),%xmm1
seta   %dil
xorpd  %xmm0,%xmm0
ja     139c <dec2str+0x24c>
movapd %xmm1,%xmm0
mov    %dil,%sil
add    %ecx,%esi
xor    %r8d,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%esi
cmovl  %esi,%r8d
setge  %cl
add    %edx,%ecx
cvttsd2si %xmm0,%r9d
movzbl %al,%edx
lea    0xcfe(%rip),%rsi
jmp    13fd <dec2str+0x2ad>
addsd  0xc5d(%rip),%xmm1
cvttsd2si %xmm1,%r9d
xor    %esi,%esi
xor    %r8d,%r8d
cmp    $0x3c,%r9d
setge  %r8b
cmovge %esi,%r9d
add    %ecx,%r8d
xor    %ecx,%ecx
cmp    $0x3c,%r8d
setge  %cl
cmovge %esi,%r8d
add    %edx,%ecx
movzbl %al,%edx
lea    0xcd5(%rip),%rsi
mov    %rsp,%rdi
call   1070 <sprintf@plt>
mov    %rsp,%rdi
call   1050 <strlen@plt>
movslq %r14d,%rbp
add    $0xffffffffffffffff,%rbp
mov    %rsp,%rsi
cmp    %eax,%ebp
jle    1425 <dec2str+0x2d5>
mov    %r15,%rdi
call   1040 <strcpy@plt>
jmp    1434 <dec2str+0x2e4>
mov    %r15,%rdi
mov    %ebp,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%r15,%rbp,1)
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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 = load i32, i32* %15
%79 = load i32, i32* %16
%80 = load double, double* %13
%81 = fptosi double %80 to i32
%82 = call i32 @sprintf(i8* %76, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8 signext %77, i32 %78, i32 %79, i32 %81)
br label %225
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 = load i32, i32* %15
%102 = load i32, i32* %16
%103 = load double, double* %13
%104 = fptosi double %103 to i32
%105 = call i32 @sprintf(i8* %99, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8 signext %100, i32 %101, i32 %102, i32 %104)
br label %224
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 = load i32, i32* %15
%125 = load i32, i32* %16
%126 = load double, double* %13
%127 = fptosi double %126 to i32
%128 = call i32 @sprintf(i8* %122, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8 signext %123, i32 %124, i32 %125, i32 %127)
br label %223
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 = load i32, i32* %15
%148 = load i32, i32* %16
%149 = load double, double* %13
%150 = fptosi double %149 to i32
%151 = call i32 @sprintf(i8* %145, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8 signext %146, i32 %147, i32 %148, i32 %150)
br label %222
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 = load i32, i32* %15
%171 = load i32, i32* %16
%172 = load double, double* %13
%173 = fptosi double %172 to i32
%174 = call i32 @sprintf(i8* %168, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8 signext %169, i32 %170, i32 %171, i32 %173)
br label %221
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 = load i32, i32* %15
%194 = load i32, i32* %16
%195 = load double, double* %13
%196 = fptosi double %195 to i32
%197 = call i32 @sprintf(i8* %191, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8 signext %192, i32 %193, i32 %194, i32 %196)
br label %220
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 = load i32, i32* %15
%217 = load i32, i32* %16
%218 = load i32, i32* %17
%219 = call i32 @sprintf(i8* %214, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8 signext %215, i32 %216, i32 %217, i32 %218)
br label %220
220: ; preds = %213, %190
br label %221
221: ; preds = %220, %167
br label %222
222: ; preds = %221, %144
br label %223
223: ; preds = %222, %121
br label %224
224: ; preds = %223, %98
br label %225
225: ; preds = %224, %75
%226 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%227 = call i64 @strlen(i8* %226)
%228 = trunc i64 %227 to i32
store i32 %228, i32* %18
%229 = load i32, i32* %18
%230 = load i32, i32* %6
%231 = sub nsw i32 %230, 1
%232 = icmp slt i32 %229, %231
br i1 %232, label %233, label %237
233: ; preds = %225
%234 = load i8*, i8** %5
%235 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%236 = call i32 @strcpy(i8* %234, i8* %235)
br label %248
237: ; preds = %225
%238 = load i8*, i8** %5
%239 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%240 = load i32, i32* %6
%241 = sub nsw i32 %240, 1
%242 = call i32 @strncpy(i8* %238, i8* %239, i32 %241)
%243 = load i8*, i8** %5
%244 = load i32, i32* %6
%245 = sub nsw i32 %244, 1
%246 = sext i32 %245 to i64
%247 = getelementptr inbounds i8, i8* %243, i64 %246
store i8 0, i8* %247
br label %248
248: ; preds = %237, %233
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, i8 45, i8 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 %40
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 = fptosi double %31 to i32
%39 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8 signext %18, i32 %36, i32 %37, i32 %38)
br label %117
40: ; preds = %4
%41 = icmp eq i32 %3, 5
br i1 %41, label %42, label %53
42: ; preds = %40
%43 = fcmp ogt double %27, 0x404DFFFFAC1D29DC
%44 = select i1 %43, double 0.000000e+00, double %27
%45 = zext i1 %43 to i32
%46 = add nsw i32 %45, %24
%47 = icmp sgt i32 %46, 59
%48 = zext i1 %47 to i32
%49 = add nsw i32 %48, %20
%50 = select i1 %47, i32 0, i32 %46
%51 = fptosi double %44 to i32
%52 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8 signext %18, i32 %49, i32 %50, i32 %51)
br label %117
53: ; preds = %40
%54 = icmp sgt i32 %3, 3
br i1 %54, label %55, label %66
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 = fptosi double %57 to i32
%65 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8 signext %18, i32 %62, i32 %63, i32 %64)
br label %117
66: ; preds = %53
%67 = icmp eq i32 %3, 3
br i1 %67, label %68, label %79
68: ; preds = %66
%69 = fcmp ogt double %27, 5.999900e+01
%70 = select i1 %69, double 0.000000e+00, double %27
%71 = zext i1 %69 to i32
%72 = add nsw i32 %71, %24
%73 = icmp sgt i32 %72, 59
%74 = zext i1 %73 to i32
%75 = add nsw i32 %74, %20
%76 = select i1 %73, i32 0, i32 %72
%77 = fptosi double %70 to i32
%78 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8 signext %18, i32 %75, i32 %76, i32 %77)
br label %117
79: ; preds = %66
%80 = icmp sgt i32 %3, 1
br i1 %80, label %81, label %92
81: ; preds = %79
%82 = fcmp ogt double %27, 5.999000e+01
%83 = select i1 %82, double 0.000000e+00, double %27
%84 = zext i1 %82 to i32
%85 = add nsw i32 %84, %24
%86 = icmp sgt i32 %85, 59
%87 = zext i1 %86 to i32
%88 = add nsw i32 %87, %20
%89 = select i1 %86, i32 0, i32 %85
%90 = fptosi double %83 to i32
%91 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8 signext %18, i32 %88, i32 %89, i32 %90)
br label %117
92: ; preds = %79
%93 = icmp eq i32 %3, 1
br i1 %93, label %94, label %105
94: ; preds = %92
%95 = fcmp ogt double %27, 0x404DF33333333333
%96 = select i1 %95, double 0.000000e+00, double %27
%97 = zext i1 %95 to i32
%98 = add nsw i32 %97, %24
%99 = icmp sgt i32 %98, 59
%100 = zext i1 %99 to i32
%101 = add nsw i32 %100, %20
%102 = select i1 %99, i32 0, i32 %98
%103 = fptosi double %96 to i32
%104 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8 signext %18, i32 %101, i32 %102, i32 %103)
br label %117
105: ; preds = %92
%106 = fadd double %27, 5.000000e-01
%107 = fptosi double %106 to i32
%108 = icmp sgt i32 %107, 59
%109 = zext i1 %108 to i32
%110 = add nsw i32 %109, %24
%111 = select i1 %108, i32 0, i32 %107
%112 = icmp sgt i32 %110, 59
%113 = zext i1 %112 to i32
%114 = add nsw i32 %113, %20
%115 = select i1 %112, i32 0, i32 %110
%116 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8 signext %18, i32 %114, i32 %115, i32 %111)
br label %117
117: ; preds = %42, %68, %94, %105, %81, %55, %29
%118 = call i64 @strlen(i8* %6)
%119 = trunc i64 %118 to i32
%120 = add nsw i32 %1, -1
%121 = icmp sgt i32 %120, %119
br i1 %121, label %122, label %124
122: ; preds = %117
%123 = call i32 @strcpy(i8* %0, i8* %6)
br label %128
124: ; preds = %117
%125 = call i32 @strncpy(i8* %0, i8* %6, i32 %120)
%126 = sext i32 %120 to i64
%127 = getelementptr inbounds i8, i8* %0, i64 %126
store i8 0, i8* %127
br label %128
128: ; preds = %124, %122
ret void
}