#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 fabs(double);
int toupper(char);
double geoDms2DD(double deg, double min, double sec, char *sign) {
  double direction;
  switch (toupper(*sign)) {
  case 'W':
  case 'S':
    direction = -1.0;
    break;
  case 'E':
  case 'N':
    direction = 1.0;
    break;
  default:
    direction = 1.0;
  }
  return (direction *
          (fabs(deg) + (min * (1.0 / 60.0)) + (sec * (1.0 / 3600.0))));
}


x86 assembly (clang, -O0):
<geoDms2DD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
add    $0xffffffbb,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x12,%eax
ja     1181 <geoDms2DD+0x71>
mov    -0x30(%rbp),%rax
lea    0xedc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xea3(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    118e <geoDms2DD+0x7e>
movsd  0xe89(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    118e <geoDms2DD+0x7e>
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movaps 0xe81(%rip),%xmm2
pand   %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  0xe68(%rip),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x18(%rbp),%xmm1
movsd  0xe4b(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geoDms2DD>:
sub    $0x28,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,(%rsp)
movaps %xmm0,0x10(%rsp)
movsbl (%rdi),%edi
call   1030 <toupper@plt>
add    $0xffffffbb,%eax
cmp    $0x12,%eax
ja     114c <geoDms2DD+0x3c>
movsd  0xec4(%rip),%xmm1
lea    0xeed(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xeb4(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
andpd  0xebe(%rip),%xmm0
movsd  (%rsp),%xmm2
mulsd  0xea1(%rip),%xmm2
addsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  0xe97(%rip),%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @geoDms2DD(double %0, double %1, double %2, i8* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i8*
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store i8* %3, i8** %8
%10 = load i8*, i8** %8
%11 = load i8, i8* %10
%12 = call i32 @toupper(i8 signext %11)
switch i32 %12, label %15 [
i32 87, label %13
i32 83, label %13
i32 69, label %14
i32 78, label %14
]
13: ; preds = %4, %4
store double -1.000000e+00, double* %9
br label %16
14: ; preds = %4, %4
store double 1.000000e+00, double* %9
br label %16
15: ; preds = %4
store double 1.000000e+00, double* %9
br label %16
16: ; preds = %15, %14, %13
%17 = load double, double* %9
%18 = load double, double* %5
%19 = call double @llvm.fabs.f64(double %18)
%20 = load double, double* %6
%21 = call double @llvm.fmuladd.f64(double %20, double 0x3F91111111111111, double %19)
%22 = load double, double* %7
%23 = call double @llvm.fmuladd.f64(double %22, double 0x3F323456789ABCDF, double %21)
%24 = fmul double %17, %23
ret double %24
}

LLVM IR (-O2):
define double @geoDms2DD(double %0, double %1, double %2, i8* nocapture %3) {
%5 = load i8, i8* %3
%6 = tail call i32 @toupper(i8 signext %5)
switch i32 %6, label %8 [
i32 87, label %9
i32 83, label %9
i32 69, label %7
i32 78, label %7
]
7: ; preds = %4, %4
br label %9
8: ; preds = %4
br label %9
9: ; preds = %4, %4, %8, %7
%10 = phi double [ 1.000000e+00, %8 ], [ 1.000000e+00, %7 ], [ -1.000000e+00, %4 ], [ -1.000000e+00, %4 ]
%11 = tail call double @llvm.fabs.f64(double %0)
%12 = tail call double @llvm.fmuladd.f64(double %1, double 0x3F91111111111111, double %11)
%13 = tail call double @llvm.fmuladd.f64(double %2, double 0x3F323456789ABCDF, double %12)
%14 = fmul double %13, %10
ret double %14
}