#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int quot;
  int rem;
};
typedef TYPE_1__ div_t;

/* Variables and functions */
TYPE_1__ div(int, int);
scalar_t__ errno;
int /*<<< orphan*/ perror(char *);
int sscanf(char const *, char *, int *, int *);
scalar_t__ strcmp(char const *, char *);
float degmin2dec(const char *degmin, const char *dir) {
  int lat1, lat2;
  int n;
  float ret = -1.0;
  div_t deg_min;
  if (0 == strcmp(dir, "N")) {
    errno = 0;
    n = sscanf(degmin, "%d.%d", &lat1, &lat2);
    if (2 != n) {
      perror("sscanf failed");
      return -1.0;
    }
    deg_min = div(lat1, 100);
    ret = deg_min.quot + (lat2 / 10000.0 + deg_min.rem) / 60;
    return ret;
  }
  if (0 == strcmp(dir, "E")) {
    errno = 0;
    n = sscanf(degmin, "%d.%d", &lat1, &lat2);
    if (2 != n) {
      perror("sscanf failed");
      return -1.0;
    }
    deg_min = div(lat1, 100);
    ret = deg_min.quot + (lat2 / 10000.0 + deg_min.rem) / 60;
    return ret;
  }
  return ret;
}


x86 assembly (clang, -O0):
<degmin2dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  0xea8(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1230 <degmin2dec+0xf0>
mov    0x2e5e(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xe86(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <sscanf@plt>
mov    %eax,-0x24(%rbp)
mov    $0x2,%eax
cmp    -0x24(%rbp),%eax
je     11d0 <degmin2dec+0x90>
lea    0xe67(%rip),%rdi
call   1060 <perror@plt>
movss  0xe3a(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    130d <degmin2dec+0x1cd>
mov    -0x1c(%rbp),%edi
mov    $0x64,%esi
call   1040 <div@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
cvtsi2sdl -0x30(%rbp),%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
movsd  0xe15(%rip),%xmm2
divsd  %xmm2,%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm2
addsd  %xmm2,%xmm1
movsd  0xdf8(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    130d <degmin2dec+0x1cd>
mov    -0x18(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1303 <degmin2dec+0x1c3>
mov    0x2d8b(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xdb3(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <sscanf@plt>
mov    %eax,-0x24(%rbp)
mov    $0x2,%eax
cmp    -0x24(%rbp),%eax
je     12a3 <degmin2dec+0x163>
lea    0xd94(%rip),%rdi
call   1060 <perror@plt>
movss  0xd67(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    130d <degmin2dec+0x1cd>
mov    -0x1c(%rbp),%edi
mov    $0x64,%esi
call   1040 <div@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x30(%rbp)
cvtsi2sdl -0x30(%rbp),%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
movsd  0xd42(%rip),%xmm2
divsd  %xmm2,%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm2
addsd  %xmm2,%xmm1
movsd  0xd25(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    130d <degmin2dec+0x1cd>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<degmin2dec>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xec7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     117a <degmin2dec+0x3a>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
movss  0xe8b(%rip),%xmm0
test   %rax,%rax
jne    11e5 <degmin2dec+0xa5>
mov    0x2e5f(%rip),%rax
movq   $0x0,(%rax)
lea    0xe8b(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %r14,%rdi
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    11ed <degmin2dec+0xad>
mov    0x4(%rsp),%edi
mov    $0x64,%esi
call   1040 <div@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
shr    $0x20,%rax
cvtsi2sdl (%rsp),%xmm1
divsd  0xe3e(%rip),%xmm1
cvtsi2sd %eax,%xmm2
addsd  %xmm1,%xmm2
divsd  0xe36(%rip),%xmm2
addsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe2c(%rip),%rdi
call   1060 <perror@plt>
movss  0xdff(%rip),%xmm0
jmp    11e5 <degmin2dec+0xa5>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@.str = [2 x i8] c"N\00"
@errno = global i64 0
@.str.1 = [6 x i8] c"%d.%d\00"
@.str.2 = [14 x i8] c"sscanf failed\00"
@.str.3 = [2 x i8] c"E\00"
define float @degmin2dec(i8* %0, i8* %1) {
%3 = alloca float
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca %struct.TYPE_3__
%11 = alloca %struct.TYPE_3__
%12 = alloca %struct.TYPE_3__
store i8* %0, i8** %4
store i8* %1, i8** %5
store float -1.000000e+00, float* %9
%13 = load i8*, i8** %5
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 0, %14
br i1 %15, label %16, label %43
16: ; preds = %2
store i64 0, i64* @errno
%17 = load i8*, i8** %4
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = icmp ne i32 2, %19
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store float -1.000000e+00, float* %3
br label %76
23: ; preds = %16
%24 = load i32, i32* %6
%25 = call i64 @div(i32 %24, i32 100)
%26 = bitcast %struct.TYPE_3__* %11 to i64*
store i64 %25, i64* %26
%27 = bitcast %struct.TYPE_3__* %10 to i8*
%28 = bitcast %struct.TYPE_3__* %11 to i8*
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
%30 = load i32, i32* %29
%31 = sitofp i32 %30 to double
%32 = load i32, i32* %7
%33 = sitofp i32 %32 to double
%34 = fdiv double %33, 1.000000e+04
%35 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 1
%36 = load i32, i32* %35
%37 = sitofp i32 %36 to double
%38 = fadd double %34, %37
%39 = fdiv double %38, 6.000000e+01
%40 = fadd double %31, %39
%41 = fptrunc double %40 to float
store float %41, float* %9
%42 = load float, float* %9
store float %42, float* %3
br label %76
43: ; preds = %2
%44 = load i8*, i8** %5
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%46 = icmp eq i64 0, %45
br i1 %46, label %47, label %74
47: ; preds = %43
store i64 0, i64* @errno
%48 = load i8*, i8** %4
%49 = call i32 @sscanf(i8* %48, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
store i32 %49, i32* %8
%50 = load i32, i32* %8
%51 = icmp ne i32 2, %50
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store float -1.000000e+00, float* %3
br label %76
54: ; preds = %47
%55 = load i32, i32* %6
%56 = call i64 @div(i32 %55, i32 100)
%57 = bitcast %struct.TYPE_3__* %12 to i64*
store i64 %56, i64* %57
%58 = bitcast %struct.TYPE_3__* %10 to i8*
%59 = bitcast %struct.TYPE_3__* %12 to i8*
%60 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
%61 = load i32, i32* %60
%62 = sitofp i32 %61 to double
%63 = load i32, i32* %7
%64 = sitofp i32 %63 to double
%65 = fdiv double %64, 1.000000e+04
%66 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 1
%67 = load i32, i32* %66
%68 = sitofp i32 %67 to double
%69 = fadd double %65, %68
%70 = fdiv double %69, 6.000000e+01
%71 = fadd double %62, %70
%72 = fptrunc double %71 to float
store float %72, float* %9
%73 = load float, float* %9
store float %73, float* %3
br label %76
74: ; preds = %43
%75 = load float, float* %9
store float %75, float* %3
br label %76
76: ; preds = %74, %54, %52, %23, %21
%77 = load float, float* %3
ret float %77
}

LLVM IR (-O2):
@.str = [2 x i8] c"N\00"
@errno = global i64 0
@.str.1 = [6 x i8] c"%d.%d\00"
@.str.2 = [14 x i8] c"sscanf failed\00"
@.str.3 = [2 x i8] c"E\00"
define float @degmin2dec(i8* nocapture %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %29
9: ; preds = %2
store i64 0, i64* @errno
%10 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%11 = icmp eq i32 %10, 2
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %52
14: ; preds = %9
%15 = load i32, i32* %3
%16 = call i64 @div(i32 %15, i32 100)
%17 = trunc i64 %16 to i32
%18 = lshr i64 %16, 32
%19 = trunc i64 %18 to i32
%20 = sitofp i32 %17 to double
%21 = load i32, i32* %4
%22 = sitofp i32 %21 to double
%23 = fdiv double %22, 1.000000e+04
%24 = sitofp i32 %19 to double
%25 = fadd double %23, %24
%26 = fdiv double %25, 6.000000e+01
%27 = fadd double %26, %20
%28 = fptrunc double %27 to float
br label %52
29: ; preds = %2
%30 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %52
32: ; preds = %29
store i64 0, i64* @errno
%33 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%34 = icmp eq i32 %33, 2
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %52
37: ; preds = %32
%38 = load i32, i32* %3
%39 = call i64 @div(i32 %38, i32 100)
%40 = trunc i64 %39 to i32
%41 = lshr i64 %39, 32
%42 = trunc i64 %41 to i32
%43 = sitofp i32 %40 to double
%44 = load i32, i32* %4
%45 = sitofp i32 %44 to double
%46 = fdiv double %45, 1.000000e+04
%47 = sitofp i32 %42 to double
%48 = fadd double %46, %47
%49 = fdiv double %48, 6.000000e+01
%50 = fadd double %49, %43
%51 = fptrunc double %50 to float
br label %52
52: ; preds = %29, %37, %35, %14, %12
%53 = phi float [ -1.000000e+00, %12 ], [ %28, %14 ], [ -1.000000e+00, %35 ], [ %51, %37 ], [ -1.000000e+00, %29 ]
ret float %53
}