#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*/ deb_printf(int /*<<< orphan*/, char *);
int dms_to_degrees(char *, double *);
int scan_ra(double *d, char *val) {
  int ret;
  double v;
  ret = dms_to_degrees(val, &v);
  if (!ret) {
    return -1;
  }
  if (v < 0) {
    deb_printf(0, "RA value is negative, ignoring sign\n");
    v = -v;
  }
  if (v > 24.0) {
    deb_printf(0, "RA value is too large, ignoring\n");
    return -1;
  }
  *d = v;
  return 0;
}


x86 assembly (clang, -O0):
<scan_ra>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <dms_to_degrees@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1156 <scan_ra+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d8 <scan_ra+0xb8>
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1193 <scan_ra+0x73>
xor    %edi,%edi
lea    0xe9b(%rip),%rsi
call   1040 <deb_printf@plt>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe60(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c4 <scan_ra+0xa4>
xor    %edi,%edi
lea    0xe7a(%rip),%rsi
call   1040 <deb_printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d8 <scan_ra+0xb8>
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_ra>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%r14
mov    %rsp,%rsi
mov    %rax,%rdi
call   1030 <dms_to_degrees@plt>
mov    $0xffffffff,%ebx
test   %eax,%eax
je     118e <scan_ra+0x6e>
movsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    116d <scan_ra+0x4d>
lea    0xec4(%rip),%rsi
xor    %edi,%edi
call   1040 <deb_printf@plt>
movsd  (%rsp),%xmm0
xorpd  0xe98(%rip),%xmm0
movlpd %xmm0,(%rsp)
ucomisd 0xe9b(%rip),%xmm0
jbe    1187 <scan_ra+0x67>
lea    0xebf(%rip),%rsi
xor    %edi,%edi
call   1040 <deb_printf@plt>
jmp    118e <scan_ra+0x6e>
movsd  %xmm0,(%r14)
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"RA value is negative, ignoring sign\0A\00"
@.str.1 = [33 x i8] c"RA value is too large, ignoring\0A\00"
define i32 @scan_ra(double* %0, i8* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca double
store double* %0, double** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @dms_to_degrees(i8* %8, double* %7)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %2
store i32 -1, i32* %3
br label %28
13: ; preds = %2
%14 = load double, double* %7
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = call i32 @deb_printf(i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%18 = load double, double* %7
%19 = fneg double %18
store double %19, double* %7
br label %20
20: ; preds = %16, %13
%21 = load double, double* %7
%22 = fcmp ogt double %21, 2.400000e+01
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @deb_printf(i32 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %28
25: ; preds = %20
%26 = load double, double* %7
%27 = load double*, double** %4
store double %26, double* %27
store i32 0, i32* %3
br label %28
28: ; preds = %25, %23, %12
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [37 x i8] c"RA value is negative, ignoring sign\0A\00"
@.str.1 = [33 x i8] c"RA value is too large, ignoring\0A\00"
define i32 @scan_ra(double* nocapture writeonly %0, i8* %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = call i32 @dms_to_degrees(i8* %1, double* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %2
%8 = load double, double* %3
%9 = fcmp olt double %8, 0.000000e+00
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = call i32 @deb_printf(i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%12 = load double, double* %3
%13 = fneg double %12
store double %13, double* %3
br label %14
14: ; preds = %10, %7
%15 = phi double [ %13, %10 ], [ %8, %7 ]
%16 = fcmp ogt double %15, 2.400000e+01
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @deb_printf(i32 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %20
19: ; preds = %14
store double %15, double* %0
br label %20
20: ; preds = %2, %19, %17
%21 = phi i32 [ -1, %17 ], [ 0, %19 ], [ -1, %2 ]
ret i32 %21
}