#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 floor(double);
int /*<<< orphan*/ sprintf(char *, char *, double, ...);
void medmLocalCvtDoubleToSexaStr(double value, char *string,
                                 unsigned short prec, double hopr, double lopr,
                                 int *status) {
  static const double prec_tab[8 + 1] = {1.0,         1.0 / 6.0,   1.0 / 60.0,
                                         1.0 / 360.0, 1.0 / 3.6E3, 1.0 / 3.6E4,
                                         1.0 / 3.6E5, 1.0 / 3.6E6, 1.0 / 3.6E7};
  double prec_frac, range, hrs, frac;
  char *ptr;
  int i, min, sec;
  *status = 0;
  if (prec <= 8) {
    prec_frac = prec_tab[prec];
  } else {
    prec_frac = prec_tab[8];
    for (i = prec; i > 8; i--, prec_frac *= 0.1)
      ;
  }
  value = value + 0.5 * prec_frac;
  range = (hopr - lopr);
  if (range == 360.0 || range == 24.0) {
    value = value - floor((value - lopr) / range) * range;
  }
  if (value < 0.0) {
    string[0] = '-';
    ptr = &string[1];
    value = -value + prec_frac;
  } else {
    ptr = string;
  }
  hrs = floor(value);
  value = (value - hrs) * 60.0;
  min = (int)value;
  value = (value - min) * 60.0;
  sec = (int)value;
  if (prec == 0)
    sprintf(ptr, "%.0f", hrs);
  else if (prec == 1)
    sprintf(ptr, "%.0f:%d", hrs, (min / 10));
  else if (prec == 2)
    sprintf(ptr, "%.0f:%02d", hrs, min);
  else if (prec == 3)
    sprintf(ptr, "%.0f:%02d:%d", hrs, min, sec / 10);
  else if (prec == 4)
    sprintf(ptr, "%.0f:%02d:%02d", hrs, min, sec);
  else {
    frac = floor((value - sec) / (prec_frac * 3600.0));
    sprintf(ptr, "%.0f:%02d:%02d.%0*.0f", hrs, min, sec, (prec - 4), frac);
  }
}


