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

/* Variables and functions */
scalar_t__ EINTR;
scalar_t__ errno;
scalar_t__ nanosleep(struct timespec *, struct timespec *);
int t_delay(double secondes) {
  struct timespec delai;
  struct timespec reste;
  delai.tv_sec = (time_t)secondes;
  delai.tv_nsec = (long)((secondes - delai.tv_sec) * 1.e9);
  while (nanosleep(&delai, &reste) != 0) {
    if (errno == EINTR) {
      delai = reste;
      continue;
    } else
      return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<t_delay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xec7(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <nanosleep@plt>
cmp    $0x0,%rax
je     1198 <t_delay+0x88>
mov    0x2e7c(%rip),%rax
mov    (%rax),%rax
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%rax
jne    118c <t_delay+0x7c>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1146 <t_delay+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    119f <t_delay+0x8f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_delay>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,(%rsp)
subsd  %xmm0,%xmm0
mulsd  0xed3(%rip),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,0x8(%rsp)
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
call   1030 <nanosleep@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     119c <t_delay+0x8c>
mov    0x2e8d(%rip),%r15
mov    0x2e7e(%rip),%r12
mov    %rsp,%rbx
lea    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15),%rax
cmp    (%r12),%rax
jne    1196 <t_delay+0x86>
movupd 0x10(%rsp),%xmm0
movapd %xmm0,(%rsp)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <nanosleep@plt>
test   %rax,%rax
jne    1170 <t_delay+0x60>
jmp    119c <t_delay+0x8c>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { double, i64 }
@errno = global i64 0
@EINTR = global i64 0
define i32 @t_delay(double %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca %struct.timespec
%5 = alloca %struct.timespec
store double %0, double* %3
%6 = load double, double* %3
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
store double %6, double* %7
%8 = load double, double* %3
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%10 = load double, double* %9
%11 = fsub double %8, %10
%12 = fmul double %11, 1.000000e+09
%13 = fptosi double %12 to i64
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
store i64 %13, i64* %14
br label %15
15: ; preds = %22, %1
%16 = call i64 @nanosleep(%struct.timespec* %4, %struct.timespec* %5)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i64, i64* @errno
%20 = load i64, i64* @EINTR
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = bitcast %struct.timespec* %4 to i8*
%24 = bitcast %struct.timespec* %5 to i8*
br label %15
25: ; preds = %18
store i32 -1, i32* %2
br label %27
26: ; preds = %15
store i32 0, i32* %2
br label %27
27: ; preds = %26, %25
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
%struct.timespec = type { double, i64 }
@errno = global i64 0
@EINTR = global i64 0
define i32 @t_delay(double %0) {
%2 = alloca %struct.timespec
%3 = alloca %struct.timespec
%4 = bitcast %struct.timespec* %2 to i8*
%5 = bitcast %struct.timespec* %3 to i8*
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
store double %0, double* %6
%7 = fsub double %0, %0
%8 = fmul double %7, 1.000000e+09
%9 = fptosi double %8 to i64
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
store i64 %9, i64* %10
%11 = call i64 @nanosleep(%struct.timespec* %2, %struct.timespec* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %1, %17
%14 = load i64, i64* @errno
%15 = load i64, i64* @EINTR
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = call i64 @nanosleep(%struct.timespec* %2, %struct.timespec* %3)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %13
20: ; preds = %13, %17, %1
%21 = phi i32 [ 0, %1 ], [ 0, %17 ], [ -1, %13 ]
ret i32 %21
}