#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 */
int /*<<< orphan*/ assert(int);
double atof(char const *);
double nmeap_latitude(const char *plat, const char *phem) {
  double lat;
  int deg;
  double min;
  int ns;
  assert(plat != 0);
  assert(phem != 0);
  if (*plat == 0) {
    return 0.0;
  }
  if (*phem == 0) {
    return 0.0;
  }
  if (*phem == 'N') {
    ns = 1;
  } else {
    ns = -1;
  }
  lat = atof(plat);
  deg = (int)(lat / 100.0);
  min = lat - (deg * 100.0);
  lat = (deg + (min / 60.0)) * ns;
  return lat;
}


x86 assembly (clang, -O0):
<nmeap_latitude>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1171 <nmeap_latitude+0x51>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123f <nmeap_latitude+0x11f>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    118e <nmeap_latitude+0x6e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123f <nmeap_latitude+0x11f>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4e,%eax
jne    11aa <nmeap_latitude+0x8a>
movl   $0x1,-0x34(%rbp)
jmp    11b1 <nmeap_latitude+0x91>
movl   $0xffffffff,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe3c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe08(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xde1(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nmeap_latitude>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
xorpd  %xmm0,%xmm0
cmpb   $0x0,(%r14)
je     11aa <nmeap_latitude+0x8a>
mov    (%rbx),%al
test   %al,%al
je     11aa <nmeap_latitude+0x8a>
cmp    $0x4e,%al
jne    1164 <nmeap_latitude+0x44>
movsd  0xe9e(%rip),%xmm0
jmp    116c <nmeap_latitude+0x4c>
movsd  0xe9c(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
call   1030 <atof@plt>
movsd  0xe8f(%rip),%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
cvttpd2dq %xmm2,%xmm2
cvtdq2pd %xmm2,%xmm2
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
divsd  0xe77(%rip),%xmm0
addsd  %xmm2,%xmm0
mulsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @nmeap_latitude(i8* %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %2
store double 0.000000e+00, double* %3
br label %56
23: ; preds = %2
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store double 0.000000e+00, double* %3
br label %56
29: ; preds = %23
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 78
br i1 %33, label %34, label %35
34: ; preds = %29
store i32 1, i32* %9
br label %36
35: ; preds = %29
store i32 -1, i32* %9
br label %36
36: ; preds = %35, %34
%37 = load i8*, i8** %4
%38 = call double @atof(i8* %37)
store double %38, double* %6
%39 = load double, double* %6
%40 = fdiv double %39, 1.000000e+02
%41 = fptosi double %40 to i32
store i32 %41, i32* %7
%42 = load double, double* %6
%43 = load i32, i32* %7
%44 = sitofp i32 %43 to double
%45 = fneg double %44
%46 = call double @llvm.fmuladd.f64(double %45, double 1.000000e+02, double %42)
store double %46, double* %8
%47 = load i32, i32* %7
%48 = sitofp i32 %47 to double
%49 = load double, double* %8
%50 = fdiv double %49, 6.000000e+01
%51 = fadd double %48, %50
%52 = load i32, i32* %9
%53 = sitofp i32 %52 to double
%54 = fmul double %51, %53
store double %54, double* %6
%55 = load double, double* %6
store double %55, double* %3
br label %56
56: ; preds = %36, %28, %22
%57 = load double, double* %3
ret double %57
}

LLVM IR (-O2):
define double @nmeap_latitude(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne i8* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 0
br i1 %10, label %25, label %11
11: ; preds = %2
%12 = load i8, i8* %1
switch i8 %12, label %13 [
i8 0, label %25
i8 78, label %14
]
13: ; preds = %11
br label %14
14: ; preds = %11, %13
%15 = phi double [ -1.000000e+00, %13 ], [ 1.000000e+00, %11 ]
%16 = tail call double @atof(i8* %0)
%17 = fdiv double %16, 1.000000e+02
%18 = fptosi double %17 to i32
%19 = sitofp i32 %18 to double
%20 = fneg double %19
%21 = tail call double @llvm.fmuladd.f64(double %20, double 1.000000e+02, double %16)
%22 = fdiv double %21, 6.000000e+01
%23 = fadd double %22, %19
%24 = fmul double %15, %23
br label %25
25: ; preds = %11, %2, %14
%26 = phi double [ %24, %14 ], [ 0.000000e+00, %2 ], [ 0.000000e+00, %11 ]
ret double %26
}