x86 assembly (clang, -O0):
<medmLocalCvtDoubleToSexaStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %si,%ax
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
movzwl -0x12(%rbp),%eax
cmp    $0x8,%eax
jg     117c <medmLocalCvtDoubleToSexaStr+0x5c>
movzwl -0x12(%rbp),%eax
mov    %eax,%ecx
lea    0xec3(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11c4 <medmLocalCvtDoubleToSexaStr+0xa4>
movsd  0xeec(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movzwl -0x12(%rbp),%eax
mov    %eax,-0x5c(%rbp)
cmpl   $0x8,-0x5c(%rbp)
jle    11bf <medmLocalCvtDoubleToSexaStr+0x9f>
jmp    119f <medmLocalCvtDoubleToSexaStr+0x7f>
mov    -0x5c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x5c(%rbp)
movsd  0xe50(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1190 <medmLocalCvtDoubleToSexaStr+0x70>
jmp    11c4 <medmLocalCvtDoubleToSexaStr+0xa4>
movsd  -0x8(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  0xe3a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xe09(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1214 <medmLocalCvtDoubleToSexaStr+0xf4>
jp     1214 <medmLocalCvtDoubleToSexaStr+0xf4>
jmp    1231 <medmLocalCvtDoubleToSexaStr+0x111>
movsd  -0x40(%rbp),%xmm0
movsd  0xdf7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    127d <medmLocalCvtDoubleToSexaStr+0x15d>
jp     127d <medmLocalCvtDoubleToSexaStr+0x15d>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
call   1040 <floor@plt>
movsd  -0x70(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    12c9 <medmLocalCvtDoubleToSexaStr+0x1a9>
mov    -0x10(%rbp),%rax
movb   $0x2d,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d1 <medmLocalCvtDoubleToSexaStr+0x1b1>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  0xd2e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x60(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xd07(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0x64(%rbp)
movzwl -0x12(%rbp),%eax
cmp    $0x0,%eax
jne    1353 <medmLocalCvtDoubleToSexaStr+0x233>
mov    -0x58(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
lea    0xd31(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    148b <medmLocalCvtDoubleToSexaStr+0x36b>
movzwl -0x12(%rbp),%eax
cmp    $0x1,%eax
jne    1389 <medmLocalCvtDoubleToSexaStr+0x269>
mov    -0x58(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
mov    -0x60(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xd00(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    1486 <medmLocalCvtDoubleToSexaStr+0x366>
movzwl -0x12(%rbp),%eax
cmp    $0x2,%eax
jne    13b5 <medmLocalCvtDoubleToSexaStr+0x295>
mov    -0x58(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
mov    -0x60(%rbp),%edx
lea    0xcdc(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    1481 <medmLocalCvtDoubleToSexaStr+0x361>
movzwl -0x12(%rbp),%eax
cmp    $0x3,%eax
jne    13f4 <medmLocalCvtDoubleToSexaStr+0x2d4>
mov    -0x58(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
mov    -0x60(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x64(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x74(%rbp),%edx
mov    %eax,%ecx
lea    0xca7(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    147c <medmLocalCvtDoubleToSexaStr+0x35c>
movzwl -0x12(%rbp),%eax
cmp    $0x4,%eax
jne    1423 <medmLocalCvtDoubleToSexaStr+0x303>
mov    -0x58(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
mov    -0x60(%rbp),%edx
mov    -0x64(%rbp),%ecx
lea    0xc85(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    1477 <medmLocalCvtDoubleToSexaStr+0x357>
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x64(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xbef(%rip),%xmm1
mulsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x58(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
mov    -0x60(%rbp),%edx
mov    -0x64(%rbp),%ecx
movzwl -0x12(%rbp),%r8d
sub    $0x4,%r8d
movsd  -0x50(%rbp),%xmm1
lea    0xc3b(%rip),%rsi
mov    $0x2,%al
call   1030 <sprintf@plt>
jmp    147c <medmLocalCvtDoubleToSexaStr+0x35c>
jmp    1481 <medmLocalCvtDoubleToSexaStr+0x361>
jmp    1486 <medmLocalCvtDoubleToSexaStr+0x366>
jmp    148b <medmLocalCvtDoubleToSexaStr+0x36b>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<medmLocalCvtDoubleToSexaStr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
movl   $0x0,(%rdx)
movzwl %bx,%r12d
cmp    $0x9,%bx
jae    1150 <medmLocalCvtDoubleToSexaStr+0x30>
lea    0xf18(%rip),%rax
movsd  (%rax,%r12,8),%xmm3
jmp    11c8 <medmLocalCvtDoubleToSexaStr+0xa8>
lea    -0x9(%rbx),%ecx
mov    %ebx,%eax
and    $0x7,%eax
je     1186 <medmLocalCvtDoubleToSexaStr+0x66>
xor    %edx,%edx
movsd  0xe9c(%rip),%xmm3
movsd  0xe9c(%rip),%xmm4
nopl   0x0(%rax)
mulsd  %xmm4,%xmm3
add    $0x1,%edx
cmp    %edx,%eax
jne    1170 <medmLocalCvtDoubleToSexaStr+0x50>
mov    %ebx,%eax
sub    %edx,%eax
cmp    $0x7,%ecx
jae    1195 <medmLocalCvtDoubleToSexaStr+0x75>
jmp    11c8 <medmLocalCvtDoubleToSexaStr+0xa8>
movsd  0xe72(%rip),%xmm3
mov    %ebx,%eax
cmp    $0x7,%ecx
jb     11c8 <medmLocalCvtDoubleToSexaStr+0xa8>
add    $0xfffffff7,%eax
movsd  0xe68(%rip),%xmm4
mulsd  %xmm4,%xmm3
mulsd  %xmm4,%xmm3
mulsd  %xmm4,%xmm3
mulsd  %xmm4,%xmm3
mulsd  %xmm4,%xmm3
mulsd  %xmm4,%xmm3
mulsd  %xmm4,%xmm3
mulsd  %xmm4,%xmm3
add    $0xfffffff8,%eax
cmp    $0xfffffff6,%eax
jb     11a0 <medmLocalCvtDoubleToSexaStr+0x80>
movsd  0xe40(%rip),%xmm4
mulsd  %xmm3,%xmm4
addsd  %xmm0,%xmm4
subsd  %xmm2,%xmm1
ucomisd 0xe34(%rip),%xmm1
movsd  %xmm3,0x10(%rsp)
jne    11ee <medmLocalCvtDoubleToSexaStr+0xce>
jnp    11fa <medmLocalCvtDoubleToSexaStr+0xda>
ucomisd 0xe2a(%rip),%xmm1
jne    122b <medmLocalCvtDoubleToSexaStr+0x10b>
jp     122b <medmLocalCvtDoubleToSexaStr+0x10b>
movapd %xmm4,%xmm0
subsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm1,0x18(%rsp)
movapd %xmm4,(%rsp)
call   1040 <floor@plt>
movapd (%rsp),%xmm4
movsd  0x10(%rsp),%xmm3
mulsd  0x18(%rsp),%xmm0
subsd  %xmm0,%xmm4
xorpd  %xmm0,%xmm0
ucomisd %xmm4,%xmm0
jbe    1249 <medmLocalCvtDoubleToSexaStr+0x129>
movb   $0x2d,(%r14)
add    $0x1,%r14
movapd %xmm3,%xmm0
subsd  %xmm4,%xmm0
movapd %xmm0,%xmm4
movapd %xmm4,(%rsp)
movapd %xmm4,%xmm0
call   1040 <floor@plt>
movapd (%rsp),%xmm3
movapd %xmm0,%xmm2
subsd  %xmm0,%xmm3
movsd  0xdbc(%rip),%xmm0
mulsd  %xmm0,%xmm3
cvttsd2si %xmm3,%r15d
cvttpd2dq %xmm3,%xmm1
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm3
mulsd  %xmm0,%xmm3
cvttsd2si %xmm3,%ebp
cmp    $0x4,%bx
ja     12c0 <medmLocalCvtDoubleToSexaStr+0x1a0>
lea    0xdaa(%rip),%rax
movslq (%rax,%r12,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xe02(%rip),%rsi
mov    %r14,%rdi
movapd %xmm2,%xmm0
mov    $0x1,%al
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <sprintf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
subsd  %xmm0,%xmm3
movsd  0x10(%rsp),%xmm0
mulsd  0xd57(%rip),%xmm0
divsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
movsd  %xmm2,(%rsp)
call   1040 <floor@plt>
movapd %xmm0,%xmm1
add    $0xfffffffc,%ebx
lea    0xde2(%rip),%rsi
mov    %r14,%rdi
movsd  (%rsp),%xmm0
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
mov    $0x2,%al
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <sprintf@plt>
movslq %r15d,%rax
imul   $0x66666667,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x22,%rdx
add    %eax,%edx
lea    0xd73(%rip),%rsi
mov    %r14,%rdi
movapd %xmm2,%xmm0
jmp    1354 <medmLocalCvtDoubleToSexaStr+0x234>
lea    0xd6b(%rip),%rsi
mov    %r14,%rdi
movapd %xmm2,%xmm0
mov    %r15d,%edx
mov    $0x1,%al
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <sprintf@plt>
movslq %ebp,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x22,%rcx
add    %eax,%ecx
lea    0xd3a(%rip),%rsi
mov    %r14,%rdi
movapd %xmm2,%xmm0
mov    %r15d,%edx
jmp    13a4 <medmLocalCvtDoubleToSexaStr+0x284>
lea    0xd34(%rip),%rsi
mov    %r14,%rdi
movapd %xmm2,%xmm0
mov    %r15d,%edx
mov    %ebp,%ecx
mov    $0x1,%al
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@medmLocalCvtDoubleToSexaStr.prec_tab = internal constant [9 x double] [double 1.000000e+00, double 0x3FC5555555555555, double 0x3F91111111111111, double 0x3F66C16C16C16C17, double 0x3F323456789ABCDF, double 0x3EFD208A5A912E32, double 0x3EC74D3B7BA75828, double 0x3E92A42F961F79B9, double 0x3E5DD37F5698C2C2]
@.str = [5 x i8] c"%.0f\00"
@.str.1 = [8 x i8] c"%.0f:%d\00"
@.str.2 = [10 x i8] c"%.0f:%02d\00"
@.str.3 = [13 x i8] c"%.0f:%02d:%d\00"
@.str.4 = [15 x i8] c"%.0f:%02d:%02d\00"
@.str.5 = [22 x i8] c"%.0f:%02d:%02d.%0*.0f\00"
define void @medmLocalCvtDoubleToSexaStr(double %0, i8* %1, i16 zeroext %2, double %3, double %4, i32* %5) {
%7 = alloca double
%8 = alloca i8*
%9 = alloca i16
%10 = alloca double
%11 = alloca double
%12 = alloca i32*
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store double %0, double* %7
store i8* %1, i8** %8
store i16 %2, i16* %9
store double %3, double* %10
store double %4, double* %11
store i32* %5, i32** %12
%21 = load i32*, i32** %12
store i32 0, i32* %21
%22 = load i16, i16* %9
%23 = zext i16 %22 to i32
%24 = icmp sle i32 %23, 8
br i1 %24, label %25, label %30
25: ; preds = %6
%26 = load i16, i16* %9
%27 = zext i16 %26 to i64
%28 = getelementptr inbounds [9 x double], [9 x double]* @medmLocalCvtDoubleToSexaStr.prec_tab, i64 0, i64 %27
%29 = load double, double* %28
store double %29, double* %13
br label %44
30: ; preds = %6
%31 = load double, double* getelementptr inbounds ([9 x double], [9 x double]* @medmLocalCvtDoubleToSexaStr.prec_tab, i64 0, i64 8)
store double %31, double* %13
%32 = load i16, i16* %9
%33 = zext i16 %32 to i32
store i32 %33, i32* %18
br label %34
34: ; preds = %38, %30
%35 = load i32, i32* %18
%36 = icmp sgt i32 %35, 8
br i1 %36, label %37, label %43
37: ; preds = %34
br label %38
38: ; preds = %37
%39 = load i32, i32* %18
%40 = add nsw i32 %39, -1
store i32 %40, i32* %18
%41 = load double, double* %13
%42 = fmul double %41, 1.000000e-01
store double %42, double* %13
br label %34
43: ; preds = %34
br label %44
44: ; preds = %43, %25
%45 = load double, double* %7
%46 = load double, double* %13
%47 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %46, double %45)
store double %47, double* %7
%48 = load double, double* %10
%49 = load double, double* %11
%50 = fsub double %48, %49
store double %50, double* %14
%51 = load double, double* %14
%52 = fcmp oeq double %51, 3.600000e+02
br i1 %52, label %56, label %53
53: ; preds = %44
%54 = load double, double* %14
%55 = fcmp oeq double %54, 2.400000e+01
br i1 %55, label %56, label %67
56: ; preds = %53, %44
%57 = load double, double* %7
%58 = load double, double* %7
%59 = load double, double* %11
%60 = fsub double %58, %59
%61 = load double, double* %14
%62 = fdiv double %60, %61
%63 = call double @llvm.floor.f64(double %62)
%64 = load double, double* %14
%65 = fneg double %63
%66 = call double @llvm.fmuladd.f64(double %65, double %64, double %57)
store double %66, double* %7
br label %67
67: ; preds = %56, %53
%68 = load double, double* %7
%69 = fcmp olt double %68, 0.000000e+00
br i1 %69, label %70, label %79
70: ; preds = %67
%71 = load i8*, i8** %8
%72 = getelementptr inbounds i8, i8* %71, i64 0
store i8 45, i8* %72
%73 = load i8*, i8** %8
%74 = getelementptr inbounds i8, i8* %73, i64 1
store i8* %74, i8** %17
%75 = load double, double* %7
%76 = fneg double %75
%77 = load double, double* %13
%78 = fadd double %76, %77
store double %78, double* %7
br label %81
79: ; preds = %67
%80 = load i8*, i8** %8
store i8* %80, i8** %17
br label %81
81: ; preds = %79, %70
%82 = load double, double* %7
%83 = call double @llvm.floor.f64(double %82)
store double %83, double* %15
%84 = load double, double* %7
%85 = load double, double* %15
%86 = fsub double %84, %85
%87 = fmul double %86, 6.000000e+01
store double %87, double* %7
%88 = load double, double* %7
%89 = fptosi double %88 to i32
store i32 %89, i32* %19
%90 = load double, double* %7
%91 = load i32, i32* %19
%92 = sitofp i32 %91 to double
%93 = fsub double %90, %92
%94 = fmul double %93, 6.000000e+01
store double %94, double* %7
%95 = load double, double* %7
%96 = fptosi double %95 to i32
store i32 %96, i32* %20
%97 = load i16, i16* %9
%98 = zext i16 %97 to i32
%99 = icmp eq i32 %98, 0
br i1 %99, label %100, label %104
100: ; preds = %81
%101 = load i8*, i8** %17
%102 = load double, double* %15
%103 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %101, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %102)
br label %166
104: ; preds = %81
%105 = load i16, i16* %9
%106 = zext i16 %105 to i32
%107 = icmp eq i32 %106, 1
br i1 %107, label %108, label %114
108: ; preds = %104
%109 = load i8*, i8** %17
%110 = load double, double* %15
%111 = load i32, i32* %19
%112 = sdiv i32 %111, 10
%113 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %109, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %110, i32 %112)
br label %165
114: ; preds = %104
%115 = load i16, i16* %9
%116 = zext i16 %115 to i32
%117 = icmp eq i32 %116, 2
br i1 %117, label %118, label %123
118: ; preds = %114
%119 = load i8*, i8** %17
%120 = load double, double* %15
%121 = load i32, i32* %19
%122 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %119, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %120, i32 %121)
br label %164
123: ; preds = %114
%124 = load i16, i16* %9
%125 = zext i16 %124 to i32
%126 = icmp eq i32 %125, 3
br i1 %126, label %127, label %134
127: ; preds = %123
%128 = load i8*, i8** %17
%129 = load double, double* %15
%130 = load i32, i32* %19
%131 = load i32, i32* %20
%132 = sdiv i32 %131, 10
%133 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %128, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %129, i32 %130, i32 %132)
br label %163
134: ; preds = %123
%135 = load i16, i16* %9
%136 = zext i16 %135 to i32
%137 = icmp eq i32 %136, 4
br i1 %137, label %138, label %144
138: ; preds = %134
%139 = load i8*, i8** %17
%140 = load double, double* %15
%141 = load i32, i32* %19
%142 = load i32, i32* %20
%143 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %139, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), double %140, i32 %141, i32 %142)
br label %162
144: ; preds = %134
%145 = load double, double* %7
%146 = load i32, i32* %20
%147 = sitofp i32 %146 to double
%148 = fsub double %145, %147
%149 = load double, double* %13
%150 = fmul double %149, 3.600000e+03
%151 = fdiv double %148, %150
%152 = call double @llvm.floor.f64(double %151)
store double %152, double* %16
%153 = load i8*, i8** %17
%154 = load double, double* %15
%155 = load i32, i32* %19
%156 = load i32, i32* %20
%157 = load i16, i16* %9
%158 = zext i16 %157 to i32
%159 = sub nsw i32 %158, 4
%160 = load double, double* %16
%161 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %153, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), double %154, i32 %155, i32 %156, i32 %159, double %160)
br label %162
162: ; preds = %144, %138
br label %163
163: ; preds = %162, %127
br label %164
164: ; preds = %163, %118
br label %165
165: ; preds = %164, %108
br label %166
166: ; preds = %165, %100
ret void
}

LLVM IR (-O2):
@medmLocalCvtDoubleToSexaStr.prec_tab = internal unnamed_addr constant [9 x double] [double 1.000000e+00, double 0x3FC5555555555555, double 0x3F91111111111111, double 0x3F66C16C16C16C17, double 0x3F323456789ABCDF, double 0x3EFD208A5A912E32, double 0x3EC74D3B7BA75828, double 0x3E92A42F961F79B9, double 0x3E5DD37F5698C2C2]
@.str = [5 x i8] c"%.0f\00"
@.str.1 = [8 x i8] c"%.0f:%d\00"
@.str.2 = [10 x i8] c"%.0f:%02d\00"
@.str.3 = [13 x i8] c"%.0f:%02d:%d\00"
@.str.4 = [15 x i8] c"%.0f:%02d:%02d\00"
@.str.5 = [22 x i8] c"%.0f:%02d:%02d.%0*.0f\00"
define void @medmLocalCvtDoubleToSexaStr(double %0, i8* nocapture writeonly %1, i16 zeroext %2, double %3, double %4, i32* nocapture writeonly %5) {
store i32 0, i32* %5
%7 = zext i16 %2 to i32
%8 = icmp ult i16 %2, 9
br i1 %8, label %26, label %9
9: ; preds = %6
%10 = add nsw i32 %7, -9
%11 = and i32 %7, 7
%12 = icmp eq i32 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %9, %13
%14 = phi double [ %18, %13 ], [ 0x3E5DD37F5698C2C2, %9 ]
%15 = phi i32 [ %17, %13 ], [ %7, %9 ]
%16 = phi i32 [ %19, %13 ], [ 0, %9 ]
%17 = add nsw i32 %15, -1
%18 = fmul double %14, 1.000000e-01
%19 = add i32 %16, 1
%20 = icmp eq i32 %19, %11
br i1 %20, label %21, label %13
21: ; preds = %13, %9
%22 = phi double [ 0x3E5DD37F5698C2C2, %9 ], [ %18, %13 ]
%23 = phi i32 [ %7, %9 ], [ %17, %13 ]
%24 = phi double [ undef, %9 ], [ %18, %13 ]
%25 = icmp ult i32 %10, 7
br i1 %25, label %44, label %30
26: ; preds = %6
%27 = zext i16 %2 to i64
%28 = getelementptr inbounds [9 x double], [9 x double]* @medmLocalCvtDoubleToSexaStr.prec_tab, i64 0, i64 %27
%29 = load double, double* %28
br label %44
30: ; preds = %21, %30
%31 = phi double [ %41, %30 ], [ %22, %21 ]
%32 = phi i32 [ %40, %30 ], [ %23, %21 ]
%33 = fmul double %31, 1.000000e-01
%34 = fmul double %33, 1.000000e-01
%35 = fmul double %34, 1.000000e-01
%36 = fmul double %35, 1.000000e-01
%37 = fmul double %36, 1.000000e-01
%38 = fmul double %37, 1.000000e-01
%39 = fmul double %38, 1.000000e-01
%40 = add nsw i32 %32, -8
%41 = fmul double %39, 1.000000e-01
%42 = add i32 %32, -17
%43 = icmp ult i32 %42, -10
br i1 %43, label %30, label %44
44: ; preds = %21, %30, %26
%45 = phi double [ %29, %26 ], [ %24, %21 ], [ %41, %30 ]
%46 = tail call double @llvm.fmuladd.f64(double %45, double 5.000000e-01, double %0)
%47 = fsub double %3, %4
%48 = fcmp oeq double %47, 3.600000e+02
%49 = fcmp oeq double %47, 2.400000e+01
%50 = or i1 %48, %49
br i1 %50, label %51, label %57
51: ; preds = %44
%52 = fsub double %46, %4
%53 = fdiv double %52, %47
%54 = tail call double @llvm.floor.f64(double %53)
%55 = fneg double %54
%56 = tail call double @llvm.fmuladd.f64(double %55, double %47, double %46)
br label %57
57: ; preds = %44, %51
%58 = phi double [ %56, %51 ], [ %46, %44 ]
%59 = fcmp olt double %58, 0.000000e+00
br i1 %59, label %60, label %63
60: ; preds = %57
store i8 45, i8* %1
%61 = getelementptr inbounds i8, i8* %1, i64 1
%62 = fsub double %45, %58
br label %63
63: ; preds = %57, %60
%64 = phi i8* [ %61, %60 ], [ %1, %57 ]
%65 = phi double [ %62, %60 ], [ %58, %57 ]
%66 = tail call double @llvm.floor.f64(double %65)
%67 = fsub double %65, %66
%68 = fmul double %67, 6.000000e+01
%69 = fptosi double %68 to i32
%70 = sitofp i32 %69 to double
%71 = fsub double %68, %70
%72 = fmul double %71, 6.000000e+01
%73 = fptosi double %72 to i32
switch i16 %2, label %86 [
i16 0, label %74
i16 1, label %76
i16 2, label %79
i16 3, label %81
i16 4, label %84
]
74: ; preds = %63
%75 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %64, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %66)
br label %94
76: ; preds = %63
%77 = sdiv i32 %69, 10
%78 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %64, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %66, i32 %77)
br label %94
79: ; preds = %63
%80 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %64, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %66, i32 %69)
br label %94
81: ; preds = %63
%82 = sdiv i32 %73, 10
%83 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %64, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %66, i32 %69, i32 %82)
br label %94
84: ; preds = %63
%85 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %64, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), double %66, i32 %69, i32 %73)
br label %94
86: ; preds = %63
%87 = sitofp i32 %73 to double
%88 = fsub double %72, %87
%89 = fmul double %45, 3.600000e+03
%90 = fdiv double %88, %89
%91 = tail call double @llvm.floor.f64(double %90)
%92 = add nsw i32 %7, -4
%93 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %64, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), double %66, i32 %69, i32 %73, i32 %92, double %91)
br label %94
94: ; preds = %76, %81, %86, %84, %79, %74
ret void
}