#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 abs(int);
int /*<<< orphan*/ exif_put_double(int const, int const, int, double);
int fabs(double const);
double floor(double);
void exif_put_coord(const int ifd_nr, const int tag_id, const double val) {
  double vmin, vsec;
  int vint;
  vint = abs((int)val);
  vmin = 60.0 * (fabs(val) - vint);
  vsec = 60.0 * (vmin - floor(vmin));
  vmin = floor(vmin);
  exif_put_double(ifd_nr, tag_id, 0, (double)vint);
  exif_put_double(ifd_nr, tag_id, 1, (double)vmin);
  exif_put_double(ifd_nr, tag_id, 2, (double)vsec);
}


x86 assembly (clang, -O0):
<exif_put_coord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <fabs@plt>
sub    -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe87(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <floor@plt>
movsd  -0x30(%rbp),%xmm1
subsd  %xmm0,%xmm1
movsd  0xe59(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <floor@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
cvtsi2sdl -0x24(%rbp),%xmm0
xor    %edx,%edx
call   1030 <exif_put_double@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
mov    $0x1,%edx
call   1030 <exif_put_double@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
mov    $0x2,%edx
call   1030 <exif_put_double@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exif_put_coord>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cvttsd2si %xmm0,%eax
mov    %esi,%r14d
mov    %edi,%ebp
mov    %eax,%ebx
neg    %ebx
cmovs  %eax,%ebx
call   1040 <fabs@plt>
sub    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xea2(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1050 <floor@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe81(%rip),%xmm1
movsd  %xmm1,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mov    %ebp,%edi
mov    %r14d,%esi
xor    %edx,%edx
call   1030 <exif_put_double@plt>
mov    %ebp,%edi
mov    %r14d,%esi
mov    $0x1,%edx
movsd  0x8(%rsp),%xmm0
call   1030 <exif_put_double@plt>
mov    %ebp,%edi
mov    %r14d,%esi
mov    $0x2,%edx
movsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <exif_put_double@plt>

LLVM IR (-O0):
define void @exif_put_coord(i32 %0, i32 %1, double %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store double %2, double* %6
%10 = load double, double* %6
%11 = fptosi double %10 to i32
%12 = call i32 @abs(i32 %11)
store i32 %12, i32* %9
%13 = load double, double* %6
%14 = call i32 @fabs(double %13)
%15 = load i32, i32* %9
%16 = sub nsw i32 %14, %15
%17 = sitofp i32 %16 to double
%18 = fmul double 6.000000e+01, %17
store double %18, double* %7
%19 = load double, double* %7
%20 = load double, double* %7
%21 = call double @llvm.floor.f64(double %20)
%22 = fsub double %19, %21
%23 = fmul double 6.000000e+01, %22
store double %23, double* %8
%24 = load double, double* %7
%25 = call double @llvm.floor.f64(double %24)
store double %25, double* %7
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = load i32, i32* %9
%29 = sitofp i32 %28 to double
%30 = call i32 @exif_put_double(i32 %26, i32 %27, i32 0, double %29)
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = load double, double* %7
%34 = call i32 @exif_put_double(i32 %31, i32 %32, i32 1, double %33)
%35 = load i32, i32* %4
%36 = load i32, i32* %5
%37 = load double, double* %8
%38 = call i32 @exif_put_double(i32 %35, i32 %36, i32 2, double %37)
ret void
}

LLVM IR (-O2):
define void @exif_put_coord(i32 %0, i32 %1, double %2) {
%4 = fptosi double %2 to i32
%5 = tail call i32 @llvm.abs.i32(i32 %4, i1 true)
%6 = tail call i32 @fabs(double %2)
%7 = sub nsw i32 %6, %5
%8 = sitofp i32 %7 to double
%9 = fmul double %8, 6.000000e+01
%10 = tail call double @llvm.floor.f64(double %9)
%11 = fsub double %9, %10
%12 = fmul double %11, 6.000000e+01
%13 = sitofp i32 %5 to double
%14 = tail call i32 @exif_put_double(i32 %0, i32 %1, i32 0, double %13)
%15 = tail call i32 @exif_put_double(i32 %0, i32 %1, i32 1, double %10)
%16 = tail call i32 @exif_put_double(i32 %0, i32 %1, i32 2, double %12)
ret void
}