#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 geoDms2Rads(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 * (3.14159265358979323846 / 180.0) *
          (fabs(deg) + (min * (1.0 / 60.0)) + (sec * (1.0 / 3600.0))));
}


x86 assembly (clang, -O0):
<geoDms2Rads>:
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 <geoDms2Rads+0x71>
mov    -0x30(%rbp),%rax
lea    0xeec(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xea3(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    118e <geoDms2Rads+0x7e>
movsd  0xe89(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    118e <geoDms2Rads+0x7e>
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe8a(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movaps 0xe89(%rip),%xmm2
pand   %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  0xe60(%rip),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x18(%rbp),%xmm1
movsd  0xe43(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geoDms2Rads>:
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 <geoDms2Rads+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 @geoDms2Rads(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 = fmul double %17, 0x3F91DF46A2529D39
%19 = load double, double* %5
%20 = call double @llvm.fabs.f64(double %19)
%21 = load double, double* %6
%22 = call double @llvm.fmuladd.f64(double %21, double 0x3F91111111111111, double %20)
%23 = load double, double* %7
%24 = call double @llvm.fmuladd.f64(double %23, double 0x3F323456789ABCDF, double %22)
%25 = fmul double %18, %24
ret double %25
}

LLVM IR (-O2):
define double @geoDms2Rads(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 [ 0x3F91DF46A2529D39, %8 ], [ 0x3F91DF46A2529D39, %7 ], [ 0xBF91DF46A2529D39, %4 ], [ 0xBF91DF46A2529D39, %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
}