#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 */
double fabs(double);
scalar_t__ floor(double);
scalar_t__ lround(double);
int swh_geod2i(double coord, int *ret) {
  coord = fabs(coord);
  ret[0] = (int)floor(coord);
  coord -= ret[0];
  ret[1] = (int)lround(coord * 60);
  coord -= ret[1] / 60.0;
  ret[2] = (int)lround(coord * 3600);
  if (ret[2] < 0)
    ret[2] = 0;
  return 0;
}


x86 assembly (clang, -O0):
<swh_geod2i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xed3(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
movsd  -0x8(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xe92(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <lround@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
cvtsi2sdl 0x4(%rax),%xmm1
movsd  0xe6e(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  -0x8(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xe4c(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <lround@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,0x8(%rax)
jge    11e0 <swh_geod2i+0xc0>
mov    -0x10(%rbp),%rax
movl   $0x0,0x8(%rax)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swh_geod2i>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
andps  0xed1(%rip),%xmm0
movaps %xmm0,(%rsp)
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %eax,(%rbx)
movapd (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movapd %xmm1,%xmm0
mulsd  0xeb5(%rip),%xmm0
call   1030 <lround@plt>
mov    %eax,0x4(%rbx)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe9e(%rip),%xmm0
movapd (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe95(%rip),%xmm1
movapd %xmm1,%xmm0
call   1030 <lround@plt>
xor    %ecx,%ecx
test   %eax,%eax
cmovs  %ecx,%eax
mov    %eax,0x8(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @swh_geod2i(double %0, i32* %1) {
%3 = alloca double
%4 = alloca i32*
store double %0, double* %3
store i32* %1, i32** %4
%5 = load double, double* %3
%6 = call double @llvm.fabs.f64(double %5)
store double %6, double* %3
%7 = load double, double* %3
%8 = call i64 @floor(double %7)
%9 = trunc i64 %8 to i32
%10 = load i32*, i32** %4
%11 = getelementptr inbounds i32, i32* %10, i64 0
store i32 %9, i32* %11
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i64 0
%14 = load i32, i32* %13
%15 = sitofp i32 %14 to double
%16 = load double, double* %3
%17 = fsub double %16, %15
store double %17, double* %3
%18 = load double, double* %3
%19 = fmul double %18, 6.000000e+01
%20 = call i64 @lround(double %19)
%21 = trunc i64 %20 to i32
%22 = load i32*, i32** %4
%23 = getelementptr inbounds i32, i32* %22, i64 1
store i32 %21, i32* %23
%24 = load i32*, i32** %4
%25 = getelementptr inbounds i32, i32* %24, i64 1
%26 = load i32, i32* %25
%27 = sitofp i32 %26 to double
%28 = fdiv double %27, 6.000000e+01
%29 = load double, double* %3
%30 = fsub double %29, %28
store double %30, double* %3
%31 = load double, double* %3
%32 = fmul double %31, 3.600000e+03
%33 = call i64 @lround(double %32)
%34 = trunc i64 %33 to i32
%35 = load i32*, i32** %4
%36 = getelementptr inbounds i32, i32* %35, i64 2
store i32 %34, i32* %36
%37 = load i32*, i32** %4
%38 = getelementptr inbounds i32, i32* %37, i64 2
%39 = load i32, i32* %38
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %2
%42 = load i32*, i32** %4
%43 = getelementptr inbounds i32, i32* %42, i64 2
store i32 0, i32* %43
br label %44
44: ; preds = %41, %2
ret i32 0
}

LLVM IR (-O2):
define i32 @swh_geod2i(double %0, i32* nocapture writeonly %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = tail call i64 @floor(double %3)
%5 = trunc i64 %4 to i32
store i32 %5, i32* %1
%6 = sitofp i32 %5 to double
%7 = fsub double %3, %6
%8 = fmul double %7, 6.000000e+01
%9 = tail call i64 @lround(double %8)
%10 = trunc i64 %9 to i32
%11 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %10, i32* %11
%12 = sitofp i32 %10 to double
%13 = fdiv double %12, 6.000000e+01
%14 = fsub double %7, %13
%15 = fmul double %14, 3.600000e+03
%16 = tail call i64 @lround(double %15)
%17 = trunc i64 %16 to i32
%18 = icmp sgt i32 %17, 0
%19 = select i1 %18, i32 %17, i32 0
%20 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %19, i32* %20
ret i32 0
}