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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
double difftime(scalar_t__, scalar_t__);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ time(scalar_t__ *);
int main(void) {
  time_t start, end;
  if ((start = time(&start)) < 0) {
    fprintf(stderr, "Err.(%s) getting time(), start\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  sleep(5);
  if ((end = time(&end)) < 0) {
    fprintf(stderr, "Err.(%s) getting time(), end\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("start: %d\n", (unsigned int)start);
  printf("  end: %d\n", (unsigned int)end);
  printf("Tempo trascorso: %.f secondi\n", difftime(start, end));
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
call   1060 <time@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jge    11d0 <main+0x60>
mov    0x2e43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe43(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    $0x5,%edi
call   1090 <sleep@plt>
lea    -0x18(%rbp),%rdi
call   1060 <time@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jge    122b <main+0xbb>
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xe08(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%eax
cvtsi2sd %rax,%xmm0
lea    0xe04(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
cvtsi2sd %rax,%xmm0
lea    0xdfb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <difftime@plt>
lea    0xded(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d55(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1060 <time@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
js     11f9 <main+0x89>
mov    $0x5,%edi
call   1090 <sleep@plt>
mov    %rsp,%rdi
call   1060 <time@plt>
mov    %rax,(%rsp)
test   %rax,%rax
js     1219 <main+0xa9>
mov    0x8(%rsp),%eax
cvtsi2sd %rax,%xmm0
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    (%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
call   1040 <difftime@plt>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2de0(%rip),%rax
mov    (%rax),%ebx
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xde9(%rip),%rsi
jmp    1237 <main+0xc7>
mov    0x2dc0(%rip),%rax
mov    (%rax),%ebx
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xde9(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Err.(%s) getting time(), start\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"Err.(%s) getting time(), end\0A\00"
@.str.2 = [11 x i8] c"start: %d\0A\00"
@.str.3 = [11 x i8] c" end: %d\0A\00"
@.str.4 = [30 x i8] c"Tempo trascorso: %.f secondi\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
%4 = call i64 @time(i64* %2)
store i64 %4, i64* %2
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = call i8* @strerror(i32 %8)
%10 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %0
%14 = call i32 @sleep(i32 5)
%15 = call i64 @time(i64* %3)
store i64 %15, i64* %3
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %13
%25 = load i64, i64* %2
%26 = trunc i64 %25 to i32
%27 = uitofp i32 %26 to double
%28 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = load i64, i64* %3
%30 = trunc i64 %29 to i32
%31 = uitofp i32 %30 to double
%32 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %31)
%33 = load i64, i64* %2
%34 = load i64, i64* %3
%35 = call double @difftime(i64 %33, i64 %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), double %35)
%37 = load i32, i32* @EXIT_SUCCESS
ret i32 %37
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Err.(%s) getting time(), start\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"Err.(%s) getting time(), end\0A\00"
@.str.2 = [11 x i8] c"start: %d\0A\00"
@.str.3 = [11 x i8] c" end: %d\0A\00"
@.str.4 = [30 x i8] c"Tempo trascorso: %.f secondi\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i64 @time(i64* %1)
store i64 %5, i64* %1
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = call i32 @sleep(i32 5)
%16 = call i64 @time(i64* %2)
store i64 %16, i64* %2
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %14
%26 = load i64, i64* %1
%27 = trunc i64 %26 to i32
%28 = uitofp i32 %27 to double
%29 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %28)
%30 = load i64, i64* %2
%31 = trunc i64 %30 to i32
%32 = uitofp i32 %31 to double
%33 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %32)
%34 = load i64, i64* %1
%35 = load i64, i64* %2
%36 = call double @difftime(i64 %34, i64 %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), double %36)
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}