#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 fabs(double);
double unpacked_deg(double angle) {
  double fac;
  double deg;
  double min;
  double sec;
  double tmp;
  int i;
  if (angle < 0.0)
    fac = -1;
  else
    fac = 1;
  sec = fabs(angle);
  tmp = 1000000.0;
  i = (int)sec / tmp;
  if (i > 360) {
    return (-1);
  } else {
    deg = i;
  }
  sec = sec - deg * tmp;
  tmp = 1000;
  i = (int)sec / tmp;
  if (i > 60) {
    return (-1);
  } else {
    min = i;
  }
  sec = sec - min * tmp;
  if (sec > 60) {
    return (-1);
  } else {
    sec = fac * (deg * 3600.0 + min * 60.0 + sec);
  }
  deg = sec / 3600.0;
  return (deg);
}


x86 assembly (clang, -O0):
<unpacked_deg>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1129 <unpacked_deg+0x29>
movsd  0xee9(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1136 <unpacked_deg+0x36>
movsd  0xecf(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xeee(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xebd(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
cvttsd2si -0x30(%rbp),%eax
cvtsi2sd %eax,%xmm0
divsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x168,-0x3c(%rbp)
jle    118c <unpacked_deg+0x8c>
movsd  0xe86(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c2 <unpacked_deg+0x1c2>
cvtsi2sdl -0x3c(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe47(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
cvttsd2si -0x30(%rbp),%eax
cvtsi2sd %eax,%xmm0
divsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x3c,-0x3c(%rbp)
jle    1207 <unpacked_deg+0x107>
movsd  0xe0b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c2 <unpacked_deg+0x1c2>
cvtsi2sdl -0x3c(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdcf(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    126d <unpacked_deg+0x16d>
movsd  0xda5(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c2 <unpacked_deg+0x1c2>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xda1(%rip),%xmm2
mulsd  -0x28(%rbp),%xmm2
movsd  0xd9c(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
addsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xd79(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<unpacked_deg>:
movapd 0xef8(%rip),%xmm4
andpd  %xmm0,%xmm4
cvttpd2dq %xmm4,%xmm1
cvtdq2pd %xmm1,%xmm1
divsd  0xf04(%rip),%xmm1
cvttsd2si %xmm1,%eax
movsd  0xf00(%rip),%xmm1
cmp    $0x168,%eax
jg     11ca <unpacked_deg+0xca>
cvtsi2sd %eax,%xmm3
movsd  0xef1(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  %xmm4,%xmm2
cvttpd2dq %xmm2,%xmm4
cvtdq2pd %xmm4,%xmm4
divsd  0xee1(%rip),%xmm4
cvttsd2si %xmm4,%eax
cmp    $0x3c,%eax
jg     11ca <unpacked_deg+0xca>
xorps  %xmm4,%xmm4
cvtsi2sd %eax,%xmm4
movsd  0xed1(%rip),%xmm5
mulsd  %xmm4,%xmm5
addsd  %xmm5,%xmm2
ucomisd 0xec9(%rip),%xmm2
ja     11ca <unpacked_deg+0xca>
mulsd  0xebf(%rip),%xmm4
movsd  0xebf(%rip),%xmm1
mulsd  %xmm1,%xmm3
addsd  %xmm4,%xmm3
addsd  %xmm3,%xmm2
movapd 0xe6b(%rip),%xmm3
xorpd  %xmm2,%xmm3
xorpd  %xmm4,%xmm4
cmpltsd %xmm4,%xmm0
movapd %xmm0,%xmm4
andnpd %xmm2,%xmm4
andpd  %xmm3,%xmm0
orpd   %xmm4,%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @unpacked_deg(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store double %0, double* %3
%10 = load double, double* %3
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %1
store double -1.000000e+00, double* %4
br label %14
13: ; preds = %1
store double 1.000000e+00, double* %4
br label %14
14: ; preds = %13, %12
%15 = load double, double* %3
%16 = call double @llvm.fabs.f64(double %15)
store double %16, double* %7
store double 1.000000e+06, double* %8
%17 = load double, double* %7
%18 = fptosi double %17 to i32
%19 = sitofp i32 %18 to double
%20 = load double, double* %8
%21 = fdiv double %19, %20
%22 = fptosi double %21 to i32
store i32 %22, i32* %9
%23 = load i32, i32* %9
%24 = icmp sgt i32 %23, 360
br i1 %24, label %25, label %26
25: ; preds = %14
store double -1.000000e+00, double* %2
br label %69
26: ; preds = %14
%27 = load i32, i32* %9
%28 = sitofp i32 %27 to double
store double %28, double* %5
br label %29
29: ; preds = %26
%30 = load double, double* %7
%31 = load double, double* %5
%32 = load double, double* %8
%33 = fneg double %31
%34 = call double @llvm.fmuladd.f64(double %33, double %32, double %30)
store double %34, double* %7
store double 1.000000e+03, double* %8
%35 = load double, double* %7
%36 = fptosi double %35 to i32
%37 = sitofp i32 %36 to double
%38 = load double, double* %8
%39 = fdiv double %37, %38
%40 = fptosi double %39 to i32
store i32 %40, i32* %9
%41 = load i32, i32* %9
%42 = icmp sgt i32 %41, 60
br i1 %42, label %43, label %44
43: ; preds = %29
store double -1.000000e+00, double* %2
br label %69
44: ; preds = %29
%45 = load i32, i32* %9
%46 = sitofp i32 %45 to double
store double %46, double* %6
br label %47
47: ; preds = %44
%48 = load double, double* %7
%49 = load double, double* %6
%50 = load double, double* %8
%51 = fneg double %49
%52 = call double @llvm.fmuladd.f64(double %51, double %50, double %48)
store double %52, double* %7
%53 = load double, double* %7
%54 = fcmp ogt double %53, 6.000000e+01
br i1 %54, label %55, label %56
55: ; preds = %47
store double -1.000000e+00, double* %2
br label %69
56: ; preds = %47
%57 = load double, double* %4
%58 = load double, double* %5
%59 = load double, double* %6
%60 = fmul double %59, 6.000000e+01
%61 = call double @llvm.fmuladd.f64(double %58, double 3.600000e+03, double %60)
%62 = load double, double* %7
%63 = fadd double %61, %62
%64 = fmul double %57, %63
store double %64, double* %7
br label %65
65: ; preds = %56
%66 = load double, double* %7
%67 = fdiv double %66, 3.600000e+03
store double %67, double* %5
%68 = load double, double* %5
store double %68, double* %2
br label %69
69: ; preds = %65, %55, %43, %25
%70 = load double, double* %2
ret double %70
}

LLVM IR (-O2):
define double @unpacked_deg(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = fptosi double %3 to i32
%5 = sitofp i32 %4 to double
%6 = fdiv double %5, 1.000000e+06
%7 = fptosi double %6 to i32
%8 = icmp sgt i32 %7, 360
br i1 %8, label %30, label %9
9: ; preds = %1
%10 = sitofp i32 %7 to double
%11 = fneg double %10
%12 = tail call double @llvm.fmuladd.f64(double %11, double 1.000000e+06, double %3)
%13 = fptosi double %12 to i32
%14 = sitofp i32 %13 to double
%15 = fdiv double %14, 1.000000e+03
%16 = fptosi double %15 to i32
%17 = icmp sgt i32 %16, 60
br i1 %17, label %30, label %18
18: ; preds = %9
%19 = sitofp i32 %16 to double
%20 = fneg double %19
%21 = tail call double @llvm.fmuladd.f64(double %20, double 1.000000e+03, double %12)
%22 = fcmp ogt double %21, 6.000000e+01
br i1 %22, label %30, label %23
23: ; preds = %18
%24 = fmul double %19, 6.000000e+01
%25 = tail call double @llvm.fmuladd.f64(double %10, double 3.600000e+03, double %24)
%26 = fadd double %21, %25
%27 = fneg double %26
%28 = select i1 %2, double %27, double %26
%29 = fdiv double %28, 3.600000e+03
br label %30
30: ; preds = %18, %9, %1, %23
%31 = phi double [ %29, %23 ], [ -1.000000e+00, %1 ], [ -1.000000e+00, %9 ], [ -1.000000e+00, %18 ]
ret double %31
}