#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 */
unsigned int abs(int);
float bin2deg(int val) {
  float deg;
  int deg_int, min_scaled, isneg;
  unsigned absval;
  absval = abs(val);
  isneg = (val < 0);
  deg_int = absval / 1000000;
  min_scaled = absval % 1000000;
  deg = deg_int + (double)min_scaled / (10000 * 60);
  deg = isneg ? -deg : deg;
  return (deg);
}


x86 assembly (clang, -O0):
<bin2deg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xf4240,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xf4240,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x10(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe9b(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     119c <bin2deg+0x8c>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11a6 <bin2deg+0x96>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bin2deg>:
mov    %edi,%eax
neg    %eax
cmovs  %edi,%eax
imul   $0x431bde83,%rax,%rcx
shr    $0x32,%rcx
imul   $0xf4240,%ecx,%edx
sub    %edx,%eax
cvtsi2sd %ecx,%xmm0
cvtsi2sd %eax,%xmm1
divsd  0xed6(%rip),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
test   %edi,%edi
jns    1140 <bin2deg+0x40>
xorps  0xed0(%rip),%xmm0
ret

LLVM IR (-O0):
define float @bin2deg(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %2
%8 = load i32, i32* %2
%9 = call i32 @abs(i32 %8)
store i32 %9, i32* %7
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 0
%12 = zext i1 %11 to i32
store i32 %12, i32* %6
%13 = load i32, i32* %7
%14 = udiv i32 %13, 1000000
store i32 %14, i32* %4
%15 = load i32, i32* %7
%16 = urem i32 %15, 1000000
store i32 %16, i32* %5
%17 = load i32, i32* %4
%18 = sitofp i32 %17 to double
%19 = load i32, i32* %5
%20 = sitofp i32 %19 to double
%21 = fdiv double %20, 6.000000e+05
%22 = fadd double %18, %21
%23 = fptrunc double %22 to float
store float %23, float* %3
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %1
%27 = load float, float* %3
%28 = fneg float %27
br label %31
29: ; preds = %1
%30 = load float, float* %3
br label %31
31: ; preds = %29, %26
%32 = phi float [ %28, %26 ], [ %30, %29 ]
store float %32, float* %3
%33 = load float, float* %3
ret float %33
}

LLVM IR (-O2):
define float @bin2deg(i32 %0) {
%2 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%3 = icmp slt i32 %0, 0
%4 = udiv i32 %2, 1000000
%5 = urem i32 %2, 1000000
%6 = sitofp i32 %4 to double
%7 = sitofp i32 %5 to double
%8 = fdiv double %7, 6.000000e+05
%9 = fadd double %8, %6
%10 = fptrunc double %9 to float
%11 = fneg float %10
%12 = select i1 %3, float %11, float %10
ret float %12
}