#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);
scalar_t__ floor(double);
double roundValue(double, int);
int degreeToHMS(double deg, int prec, int *neg, int *h, int *m, double *s) {
  double hr, min;
  if (deg < -360.0 || deg > 360.0)
    return (-1);
  if (deg < 0) {
    *neg = 1;
    deg = fabs(deg);
  } else
    *neg = 0;
  hr = deg / 15.;
  *h = (int)floor(hr);
  min = (hr - (double)(*h)) * 60.0;
  *m = (int)floor(min);
  *s = (min - (double)(*m)) * 60.0;
  *s = roundValue(*s, prec);
  if (*s >= 60.) {
    *s -= 60.;
    *m += 1;
  }
  if (*m >= 60) {
    *m -= 60;
    *h += 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<degreeToHMS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
movsd  0xeb8(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     116a <degreeToHMS+0x4a>
movsd  -0x10(%rbp),%xmm0
movsd  0xea8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1176 <degreeToHMS+0x56>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b2 <degreeToHMS+0x192>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11a8 <degreeToHMS+0x88>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
movsd  -0x10(%rbp),%xmm0
movaps 0xe86(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11b2 <degreeToHMS+0x92>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  0xe59(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe1d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
subsd  %xmm1,%xmm0
movsd  0xde9(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x14(%rbp),%edi
call   1030 <roundValue@plt>
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xdb5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1288 <degreeToHMS+0x168>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xd9b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
cmpl   $0x3c,(%rax)
jl     12ab <degreeToHMS+0x18b>
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
sub    $0x3c,%ecx
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<degreeToHMS>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  0xece(%rip),%xmm1
ucomisd %xmm0,%xmm1
mov    $0xffffffff,%eax
ja     1214 <degreeToHMS+0xf4>
ucomisd 0xebf(%rip),%xmm0
ja     1214 <degreeToHMS+0xf4>
mov    %r8,%rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %edi,%ebp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1174 <degreeToHMS+0x54>
movl   $0x1,(%rsi)
andpd  0xebe(%rip),%xmm0
jmp    117a <degreeToHMS+0x5a>
movl   $0x0,(%rsi)
divsd  0xe8e(%rip),%xmm0
movapd %xmm0,(%rsp)
call   1040 <floor@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mov    %eax,(%r14)
movapd (%rsp),%xmm0
subsd  %xmm1,%xmm0
mulsd  0xe71(%rip),%xmm0
movapd %xmm0,(%rsp)
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %eax,(%r15)
movapd (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe4c(%rip),%xmm1
movsd  %xmm1,(%rbx)
movapd %xmm1,%xmm0
mov    %ebp,%edi
call   1030 <roundValue@plt>
movsd  %xmm0,(%rbx)
ucomisd 0xe31(%rip),%xmm0
jae    11ee <degreeToHMS+0xce>
mov    (%r15),%ecx
jmp    1203 <degreeToHMS+0xe3>
addsd  0xe2a(%rip),%xmm0
movsd  %xmm0,(%rbx)
mov    (%r15),%ecx
add    $0x1,%ecx
mov    %ecx,(%r15)
xor    %eax,%eax
cmp    $0x3c,%ecx
jl     1214 <degreeToHMS+0xf4>
add    $0xffffffc4,%ecx
mov    %ecx,(%r15)
addl   $0x1,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @degreeToHMS(double %0, i32 %1, i32* %2, i32* %3, i32* %4, double* %5) {
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca double*
%14 = alloca double
%15 = alloca double
store double %0, double* %8
store i32 %1, i32* %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store double* %5, double** %13
%16 = load double, double* %8
%17 = fcmp olt double %16, -3.600000e+02
br i1 %17, label %21, label %18
18: ; preds = %6
%19 = load double, double* %8
%20 = fcmp ogt double %19, 3.600000e+02
br i1 %20, label %21, label %22
21: ; preds = %18, %6
store i32 -1, i32* %7
br label %82
22: ; preds = %18
%23 = load double, double* %8
%24 = fcmp olt double %23, 0.000000e+00
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32*, i32** %10
store i32 1, i32* %26
%27 = load double, double* %8
%28 = call double @llvm.fabs.f64(double %27)
store double %28, double* %8
br label %31
29: ; preds = %22
%30 = load i32*, i32** %10
store i32 0, i32* %30
br label %31
31: ; preds = %29, %25
%32 = load double, double* %8
%33 = fdiv double %32, 1.500000e+01
store double %33, double* %14
%34 = load double, double* %14
%35 = call i64 @floor(double %34)
%36 = trunc i64 %35 to i32
%37 = load i32*, i32** %11
store i32 %36, i32* %37
%38 = load double, double* %14
%39 = load i32*, i32** %11
%40 = load i32, i32* %39
%41 = sitofp i32 %40 to double
%42 = fsub double %38, %41
%43 = fmul double %42, 6.000000e+01
store double %43, double* %15
%44 = load double, double* %15
%45 = call i64 @floor(double %44)
%46 = trunc i64 %45 to i32
%47 = load i32*, i32** %12
store i32 %46, i32* %47
%48 = load double, double* %15
%49 = load i32*, i32** %12
%50 = load i32, i32* %49
%51 = sitofp i32 %50 to double
%52 = fsub double %48, %51
%53 = fmul double %52, 6.000000e+01
%54 = load double*, double** %13
store double %53, double* %54
%55 = load double*, double** %13
%56 = load double, double* %55
%57 = load i32, i32* %9
%58 = call double @roundValue(double %56, i32 %57)
%59 = load double*, double** %13
store double %58, double* %59
%60 = load double*, double** %13
%61 = load double, double* %60
%62 = fcmp oge double %61, 6.000000e+01
br i1 %62, label %63, label %70
63: ; preds = %31
%64 = load double*, double** %13
%65 = load double, double* %64
%66 = fsub double %65, 6.000000e+01
store double %66, double* %64
%67 = load i32*, i32** %12
%68 = load i32, i32* %67
%69 = add nsw i32 %68, 1
store i32 %69, i32* %67
br label %70
70: ; preds = %63, %31
%71 = load i32*, i32** %12
%72 = load i32, i32* %71
%73 = icmp sge i32 %72, 60
br i1 %73, label %74, label %81
74: ; preds = %70
%75 = load i32*, i32** %12
%76 = load i32, i32* %75
%77 = sub nsw i32 %76, 60
store i32 %77, i32* %75
%78 = load i32*, i32** %11
%79 = load i32, i32* %78
%80 = add nsw i32 %79, 1
store i32 %80, i32* %78
br label %81
81: ; preds = %74, %70
store i32 0, i32* %7
br label %82
82: ; preds = %81, %21
%83 = load i32, i32* %7
ret i32 %83
}

LLVM IR (-O2):
define i32 @degreeToHMS(double %0, i32 %1, i32* nocapture writeonly %2, i32* nocapture %3, i32* nocapture %4, double* nocapture writeonly %5) {
%7 = fcmp olt double %0, -3.600000e+02
%8 = fcmp ogt double %0, 3.600000e+02
%9 = or i1 %7, %8
br i1 %9, label %43, label %10
10: ; preds = %6
%11 = fcmp olt double %0, 0.000000e+00
br i1 %11, label %12, label %14
12: ; preds = %10
store i32 1, i32* %2
%13 = tail call double @llvm.fabs.f64(double %0)
br label %15
14: ; preds = %10
store i32 0, i32* %2
br label %15
15: ; preds = %14, %12
%16 = phi double [ %13, %12 ], [ %0, %14 ]
%17 = fdiv double %16, 1.500000e+01
%18 = tail call i64 @floor(double %17)
%19 = trunc i64 %18 to i32
store i32 %19, i32* %3
%20 = sitofp i32 %19 to double
%21 = fsub double %17, %20
%22 = fmul double %21, 6.000000e+01
%23 = tail call i64 @floor(double %22)
%24 = trunc i64 %23 to i32
store i32 %24, i32* %4
%25 = sitofp i32 %24 to double
%26 = fsub double %22, %25
%27 = fmul double %26, 6.000000e+01
store double %27, double* %5
%28 = tail call double @roundValue(double %27, i32 %1)
store double %28, double* %5
%29 = fcmp ult double %28, 6.000000e+01
br i1 %29, label %34, label %30
30: ; preds = %15
%31 = fadd double %28, -6.000000e+01
store double %31, double* %5
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %36
34: ; preds = %15
%35 = load i32, i32* %4
br label %36
36: ; preds = %34, %30
%37 = phi i32 [ %35, %34 ], [ %33, %30 ]
%38 = icmp sgt i32 %37, 59
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = add nsw i32 %37, -60
store i32 %40, i32* %4
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %43
43: ; preds = %36, %39, %6
%44 = phi i32 [ -1, %6 ], [ 0, %39 ], [ 0, %36 ]
ret i32 %44
}