#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 snprintf(char *, size_t, char *, int, int, double);
int fill_angle_str(char *str, size_t len, double r) {
  int deg, min;
  double sec;
  if (r < 0) {
    r = -r;
  }
  deg = (int)r;
  min = (int)((r - deg) * 60.0);
  sec = (r - deg - min / 60.0) * 3600.0;
  return snprintf(str, len - 1, "%d°%d′%.2f″", deg, min, sec);
}


x86 assembly (clang, -O0):
<fill_angle_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1154 <fill_angle_str+0x44>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe96(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
movsd  0xe70(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe58(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
sub    $0x1,%rsi
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
movsd  -0x28(%rbp),%xmm0
lea    0xe40(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_angle_str>:
movapd %xmm0,%xmm1
movapd 0xee4(%rip),%xmm2
xorpd  %xmm0,%xmm2
xorpd  %xmm3,%xmm3
cmpltsd %xmm3,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
cvttsd2si %xmm0,%ecx
cvttpd2dq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  0xec3(%rip),%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
cvttsd2si %xmm2,%r8d
cvttpd2dq %xmm2,%xmm2
cvtdq2pd %xmm2,%xmm2
divsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
mulsd  0xea6(%rip),%xmm0
add    $0xffffffffffffffff,%rsi
lea    0xea3(%rip),%rdx
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"%d\C2\B0%d\E2\80\B2%.2f\E2\80\B3\00"
define i32 @fill_angle_str(i8* %0, i64 %1, double %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
store i8* %0, i8** %4
store i64 %1, i64* %5
store double %2, double* %6
%10 = load double, double* %6
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load double, double* %6
%14 = fneg double %13
store double %14, double* %6
br label %15
15: ; preds = %12, %3
%16 = load double, double* %6
%17 = fptosi double %16 to i32
store i32 %17, i32* %7
%18 = load double, double* %6
%19 = load i32, i32* %7
%20 = sitofp i32 %19 to double
%21 = fsub double %18, %20
%22 = fmul double %21, 6.000000e+01
%23 = fptosi double %22 to i32
store i32 %23, i32* %8
%24 = load double, double* %6
%25 = load i32, i32* %7
%26 = sitofp i32 %25 to double
%27 = fsub double %24, %26
%28 = load i32, i32* %8
%29 = sitofp i32 %28 to double
%30 = fdiv double %29, 6.000000e+01
%31 = fsub double %27, %30
%32 = fmul double %31, 3.600000e+03
store double %32, double* %9
%33 = load i8*, i8** %4
%34 = load i64, i64* %5
%35 = sub i64 %34, 1
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = load double, double* %9
%39 = call i32 @snprintf(i8* %33, i64 %35, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %36, i32 %37, double %38)
ret i32 %39
}

LLVM IR (-O2):
@.str = [17 x i8] c"%d\C2\B0%d\E2\80\B2%.2f\E2\80\B3\00"
define i32 @fill_angle_str(i8* %0, i64 %1, double %2) {
%4 = fcmp olt double %2, 0.000000e+00
%5 = fneg double %2
%6 = select i1 %4, double %5, double %2
%7 = fptosi double %6 to i32
%8 = sitofp i32 %7 to double
%9 = fsub double %6, %8
%10 = fmul double %9, 6.000000e+01
%11 = fptosi double %10 to i32
%12 = sitofp i32 %11 to double
%13 = fdiv double %12, 6.000000e+01
%14 = fsub double %9, %13
%15 = fmul double %14, 3.600000e+03
%16 = add i64 %1, -1
%17 = tail call i32 @snprintf(i8* %0, i64 %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %11, double %15)
ret i32 %17
}