#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 */
struct timespec {
  double tv_sec;
  double tv_nsec;
};

/* Variables and functions */
double floor(double);
void timespec_div(struct timespec *t1, double div) {
  double sec = t1->tv_sec / div;
  double nsec = (sec - floor(sec)) * 1000000000 + t1->tv_nsec / div;
  t1->tv_sec = floor(sec);
  t1->tv_nsec = floor(nsec);
}


x86 assembly (clang, -O0):
<timespec_div>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
divsd  -0x10(%rbp),%xmm1
movsd  0xe97(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <floor@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
call   1030 <floor@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timespec_div>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rbx
movsd  (%rdi),%xmm2
movsd  0x8(%rdi),%xmm1
movsd  %xmm1,0x18(%rsp)
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm0
call   1030 <floor@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm2
divsd  0x10(%rsp),%xmm2
mulsd  0xea2(%rip),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm0,(%rbx)
movapd %xmm1,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x8(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { double, double }
define void @timespec_div(%struct.timespec* %0, double %1) {
%3 = alloca %struct.timespec*
%4 = alloca double
%5 = alloca double
%6 = alloca double
store %struct.timespec* %0, %struct.timespec** %3
store double %1, double* %4
%7 = load %struct.timespec*, %struct.timespec** %3
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
%9 = load double, double* %8
%10 = load double, double* %4
%11 = fdiv double %9, %10
store double %11, double* %5
%12 = load double, double* %5
%13 = load double, double* %5
%14 = call double @llvm.floor.f64(double %13)
%15 = fsub double %12, %14
%16 = load %struct.timespec*, %struct.timespec** %3
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 1
%18 = load double, double* %17
%19 = load double, double* %4
%20 = fdiv double %18, %19
%21 = call double @llvm.fmuladd.f64(double %15, double 1.000000e+09, double %20)
store double %21, double* %6
%22 = load double, double* %5
%23 = call double @llvm.floor.f64(double %22)
%24 = load %struct.timespec*, %struct.timespec** %3
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %24, i32 0, i32 0
store double %23, double* %25
%26 = load double, double* %6
%27 = call double @llvm.floor.f64(double %26)
%28 = load %struct.timespec*, %struct.timespec** %3
%29 = getelementptr inbounds %struct.timespec, %struct.timespec* %28, i32 0, i32 1
store double %27, double* %29
ret void
}

LLVM IR (-O2):
%struct.timespec = type { double, double }
define void @timespec_div(%struct.timespec* nocapture %0, double %1) {
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 0
%4 = load double, double* %3
%5 = fdiv double %4, %1
%6 = tail call double @llvm.floor.f64(double %5)
%7 = fsub double %5, %6
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 1
%9 = load double, double* %8
%10 = fdiv double %9, %1
%11 = tail call double @llvm.fmuladd.f64(double %7, double 1.000000e+09, double %10)
store double %6, double* %3
%12 = tail call double @llvm.floor.f64(double %11)
store double %12, double* %8
ret void
}