#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 */
typedef scalar_t__ time_t;
typedef scalar_t__ suseconds_t;
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
double floor(double);
int /*<<< orphan*/ neubot_info(char *);
struct timeval *neubot_timeval_init(struct timeval *tv, double delta) {
  neubot_info("utils:neubot_timeval_init - enter");
  if (delta < 0) {
    neubot_info("utils:neubot_timeval_init - no init needed");
    return (NULL);
  }
  tv->tv_sec = (time_t)floor(delta);
  tv->tv_usec = (suseconds_t)((delta - floor(delta)) * 1000000);
  neubot_info("utils:neubot_timeval_init - ok");
  return (tv);
}


x86 assembly (clang, -O0):
<neubot_timeval_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
lea    0xed0(%rip),%rdi
call   1030 <neubot_info@plt>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1164 <neubot_timeval_init+0x44>
lea    0xed8(%rip),%rdi
call   1030 <neubot_info@plt>
movq   $0x0,-0x8(%rbp)
jmp    11c7 <neubot_timeval_init+0xa7>
movsd  -0x18(%rbp),%xmm0
call   1040 <floor@plt>
cvttsd2si %xmm0,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  0xe5d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
lea    0xe9b(%rip),%rdi
call   1030 <neubot_info@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<neubot_timeval_init>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
lea    0xed3(%rip),%rdi
call   1030 <neubot_info@plt>
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm2
ucomisd %xmm2,%xmm0
jbe    1155 <neubot_timeval_init+0x35>
lea    0xed9(%rip),%rdi
xor    %ebx,%ebx
jmp    1188 <neubot_timeval_init+0x68>
movapd %xmm2,%xmm0
call   1040 <floor@plt>
cvttsd2si %xmm0,%rax
mov    %rax,0x8(%rbx)
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe87(%rip),%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,(%rbx)
lea    0xecd(%rip),%rdi
call   1030 <neubot_info@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [34 x i8] c"utils:neubot_timeval_init - enter\00"
@.str.1 = [43 x i8] c"utils:neubot_timeval_init - no init needed\00"
@.str.2 = [31 x i8] c"utils:neubot_timeval_init - ok\00"
define %struct.timeval* @neubot_timeval_init(%struct.timeval* %0, double %1) {
%3 = alloca %struct.timeval*
%4 = alloca %struct.timeval*
%5 = alloca double
store %struct.timeval* %0, %struct.timeval** %4
store double %1, double* %5
%6 = call i32 @neubot_info(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = load double, double* %5
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @neubot_info(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
store %struct.timeval* null, %struct.timeval** %3
br label %27
11: ; preds = %2
%12 = load double, double* %5
%13 = call double @llvm.floor.f64(double %12)
%14 = fptosi double %13 to i64
%15 = load %struct.timeval*, %struct.timeval** %4
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
store i64 %14, i64* %16
%17 = load double, double* %5
%18 = load double, double* %5
%19 = call double @llvm.floor.f64(double %18)
%20 = fsub double %17, %19
%21 = fmul double %20, 1.000000e+06
%22 = fptosi double %21 to i64
%23 = load %struct.timeval*, %struct.timeval** %4
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 0
store i64 %22, i64* %24
%25 = call i32 @neubot_info(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%26 = load %struct.timeval*, %struct.timeval** %4
store %struct.timeval* %26, %struct.timeval** %3
br label %27
27: ; preds = %11, %9
%28 = load %struct.timeval*, %struct.timeval** %3
ret %struct.timeval* %28
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str = [34 x i8] c"utils:neubot_timeval_init - enter\00"
@.str.1 = [43 x i8] c"utils:neubot_timeval_init - no init needed\00"
@.str.2 = [31 x i8] c"utils:neubot_timeval_init - ok\00"
define %struct.timeval* @neubot_timeval_init(%struct.timeval* writeonly %0, double %1) {
%3 = tail call i32 @neubot_info(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = fcmp olt double %1, 0.000000e+00
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = tail call double @llvm.floor.f64(double %1)
%7 = fptosi double %6 to i64
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
store i64 %7, i64* %8
%9 = fsub double %1, %6
%10 = fmul double %9, 1.000000e+06
%11 = fptosi double %10 to i64
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
store i64 %11, i64* %12
br label %13
13: ; preds = %2, %5
%14 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), %2 ]
%15 = phi %struct.timeval* [ %0, %5 ], [ null, %2 ]
%16 = tail call i32 @neubot_info(i8* %14)
ret %struct.timeval* %15
}