#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 extract_date_from_mpc_report(char const *, int /*<<< orphan*/ *);
int strlen(char const *);
int td_minus_utc(double);
double get_sat_obs_jd(const char *buff) {
  double jd = 0.;
  if (strlen(buff) > 80 && (buff[14] == 'S' || buff[14] == 's'))
    jd = extract_date_from_mpc_report(buff, NULL);
  if (jd < 2450000.)
    jd = 0.;
  else
    jd += td_minus_utc(jd) / ((60 * 60) * 24);
  return (jd);
}


x86 assembly (clang, -O0):
<get_sat_obs_jd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x50,%eax
jle    118a <get_sat_obs_jd+0x5a>
mov    -0x8(%rbp),%rax
movsbl 0xe(%rax),%eax
cmp    $0x53,%eax
je     1178 <get_sat_obs_jd+0x48>
mov    -0x8(%rbp),%rax
movsbl 0xe(%rax),%eax
cmp    $0x73,%eax
jne    118a <get_sat_obs_jd+0x5a>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <extract_date_from_mpc_report@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xe6e(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11aa <get_sat_obs_jd+0x7a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11ca <get_sat_obs_jd+0x9a>
movsd  -0x10(%rbp),%xmm0
call   1050 <td_minus_utc@plt>
mov    $0x15180,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sat_obs_jd>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
xorpd  %xmm0,%xmm0
cmp    $0x51,%eax
jl     11a4 <get_sat_obs_jd+0x74>
mov    0xe(%rbx),%al
or     $0x20,%al
cmp    $0x73,%al
jne    11a4 <get_sat_obs_jd+0x74>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <extract_date_from_mpc_report@plt>
movapd %xmm0,%xmm1
movsd  0xe9b(%rip),%xmm0
ucomisd %xmm1,%xmm0
xorpd  %xmm0,%xmm0
ja     11a4 <get_sat_obs_jd+0x74>
movapd %xmm1,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1050 <td_minus_utc@plt>
cltq
imul   $0xffffffffc22e4507,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x10,%eax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @get_sat_obs_jd(i8* %0) {
%2 = alloca i8*
%3 = alloca double
store i8* %0, i8** %2
store double 0.000000e+00, double* %3
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = icmp sgt i32 %5, 80
br i1 %6, label %7, label %22
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 14
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 83
br i1 %12, label %19, label %13
13: ; preds = %7
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 115
br i1 %18, label %19, label %22
19: ; preds = %13, %7
%20 = load i8*, i8** %2
%21 = call double @extract_date_from_mpc_report(i8* %20, i32* null)
store double %21, double* %3
br label %22
22: ; preds = %19, %13, %1
%23 = load double, double* %3
%24 = fcmp olt double %23, 2.450000e+06
br i1 %24, label %25, label %26
25: ; preds = %22
store double 0.000000e+00, double* %3
br label %33
26: ; preds = %22
%27 = load double, double* %3
%28 = call i32 @td_minus_utc(double %27)
%29 = sdiv i32 %28, 86400
%30 = sitofp i32 %29 to double
%31 = load double, double* %3
%32 = fadd double %31, %30
store double %32, double* %3
br label %33
33: ; preds = %26, %25
%34 = load double, double* %3
ret double %34
}

LLVM IR (-O2):
define double @get_sat_obs_jd(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 80
br i1 %3, label %4, label %15
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 14
%6 = load i8, i8* %5
switch i8 %6, label %15 [
i8 83, label %7
i8 115, label %7
]
7: ; preds = %4, %4
%8 = tail call double @extract_date_from_mpc_report(i8* %0, i32* null)
%9 = fcmp olt double %8, 2.450000e+06
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = tail call i32 @td_minus_utc(double %8)
%12 = sdiv i32 %11, 86400
%13 = sitofp i32 %12 to double
%14 = fadd double %8, %13
br label %15
15: ; preds = %4, %1, %7, %10
%16 = phi double [ %14, %10 ], [ 0.000000e+00, %7 ], [ 0.000000e+00, %1 ], [ 0.000000e+00, %4 ]
ret double %16
}