#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 atof(char const *);
long atol(char const *);
int strlen(char const *);
double extract_ra_dec(const char *str, const bool is_ra) {
  double rval;
  bool is_negative = false;
  if (*str == '-') {
    is_negative = true;
    str++;
  } else if (*str == '+')
    str++;
  if (strlen(str) > 5 && str[6] == '.') {
    const long seconds = atol(str);
    rval = (double)(seconds / 10000L) +
           (double)((seconds / 100L) % 100L) / 60. + atof(str + 4) / 3600.;
    if (is_ra)
      rval *= 15.;
  } else
    rval = atof(str);
  if (is_negative)
    rval = -rval;
  return (rval);
}


x86 assembly (clang, -O0):
<extract_ra_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    116e <extract_ra_dec+0x3e>
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    118f <extract_ra_dec+0x5f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    118a <extract_ra_dec+0x5a>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    118f <extract_ra_dec+0x5f>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x5,%eax
jle    1250 <extract_ra_dec+0x120>
mov    -0x8(%rbp),%rax
movsbl 0x6(%rax),%eax
cmp    $0x2e,%eax
jne    1250 <extract_ra_dec+0x120>
mov    -0x8(%rbp),%rdi
call   1050 <atol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
cvtsi2sd %rax,%xmm0
mov    -0x28(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    $0x64,%ecx
cqto
idiv   %rcx
cvtsi2sd %rdx,%xmm1
movsd  0xe11(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1030 <atof@plt>
movsd  -0x30(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
movsd  0xdde(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     124b <extract_ra_dec+0x11b>
movsd  0xdcf(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1262 <extract_ra_dec+0x132>
mov    -0x8(%rbp),%rdi
call   1030 <atof@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     128d <extract_ra_dec+0x15d>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_ra_dec>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    (%rdi),%al
mov    $0x1,%bpl
cmp    $0x2b,%al
je     1153 <extract_ra_dec+0x23>
cmp    $0x2d,%al
jne    1157 <extract_ra_dec+0x27>
add    $0x1,%rbx
xor    %ebp,%ebp
jmp    1157 <extract_ra_dec+0x27>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x6,%eax
jl     1232 <extract_ra_dec+0x102>
cmpb   $0x2e,0x6(%rbx)
jne    1232 <extract_ra_dec+0x102>
mov    %rbx,%rdi
call   1050 <atol@plt>
mov    %rax,%rcx
movabs $0x346dc5d63886594b,%rdx
c5 6d 34
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xb,%rdx
add    %rax,%rdx
cvtsi2sd %rdx,%xmm0
movsd  %xmm0,0x8(%rsp)
movabs $0xa3d70a3d70a3d70b,%rdi
0a d7 a3
mov    %rcx,%rax
imul   %rdi
mov    %rdx,%rsi
add    %rcx,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x6,%rsi
add    %rax,%rsi
mov    %rsi,%rax
imul   %rdi
add    %rsi,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x6,%rdx
add    %rax,%rdx
imul   $0x64,%rdx,%rax
sub    %rax,%rsi
xorps  %xmm0,%xmm0
cvtsi2sd %rsi,%xmm0
movapd %xmm0,0x10(%rsp)
add    $0x4,%rbx
mov    %rbx,%rdi
call   1030 <atof@plt>
cvtsi2sd %eax,%xmm1
unpcklpd 0x10(%rsp),%xmm1
divpd  0xdef(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
test   %r14d,%r14d
je     123e <extract_ra_dec+0x10e>
mulsd  0xdf0(%rip),%xmm0
jmp    123e <extract_ra_dec+0x10e>
mov    %rbx,%rdi
call   1030 <atof@plt>
cvtsi2sd %eax,%xmm0
test   %bpl,%bpl
jne    124b <extract_ra_dec+0x11b>
xorpd  0xdc5(%rip),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @extract_ra_dec(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca i64
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %6
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 45
br i1 %11, label %12, label %15
12: ; preds = %2
store i32 1, i32* %6
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %3
br label %24
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 43
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
br label %23
23: ; preds = %20, %15
br label %24
24: ; preds = %23, %12
%25 = load i8*, i8** %3
%26 = call i32 @strlen(i8* %25)
%27 = icmp sgt i32 %26, 5
br i1 %27, label %28, label %58
28: ; preds = %24
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 6
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 46
br i1 %33, label %34, label %58
34: ; preds = %28
%35 = load i8*, i8** %3
%36 = call i64 @atol(i8* %35)
store i64 %36, i64* %7
%37 = load i64, i64* %7
%38 = sdiv i64 %37, 10000
%39 = sitofp i64 %38 to double
%40 = load i64, i64* %7
%41 = sdiv i64 %40, 100
%42 = srem i64 %41, 100
%43 = sitofp i64 %42 to double
%44 = fdiv double %43, 6.000000e+01
%45 = fadd double %39, %44
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i64 4
%48 = call i32 @atof(i8* %47)
%49 = sitofp i32 %48 to double
%50 = fdiv double %49, 3.600000e+03
%51 = fadd double %45, %50
store double %51, double* %5
%52 = load i32, i32* %4
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %34
%55 = load double, double* %5
%56 = fmul double %55, 1.500000e+01
store double %56, double* %5
br label %57
57: ; preds = %54, %34
br label %62
58: ; preds = %28, %24
%59 = load i8*, i8** %3
%60 = call i32 @atof(i8* %59)
%61 = sitofp i32 %60 to double
store double %61, double* %5
br label %62
62: ; preds = %58, %57
%63 = load i32, i32* %6
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load double, double* %5
%67 = fneg double %66
store double %67, double* %5
br label %68
68: ; preds = %65, %62
%69 = load double, double* %5
ret double %69
}

LLVM IR (-O2):
define double @extract_ra_dec(i8* %0, i32 %1) {
%3 = load i8, i8* %0
switch i8 %3, label %8 [
i8 45, label %4
i8 43, label %6
]
4: ; preds = %2
%5 = getelementptr inbounds i8, i8* %0, i64 1
br label %8
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %0, i64 1
br label %8
8: ; preds = %2, %6, %4
%9 = phi i1 [ true, %6 ], [ false, %4 ], [ true, %2 ]
%10 = phi i8* [ %7, %6 ], [ %5, %4 ], [ %0, %2 ]
%11 = tail call i32 @strlen(i8* %10)
%12 = icmp sgt i32 %11, 5
br i1 %12, label %13, label %37
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %10, i64 6
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 46
br i1 %16, label %17, label %37
17: ; preds = %13
%18 = tail call i64 @atol(i8* %10)
%19 = sdiv i64 %18, 10000
%20 = sitofp i64 %19 to double
%21 = sdiv i64 %18, 100
%22 = srem i64 %21, 100
%23 = sitofp i64 %22 to double
%24 = getelementptr inbounds i8, i8* %10, i64 4
%25 = tail call i32 @atof(i8* %24)
%26 = sitofp i32 %25 to double
%27 = insertelement <2 x double> poison, double %26, i64 0
%28 = insertelement <2 x double> %27, double %23, i64 1
%29 = fdiv <2 x double> %28, <double 3.600000e+03, double 6.000000e+01>
%30 = extractelement <2 x double> %29, i64 1
%31 = fadd double %30, %20
%32 = extractelement <2 x double> %29, i64 0
%33 = fadd double %32, %31
%34 = icmp eq i32 %1, 0
%35 = fmul double %33, 1.500000e+01
%36 = select i1 %34, double %33, double %35
br label %40
37: ; preds = %13, %8
%38 = tail call i32 @atof(i8* %10)
%39 = sitofp i32 %38 to double
br label %40
40: ; preds = %37, %17
%41 = phi double [ %36, %17 ], [ %39, %37 ]
%42 = fneg double %41
%43 = select i1 %9, double %41, double %42
ret double %43
}