#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*/ sprintf(char *, char *, char, int, int, double);
char *convert_deg_to_str(double deg) {
  int d, m;
  double s;
  int sign;
  static char buf[13];
  sign = 1;
  if (deg < 0.)
    sign = -1;
  deg *= sign;
  d = (int)deg;
  m = (int)((deg - d) * 60);
  s = (deg - d) * 3600. - m * 60;
  sprintf(buf, "'%c%02d:%02d:%06.3f'", (sign < 0) ? '-' : ' ', d, m, s);
  return (buf);
}


x86 assembly (clang, -O0):
<convert_deg_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movl   $0x1,-0x1c(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1139 <convert_deg_to_str+0x29>
movl   $0xffffffff,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xea2(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
subsd  %xmm1,%xmm0
imul   $0x3c,-0x10(%rbp),%eax
cvtsi2sd %eax,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe5a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%edx
mov    $0x20,%eax
mov    $0x2d,%ecx
cmp    $0x0,%edx
cmovl  %ecx,%eax
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
movsd  -0x18(%rbp),%xmm0
lea    0x2e50(%rip),%rdi
lea    0xe30(%rip),%rsi
movsbl %al,%edx
call   1030 <sprintf@plt>
lea    0x2e3a(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_deg_to_str>:
push   %rbx
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1123 <convert_deg_to_str+0x13>
xorpd  0xedd(%rip),%xmm0
cvttsd2si %xmm0,%ecx
cvttpd2dq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  0xed5(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%r8d
mov    $0x2d,%eax
mov    $0x20,%edx
cmova  %eax,%edx
imul   $0x3c,%r8d,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xeb4(%rip),%xmm0
subsd  %xmm1,%xmm0
lea    0x2eba(%rip),%rbx
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@convert_deg_to_str.buf = internal global [13 x i8] zeroinitializer
@.str = [21 x i8] c"'%c%02d:%02d:%06.3f'\00"
define i8* @convert_deg_to_str(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
store double %0, double* %2
store i32 1, i32* %6
%7 = load double, double* %2
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %6
br label %10
10: ; preds = %9, %1
%11 = load i32, i32* %6
%12 = sitofp i32 %11 to double
%13 = load double, double* %2
%14 = fmul double %13, %12
store double %14, double* %2
%15 = load double, double* %2
%16 = fptosi double %15 to i32
store i32 %16, i32* %3
%17 = load double, double* %2
%18 = load i32, i32* %3
%19 = sitofp i32 %18 to double
%20 = fsub double %17, %19
%21 = fmul double %20, 6.000000e+01
%22 = fptosi double %21 to i32
store i32 %22, i32* %4
%23 = load double, double* %2
%24 = load i32, i32* %3
%25 = sitofp i32 %24 to double
%26 = fsub double %23, %25
%27 = load i32, i32* %4
%28 = mul nsw i32 %27, 60
%29 = sitofp i32 %28 to double
%30 = fneg double %29
%31 = call double @llvm.fmuladd.f64(double %26, double 3.600000e+03, double %30)
store double %31, double* %5
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 0
%34 = zext i1 %33 to i64
%35 = select i1 %33, i32 45, i32 32
%36 = trunc i32 %35 to i8
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = load double, double* %5
%40 = call i32 @sprintf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @convert_deg_to_str.buf, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8 signext %36, i32 %37, i32 %38, double %39)
ret i8* getelementptr inbounds ([13 x i8], [13 x i8]* @convert_deg_to_str.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@convert_deg_to_str.buf = internal global [13 x i8] zeroinitializer
@.str = [21 x i8] c"'%c%02d:%02d:%06.3f'\00"
define i8* @convert_deg_to_str(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = select i1 %2, i8 45, i8 32
%4 = fneg double %0
%5 = select i1 %2, double %4, double %0
%6 = fptosi double %5 to i32
%7 = sitofp i32 %6 to double
%8 = fsub double %5, %7
%9 = fmul double %8, 6.000000e+01
%10 = fptosi double %9 to i32
%11 = mul nsw i32 %10, 60
%12 = sitofp i32 %11 to double
%13 = fneg double %12
%14 = tail call double @llvm.fmuladd.f64(double %8, double 3.600000e+03, double %13)
%15 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @convert_deg_to_str.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8 signext %3, i32 %6, i32 %10, double %14)
ret i8* getelementptr inbounds ([13 x i8], [13 x i8]* @convert_deg_to_str.buf, i64 0, i64 0)
}