#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 clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
double clock();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(double);
int main(void) {
  long i = 6000000L;
  clock_t start, finish;
  double duration;
  printf("Delay for three seconds\n");
  sleep((clock_t)3 * CLOCKS_PER_SEC);
  printf("Done!\n");
  printf("Time to do %ld empty loops is ", i);
  start = clock();
  while (i--)
    ;
  finish = clock();
  duration = (double)(finish - start) / CLOCKS_PER_SEC;
  printf("%2.1f seconds\n", duration);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x5b8d80,-0x10(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0xea3(%rip),%xmm0
mov    0x2e84(%rip),%rax
mulsd  (%rax),%xmm0
call   1050 <sleep@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11b7 <main+0x87>
jmp    1199 <main+0x69>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2e14(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe5e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e90(%rip),%rbx
movsd  (%rbx),%xmm0
mulsd  0xe9c(%rip),%xmm0
call   1060 <sleep@plt>
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8c(%rip),%rdi
mov    $0x5b8d80,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <clock@plt>
subsd  0x8(%rsp),%xmm0
divsd  (%rbx),%xmm0
lea    0xe7a(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Delay for three seconds\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [7 x i8] c"Done!\0A\00"
@.str.2 = [31 x i8] c"Time to do %ld empty loops is \00"
@.str.3 = [15 x i8] c"%2.1f seconds\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
store i64 6000000, i64* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = load double, double* @CLOCKS_PER_SEC
%8 = fmul double 3.000000e+00, %7
%9 = call i32 @sleep(double %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = load i64, i64* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i64 %11)
%13 = call double (...) @clock()
store double %13, double* %3
br label %14
14: ; preds = %18, %0
%15 = load i64, i64* %2
%16 = add nsw i64 %15, -1
store i64 %16, i64* %2
%17 = icmp ne i64 %15, 0
br i1 %17, label %18, label %19
18: ; preds = %14
br label %14
19: ; preds = %14
%20 = call double (...) @clock()
store double %20, double* %4
%21 = load double, double* %4
%22 = load double, double* %3
%23 = fsub double %21, %22
%24 = load double, double* @CLOCKS_PER_SEC
%25 = fdiv double %23, %24
store double %25, double* %5
%26 = load double, double* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %26)
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.2 = [31 x i8] c"Time to do %ld empty loops is \00"
@.str.3 = [15 x i8] c"%2.1f seconds\0A\00"
@str = [24 x i8] c"Delay for three seconds\00"
@str.4 = [6 x i8] c"Done!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%2 = load double, double* @CLOCKS_PER_SEC
%3 = fmul double %2, 3.000000e+00
%4 = tail call i32 @sleep(double %3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.4, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i64 6000000)
%7 = tail call double (...) @clock()
%8 = tail call double (...) @clock()
%9 = fsub double %8, %7
%10 = load double, double* @CLOCKS_PER_SEC
%11 = fdiv double %9, %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %11)
ret i32 0
}