#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 */
struct ccd_frame {
  int dummy;
};

/* Variables and functions */
scalar_t__ dms_to_degrees(char *, double *);
int fits_get_string(struct ccd_frame *, char *, char *, int);
int fits_get_dms(struct ccd_frame *fr, char *kwd, double *v) {
  char dms[80];
  int ret;
  ret = fits_get_string(fr, kwd, dms, 80 - 1);
  if (ret <= 0)
    return ret;
  if (dms_to_degrees(dms, v)) {
    return -1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<fits_get_dms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x70(%rbp),%rdx
mov    $0x4f,%ecx
call   1040 <fits_get_string@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jg     1165 <fits_get_dms+0x45>
mov    -0x74(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118f <fits_get_dms+0x6f>
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <dms_to_degrees@plt>
cmp    $0x0,%rax
je     1188 <fits_get_dms+0x68>
movl   $0xffffffff,-0x4(%rbp)
jmp    118f <fits_get_dms+0x6f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fits_get_dms>:
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%rbx
mov    %rsp,%rdx
mov    $0x4f,%ecx
call   1040 <fits_get_string@plt>
test   %eax,%eax
jle    114c <fits_get_dms+0x2c>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <dms_to_degrees@plt>
neg    %rax
sbb    %eax,%eax
or     $0x1,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.ccd_frame = type { i32 }
define i32 @fits_get_dms(%struct.ccd_frame* %0, i8* %1, double* %2) {
%4 = alloca i32
%5 = alloca %struct.ccd_frame*
%6 = alloca i8*
%7 = alloca double*
%8 = alloca [80 x i8]
%9 = alloca i32
store %struct.ccd_frame* %0, %struct.ccd_frame** %5
store i8* %1, i8** %6
store double* %2, double** %7
%10 = load %struct.ccd_frame*, %struct.ccd_frame** %5
%11 = load i8*, i8** %6
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%13 = call i32 @fits_get_string(%struct.ccd_frame* %10, i8* %11, i8* %12, i32 79)
store i32 %13, i32* %9
%14 = load i32, i32* %9
%15 = icmp sle i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load i32, i32* %9
store i32 %17, i32* %4
br label %25
18: ; preds = %3
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%20 = load double*, double** %7
%21 = call i64 @dms_to_degrees(i8* %19, double* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 -1, i32* %4
br label %25
24: ; preds = %18
store i32 1, i32* %4
br label %25
25: ; preds = %24, %23, %16
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
%struct.ccd_frame = type { i32 }
define i32 @fits_get_dms(%struct.ccd_frame* %0, i8* %1, double* %2) {
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%6 = call i32 @fits_get_string(%struct.ccd_frame* %0, i8* %1, i8* %5, i32 79)
%7 = icmp slt i32 %6, 1
br i1 %7, label %12, label %8
8: ; preds = %3
%9 = call i64 @dms_to_degrees(i8* %5, double* %2)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i32 1, i32 -1
br label %12
12: ; preds = %8, %3
%13 = phi i32 [ %6, %3 ], [ %11, %8 ]
ret i32 %13
}