#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 */
scalar_t__ floor(double);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
void conv_ang(char *string, double dec) {
  int deg, min, sec;
  int negative;
  negative = (dec < 0.0);
  if (negative)
    dec = -dec;
  deg = (int)floor(dec);
  dec -= (double)deg;
  dec *= 60.0;
  min = (int)floor(dec);
  dec -= (double)min;
  sec = (int)floor(dec * 60.0);
  if (negative)
    sprintf(string, "-%i°%i'%i\"", deg, min, sec);
  else
    sprintf(string, "%i°%i'%i\"", deg, min, sec);
  return;
}


x86 assembly (clang, -O0):
<conv_ang>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     116f <conv_ang+0x4f>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe69(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x18(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe37(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11ff <conv_ang+0xdf>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe13(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1219 <conv_ang+0xf9>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xdf5(%rip),%rsi
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_ang>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1140 <conv_ang+0x20>
xorpd  0xec0(%rip),%xmm0
movapd %xmm0,(%rsp)
lea    0xecc(%rip),%rax
lea    0xec6(%rip),%r12
cmova  %rax,%r12
call   1040 <floor@plt>
mov    %rax,%r15
xorps  %xmm1,%xmm1
cvtsi2sd %r15d,%xmm1
movapd (%rsp),%xmm0
subsd  %xmm1,%xmm0
mulsd  0xe98(%rip),%xmm0
movapd %xmm0,(%rsp)
call   1040 <floor@plt>
mov    %rax,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movapd (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe73(%rip),%xmm1
movapd %xmm1,%xmm0
call   1040 <floor@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"-%i\C2\B0%i'%i\22\00"
@.str.1 = [11 x i8] c"%i\C2\B0%i'%i\22\00"
define void @conv_ang(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store double %1, double* %4
%9 = load double, double* %4
%10 = fcmp olt double %9, 0.000000e+00
%11 = zext i1 %10 to i32
store i32 %11, i32* %8
%12 = load i32, i32* %8
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load double, double* %4
%16 = fneg double %15
store double %16, double* %4
br label %17
17: ; preds = %14, %2
%18 = load double, double* %4
%19 = call i64 @floor(double %18)
%20 = trunc i64 %19 to i32
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = sitofp i32 %21 to double
%23 = load double, double* %4
%24 = fsub double %23, %22
store double %24, double* %4
%25 = load double, double* %4
%26 = fmul double %25, 6.000000e+01
store double %26, double* %4
%27 = load double, double* %4
%28 = call i64 @floor(double %27)
%29 = trunc i64 %28 to i32
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = sitofp i32 %30 to double
%32 = load double, double* %4
%33 = fsub double %32, %31
store double %33, double* %4
%34 = load double, double* %4
%35 = fmul double %34, 6.000000e+01
%36 = call i64 @floor(double %35)
%37 = trunc i64 %36 to i32
store i32 %37, i32* %7
%38 = load i32, i32* %8
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %17
%41 = load i8*, i8** %3
%42 = load i32, i32* %5
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = call i32 @sprintf(i8* %41, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %42, i32 %43, i32 %44)
br label %52
46: ; preds = %17
%47 = load i8*, i8** %3
%48 = load i32, i32* %5
%49 = load i32, i32* %6
%50 = load i32, i32* %7
%51 = call i32 @sprintf(i8* %47, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %48, i32 %49, i32 %50)
br label %52
52: ; preds = %46, %40
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"-%i\C2\B0%i'%i\22\00"
@.str.1 = [11 x i8] c"%i\C2\B0%i'%i\22\00"
define void @conv_ang(i8* nocapture writeonly %0, double %1) {
%3 = fcmp olt double %1, 0.000000e+00
%4 = fneg double %1
%5 = select i1 %3, double %4, double %1
%6 = tail call i64 @floor(double %5)
%7 = trunc i64 %6 to i32
%8 = sitofp i32 %7 to double
%9 = fsub double %5, %8
%10 = fmul double %9, 6.000000e+01
%11 = tail call i64 @floor(double %10)
%12 = trunc i64 %11 to i32
%13 = sitofp i32 %12 to double
%14 = fsub double %10, %13
%15 = fmul double %14, 6.000000e+01
%16 = tail call i64 @floor(double %15)
%17 = trunc i64 %16 to i32
%18 = select i1 %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0)
%19 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) %18, i32 %7, i32 %12, i32 %17)
ret void
}