short longitudeAdjustmentMinutes(double longitude) {
  const int degreeResolution = 10;
  short difference = (short)((0 - longitude) * degreeResolution + 0.5);
  short minutes = (difference * 4) / 10;
  short remainder = (difference * 4) % 10;
  return minutes + (remainder >= 5 ? 1 : remainder <= -5 ? -1 : 0);
}


x86 assembly (clang, -O0):
<longitudeAdjustmentMinutes>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm1
xorps  %xmm0,%xmm0
subsd  %xmm1,%xmm0
movsd  0xedc(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xed8(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %ax,-0xe(%rbp)
movswl -0xe(%rbp),%eax
shl    $0x2,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %ax,-0x10(%rbp)
movswl -0xe(%rbp),%eax
shl    $0x2,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %dx,%ax
mov    %ax,-0x12(%rbp)
movswl -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
movswl -0x12(%rbp),%eax
cmp    $0x5,%eax
jl     1186 <longitudeAdjustmentMinutes+0x86>
mov    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119a <longitudeAdjustmentMinutes+0x9a>
movswl -0x12(%rbp),%edx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0xfffffffb,%edx
cmovle %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    %ecx,%eax
cwtl
pop    %rbp
ret

x86 assembly (clang, -O2):
<longitudeAdjustmentMinutes>:
xorpd  %xmm1,%xmm1
subsd  %xmm0,%xmm1
mulsd  0xef0(%rip),%xmm1
addsd  0xef0(%rip),%xmm1
cvttsd2si %xmm1,%eax
cwtl
shl    $0x2,%eax
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
xor    %edx,%edx
cmp    $0xfffffffc,%eax
setl   %dl
neg    %edx
cmp    $0x5,%eax
mov    $0x1,%eax
cmovl  %edx,%eax
add    %ecx,%eax
ret

LLVM IR (-O0):
define signext i16 @longitudeAdjustmentMinutes(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
store double %0, double* %2
store i32 10, i32* %3
%7 = load double, double* %2
%8 = fsub double 0.000000e+00, %7
%9 = call double @llvm.fmuladd.f64(double %8, double 1.000000e+01, double 5.000000e-01)
%10 = fptosi double %9 to i16
store i16 %10, i16* %4
%11 = load i16, i16* %4
%12 = sext i16 %11 to i32
%13 = mul nsw i32 %12, 4
%14 = sdiv i32 %13, 10
%15 = trunc i32 %14 to i16
store i16 %15, i16* %5
%16 = load i16, i16* %4
%17 = sext i16 %16 to i32
%18 = mul nsw i32 %17, 4
%19 = srem i32 %18, 10
%20 = trunc i32 %19 to i16
store i16 %20, i16* %6
%21 = load i16, i16* %5
%22 = sext i16 %21 to i32
%23 = load i16, i16* %6
%24 = sext i16 %23 to i32
%25 = icmp sge i32 %24, 5
br i1 %25, label %26, label %27
26: ; preds = %1
br label %33
27: ; preds = %1
%28 = load i16, i16* %6
%29 = sext i16 %28 to i32
%30 = icmp sle i32 %29, -5
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 -1, i32 0
br label %33
33: ; preds = %27, %26
%34 = phi i32 [ 1, %26 ], [ %32, %27 ]
%35 = add nsw i32 %22, %34
%36 = trunc i32 %35 to i16
ret i16 %36
}

LLVM IR (-O2):
define signext i16 @longitudeAdjustmentMinutes(double %0) {
%2 = fsub double 0.000000e+00, %0
%3 = tail call double @llvm.fmuladd.f64(double %2, double 1.000000e+01, double 5.000000e-01)
%4 = fptosi double %3 to i16
%5 = sext i16 %4 to i32
%6 = shl nsw i32 %5, 2
%7 = srem i32 %6, 10
%8 = icmp sgt i32 %7, 4
%9 = icmp slt i32 %7, -4
%10 = sext i1 %9 to i32
%11 = select i1 %8, i32 1, i32 %10
%12 = sdiv i32 %6, 10
%13 = add nsw i32 %11, %12
%14 = trunc i32 %13 to i16
ret i16 %14
}