#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 {
  int tv_sec;
  long tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ nanosleep(struct timespec *, struct timespec *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  struct timespec interval, remainder;
  double time = 1.0;
  int count, input = 100;
  count = 0;
  int seconds = 0;
  long nanoseconds = 0.0;
  scanf("%d", &input);
  interval.tv_sec = 60;
  interval.tv_nsec = 0;
  nanosleep(&interval, &remainder);
  while (count < input) {
    printf("a");
    fflush(stdout);
    scanf("%lf", &time);
    count = count + 1;
    seconds = (int)time;
    nanoseconds = (time - (double)seconds) * 1000000000;
    interval.tv_sec = seconds;
    interval.tv_nsec = nanoseconds;
    nanosleep(&interval, &remainder);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x64,-0x40(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
lea    0xe89(%rip),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x3c,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <nanosleep@plt>
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    123a <main+0xfa>
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    0xe3a(%rip),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
cvttsd2si -0x38(%rbp),%eax
mov    %eax,-0x44(%rbp)
movsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0x44(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xdfb(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x50(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <nanosleep@plt>
jmp    11ae <main+0x6e>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movabs $0x3ff0000000000000,%rax
mov    %rax,0x10(%rsp)
movl   $0x64,0xc(%rsp)
lea    0xe9c(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movl   $0x3c,0x18(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x18(%rsp),%rdi
lea    0x28(%rsp),%rsi
call   1040 <nanosleep@plt>
cmpl   $0x0,0xc(%rsp)
jle    1230 <main+0xf0>
mov    0x2e36(%rip),%r13
lea    0xe5a(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x18(%rsp),%r12
lea    0x28(%rsp),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x61,%edi
call   1030 <putchar@plt>
mov    0x0(%r13),%edi
call   1050 <fflush@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
add    $0x1,%ebp
movsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%eax
cvttpd2dq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm0
mulsd  0xdef(%rip),%xmm0
cvttsd2si %xmm0,%rcx
mov    %eax,0x18(%rsp)
mov    %rcx,0x20(%rsp)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <nanosleep@plt>
cmp    0xc(%rsp),%ebp
jl     11d0 <main+0x90>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"a\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%lf\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timespec
%7 = alloca %struct.timespec
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 1.000000e+00, double* %8
store i32 100, i32* %10
store i32 0, i32* %9
store i32 0, i32* %11
store i64 0, i64* %12
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %10)
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
store i32 60, i32* %14
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
store i64 0, i64* %15
%16 = call i32 @nanosleep(%struct.timespec* %6, %struct.timespec* %7)
br label %17
17: ; preds = %21, %2
%18 = load i32, i32* %9
%19 = load i32, i32* %10
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %41
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* @stdout
%24 = call i32 @fflush(i32 %23)
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %8)
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
%28 = load double, double* %8
%29 = fptosi double %28 to i32
store i32 %29, i32* %11
%30 = load double, double* %8
%31 = load i32, i32* %11
%32 = sitofp i32 %31 to double
%33 = fsub double %30, %32
%34 = fmul double %33, 1.000000e+09
%35 = fptosi double %34 to i64
store i64 %35, i64* %12
%36 = load i32, i32* %11
%37 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
store i32 %36, i32* %37
%38 = load i64, i64* %12
%39 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
store i64 %38, i64* %39
%40 = call i32 @nanosleep(%struct.timespec* %6, %struct.timespec* %7)
br label %17
41: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
@.str = [3 x i8] c"%d\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%lf\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = alloca double
%6 = alloca i32
%7 = bitcast %struct.timespec* %3 to i8*
%8 = bitcast %struct.timespec* %4 to i8*
%9 = bitcast double* %5 to i8*
store double 1.000000e+00, double* %5
%10 = bitcast i32* %6 to i8*
store i32 100, i32* %6
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
store i32 60, i32* %12
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
store i64 0, i64* %13
%14 = call i32 @nanosleep(%struct.timespec* %3, %struct.timespec* %4)
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %33
17: ; preds = %2, %17
%18 = phi i32 [ %23, %17 ], [ 0, %2 ]
%19 = call i32 @putchar(i32 97)
%20 = load i32, i32* @stdout
%21 = call i32 @fflush(i32 %20)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%23 = add nuw nsw i32 %18, 1
%24 = load double, double* %5
%25 = fptosi double %24 to i32
%26 = sitofp i32 %25 to double
%27 = fsub double %24, %26
%28 = fmul double %27, 1.000000e+09
%29 = fptosi double %28 to i64
store i32 %25, i32* %12
store i64 %29, i64* %13
%30 = call i32 @nanosleep(%struct.timespec* %3, %struct.timespec* %4)
%31 = load i32, i32* %6
%32 = icmp slt i32 %23, %31
br i1 %32, label %17, label %33
33: ; preds = %17, %2
ret i32 0
}