#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 degreeToDMS(double deg, int prec, int *neg, int *d, int *m, double *s) {
  double min;
  if (deg < -360.0 || deg > 360.0)
    return (-1);
  if (deg < 0) {
    *neg = 1;
    deg = fabs(deg);
  } else
    *neg = 0;
  *d = (int)floor(deg);
  min = (deg - (double)(*d)) * 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;
    *d += 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<degreeToDMS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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 <degreeToDMS+0x4a>
movsd  -0x10(%rbp),%xmm0
movsd  0xea8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1176 <degreeToDMS+0x56>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <degreeToDMS+0x17c>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11a8 <degreeToDMS+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 <degreeToDMS+0x92>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
movsd  -0x10(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe33(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
subsd  %xmm1,%xmm0
movsd  0xdff(%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  0xdcb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1272 <degreeToDMS+0x152>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xdb1(%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     1295 <degreeToDMS+0x175>
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    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<degreeToDMS>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  0xece(%rip),%xmm1
ucomisd %xmm0,%xmm1
mov    $0xffffffff,%eax
ja     120c <degreeToDMS+0xec>
ucomisd 0xebf(%rip),%xmm0
ja     120c <degreeToDMS+0xec>
mov    %r8,%rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %edi,%ebp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1174 <degreeToDMS+0x54>
movl   $0x1,(%rsi)
andpd  0xeae(%rip),%xmm0
jmp    117a <degreeToDMS+0x5a>
movl   $0x0,(%rsi)
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    11e6 <degreeToDMS+0xc6>
mov    (%r15),%ecx
jmp    11fb <degreeToDMS+0xdb>
addsd  0xe2a(%rip),%xmm0
movsd  %xmm0,(%rbx)
mov    (%r15),%ecx
add    $0x1,%ecx
mov    %ecx,(%r15)
xor    %eax,%eax
cmp    $0x3c,%ecx
jl     120c <degreeToDMS+0xec>
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 @degreeToDMS(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
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
%15 = load double, double* %8
%16 = fcmp olt double %15, -3.600000e+02
br i1 %16, label %20, label %17
17: ; preds = %6
%18 = load double, double* %8
%19 = fcmp ogt double %18, 3.600000e+02
br i1 %19, label %20, label %21
20: ; preds = %17, %6
store i32 -1, i32* %7
br label %79
21: ; preds = %17
%22 = load double, double* %8
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i32*, i32** %10
store i32 1, i32* %25
%26 = load double, double* %8
%27 = call double @llvm.fabs.f64(double %26)
store double %27, double* %8
br label %30
28: ; preds = %21
%29 = load i32*, i32** %10
store i32 0, i32* %29
br label %30
30: ; preds = %28, %24
%31 = load double, double* %8
%32 = call i64 @floor(double %31)
%33 = trunc i64 %32 to i32
%34 = load i32*, i32** %11
store i32 %33, i32* %34
%35 = load double, double* %8
%36 = load i32*, i32** %11
%37 = load i32, i32* %36
%38 = sitofp i32 %37 to double
%39 = fsub double %35, %38
%40 = fmul double %39, 6.000000e+01
store double %40, double* %14
%41 = load double, double* %14
%42 = call i64 @floor(double %41)
%43 = trunc i64 %42 to i32
%44 = load i32*, i32** %12
store i32 %43, i32* %44
%45 = load double, double* %14
%46 = load i32*, i32** %12
%47 = load i32, i32* %46
%48 = sitofp i32 %47 to double
%49 = fsub double %45, %48
%50 = fmul double %49, 6.000000e+01
%51 = load double*, double** %13
store double %50, double* %51
%52 = load double*, double** %13
%53 = load double, double* %52
%54 = load i32, i32* %9
%55 = call double @roundValue(double %53, i32 %54)
%56 = load double*, double** %13
store double %55, double* %56
%57 = load double*, double** %13
%58 = load double, double* %57
%59 = fcmp oge double %58, 6.000000e+01
br i1 %59, label %60, label %67
60: ; preds = %30
%61 = load double*, double** %13
%62 = load double, double* %61
%63 = fsub double %62, 6.000000e+01
store double %63, double* %61
%64 = load i32*, i32** %12
%65 = load i32, i32* %64
%66 = add nsw i32 %65, 1
store i32 %66, i32* %64
br label %67
67: ; preds = %60, %30
%68 = load i32*, i32** %12
%69 = load i32, i32* %68
%70 = icmp sge i32 %69, 60
br i1 %70, label %71, label %78
71: ; preds = %67
%72 = load i32*, i32** %12
%73 = load i32, i32* %72
%74 = sub nsw i32 %73, 60
store i32 %74, i32* %72
%75 = load i32*, i32** %11
%76 = load i32, i32* %75
%77 = add nsw i32 %76, 1
store i32 %77, i32* %75
br label %78
78: ; preds = %71, %67
store i32 0, i32* %7
br label %79
79: ; preds = %78, %20
%80 = load i32, i32* %7
ret i32 %80
}

LLVM IR (-O2):
define i32 @degreeToDMS(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 %42, 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 = tail call i64 @floor(double %16)
%18 = trunc i64 %17 to i32
store i32 %18, i32* %3
%19 = sitofp i32 %18 to double
%20 = fsub double %16, %19
%21 = fmul double %20, 6.000000e+01
%22 = tail call i64 @floor(double %21)
%23 = trunc i64 %22 to i32
store i32 %23, i32* %4
%24 = sitofp i32 %23 to double
%25 = fsub double %21, %24
%26 = fmul double %25, 6.000000e+01
store double %26, double* %5
%27 = tail call double @roundValue(double %26, i32 %1)
store double %27, double* %5
%28 = fcmp ult double %27, 6.000000e+01
br i1 %28, label %33, label %29
29: ; preds = %15
%30 = fadd double %27, -6.000000e+01
store double %30, double* %5
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %35
33: ; preds = %15
%34 = load i32, i32* %4
br label %35
35: ; preds = %33, %29
%36 = phi i32 [ %34, %33 ], [ %32, %29 ]
%37 = icmp sgt i32 %36, 59
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = add nsw i32 %36, -60
store i32 %39, i32* %4
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %42
42: ; preds = %35, %38, %6
%43 = phi i32 [ -1, %6 ], [ 0, %38 ], [ 0, %35 ]
ret i32 %43
}