#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 M_PI;
int /*<<< orphan*/ fabs(double);
double floor(int /*<<< orphan*/);
double radtodegsec(double rad) {
  const double dgrd = 360.0 / (2 * M_PI);
  double deg, d, s;
  deg = dgrd * rad;
  d = (deg >= 0 ? 1.0 : -1.0) * floor(fabs(deg));
  s = (deg - d) * 60.0;
  return 100.0 * d + s;
}


x86 assembly (clang, -O0):
<radtodegsec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    0x2eb4(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xedb(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  0xea6(%rip),%xmm3
movsd  0xea6(%rip),%xmm2
xorps  %xmm0,%xmm0
cmplesd %xmm1,%xmm0
movaps %xmm0,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xe46(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe23(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radtodegsec>:
push   %rax
mov    0x2ec0(%rip),%rax
mov    (%rax),%eax
add    %eax,%eax
cvtsi2sd %eax,%xmm1
movsd  0xec8(%rip),%xmm2
divsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <floor@plt>
movapd 0xec7(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movsd  (%rsp),%xmm3
cmplesd %xmm3,%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm2,%xmm0
movapd %xmm3,%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe81(%rip),%xmm1
mulsd  0xe81(%rip),%xmm0
addsd  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @radtodegsec(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %2
%7 = load i32, i32* @M_PI
%8 = mul nsw i32 2, %7
%9 = sitofp i32 %8 to double
%10 = fdiv double 3.600000e+02, %9
store double %10, double* %3
%11 = load double, double* %3
%12 = load double, double* %2
%13 = fmul double %11, %12
store double %13, double* %4
%14 = load double, double* %4
%15 = fcmp oge double %14, 0.000000e+00
%16 = zext i1 %15 to i64
%17 = select i1 %15, double 1.000000e+00, double -1.000000e+00
%18 = load double, double* %4
%19 = call i32 @fabs(double %18)
%20 = call double @floor(i32 %19)
%21 = fmul double %17, %20
store double %21, double* %5
%22 = load double, double* %4
%23 = load double, double* %5
%24 = fsub double %22, %23
%25 = fmul double %24, 6.000000e+01
store double %25, double* %6
%26 = load double, double* %5
%27 = load double, double* %6
%28 = call double @llvm.fmuladd.f64(double 1.000000e+02, double %26, double %27)
ret double %28
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @radtodegsec(double %0) {
%2 = load i32, i32* @M_PI
%3 = shl nsw i32 %2, 1
%4 = sitofp i32 %3 to double
%5 = fdiv double 3.600000e+02, %4
%6 = fmul double %5, %0
%7 = fcmp oge double %6, 0.000000e+00
%8 = tail call i32 @fabs(double %6)
%9 = tail call double @floor(i32 %8)
%10 = fneg double %9
%11 = select i1 %7, double %9, double %10
%12 = fsub double %6, %11
%13 = fmul double %12, 6.000000e+01
%14 = tail call double @llvm.fmuladd.f64(double %11, double 1.000000e+02, double %13)
ret double %14
}