char *SFMLongitudeToString(double dms_x) {
  double m, s;
  static char str[256];
  while (dms_x < -140.0)
    dms_x += (2 * 140.0);
  while (dms_x > 140.0)
    dms_x -= (2 * 140.0);
  if (dms_x < 0.0) {
    dms_x = fabs(dms_x);
    m = (dms_x - floor(dms_x)) * 60.0;
    s = floor((m - floor(m)) * 60.0);
    m = floor(m);
    sprintf(str, "%.0f'%s%.0f:%s%.0fW", floor(dms_x), (m < 10.0f) ? "0" : "", m,
            (s < 10.0f) ? "0" : "", s);
  } else {
    m = (dms_x - floor(dms_x)) * 60.0;
    s = floor((m - floor(m)) * 60.0);
    m = floor(m);
    sprintf(str, "%.0f'%s%.0f:%s%.0fE", floor(dms_x), (m < 10.0f) ? "0" : "", m,
            (s < 10.0f) ? "0" : "", s);
  }
  return (str);
}


x86 assembly (clang, -O0):
<SFMLongitudeToString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xecb(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1157 <SFMLongitudeToString+0x37>
movsd  0xed8(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    112d <SFMLongitudeToString+0xd>
jmp    115c <SFMLongitudeToString+0x3c>
movsd  -0x8(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118e <SFMLongitudeToString+0x6e>
movsd  -0x8(%rbp),%xmm0
movsd  0xea0(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    115c <SFMLongitudeToString+0x3c>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    129b <SFMLongitudeToString+0x17b>
movsd  -0x8(%rbp),%xmm0
movaps 0xe88(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  0xe3f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  0xe0e(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
movsd  -0x10(%rbp),%xmm2
movsd  0xdd2(%rip),%xmm1
lea    0xe10(%rip),%rdx
lea    0xe08(%rip),%rax
ucomisd %xmm2,%xmm1
cmova  %rax,%rdx
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm3
movsd  0xdaa(%rip),%xmm2
lea    0xde8(%rip),%rcx
lea    0xde0(%rip),%rax
ucomisd %xmm3,%xmm2
cmova  %rax,%rcx
movsd  -0x18(%rbp),%xmm2
lea    0x2db8(%rip),%rdi
lea    0xdb1(%rip),%rsi
mov    $0x3,%al
call   1030 <sprintf@plt>
jmp    1380 <SFMLongitudeToString+0x260>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  0xd55(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  0xd24(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
movsd  -0x10(%rbp),%xmm2
movsd  0xce8(%rip),%xmm1
lea    0xd26(%rip),%rdx
lea    0xd1e(%rip),%rax
ucomisd %xmm2,%xmm1
cmova  %rax,%rdx
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm3
movsd  0xcc0(%rip),%xmm2
lea    0xcfe(%rip),%rcx
lea    0xcf6(%rip),%rax
ucomisd %xmm3,%xmm2
cmova  %rax,%rcx
movsd  -0x18(%rbp),%xmm2
lea    0x2cce(%rip),%rdi
lea    0xcdd(%rip),%rsi
mov    $0x3,%al
call   1030 <sprintf@plt>
lea    0x2cb9(%rip),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SFMLongitudeToString>:
sub    $0x28,%rsp
movsd  0xed4(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    114a <SFMLongitudeToString+0x2a>
movsd  0xece(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
addsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
ja     1140 <SFMLongitudeToString+0x20>
ucomisd 0xebe(%rip),%xmm0
jbe    117a <SFMLongitudeToString+0x5a>
movsd  0xebc(%rip),%xmm2
movsd  0xeac(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
ja     1170 <SFMLongitudeToString+0x50>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1225 <SFMLongitudeToString+0x105>
andpd  0xea0(%rip),%xmm0
movapd %xmm0,(%rsp)
call   1040 <floor@plt>
movsd  %xmm0,0x20(%rsp)
movapd (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe6f(%rip),%xmm1
movapd %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,0x18(%rsp)
movapd (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe4a(%rip),%xmm1
movapd %xmm1,%xmm0
call   1040 <floor@plt>
movsd  0xe41(%rip),%xmm3
movsd  0x18(%rsp),%xmm1
ucomisd %xmm1,%xmm3
lea    0xe5c(%rip),%rax
lea    0xe56(%rip),%rcx
mov    %rcx,%rdx
cmova  %rax,%rdx
movapd %xmm0,%xmm2
ucomisd %xmm0,%xmm3
cmova  %rax,%rcx
lea    0x2e27(%rip),%rdi
lea    0xe20(%rip),%rsi
jmp    12b5 <SFMLongitudeToString+0x195>
movapd %xmm0,(%rsp)
call   1040 <floor@plt>
movsd  %xmm0,0x20(%rsp)
movapd (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xdda(%rip),%xmm1
movapd %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,0x18(%rsp)
movapd (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xdb5(%rip),%xmm1
movapd %xmm1,%xmm0
call   1040 <floor@plt>
movsd  0xdac(%rip),%xmm3
movsd  0x18(%rsp),%xmm1
ucomisd %xmm1,%xmm3
lea    0xdc7(%rip),%rax
lea    0xdc1(%rip),%rcx
mov    %rcx,%rdx
cmova  %rax,%rdx
movapd %xmm0,%xmm2
ucomisd %xmm0,%xmm3
cmova  %rax,%rcx
lea    0x2d92(%rip),%rdi
lea    0xda1(%rip),%rsi
movsd  0x20(%rsp),%xmm0
mov    $0x3,%al
call   1030 <sprintf@plt>
lea    0x2d77(%rip),%rax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@SFMLongitudeToString.str = internal global [256 x i8] zeroinitializer
@.str = [20 x i8] c"%.0f'%s%.0f:%s%.0fW\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [20 x i8] c"%.0f'%s%.0f:%s%.0fE\00"
define i8* @SFMLongitudeToString(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %2
br label %5
5: ; preds = %8, %1
%6 = load double, double* %2
%7 = fcmp olt double %6, -1.400000e+02
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load double, double* %2
%10 = fadd double %9, 2.800000e+02
store double %10, double* %2
br label %5
11: ; preds = %5
br label %12
12: ; preds = %15, %11
%13 = load double, double* %2
%14 = fcmp ogt double %13, 1.400000e+02
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load double, double* %2
%17 = fsub double %16, 2.800000e+02
store double %17, double* %2
br label %12
18: ; preds = %12
%19 = load double, double* %2
%20 = fcmp olt double %19, 0.000000e+00
br i1 %20, label %21, label %50
21: ; preds = %18
%22 = load double, double* %2
%23 = call double @llvm.fabs.f64(double %22)
store double %23, double* %2
%24 = load double, double* %2
%25 = load double, double* %2
%26 = call double @llvm.floor.f64(double %25)
%27 = fsub double %24, %26
%28 = fmul double %27, 6.000000e+01
store double %28, double* %3
%29 = load double, double* %3
%30 = load double, double* %3
%31 = call double @llvm.floor.f64(double %30)
%32 = fsub double %29, %31
%33 = fmul double %32, 6.000000e+01
%34 = call double @llvm.floor.f64(double %33)
store double %34, double* %4
%35 = load double, double* %3
%36 = call double @llvm.floor.f64(double %35)
store double %36, double* %3
%37 = load double, double* %2
%38 = call double @llvm.floor.f64(double %37)
%39 = load double, double* %3
%40 = fcmp olt double %39, 1.000000e+01
%41 = zext i1 %40 to i64
%42 = select i1 %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%43 = load double, double* %3
%44 = load double, double* %4
%45 = fcmp olt double %44, 1.000000e+01
%46 = zext i1 %45 to i64
%47 = select i1 %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%48 = load double, double* %4
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @SFMLongitudeToString.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %38, i8* %42, double %43, i8* %47, double %48)
br label %77
50: ; preds = %18
%51 = load double, double* %2
%52 = load double, double* %2
%53 = call double @llvm.floor.f64(double %52)
%54 = fsub double %51, %53
%55 = fmul double %54, 6.000000e+01
store double %55, double* %3
%56 = load double, double* %3
%57 = load double, double* %3
%58 = call double @llvm.floor.f64(double %57)
%59 = fsub double %56, %58
%60 = fmul double %59, 6.000000e+01
%61 = call double @llvm.floor.f64(double %60)
store double %61, double* %4
%62 = load double, double* %3
%63 = call double @llvm.floor.f64(double %62)
store double %63, double* %3
%64 = load double, double* %2
%65 = call double @llvm.floor.f64(double %64)
%66 = load double, double* %3
%67 = fcmp olt double %66, 1.000000e+01
%68 = zext i1 %67 to i64
%69 = select i1 %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%70 = load double, double* %3
%71 = load double, double* %4
%72 = fcmp olt double %71, 1.000000e+01
%73 = zext i1 %72 to i64
%74 = select i1 %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%75 = load double, double* %4
%76 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @SFMLongitudeToString.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double %65, i8* %69, double %70, i8* %74, double %75)
br label %77
77: ; preds = %50, %21
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @SFMLongitudeToString.str, i64 0, i64 0)
}

LLVM IR (-O2):
@SFMLongitudeToString.str = internal global [256 x i8] zeroinitializer
@.str = [20 x i8] c"%.0f'%s%.0f:%s%.0fW\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [20 x i8] c"%.0f'%s%.0f:%s%.0fE\00"
define i8* @SFMLongitudeToString(double %0) {
%2 = fcmp olt double %0, -1.400000e+02
br i1 %2, label %6, label %3
3: ; preds = %6, %1
%4 = phi double [ %0, %1 ], [ %8, %6 ]
%5 = fcmp ogt double %4, 1.400000e+02
br i1 %5, label %10, label %14
6: ; preds = %1, %6
%7 = phi double [ %8, %6 ], [ %0, %1 ]
%8 = fadd double %7, 2.800000e+02
%9 = fcmp olt double %8, -1.400000e+02
br i1 %9, label %6, label %3
10: ; preds = %3, %10
%11 = phi double [ %12, %10 ], [ %4, %3 ]
%12 = fadd double %11, -2.800000e+02
%13 = fcmp ogt double %12, 1.400000e+02
br i1 %13, label %10, label %14
14: ; preds = %10, %3
%15 = phi double [ %4, %3 ], [ %12, %10 ]
%16 = fcmp olt double %15, 0.000000e+00
br i1 %16, label %17, label %31
17: ; preds = %14
%18 = tail call double @llvm.fabs.f64(double %15)
%19 = tail call double @llvm.floor.f64(double %18)
%20 = fsub double %18, %19
%21 = fmul double %20, 6.000000e+01
%22 = tail call double @llvm.floor.f64(double %21)
%23 = fsub double %21, %22
%24 = fmul double %23, 6.000000e+01
%25 = tail call double @llvm.floor.f64(double %24)
%26 = fcmp olt double %22, 1.000000e+01
%27 = select i1 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%28 = fcmp olt double %25, 1.000000e+01
%29 = select i1 %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%30 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @SFMLongitudeToString.str, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %19, i8* %27, double %22, i8* %29, double %25)
br label %44
31: ; preds = %14
%32 = tail call double @llvm.floor.f64(double %15)
%33 = fsub double %15, %32
%34 = fmul double %33, 6.000000e+01
%35 = tail call double @llvm.floor.f64(double %34)
%36 = fsub double %34, %35
%37 = fmul double %36, 6.000000e+01
%38 = tail call double @llvm.floor.f64(double %37)
%39 = fcmp olt double %35, 1.000000e+01
%40 = select i1 %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%41 = fcmp olt double %38, 1.000000e+01
%42 = select i1 %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%43 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @SFMLongitudeToString.str, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double %32, i8* %40, double %35, i8* %42, double %38)
br label %44
44: ; preds = %31, %17
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @SFMLongitudeToString.str, i64 0, i64 0)
}