#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;
  unsigned int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ SIGALRM;
double modf(int /*<<< orphan*/, double *);
int /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
int /*<<< orphan*/ raise(int /*<<< orphan*/);
int /*<<< orphan*/ talk_delay();
void *schedule_talk(void *ptr) {
  double secs, nsecs;
  struct timespec delay;
  while (1) {
    raise(SIGALRM);
    nsecs = modf(talk_delay(), &secs);
    delay.tv_sec = secs;
    delay.tv_nsec = 1000000000U * nsecs;
    nanosleep(&delay, NULL);
  }
  return (void *)0;
}


x86 assembly (clang, -O0):
<schedule_talk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
xor    %eax,%eax
call   1040 <talk_delay@plt>
mov    %eax,%edi
lea    -0x10(%rbp),%rsi
call   1050 <modf@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe78(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <nanosleep@plt>
jmp    114c <schedule_talk+0xc>

x86 assembly (clang, -O2):
<schedule_talk>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2e98(%rip),%r15
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    (%r15),%edi
call   1030 <raise@plt>
xor    %eax,%eax
call   1040 <talk_delay@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1050 <modf@plt>
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  0xe73(%rip),%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,0x18(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <nanosleep@plt>
jmp    1160 <schedule_talk+0x20>

LLVM IR (-O0):
%struct.timespec = type { double, i32 }
@SIGALRM = global i32 0
define i8* @schedule_talk(i8* %0) {
%2 = alloca i8*
%3 = alloca double
%4 = alloca double
%5 = alloca %struct.timespec
store i8* %0, i8** %2
br label %6
6: ; preds = %1, %6
%7 = load i32, i32* @SIGALRM
%8 = call i32 @raise(i32 %7)
%9 = call i32 (...) @talk_delay()
%10 = call double @modf(i32 %9, double* %3)
store double %10, double* %4
%11 = load double, double* %3
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
store double %11, double* %12
%13 = load double, double* %4
%14 = fmul double 1.000000e+09, %13
%15 = fptoui double %14 to i32
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
store i32 %15, i32* %16
%17 = call i32 @nanosleep(%struct.timespec* %5, i32* null)
br label %6
}

LLVM IR (-O2):
%struct.timespec = type { double, i32 }
@SIGALRM = global i32 0
define noalias i8* @schedule_talk(i8* nocapture readnone %0) {
%2 = alloca double
%3 = alloca %struct.timespec
%4 = bitcast double* %2 to i8*
%5 = bitcast %struct.timespec* %3 to i8*
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
br label %8
8: ; preds = %8, %1
%9 = load i32, i32* @SIGALRM
%10 = call i32 @raise(i32 %9)
%11 = call i32 (...) @talk_delay()
%12 = call double @modf(i32 %11, double* %2)
%13 = load double, double* %2
store double %13, double* %6
%14 = fmul double %12, 1.000000e+09
%15 = fptoui double %14 to i32
store i32 %15, i32* %7
%16 = call i32 @nanosleep(%struct.timespec* %3, i32* null)
br label %8
}