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

/* Variables and functions */
double difftime(double, double);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
double time(int /*<<< orphan*/ *);
int main(void) {
  time_t t1 = time(NULL);
  printf("Wait a few seconds a press enter.");
  char str[10];
  fgets(str, 10, stdin);
  time_t t2 = time(NULL);
  printf("Time elapsed (in seconds):\n");
  double elapsed = difftime(t2, t1);
  printf("%lf\n", elapsed);
  time_t elapsedAlternate = t2 - t1;
  printf("%ld\n", elapsedAlternate);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
movsd  %xmm0,-0x10(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1a(%rbp),%rdi
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1050 <fgets@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
movsd  %xmm0,-0x28(%rbp)
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1040 <difftime@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe80(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xe63(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
xor    %edi,%edi
call   1070 <time@plt>
movsd  %xmm0,0x10(%rsp)
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
lea    0x1e(%rsp),%rdi
mov    $0xa,%esi
call   1060 <fgets@plt>
xor    %edi,%edi
call   1070 <time@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1050 <difftime@plt>
lea    0xe6a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Wait a few seconds a press enter.\00"
@stdin = global i32 0
@.str.1 = [28 x i8] c"Time elapsed (in seconds):\0A\00"
@.str.2 = [5 x i8] c"%lf\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca [10 x i8]
%4 = alloca double
%5 = alloca double
%6 = alloca double
store i32 0, i32* %1
%7 = call double @time(i32* null)
store double %7, double* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 10, i32 %10)
%12 = call double @time(i32* null)
store double %12, double* %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%14 = load double, double* %4
%15 = load double, double* %2
%16 = call double @difftime(double %14, double %15)
store double %16, double* %5
%17 = load double, double* %5
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %17)
%19 = load double, double* %4
%20 = load double, double* %2
%21 = fsub double %19, %20
store double %21, double* %6
%22 = load double, double* %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Wait a few seconds a press enter.\00"
@stdin = global i32 0
@.str.2 = [5 x i8] c"%lf\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
@str = [27 x i8] c"Time elapsed (in seconds):\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = tail call double @time(i32* null)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %4, i32 10, i32 %5)
%7 = call double @time(i32* null)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%9 = call double @difftime(double %7, double %2)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %9)
%11 = fsub double %7, %2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %11)
ret i32 0
}