#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 */
float parse_deg_str(char const *);
float parse_sexigesimal_str(char const *);
int /*<<< orphan*/ *strchr(char const *, char);
scalar_t__ strlen(char const *);
float coord_any_to_float_deg(const char *str) {
  if (strlen(str) == 0) {
    return 0;
  }
  if (strchr(str, ':') != NULL) {
    return parse_sexigesimal_str(str);
  } else if (strchr(str, '.') != NULL) {
    return parse_deg_str(str);
  }
  return 0;
}


x86 assembly (clang, -O0):
<coord_any_to_float_deg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    116c <coord_any_to_float_deg+0x2c>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11cf <coord_any_to_float_deg+0x8f>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     1197 <coord_any_to_float_deg+0x57>
mov    -0x10(%rbp),%rdi
call   1060 <parse_sexigesimal_str@plt>
movss  %xmm0,-0x4(%rbp)
jmp    11cf <coord_any_to_float_deg+0x8f>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     11c2 <coord_any_to_float_deg+0x82>
mov    -0x10(%rbp),%rdi
call   1030 <parse_deg_str@plt>
movss  %xmm0,-0x4(%rbp)
jmp    11cf <coord_any_to_float_deg+0x8f>
jmp    11c7 <coord_any_to_float_deg+0x87>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<coord_any_to_float_deg>:
push   %rbx
cmpb   $0x0,(%rdi)
je     116c <coord_any_to_float_deg+0x3c>
mov    %rdi,%rbx
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1151 <coord_any_to_float_deg+0x21>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <parse_sexigesimal_str@plt>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     116c <coord_any_to_float_deg+0x3c>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <parse_deg_str@plt>
xorps  %xmm0,%xmm0
pop    %rbx
ret

LLVM IR (-O0):
define float @coord_any_to_float_deg(i8* %0) {
%2 = alloca float
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @strlen(i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store float 0.000000e+00, float* %2
br label %24
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32* @strchr(i8* %9, i8 signext 58)
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = call float @parse_sexigesimal_str(i8* %13)
store float %14, float* %2
br label %24
15: ; preds = %8
%16 = load i8*, i8** %3
%17 = call i32* @strchr(i8* %16, i8 signext 46)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = call float @parse_deg_str(i8* %20)
store float %21, float* %2
br label %24
22: ; preds = %15
br label %23
23: ; preds = %22
store float 0.000000e+00, float* %2
br label %24
24: ; preds = %23, %19, %12, %7
%25 = load float, float* %2
ret float %25
}

LLVM IR (-O2):
define float @coord_any_to_float_deg(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = tail call i32* @strchr(i8* %0, i8 signext 58)
%6 = icmp eq i32* %5, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call float @parse_sexigesimal_str(i8* %0)
br label %14
9: ; preds = %4
%10 = tail call i32* @strchr(i8* %0, i8 signext 46)
%11 = icmp eq i32* %10, null
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call float @parse_deg_str(i8* %0)
br label %14
14: ; preds = %9, %1, %12, %7
%15 = phi float [ %8, %7 ], [ %13, %12 ], [ 0.000000e+00, %1 ], [ 0.000000e+00, %9 ]
ret float %15
}